Protocol Fee
Portion of trading, lending, or withdrawal fees retained by the protocol treasury rather than distributed to liquidity providers.
Protocol fees are charges taken by a DeFi protocol for its own treasury or token holders, separate from fees paid to liquidity providers. These fees fund development, create value for governance token holders, and ensure protocol sustainability.
Fee Structure Examples
Uniswap V3
- Swap fee: 0.01% - 1% (goes to LPs)
- Protocol fee: Optional, up to 1/4 of swap fee
- Controlled by governance
Balancer V2
- Swap fee: Pool-specific (goes to LPs)
- Protocol fee: Percentage of swap fees to treasury
- Flash loan fee: 0.01% (fully to protocol)
Aave V3
- Interest spread between borrowers and lenders
- Protocol takes portion of interest payments
- Liquidation bonus split with protocol
Fee Calculation
1// Example fee split2uint256 totalFee = swapAmount * feeRate / 10000;3uint256 protocolFee = totalFee * protocolFeePercentage / 10000;4uint256 lpFee = totalFee - protocolFee;
Security Considerations
Fee manipulation: Attackers may try to avoid or extract fees through:
- Flash loan arbitrage timing
- Sandwich attacks around fee changes
- Rounding exploitation on small amounts
Admin risk: Protocol fee changes can affect LP profitability and TVL.
Accounting errors: Fee calculation bugs can lead to fund loss or trapped value.
Fee Collection Patterns
Direct Collection
Fees collected immediately during swaps/operations.
Accrual Model
Fees accumulate and are claimed periodically (reduces gas costs).
Yield-Bearing
Protocol fee tokens are wrapped into yield-bearing assets.
Audit Focus Areas
- Verify fee calculations don't have rounding issues
- Check fee changes can't be front-run
- Ensure fee collection doesn't create reentrancy vectors
- Validate fee caps and governance controls
- Test edge cases: zero fees, maximum fees, fee changes mid-operation
Related Terms
Fee Tiers
Multiple fee levels (0.05%, 0.30%, 1.00%) per token pair in Uniswap v3 to accommodate different risk profiles.
Liquidity Provider (LP)
A user who deposits assets into a liquidity pool to facilitate trading, earning fees in return.
TVL
Total Value Locked representing the aggregate dollar value of assets deposited in a DeFi protocol at any given time.
Need expert guidance on Protocol Fee?
Our team at Zealynx has deep expertise in blockchain security and DeFi protocols. Whether you need an audit or consultation, we're here to help.
Get a Quote
