Submitted by 0xAlix2
/contracts/pool-manager/src/helpers.rs#L355-L364
Mantra only allows exact-in swaps; however, it provides a way for traders to compute a required amount to get an exact amount out. This could be done using query_reverse_simulation, from the code comments:
query_reverse_simulation calls compute_offer_amount, which computes offer_amount but floors the result:
The calculation here differs a bit from the calculation in compute_swap, this results in some dust differences. The main issue in the above is that it rounds the result down, which could result in underpayment, ultimately leading to unexpected results for traders and unexpected reverts to contracts built on top of this.
NB: It is better to pay some extra dust amount and get an expected amount out, rather than paying dust amount less and getting an amount less than expected.
Add the following test in contracts/pool-manager/src/tests/integration_tests.rs:
Round the offer_amount up, to make sure that the user is receiving the expected amount:
jvr0x (MANTRA) acknowledged and commented:
3docSec (judge) decreased severity to Low and commented:
a_kalout (warden) commented:
jvr0x (MANTRA) commented:
3docSec (judge) increased severity to Medium and commented:
