Summary
withdraw computes the token amount using:
let amount = (shares * pool.total_liquidity) / total_shares;
Both shares and pool.total_liquidity are i128. If a provider holds a large share position in a pool with high total liquidity, the intermediate multiplication shares * total_liquidity can overflow i128::MAX ≈ 1.7 × 10^38. The result would be silently wrong, producing an incorrect (possibly negative) withdrawal amount.
Location
contracts/liquidity-pool/src/lib.rs, withdraw
let amount = (shares * pool.total_liquidity) / total_shares; // ❌ no overflow guard
Fix
let amount = shares
.checked_mul(pool.total_liquidity)
.expect("share redemption calculation overflows i128")
/ total_shares;
Summary
withdrawcomputes the token amount using:Both
sharesandpool.total_liquidityarei128. If a provider holds a large share position in a pool with high total liquidity, the intermediate multiplicationshares * total_liquiditycan overflowi128::MAX ≈ 1.7 × 10^38. The result would be silently wrong, producing an incorrect (possibly negative) withdrawal amount.Location
contracts/liquidity-pool/src/lib.rs,withdrawFix