User swaps: 10 ETH → USDC
Execution:
1. User sends 10 ETH
2. Fee calculated: 10 * 0.1% = 0.01 ETH
3. 9.99 ETH routed to venue
4. Protocol accumulates: 0.01 ETH in feeAccumulatedETH
User swaps: 100,000 LINK → USDC
Execution:
1. User sends 100,000 LINK
2. Fee calculated: 100,000 * 0.1% = 100 LINK
3. 99,900 LINK routed to venue
4. Protocol accumulates: 100 LINK in feeAccumulated[LINK]
User swaps: 50,000 USDC → DAI
Execution:
1. User sends 50,000 USDC
2. Fee on input: 50,000 * 0.1% = 50 USDC
3. 49,950 USDC routed to venue
4. Receives ~49,950 DAI from venue
5. Protocol accumulates: 50 USDC
Swap Details:
├─ Input: 1000 USDC
├─ Expected Output: ~999 DAI (estimated)
├─ Protocol Fee: 1 USDC
├─ Venue Fee: ~0.01% (built into output)
├─ Total Slippage: 0.1%
└─ Final Amount: ~999 DAI
User confirms: "Yes, I accept these terms"
Owner-controlled fee structure
├─ Can adjust fee divisor
├─ Can add/remove fees for features
├─ Can enable/disable slippage charges
└─ Can withdraw accumulated fees
Purpose: Initial flexibility for protocol optimization
Protocol Token Distribution
├─ Community voting on fee structure
├─ Stakeholders vote on parameter changes
├─ Treasury allocation via DAO
├─ Transparent governance process
Benefits:
- Reduces operator risk
- Aligns incentives with stakeholders
- Increases protocol legitimacy
- Enables community involvement
uint public feeAccumulatedETH // ETH fees
mapping(address => uint) feeAccumulated // Token fees by address
Day 1: 1000 USDC fees accumulated
Day 2: 500 USDC + 0.5 ETH fees accumulated
Day 3: 1500 DAI fees accumulated
Total Treasury:
├─ USDC: 1500
├─ ETH: 0.5
└─ DAI: 1500
function withdrawFees() external onlyOwner {
// Transfers accumulated feeAccumulatedETH to owner
// Transfers accumulated tokens to owner
// Resets accumulators to zero
}