hats-finance / Common--Stableswap-0xd4d9a2772202ce33b24901d3fc94e95a84b37430

Apache License 2.0
0 stars 0 forks source link

token amount check is incorrect #10

Open hats-bug-reporter[bot] opened 3 months ago

hats-bug-reporter[bot] commented 3 months ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0xad337ae72586ac00818670e5495cdf21bd0aee16b2ea8f6df65c1aafe05ecbb2 Severity: medium

Description:

Description

inside fn _swap_exact_out the following check is performed:

   // Check if in token_in_amount is as constrained by the user
            ensure!(
->                token_in_amount <= max_token_in_amount,
                StablePoolError::InsufficientInputAmount
            );

This is to ensure that the received token amount is within the constraints of the user, the problem however is that it also reverts whenever it is = max_token_in_amount.

This means that the function will wrongly fail if the token_in_amount is equal to the max token in amount

Recommendation

- token_in_amount <= max_token_in_amount,
+ token_in_amount < max_token_in_amount,
whoismxuse commented 2 months ago

oversight on my end, invalid.