The codebase includes multiple conversions from u128 to u64 without adequate checks, potentially causing precision loss for large token amounts and affecting users with significant liquidity positions.
Mechanism: The code performs arithmetic operations using u128 to avoid overflow but then casts results back to u64 without verifying that no precision is lost.
Root Cause: Direct casting from u128 to u64 without checking if the value exceeds u64::MAX:
Attack Vector: Not directly exploitable, but could affect high-value users by truncating their token amounts if calculations exceed u64::MAX.
Similar patterns appear in multiple locations, including lines 328-332 and in the liquidity_calculation function.
Likelihood:
Likelihood Assessment:
Attack Complexity: High - Requires extremely large token amounts
Prerequisites: Very large liquidity positions or token supplies
Impact:
Impact Assessment:
Integrity: Low - Could affect calculation accuracy in extreme cases
Financial: Low - Potential loss of funds only in edge cases with very large values
N/A
Add overflow checks before casting from u128 to u64:
Apply similar checks to all locations where u128 is cast to u64.
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.