The fee calculation mechanism in the swap functions suffers from precision loss due to integer division, resulting in zero or reduced fees for small trade amounts.
The fee calculation uses the formula (amount * 3) / 1000
with floor division to compute 0.3% fees. However, this approach causes precision loss for trades smaller than 334 tokens, where the calculated fee rounds down to zero. Specifically:
Trades < 334 tokens: Zero fees charged (should be ~1 token)
Trades 334-666 tokens: Reduced fees (0.15-0.299% instead of 0.3%)
Trades ≥ 667 tokens: Accurate fees (0.3% as intended)
Manual code review
Static analysis of business logic
Revenue Loss: The protocol loses fee income from small trades
Economic Incentive: Users can exploit this by splitting large trades into smaller ones to minimize fees
Unfair Fee Structure: Creates an unintended fee discount for small trades while larger trades pay the full rate
Implementing higher precision arithmetic (using basis points) to ensure consistent fee collection across all trade sizes.
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.