In the swap_exact_in
instruction, the code includes a check to ensure that the amount_out
does not exceed the available reserve of the output token. However, the current check uses a strict less-than comparison (amount_out < reserve_b
), which prevents users from swapping the full reserve amount. Additionally, the check only covers one swap direction (zero_for_one == true
) and does not symmetrically validate the other direction (zero_for_one == false
). This inconsistency may lead to unexpected swap failures or potential liquidity issues.
The current strict less-than check can reject valid swap transactions where the user intends to swap the entire available reserve, causing a poor user experience or failed transactions. Moreover, the absence of a similar check in the reverse swap direction leaves the contract vulnerable to inconsistent behavior and potential underflow or liquidity errors.
Change the check to use <=
(less than or equal) to allow swapping the full available reserve amount.
Add symmetric reserve checks for both swap directions as shown below:
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.