1

My question is did Uniswap and other dexes that have same concept of amountOutMin would calc it like that:
amountOutMin = minimum amount that i want - the dex fee
or
amountOutMin = minimum amount that i want, and they will sub the fee and give me the rest

In code:

// So i should calc the fee then ask for minimum
routerToBuy.swapExactTokensForTokens(amountIn, amountOutMin - fee, path, address(this), deadline);

// Or i ask for the minimum and they will sub the fee then give me the rest (amountOutMin - fee)
routerToBuy.swapExactTokensForTokens(amountIn, amountOutMin, path, address(this), deadline);

1 Answer 1

1

The answer is 90% yes. Most of dexes at the moment are cloned from uniswap, eg: Pancakeswap, ApeSwap, Quickswap, etc. So, basically, if the dexes are forked from Uniswap, they have same calculation because they use the same infrastructure. On the other hand, if dexes are not forked from Uniswap, eg: KyberSwap, etc., they should have difference calculation.

3
  • Which one are correct amountOutMin = minimum amount that i want - the dex fee or amountOutMin = minimum amount that i want, and they will sub the fee and give me the rest
    – CorrM
    Commented Dec 27, 2023 at 21:30
  • 1
    The corrected one is amountOutMin = minimum amount that i want - the dex fee. Because amountOutMin is the minimum acceptable amount of output tokens that you want to receive after accounting for any fees (slippage tolerance). This ensures that even if the price slips due to market fluctuations or fees, you still receive at least the minimum amount you're willing to accept.
    – tqdpham96
    Commented Dec 27, 2023 at 21:46
  • Another question: is GetAmountsOut will return the output amount - fee or output amount. so i need to calc fee with the result i get of GetAmountsOut or already calculated.
    – CorrM
    Commented Dec 28, 2023 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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