The protocol's fee calculation mechanism fails to properly offset losses against profits across multiple positions, resulting in users paying fees even when experiencing net losses. This design flaw disincentivizes users from creating multiple positions, potentially reducing overall pool liquidity.
The current fee calculation system processes each position independently, leading to suboptimal fee calculations
Consider this scenario:
Position 0: +10 (profit), 20% fee rate
Position 1: -100 (loss), 20% fee rate
Current behavior:
Net position: -90 (significant loss)
Fees charged: 2 (10 * 20% from profitable position)
User pays fees despite overall loss
This creates several issues:
Users pay fees even when experiencing net losses
Multiple positions are disadvantaged compared to single positions
Liquidity providers are discouraged from diversifying positions
Pool liquidity is reduced due to disincentivized participation
Loss of funds - Users pay excessive fees and receive reduced returns due to improper fee calculation across multiple positions.
Manual Review
Implement a weighted average fee calculation that considers net profits/losses:
This solution:
Considers total profit/loss across all relevant positions (positions that are being used to remove liquidity)
Applies fees only on net profits
Uses weighted average fee rates based on position sizes
Eliminates the penalty for holding multiple positions
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.