SSSwap

First Flight #41
Beginner FriendlyRust
100 EXP
View results
Submission Details
Severity: medium
Valid

Precision Loss in Fee Calculation

Description: In the swap operations, inside the swap_operations::swap_exact_in function, fee calculations use integer division which can lead to precision loss, especially for small swap amounts. The fee is calculated as let lp_fees = (amount_out as u128 * 3).div_floor(&1000) as u64; , which rounds down and can result in zero fees for small transactions.

Impact: Users can exploit this by splitting large swaps into many small transactions to avoid paying fees, reducing protocol revenue and liquidity provider returns.

Proof of Concept: Instead of swapping 1000 tokens at once (which would incur a fee of 3 tokens), a user could perform 1000 swaps of 1 token each, potentially paying no fees due to rounding down.

Recommended Mitigation: Implement a minimum fee amount for all swaps, or use a more precise fee calculation method that accumulates fractional fees.

Updates

Lead Judging Commences

0xtimefliez Lead Judge 14 days ago
Submission Judgement Published
Validated
Assigned finding tags:

div_floor instead div_ceil during lp fee calculations

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.