In the token swap I am receiving less amount of the output token than that indicated in the parameter "amountOutMin". This is expected, because the token that I am swaping has a tax of 9%. What is not expected is that the transaction occurs. The transaction had to fail with "INSUFFICIENT_OUTPUT_AMOUNT". Since I am receiving less amount of tokens than the one indicated in the parameter "amountOutMin".

The token has 18 decimals (https://bscscan.com/token/0xf7469bad4e3da85b15b02a0dcfadb2c2d219a4b7)

Transaction: https://bscscan.com/tx/0xf8c1af25b432892f7c87ce57beacb938300ce7d6563cf17574ad8ec5e091ab85

Received: 3271.126023249240379059 tokens

amountOutMinParam: 3594640386952184892933 (18 decimal: 3594.640386952184892933)

The transaction has occurred even when the amount of output is less than amountOutMin. It seems that there is something important that I am not understanding.



The AMM is only checking that it is sending you the amountOutMin, not that you are receiving it. In other words, it calls a transfer for that token for an amount greater than or equal amountOutMin.

However, after the transfer is called by the AMM (from the pair to your address), the token contract burns the 9% tax you are mentioning. This is not captured by the AMM.

If you want the transaction to revert if the amount received is less than amountOutMin, you can use the function swapExactTokensForTokensSupportingFeeOnTransferToken function (and other similarly named functions) instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.