387 lines
12 KiB
Markdown
387 lines
12 KiB
Markdown
|
|
# Complete Integration Guide: Reserve Backing + DODO PMM
|
||
|
|
|
||
|
|
**Date**: 2025-01-12
|
||
|
|
**Status**: Complete Implementation Guide
|
||
|
|
**Purpose**: End-to-end guide for implementing 1:1 backing and exchangeability
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Executive Summary
|
||
|
|
|
||
|
|
This guide provides a complete implementation path for making CompliantUSDT (cUSDT) and CompliantUSDC (cUSDC) exchangeable with official Tether USDT and Circle USDC tokens through:
|
||
|
|
|
||
|
|
1. **Reserve Backing Mechanism**: 1:1 backing with official tokens
|
||
|
|
2. **DODO PMM Integration**: Liquidity pools for exchangeability
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Architecture Overview
|
||
|
|
|
||
|
|
```
|
||
|
|
┌─────────────────────────────────────────────────────────────────┐
|
||
|
|
│ Reserve Backing Layer │
|
||
|
|
├─────────────────────────────────────────────────────────────────┤
|
||
|
|
│ Ethereum Mainnet (Official Tokens) │
|
||
|
|
│ ┌──────────────────┐ ┌──────────────────┐ │
|
||
|
|
│ │ Official USDT │ │ Official USDC │ │
|
||
|
|
│ └────────┬─────────┘ └────────┬─────────┘ │
|
||
|
|
│ │ │ │
|
||
|
|
│ │ Lock │ Lock │
|
||
|
|
│ ▼ ▼ │
|
||
|
|
│ ┌─────────────────────────────────────────┐ │
|
||
|
|
│ │ StablecoinReserveVault │ │
|
||
|
|
│ │ - Locks official tokens │ │
|
||
|
|
│ │ - Maintains 1:1 backing │ │
|
||
|
|
│ └────────┬────────────────────────────┬───┘ │
|
||
|
|
│ │ │ │
|
||
|
|
│ │ Mint │ Mint │
|
||
|
|
│ ▼ ▼ │
|
||
|
|
│ ┌──────────────────┐ ┌──────────────────┐ │
|
||
|
|
│ │ Compliant USDT │ │ Compliant USDC │ │
|
||
|
|
│ │ (cUSDT) │ │ (cUSDC) │ │
|
||
|
|
│ └────────┬─────────┘ └────────┬─────────┘ │
|
||
|
|
│ │ │ │
|
||
|
|
└───────────┼───────────────────────────┼─────────────────────────┘
|
||
|
|
│ │
|
||
|
|
│ Chain 138 │
|
||
|
|
│ │
|
||
|
|
┌───────────▼───────────────────────────▼─────────────────────────┐
|
||
|
|
│ DODO PMM Liquidity Layer │
|
||
|
|
├─────────────────────────────────────────────────────────────────┤
|
||
|
|
│ ┌─────────────────────────────────────────┐ │
|
||
|
|
│ │ DODOPMMIntegration │ │
|
||
|
|
│ │ - Pool management │ │
|
||
|
|
│ │ - Swap execution │ │
|
||
|
|
│ └────────┬────────────────────────────┬───┘ │
|
||
|
|
│ │ │ │
|
||
|
|
│ ┌────────▼────────┐ ┌────────▼────────┐ │
|
||
|
|
│ │ Pool: cUSDT │ │ Pool: cUSDC │ │
|
||
|
|
│ │ ↔ USDT │ │ ↔ USDC │ │
|
||
|
|
│ └─────────────────┘ └─────────────────┘ │
|
||
|
|
│ │
|
||
|
|
│ Benefits: │
|
||
|
|
│ • Price stability via PMM │
|
||
|
|
│ • Efficient liquidity │
|
||
|
|
│ • Market-driven peg maintenance │
|
||
|
|
│ • Exchangeability │
|
||
|
|
└───────────────────────────────────────────────────────────────┘
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Implementation Phases
|
||
|
|
|
||
|
|
### Phase 1: Reserve Backing Setup
|
||
|
|
|
||
|
|
**Goal**: Establish 1:1 backing mechanism
|
||
|
|
|
||
|
|
**Steps**:
|
||
|
|
|
||
|
|
1. **Deploy StablecoinReserveVault on Ethereum Mainnet**
|
||
|
|
```bash
|
||
|
|
# Set environment
|
||
|
|
export ETH_MAINNET_RPC_URL=https://...
|
||
|
|
export PRIVATE_KEY=0x...
|
||
|
|
export COMPLIANT_USDT_ADDRESS=0x...
|
||
|
|
export COMPLIANT_USDC_ADDRESS=0x...
|
||
|
|
|
||
|
|
# Deploy
|
||
|
|
forge script script/reserve/DeployStablecoinReserveVault.s.sol:DeployStablecoinReserveVault \
|
||
|
|
--rpc-url $ETH_MAINNET_RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 30000000000 \
|
||
|
|
--via-ir
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **Initial Funding**
|
||
|
|
- Deposit official USDT/USDC to vault
|
||
|
|
- Verify reserves match token supply
|
||
|
|
- Enable deposit/redemption functions
|
||
|
|
|
||
|
|
3. **Verification**
|
||
|
|
- Check backing ratios
|
||
|
|
- Test deposit/redemption flows
|
||
|
|
- Monitor reserve balances
|
||
|
|
|
||
|
|
**Timeline**: 1-2 days
|
||
|
|
**Cost**: ~0.05 ETH (deployment + initial funding gas)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### Phase 2: DODO PMM Integration
|
||
|
|
|
||
|
|
**Goal**: Create liquidity pools for exchangeability
|
||
|
|
|
||
|
|
**Steps**:
|
||
|
|
|
||
|
|
1. **Deploy DODOPMMIntegration**
|
||
|
|
```bash
|
||
|
|
# Set environment
|
||
|
|
export RPC_URL=https://...
|
||
|
|
export DODO_VENDING_MACHINE_ADDRESS=0x...
|
||
|
|
export COMPLIANT_USDT_ADDRESS=0x...
|
||
|
|
export COMPLIANT_USDC_ADDRESS=0x...
|
||
|
|
export OFFICIAL_USDT_ADDRESS=0x...
|
||
|
|
export OFFICIAL_USDC_ADDRESS=0x...
|
||
|
|
|
||
|
|
# Deploy
|
||
|
|
forge script script/dex/DeployDODOPMMIntegration.s.sol:DeployDODOPMMIntegration \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 30000000000 \
|
||
|
|
--via-ir
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **Create Pools**
|
||
|
|
- Create cUSDT/USDT pool
|
||
|
|
- Create cUSDC/USDC pool
|
||
|
|
- Configure optimal parameters
|
||
|
|
|
||
|
|
3. **Seed Liquidity**
|
||
|
|
- Add initial liquidity to pools
|
||
|
|
- Balance base/quote reserves
|
||
|
|
- Monitor pool health
|
||
|
|
|
||
|
|
**Timeline**: 2-3 days
|
||
|
|
**Cost**: ~0.03 ETH (deployment + pool creation gas)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### Phase 3: Integration & Testing
|
||
|
|
|
||
|
|
**Goal**: Integrate systems and test end-to-end
|
||
|
|
|
||
|
|
**Steps**:
|
||
|
|
|
||
|
|
1. **Integration Testing**
|
||
|
|
- Test reserve vault operations
|
||
|
|
- Test DODO pool swaps
|
||
|
|
- Test price stability
|
||
|
|
- Test arbitrage flows
|
||
|
|
|
||
|
|
2. **Monitoring Setup**
|
||
|
|
- Set up reserve monitoring
|
||
|
|
- Monitor pool prices
|
||
|
|
- Track liquidity depth
|
||
|
|
- Alert on deviations
|
||
|
|
|
||
|
|
3. **Documentation**
|
||
|
|
- User guides
|
||
|
|
- API documentation
|
||
|
|
- Integration examples
|
||
|
|
|
||
|
|
**Timeline**: 3-5 days
|
||
|
|
**Cost**: Gas for testing transactions
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### Phase 4: Production Launch
|
||
|
|
|
||
|
|
**Goal**: Launch to production with safety measures
|
||
|
|
|
||
|
|
**Steps**:
|
||
|
|
|
||
|
|
1. **Security Review**
|
||
|
|
- Audit contracts
|
||
|
|
- Review access controls
|
||
|
|
- Test emergency procedures
|
||
|
|
|
||
|
|
2. **Gradual Rollout**
|
||
|
|
- Start with limited deposits
|
||
|
|
- Monitor for 24-48 hours
|
||
|
|
- Gradually increase limits
|
||
|
|
|
||
|
|
3. **Ongoing Operations**
|
||
|
|
- Monitor reserves
|
||
|
|
- Maintain liquidity
|
||
|
|
- Adjust parameters as needed
|
||
|
|
|
||
|
|
**Timeline**: 1-2 weeks
|
||
|
|
**Cost**: Audit fees (~$10k-50k)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Configuration Parameters
|
||
|
|
|
||
|
|
### Reserve Vault
|
||
|
|
|
||
|
|
| Parameter | Recommended Value | Notes |
|
||
|
|
|-----------|------------------|-------|
|
||
|
|
| Initial Reserve | 10M+ tokens | For stability |
|
||
|
|
| Reserve Ratio | 100%+ | Always maintain 1:1+ |
|
||
|
|
| Pause Threshold | 95% backing | Safety margin |
|
||
|
|
|
||
|
|
### DODO Pools
|
||
|
|
|
||
|
|
| Parameter | Recommended Value | Notes |
|
||
|
|
|-----------|------------------|-------|
|
||
|
|
| Initial Price (i) | 1e18 ($1) | For stablecoins |
|
||
|
|
| K Factor | 0.3e18 - 0.5e18 | Lower = less slippage |
|
||
|
|
| LP Fee Rate | 3-10 bps | 0.03% - 0.1% |
|
||
|
|
| TWAP | Enabled | Price stability |
|
||
|
|
| Initial Liquidity | 1M+ tokens | For each pool |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Security Considerations
|
||
|
|
|
||
|
|
### Reserve Vault
|
||
|
|
|
||
|
|
1. **Multi-sig Admin**: Use multi-sig wallet for admin role
|
||
|
|
2. **Access Control**: Limit operator roles
|
||
|
|
3. **Pause Mechanism**: Test emergency pause
|
||
|
|
4. **Audit**: Professional security audit
|
||
|
|
5. **Monitoring**: Real-time reserve monitoring
|
||
|
|
|
||
|
|
### DODO Pools
|
||
|
|
|
||
|
|
1. **Pool Parameters**: Carefully set k and fees
|
||
|
|
2. **Liquidity Depth**: Maintain sufficient liquidity
|
||
|
|
3. **Price Monitoring**: Monitor for manipulation
|
||
|
|
4. **Slippage Protection**: Use appropriate limits
|
||
|
|
5. **Emergency Procedures**: Plan for pool issues
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Monitoring & Maintenance
|
||
|
|
|
||
|
|
### Key Metrics
|
||
|
|
|
||
|
|
1. **Reserve Vault**:
|
||
|
|
- Reserve balances (USDT/USDC)
|
||
|
|
- Token supply (cUSDT/cUSDC)
|
||
|
|
- Backing ratio (target: 100%+)
|
||
|
|
- Deposit/redemption volumes
|
||
|
|
|
||
|
|
2. **DODO Pools**:
|
||
|
|
- Pool reserves (base/quote)
|
||
|
|
- Pool price vs. peg
|
||
|
|
- Swap volumes
|
||
|
|
- LP fee accumulation
|
||
|
|
- Slippage rates
|
||
|
|
|
||
|
|
### Monitoring Tools
|
||
|
|
|
||
|
|
- Custom dashboards (Grafana, etc.)
|
||
|
|
- On-chain monitoring (The Graph, etc.)
|
||
|
|
- Alert systems (PagerDuty, etc.)
|
||
|
|
- Automated scripts (check reserves, etc.)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Cost Estimates
|
||
|
|
|
||
|
|
### Deployment Costs
|
||
|
|
|
||
|
|
| Item | Estimated Cost |
|
||
|
|
|------|---------------|
|
||
|
|
| Reserve Vault Deployment | ~0.05 ETH |
|
||
|
|
| DODO Integration Deployment | ~0.03 ETH |
|
||
|
|
| Pool Creation (2 pools) | ~0.02 ETH |
|
||
|
|
| Initial Funding Gas | ~0.01 ETH |
|
||
|
|
| **Total Deployment** | **~0.11 ETH** |
|
||
|
|
|
||
|
|
### Ongoing Costs
|
||
|
|
|
||
|
|
| Item | Estimated Cost |
|
||
|
|
|------|---------------|
|
||
|
|
| Gas for operations | Variable |
|
||
|
|
| Monitoring infrastructure | $50-200/month |
|
||
|
|
| Security audits | $10k-50k (one-time) |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Success Criteria
|
||
|
|
|
||
|
|
### Phase 1 Success
|
||
|
|
|
||
|
|
- ✅ Reserve vault deployed and verified
|
||
|
|
- ✅ Initial reserves deposited
|
||
|
|
- ✅ Backing ratio = 100%+
|
||
|
|
- ✅ Deposit/redemption tested
|
||
|
|
|
||
|
|
### Phase 2 Success
|
||
|
|
|
||
|
|
- ✅ DODO integration deployed
|
||
|
|
- ✅ Pools created with optimal parameters
|
||
|
|
- ✅ Initial liquidity seeded
|
||
|
|
- ✅ Pools operational
|
||
|
|
|
||
|
|
### Phase 3 Success
|
||
|
|
|
||
|
|
- ✅ End-to-end testing completed
|
||
|
|
- ✅ Monitoring systems operational
|
||
|
|
- ✅ Documentation complete
|
||
|
|
- ✅ Security review passed
|
||
|
|
|
||
|
|
### Phase 4 Success
|
||
|
|
|
||
|
|
- ✅ Production launch successful
|
||
|
|
- ✅ Reserves maintained at 100%+
|
||
|
|
- ✅ Pools maintain 1:1 peg
|
||
|
|
- ✅ User adoption growing
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Troubleshooting
|
||
|
|
|
||
|
|
### Reserve Backing Issues
|
||
|
|
|
||
|
|
**Problem**: Backing ratio < 100%
|
||
|
|
|
||
|
|
**Solution**:
|
||
|
|
1. Deposit more official tokens
|
||
|
|
2. Pause minting if needed
|
||
|
|
3. Investigate unauthorized minting
|
||
|
|
|
||
|
|
### Pool Price Deviation
|
||
|
|
|
||
|
|
**Problem**: Pool price deviates from $1
|
||
|
|
|
||
|
|
**Solution**:
|
||
|
|
1. Check pool reserves balance
|
||
|
|
2. Add/remove liquidity as needed
|
||
|
|
3. Monitor for large trades
|
||
|
|
4. Allow arbitrage to correct
|
||
|
|
|
||
|
|
### Liquidity Issues
|
||
|
|
|
||
|
|
**Problem**: Insufficient liquidity for swaps
|
||
|
|
|
||
|
|
**Solution**:
|
||
|
|
1. Add more liquidity to pools
|
||
|
|
2. Adjust k factor if needed
|
||
|
|
3. Incentivize LPs if necessary
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Next Steps After Implementation
|
||
|
|
|
||
|
|
1. **Marketing**: Promote exchangeability features
|
||
|
|
2. **Liquidity Mining**: Incentivize liquidity providers
|
||
|
|
3. **Partnerships**: Integrate with DeFi protocols
|
||
|
|
4. **Cross-Chain**: Expand to more chains
|
||
|
|
5. **Governance**: Consider DAO governance
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Resources
|
||
|
|
|
||
|
|
- [Reserve Backing Documentation](./RESERVE_BACKING_MECHANISM.md)
|
||
|
|
- [DODO PMM Documentation](./DODO_PMM_INTEGRATION.md)
|
||
|
|
- [DODO Official Documentation](https://docs.dodoex.io)
|
||
|
|
- Setup Scripts: `scripts/setup-reserve-vault.sh`, `scripts/setup-dodo-pools.sh`
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Support
|
||
|
|
|
||
|
|
For issues or questions:
|
||
|
|
1. Review documentation
|
||
|
|
2. Check troubleshooting section
|
||
|
|
3. Review contract code comments
|
||
|
|
4. Contact development team
|
||
|
|
|