SSSwap

First Flight #41
Beginner FriendlyRust
100 EXP
View results
Submission Details
Impact: medium
Likelihood: high
Invalid

Rounding Errors in LP Token Distribution Favors Early Liquidity Providers

Root + Impact

Integer division and rounding silently favors early joiners with low granularity.

Description

  • When multiple users provide liquidity, the LP tokens are calculated via integer division. Rounding errors favor earlier users, causing fairness violations.

// @> liquidity_pool.rs
let share = (deposit_amount * total_lp_supply) / total_reserves; // @>

Risk

Likelihood:

  • Happens on every liquidity provision

  • Exacerbated with low total supply or small decimals

Impact:

  • LPs don’t receive fair share of pool

  • Encourages sybil early deposits to dominate share

Proof of Concept

  • Alice deposits first, gets 1 LP for 1000 tokens

  • Bob deposits same amount, gets 0.99 LP due to rounding

let share = (amount * total_supply) / reserves;

Recommended Mitigation

Use high-precision math libraries or implement compensation rounding like:

let share = (deposit_amount * total_lp_supply + total_reserves - 1) / total_reserves;

Or add small buffer for later joiners to level fairness.

Updates

Lead Judging Commences

0xtimefliez Lead Judge 7 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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