In the liquidity_operations.rs file, values are cast from u128
to u64
without checking whether the value fits within the u64
range. This can lead to silent truncation and incorrect calculations, especially when large input values are used.
In liquidity_calculation
:
In calculate_token_b_provision_with_a_given
:
In remove_liquidity
instruction:
A malicious or misconfigured input could trigger an overflow scenario that causes token misallocation, accounting errors, or unexpected program behavior.
In the worst case, truncated values could result in incorrect minting or burning of tokens, potentially leading to financial loss or denial of service.
Use .try_into()
or .try_from()
with proper error propagation instead of direct as
casting. This ensures the operation fails safely if the value exceeds u64::MAX
.
Example fix for liquidity_calculation
:
Apply similar error-handled casting in all other instances of u128 -> u64
conversions.
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.