Skip to content

Commit a6e1123

Browse files
dongwon8247notJoonjinoosss
authored
chore: fix documentation across contracts (#803)
* chore: fix documentation issues across contracts - Convert all-caps comments to lowercase following Go conventions - Fix halving period documentation (4 years → 2 years) - Update block-based references to timestamp-based - Add address validation to SetRoleAddresses - Apply Go convention for function documentation (Parameters/Returns format) - Fix typo: 'devided' → 'divided' * chore: improve access and emission documentation - Fix misleading comments in access contract - Simplify verbose function documentation - Update README to match actual implementation - Remove redundant parameter descriptions - Make comments concise and accurate * chore: standardize documentation across all contracts - Apply consistent Go comment conventions - Remove verbose AI-style parameter lists - Keep critical GnoSwap-specific logic explanations - Fix incorrect documentation that didn't match implementation - Simplify README files while preserving technical accuracy - Make documentation concise and human-readable * chore: add governance parameter documentation - Add 'Configurable Parameters' sections to all relevant README files - Add inline comments for governance-modifiable variables - Document default values for all configurable parameters - Include parameters for: emission distribution, fees, pool tiers, governance settings - Remove separation between admin/governance access in documentation * chore: remove test.sh * fix * fix * fix * add more details in readme and key functions * fix * fix * final readme edit * Update README.md Signed-off-by: Dongwon <[email protected]> * fix: tests * chore: update tree --------- Signed-off-by: Dongwon <[email protected]> Signed-off-by: Lee ByeongJun <[email protected]> Co-authored-by: Lee ByeongJun <[email protected]> Co-authored-by: jinoosss <[email protected]>
1 parent 79978b8 commit a6e1123

File tree

180 files changed

+3590
-4956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+3590
-4956
lines changed

README.md

Lines changed: 86 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -1,226 +1,133 @@
11
# GnoSwap Contracts
22

3-
This repository contains smart contracts (realms) for GnoSwap.
3+
Smart contracts for GnoSwap AMM DEX on Gno.land.
44

5-
## Index
6-
7-
- [Setting Up and Testing GnoSwap Contracts](#setting-up-and-testing-gnoswap-contracts)
8-
- [Prerequisites](#prerequisites)
9-
- [Setting Up GnoSwap Contracts](#setting-up-gnoswap-contracts)
10-
- [Running Tests](#running-tests)
11-
- [Realms](#realms)
12-
- [Core Realms Deployed on Testnet5](#core-realms-deployed-on-testnet5)
13-
14-
15-
## Setting Up and Testing GnoSwap Contracts
16-
17-
There are two ways to set up GnoSwap contracts: using the provided setup script or manually following the steps below.
18-
19-
### Prerequisites
5+
## Prerequisites
206

217
- GNU Make 3.81 or higher
228
- Latest version of [gno.land](https://github.com/gnolang/gno)
239
- Python 3.12 or higher
2410

25-
### Using the Setup Script
26-
27-
> Note: If you're using the script, you don't need to manually perform the steps listed in the next section.
28-
29-
For convenience, we provide a Python script that automates the setup process. This script can clone the repository, copy contracts, and move test files as needed.
30-
31-
- To set up in your home directory without cloning the repository:
11+
## Setup
3212

33-
```bash
34-
python3 setup.py
35-
```
36-
37-
- To set up in a specific directory without cloning:
38-
39-
```bash
40-
python3 setup.py -w /path/to/workdir
41-
```
42-
43-
- To clone the repository and set up in your home directory:
13+
```bash
14+
# Quick setup in home directory
15+
python3 setup.py
4416

45-
```bash
46-
python3 setup.py -c
47-
```
17+
# Setup in custom directory
18+
python3 setup.py -w /path/to/workdir
4819

49-
- To clone the repository and set up in a specific directory:
20+
# Clone repository and setup
21+
python3 setup.py -c
5022

51-
```bash
52-
python3 setup.py -w /path/to/workdir -c
53-
```
23+
# Clone to custom directory
24+
python3 setup.py -w /path/to/workdir -c
25+
```
5426

5527
Options:
5628

57-
- `-w` or `--workdir`: Specify the working directory (default is your home directory)
58-
- `-c` or `--clone`: Clone the gnoswap repository before setting up
59-
60-
The script will perform all necessary steps to set up the GnoSwap contracts in the specified directory.
61-
62-
<details>
63-
<summary><h3>Setting Up GnoSwap Contracts Manually</h3></summary>
64-
65-
> Important: This manual setup method is not recommended and should only be used as a last resort. If the setup script is not working properly, please create an issue in the repository.
66-
67-
This section guides you through the process of setting up GnoSwap contracts. The process involves three main steps: cloning the `gnoswap` repository, copying the contracts to the `gno` directory, and moving test cases to their respective directories.
68-
69-
1. Clone the repository:
70-
71-
```bash
72-
cd $WORKDIR
73-
git clone https://github.com/gnoswap-labs/gnoswap.git
74-
cd gnoswap
75-
```
76-
77-
2. Understand the directory structure pattern:
78-
79-
```tree
80-
contract/
81-
├── p/ # Packages directory
82-
│ └── gnoswap/
83-
│ ├── gnsmath/
84-
│ └── ...
85-
└── r/ # Realms directory
86-
└── gnoswap/
87-
├── common/
88-
├── pool/
89-
└── ...
90-
```
91-
92-
3. Create the base directories:
93-
94-
```bash
95-
# Create directories for packages and realms
96-
mkdir -p $WORKDIR/gno/examples/gno.land/p/gnoswap
97-
mkdir -p $WORKDIR/gno/examples/gno.land/r/gnoswap/v1
98-
```
99-
100-
4. Copy files following these patterns:
101-
102-
For packages:
103-
104-
```bash
105-
# Pattern:
106-
cp -R contract/p/gnoswap/<package_name> $WORKDIR/gno/examples/gno.land/p/gnoswap/
107-
108-
# Examples:
109-
cp -R contract/p/gnoswap/consts $WORKDIR/gno/examples/gno.land/p/gnoswap/
110-
cp -R contract/p/gnoswap/gnsmath $WORKDIR/gno/examples/gno.land/p/gnoswap/
111-
```
112-
113-
For realm modules:
114-
115-
```bash
116-
# Pattern:
117-
cp -R contract/r/gnoswap/<module_name> $WORKDIR/gno/examples/gno.land/r/gnoswap/v1/
29+
- `-w` or `--workdir`: Specify working directory (default: home directory)
30+
- `-c` or `--clone`: Clone gnoswap repository before setup
11831

119-
# Examples:
120-
cp -R contract/r/gnoswap/pool $WORKDIR/gno/examples/gno.land/r/gnoswap/v1/
121-
cp -R contract/r/gnoswap/router $WORKDIR/gno/examples/gno.land/r/gnoswap/v1/
122-
```
32+
If the setup script fails, you can manually copy contracts:
12333

124-
For test tokens:
34+
1. Clone repository:
12535

126-
```bash
127-
# Pattern:
128-
cp -R contract/r/gnoswap/test_token/<token_name> $WORKDIR/gno/examples/gno.land/r/
129-
130-
# Example:
131-
cp -R contract/r/gnoswap/test_token/usdc $WORKDIR/gno/examples/gno.land/r/
132-
```
133-
134-
5. Verify the setup:
135-
136-
```bash
137-
cd $WORKDIR/gno/examples
138-
gno test -root-dir $WORKDIR/gno -v=false ./gno.land/r/gnoswap/v1/pool
139-
```
140-
141-
> Note: The setup maintains the original directory structure, including test files which are now part of their respective packages.
142-
143-
</details>
144-
145-
### Directory Structure Overview
146-
147-
Key directories and their purposes:
148-
149-
- `p/gnoswap/`: Core packages including math utilities and constants
150-
- `r/gnoswap/v1/`: Protocol realms (pool, router, position, etc.)
151-
- `r/gnoswap/test_token/`: Test tokens for development
152-
153-
Once you understand these patterns, you can copy any additional modules using the same structure.
36+
```bash
37+
git clone https://github.com/gnoswap-labs/gnoswap.git
38+
```
15439

155-
### Running Tests
40+
2. Copy packages:
15641

157-
While it's possible to run tests in the cloned `gno` directory (where the above setup process was completed), it's recommended to run them in the `gnoswap` directory to avoid confusion due to the large number of changed files.
42+
```bash
43+
mkdir -p $WORKDIR/gno/examples/gno.land/p/gnoswap
44+
cp -R contract/p/gnoswap/* $WORKDIR/gno/examples/gno.land/p/gnoswap/
45+
```
15846

159-
First, navigate to the `gno/examples` directory:
47+
3. Copy realms:
16048

16149
```bash
162-
cd $WORKDIR/gno/examples
50+
mkdir -p $WORKDIR/gno/examples/gno.land/r/gnoswap/v1
51+
cp -R contract/r/gnoswap/* $WORKDIR/gno/examples/gno.land/r/gnoswap/v1/
16352
```
16453

165-
Next, move to the Realm directory you want to test (such as `pool`, `staker`, etc.), then run the tests using the `gno test` command:
54+
4. Copy test tokens:
16655

16756
```bash
168-
gno test -root-dir $WORKDIR/gno -v=false ./gno.land/r/gnoswap/v1/pool
57+
cp -R contract/r/gnoswap/test_token/* $WORKDIR/gno/examples/gno.land/r/
16958
```
17059

171-
## Realms
60+
## Directory Structure
17261

173-
### Core Realms Deployed on Testnet5
174-
175-
- pool: [gno.land/r/gnoswap/v1/pool](https://gnoscan.io/realms/details?path=gno.land/r/gnoswap/v1/pool)
176-
- position: [gno.land/r/gnoswap/v1/position](https://gnoscan.io/realms/details?path=gno.land/r/gnoswap/v1/position)
177-
- router: [gno.land/r/gnoswap/v1/router](https://gnoscan.io/realms/details?path=gno.land/r/gnoswap/v1/router)
178-
- staker: [gno.land/r/gnoswap/v1/staker](https://gnoscan.io/realms/details?path=gno.land/r/gnoswap/v1/staker)
62+
```
63+
gnoswap/
64+
├── contract/ # Smart contracts
65+
│ ├── p/ # Packages (libraries)
66+
│ │ └── gnoswap/
67+
│ │ ├── gnsmath/ # AMM math utilities
68+
│ │ ├── int256/ # 256-bit signed integers
69+
│ │ ├── uint256/ # 256-bit unsigned integers
70+
│ │ ├── rbac/ # Role-based access control
71+
│ │ └── consts/ # Protocol constants
72+
│ │
73+
│ └── r/ # Realms (contracts)
74+
│ └── gnoswap/
75+
│ ├── v1/ # Protocol v1 contracts
76+
│ │ ├── pool/ # Concentrated liquidity pools
77+
│ │ ├── position/ # LP position NFTs
78+
│ │ ├── router/ # Swap routing
79+
│ │ ├── staker/ # Liquidity mining
80+
│ │ ├── gov/ # Governance
81+
│ │ ├── launchpad/ # Token distribution
82+
│ │ ├── protocol_fee/ # Fee management
83+
│ │ └── community_pool/ # Treasury
84+
│ │
85+
│ ├── access/ # Access control
86+
│ ├── emission/ # GNS emission
87+
│ ├── gns/ # GNS token
88+
│ ├── halt/ # Emergency pause
89+
│ ├── rbac/ # RBAC realm
90+
│ ├── referral/ # Referral system
91+
│ └── test_token/ # Test tokens
92+
93+
├── tests/ # Test suites
94+
│ ├── scenario/ # Scenario-based tests
95+
│ ├── integration/ # Integration tests
96+
│ └── deploy/ # Deployment scripts
97+
98+
└── scripts/ # Utility scripts
99+
```
179100

180-
## Development Environment Setup
101+
## Testing
181102

182-
### Using Docker (Recommended)
103+
### Run All Tests
183104

184-
1. Build the Docker image:
185105
```bash
186-
make docker-build
106+
make test
187107
```
188108

189-
2. Start the container:
190-
```bash
191-
make docker-up
192-
```
109+
### Run Specific Scenario Tests
193110

194-
3. Access the container shell:
195111
```bash
196-
make docker-shell
112+
make test-folder FOLDER=tests/scenario/pool
113+
make test-folder FOLDER=tests/scenario/router
197114
```
198115

199-
4. View logs:
200-
```bash
201-
make docker-logs
202-
```
116+
### Run Integration Tests
203117

204-
5. Stop the container:
205118
```bash
206-
make docker-down
119+
cd $WORKDIR/gno/examples
120+
gno test -root-dir $WORKDIR/gno -v=false ./gno.land/r/gnoswap/v1/pool
207121
```
208122

209-
### Manual Setup
123+
## Security
210124

211-
If you prefer to set up the environment manually:
125+
GnoSwap implements multiple layers of security across all contracts. For security concerns or vulnerability reports, see [SECURITY.md](SECURITY.md).
212126

213-
1. Install Python 3.11 or later
214-
2. Install uv package manager:
215-
```bash
216-
pip install uv
217-
```
127+
## License
218128

219-
3. Create a virtual environment and install dependencies:
220-
```bash
221-
uv venv
222-
source .venv/bin/activate # On Unix/macOS
223-
# or
224-
.venv\Scripts\activate # On Windows
225-
uv pip install -r requirements.txt
226-
```
129+
Licensed under the GNU Affero General Public License v3.0. See [LICENSE](LICENSE) for details.
130+
131+
## Contributing
132+
133+
Contributions are welcome! Please follow existing patterns, include tests, and maintain documentation.

0 commit comments

Comments
 (0)