On Uniswap, which determines whether a trade goes through: the quote or the minimum amount received?

In a fixed-input swap on Uniswap v3, the quote is an estimate. When your wallet submits the transaction, the router contract reads another parameter, amountOutMinimum, which is the minimum amount received. The actual output must meet this threshold to pass the check. If it falls below the threshold, the contract reverts the swap.

For example, the page estimates that you’ll receive ten tokens, and the minimum amount you signed for is nine. If the actual amount comes to nine and a half, it still passes this check, even though it’s below the page’s quote. If it comes to only eight and a half, the swap will revert because it’s below the threshold. The threshold protects you from receiving too little, but the trade may fail as a result.

When a swap fails, first check the minimum amount received signed by the wallet and the failure reason in the receipt. If the minimum amount received check failed, get a new quote and verify the pool’s liquidity; this preserves the original price constraint better than simply setting the threshold to zero. Network fees should also be considered separately when calculating the actual cost. The amounts above are hypothetical and for technical discussion only.

$UNI #Uniswap #DeFi

Original source https://developers.uniswap.org/docs/protocols/v3/guides/swapping/single-hop-swapping

https://github.com/Uniswap/v3-periphery/blob/main/contracts/SwapRouter.sol