2

I elect to swap 100 UNI for 700 USDC on UniSwap, but with a low gas fee. In 1 hour, the price of 1 UNI has dropped significantly. would the pending transaction still swap for 700 USDC (as long as there is sufficient liquidity, in which case I guess it would be cancelled), or would the price not have been 'locked in' at the point the swapper confirmed the swap in Metamask?

1 Answer 1

2

The price is not locked in. The swap rate you receive will be the rate of the pair at the time that your transaction is included in a block. However, the Uniswap protocol has a "slippage" parameter built in that will cause the transaction to fail if the price has moved too much.

When you transfer on the Uniswap interface, it sets an amountOut parameter that defines the least amount of tokens you may receive. In your example, this parameter could be set to 650 USDC, for example. If the swap gives you less than 650 USDC when the transaction is finally included in a block, the transaction will fail and you will still have 100 UNI (and no USDC).

You can see the code for it here.

1
  • 1
    ah I wondered what slippage was, I thought it was just how much you were losing in fees, thanks for explaining that!
    – timhc22
    Commented Jan 22, 2021 at 3:06

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.