Liquidity Provider Fees
There is a 0.3% fee for swapping tokens. This fee is split by liquidity providers proportional to their contribution to liquidity reserves. Swapping fees are immediately deposited into liquidity reserves. This increases the value of liquidity tokens, functioning as a payout to all liquidity providers proportional to their share of the pool. Fees are collected by burning liquidity tokens to remove a proportional share of the underlying reserves. Since fees are added to liquidity pools, the invariant increases at the end of every trade. Within a single transaction, the invariant representstoken0_pool * token1_pool
at the end of the previous transaction.
The 0.3% fee is automatically applied to all swaps and distributed to liquidity providers based on their proportional share of the pool.
How Fees Work
When a user swaps tokens on Shibaswap v1:- Fee Calculation: A 0.3% fee is calculated on the input amount
- Fee Distribution: The fee is added to the liquidity reserves
- LP Token Value: This increases the value of all LP tokens in the pool
- Proportional Rewards: Each liquidity provider receives rewards proportional to their share
Protocol Fees
At the moment there are no protocol fees in Shibaswap v1. However, it is possible for a 0.05% fee to be turned on in the future.Protocol fees would be separate from liquidity provider fees and would be collected by the protocol itself, not distributed to liquidity providers.
Protocol Charge Calculation
In the future, it is possible that a protocol-wide charge of 0.05% per trade will take effect. This represents ⅙th (16.6̅%) of the 0.30% fee. The fee is in effect iffeeTo
is not address(0)
(0x0000000000000000000000000000000000000000
), indicating that feeTo
is the recipient of the charge.
This amount would not affect the fee paid by traders, but would affect the amount received by liquidity providers.
Rather than calculating this charge on swaps, which would significantly increase gas costs for all users, the charge is instead calculated when liquidity is added or removed.
Fee Implementation Details
Factory Contract
The Factory contract manages protocol fees through thefeeTo
and feeToSetter
addresses:
Pair Contract
The Pair contract handles fee collection during swaps:Fee Distribution Mechanics
For Liquidity Providers
- Automatic Distribution: Fees are automatically distributed to all LP token holders
- Proportional Rewards: Rewards are proportional to LP token ownership
- Compounding Effect: Fees compound over time, increasing LP token value
- No Claiming Required: No manual claiming process needed
For Traders
- Transparent Pricing: Fees are included in swap calculations
- Slippage Protection: Set minimum output amounts to account for fees
- Gas Efficiency: Fees are calculated efficiently to minimize gas costs
When calculating expected output amounts, always account for the 0.3% fee. The SDK provides helper functions to calculate amounts with fees included.
Fee Optimization
For Traders
- Batch Transactions: Combine multiple swaps to reduce total fees
- Optimal Routes: Use the SDK to find the most efficient swap paths
- Slippage Settings: Set appropriate slippage tolerance to avoid failed transactions
For Liquidity Providers
- Long-term Holding: Hold LP tokens longer to benefit from fee compounding
- High-Volume Pairs: Focus on pairs with high trading volume for more fee income
- Impermanent Loss: Consider impermanent loss vs. fee income
Always verify fee calculations in your smart contract integrations. Incorrect fee handling can lead to failed transactions or unexpected results.
Fee Comparison
Protocol | Swap Fee | LP Fee | Protocol Fee |
---|---|---|---|
Shibaswap v1 | 0.3% | 0.3% | 0% (potential 0.05%) |
Uniswap v2 | 0.3% | 0.3% | 0% (potential 0.05%) |
SushiSwap | 0.3% | 0.25% | 0.05% |
Shibaswap v1 currently has the same fee structure as Uniswap v2, with all fees going to liquidity providers.