0

When I use, for example, the Uniswap front-end to do a swap and I select my desired slippage, where is Uniswap calculating the minAmountOut variable that goes into the swap and takes into account this slippage?

The rule is, to what I understand, that this calculation should never happen onchain in order to avoid MEV attacks.

Is Uniswap doing this calculation in the front-end offchain?

1 Answer 1

1

Yes, Uniswap calculates the minAmountOut variable off-chain to avoid MEV (flash loan attacks) and front-running. The calculation is done in the front-end, not on the blockchain.

When you interact with Uniswap's interface, the front-end calculates the minAmountOut based on the selected slippage tolerance. This value is then passed to the smart contract when you submit the swap transaction.

The smart contract checks if the actual output amount is greater than or equal to the minAmountOut value, ensuring that the swap is not unfavorable due to slippage.

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.