Skip to content

Commit aa8d8bb

Browse files
committed
refactor: readme
1 parent ff143dd commit aa8d8bb

5 files changed

Lines changed: 196 additions & 35 deletions

File tree

README.md

Lines changed: 192 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,224 @@
22

33
Smart contracts for yield farming on Push Chain (PC) token ecosystem.
44

5-
## Quick Start
5+
## Architecture
6+
7+
Three staking contracts for different yield farming scenarios:
8+
9+
1. **MigrationYieldFarm** - Epoch-based staking with migration incentives
10+
2. **RewardSeasonsYieldFarm** - Seasonal staking with snapshot-based rewards
11+
3. **LPYield/UniswapV3Staker** - LP position staking for Uniswap V3
12+
13+
## Prerequisites
614

715
```bash
8-
# Install dependencies
16+
# Install Foundry
17+
curl -L https://foundry.paradigm.xyz | bash
18+
foundryup
19+
20+
# Install Node.js dependencies for Merkle tree generation
21+
npm install
22+
```
23+
24+
## Setup
25+
26+
```bash
27+
# Install Foundry dependencies
928
forge install
10-
npm install ethers merkletreejs
1129

12-
# Build and test
30+
# Build all contracts
1331
forge build
14-
forge test
1532

16-
# Deploy
17-
forge script script/DeployMigrationYieldFarm.s.sol --rpc-url <rpc> --private-key <key> --broadcast
33+
# Run all tests
34+
forge test
1835
```
1936

20-
## Contracts
37+
## Contract Specifications
2138

22-
- **MigrationYieldFarm**: Main staking contract with epoch-based rewards
23-
- **UniswapV3Staker**: LP position staking for Uniswap V3
39+
### MigrationYieldFarm
40+
- Lock period: 90 days (3 months)
41+
- Epoch duration: 21 days
42+
- Cooldown: 1 epoch (21 days)
43+
- Features: Merkle whitelist, epoch-based rewards, migration tracking, upgradeable
2444

25-
## Architecture
45+
### RewardSeasonsYieldFarm
46+
- Season duration: 90 days (3 months)
47+
- Lock period: Full season (no early unstaking)
48+
- Cooldown: 7 days (configurable)
49+
- Features: Merkle whitelist with multipliers, season-end snapshot, combined harvest+unstake
2650

27-
- **Epoch-based Staking**: Configurable epochs with cumulative stake tracking
28-
- **Merkle Whitelist**: Address validation using Merkle proofs
29-
- **Lock Periods**: Configurable lock and cooldown periods
30-
- **Proxy Pattern**: TransparentUpgradeableProxy for upgradeable contracts
51+
### LPYield/UniswapV3Staker
52+
- Incentive duration: Up to 90 days
53+
- Features: Real-time rewards, time-weighted distribution, multiple incentives, direct LP staking
3154

32-
## Key Functions
55+
## Deployment
3356

34-
```solidity
35-
// User functions
36-
function stake(bytes32[] calldata proof, uint256 amount, uint256 epoch) external payable
37-
function requestUnstake(uint256 amount) external
38-
function withdraw() external
39-
function harvestRewards() external
57+
### MigrationYieldFarm
58+
```bash
59+
# Update script/DeployMigrationYieldFarm.s.sol with:
60+
# - merkleRoot: Whitelist merkle root
61+
# - owner_: Admin address
62+
# - lockDays: Lock period (default: 90)
63+
# - cooldownEpochs: Cooldown in epochs (default: 1)
64+
# - rewardsDays: Epoch duration (default: 21)
65+
66+
forge script script/DeployMigrationYieldFarm.s.sol \
67+
--rpc-url <your-rpc-url> \
68+
--private-key <your-private-key> \
69+
--broadcast
70+
```
4071

41-
// Admin functions
42-
function addCurrentEpochReward() external payable
43-
function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner
72+
### RewardSeasonsYieldFarm
73+
```bash
74+
# Update script/DeployRewardSeasonsYieldFarm.s.sol with:
75+
# - merkleRoot: Whitelist merkle root
76+
# - owner_: Admin address
77+
# - lockPeriod: Season duration (default: 90 days)
78+
# - cooldownPeriod: Cooldown period (default: 7 days)
79+
80+
forge script script/DeployRewardSeasonsYieldFarm.s.sol \
81+
--rpc-url <your-rpc-url> \
82+
--private-key <your-private-key> \
83+
--broadcast
84+
```
85+
86+
### LPYield/UniswapV3Staker
87+
```bash
88+
# Update script/DeployLPYield.s.sol with:
89+
# - factory: Push Chain Uniswap V3 Factory address
90+
# - positionManager: Push Chain Position Manager address
91+
# - maxIncentiveStartLeadTime: Max advance notice (default: 30 days)
92+
# - maxIncentiveDuration: Max incentive duration (default: 90 days)
93+
94+
forge script script/DeployLPYield.s.sol \
95+
--rpc-url <your-rpc-url> \
96+
--private-key <your-private-key> \
97+
--broadcast
4498
```
4599

46100
## Testing
47101

102+
### Run All Tests
48103
```bash
49-
# Run all tests
50104
forge test
105+
forge test -v
106+
forge test --gas-report
107+
```
108+
109+
### Contract-Specific Tests
110+
```bash
111+
# MigrationYieldFarm
112+
forge test --match-contract MigrationYieldFarmTest
51113

