README.md
Protocol Fee
Fee collection and distribution for protocol operations.
Overview
The protocol-fee contract collects authorized fees from protocol operations and distributes them to GovStaker and DevOps according to configured percentages.
Configuration
- Router Fee (initial/default): 0.15% of the swap amount; configured by the router, with an admin-or-governance range of 0–10%
- Pool Creation Fee (initial/default): 100 GNS; configured by the pool and modifiable through governance
- Withdrawal Fee (initial/default): 1% of LP fees claimed; configured by the pool and modifiable through governance
- Unstaking Fee (initial/default): 1% of staking rewards; configured by the staker and modifiable by admin or governance
- Distribution (default): 100% to GovStaker and 0% to DevOps
The operation-specific fees above are configured in their owning modules; they are not protocol-fee distribution percentages.
Fee Sources
- Swaps: The router applies its configured swap fee (0.15% initially).
- Pool Creation: The pool charges its configured creation fee (100 GNS initially).
- LP Withdrawals: The pool charges its configured withdrawal fee (1% initially).
- Staking Claims: The staker charges its configured unstaking fee (1% initially).
Key Functions
DistributeProtocolFee
Distributes accumulated fees to recipients.
SetDevOpsPct
Sets the DevOps funding percentage.
SetGovStakerPct
Sets the GovStaker funding percentage.
AddToProtocolFee
Adds an approved fee amount to the distribution queue.
AdvanceAccrualEpoch
Closes the accrual epoch in force and returns the new one. Called by gov/staker on every stake change, so fees are attributed to the stake distribution live when they arrived.
ConsumeAccrualBuckets
Returns and clears up to limit of the oldest pending buckets of one token, as parallel epoch and amount slices. Called by gov/staker when that token is collected.
Usage
1// Distribute accumulated fees
2DistributeProtocolFee(cross(cur))
3
4// Configure distribution
5SetDevOpsPct(cross(cur), 2000) // 20% to DevOps
6SetGovStakerPct(cross(cur), 8000) // 80% to GovStaker
7
8// View tokens reserved for the next distribution
9GetReservedTokens()
10
11// View what gov/staker has not folded yet
12GetAccrualEpoch()
13GetAccrualPendingTokens()
14GetAccrualBuckets(tokenPath, 0)
Security
- Configuration changes are restricted to admin or governance; distribution is restricted to admin or gov/staker
- Automatic fee accumulation
- Multi-token support
- Transparent distribution tracking