52-
# Run specific test
53-
forge test --match-test test_7_HighTrafficStressTest
114+
# RewardSeasonsYieldFarm
115+
forge test --match-contract RewardSeasonsYieldFarmTest
54116

55-
# Gas report
56-
forge test --gas-report
117+
# LPYield/UniswapV3Staker
118+
forge test --match-contract UniswapV3StakerForkTest
57119
```
58120

59-
## Merkle Tree
121+
### Function-Specific Tests
122+
```bash
123+
forge test --match-test test_Stake_NewUser
124+
forge test --match-test test_CompleteRealLifecycleStaking
125+
forge test --match-test test_ReentrancyProtection_Complete
60126

61-
Generate whitelist using the provided script:
127+
# Pattern matching
128+
forge test --match-test "test_Stake*"
129+
forge test --match-test "*Security*"
130+
```
131+
132+
### Fork Testing
133+
LPYield tests use real Push Chain testnet fork and take longer due to network interaction.
134+
135+
## Merkle Tree Generation
136+
137+
### MigrationYieldFarm Whitelist
138+
```bash
139+
cd scripts
140+
node generate-merkle.js
141+
```
142+
143+
### RewardSeasonsYieldFarm Whitelist
62144
```bash
63-
cd scripts && node generate-merkle.js
145+
cd scripts
146+
node generate-reward-merkle.js
64147
```
65148

66-
## License
149+
### Customize Whitelist
150+
Edit the `claims` array in the respective script files:
151+
```javascript
152+
const claims = [
153+
{
154+
address: "0x...", // User address
155+
amount: "1000000000000000000", // Stake amount (wei)
156+
epoch: 1 // Migration epoch
157+
}
158+
// Add more users...
159+
];
160+
```
161+
162+
## Development Commands
163+
164+
### Build
165+
```bash
166+
forge build
167+
forge build --contracts src/MigrationYieldFarm.sol
168+
forge build --use solc:0.8.23
169+
```
67170

68-
MIT
171+
### Code Quality
172+
```bash
173+
forge lint
174+
forge fmt
175+
forge inspect --pretty
176+
```
177+
178+
### Gas Analysis
179+
```bash
180+
forge test --match-contract RewardSeasonsYieldFarmTest --gas-report
181+
forge snapshot
182+
```
183+
184+
## Production Deployment
185+
186+
### Pre-Deployment Checklist
187+
- [ ] Update merkle root in deployment scripts
188+
- [ ] Set correct owner address
189+
- [ ] Verify RPC endpoint and network
190+
- [ ] Test deployment on testnet first
191+
- [ ] Verify contract addresses on explorer
192+
- [ ] Test all admin functions
193+
- [ ] Verify merkle proof verification
194+
195+
### Post-Deployment
196+
- [ ] Verify contract initialization
197+
- [ ] Test staking with valid merkle proofs
198+
- [ ] Test reward distribution
199+
- [ ] Test admin functions
200+
- [ ] Monitor for any issues
201+
- [ ] Document deployed addresses
202+
203+
## Repository Structure
204+
205+
```
206+
├── src/
207+
│ ├── MigrationYieldFarm.sol # Epoch-based staking
208+
│ ├── RewardSeasonsYieldFarm.sol # Seasonal staking
209+
│ └── LPYield/
210+
│ ├── UniswapV3Staker.sol # LP position staking
211+
│ ├── interfaces/ # Contract interfaces
212+
│ └── libraries/ # Utility libraries
213+
├── script/
214+
│ ├── DeployMigrationYieldFarm.s.sol # Migration deployment
215+
│ ├── DeployRewardSeasonsYieldFarm.s.sol # Seasonal deployment
216+
│ └── DeployLPYield.s.sol # LP staking deployment
217+
├── test/
218+
│ ├── MigrationYieldFarm.t.sol # Migration tests
219+
│ ├── RewardSeasonsYieldFarm.t.sol # Seasonal tests
220+
│ └── UniswapV3StakerFork.t.sol # LP staking tests
221+
├── scripts/
222+
│ ├── generate-merkle.js # Migration whitelist
223+
│ └── generate-reward-merkle.js # Seasonal whitelist
224+
└── foundry.toml # Foundry configuration
225+
```

lib/openzeppelin-contracts

Submodule openzeppelin-contracts added at 1c3d6c9

lib/openzeppelin-v5

Submodule openzeppelin-v5 added at 932fddf

lib/v3-core

Submodule v3-core added at e3589b1

lib/v3-periphery

Submodule v3-periphery added at 80f26c8

0 commit comments

Comments
 (0)