2

The UniswapV2 Router02 performs a deadline check for adding/removing liquidity and swaps.

modifier ensure(uint deadline) {
    require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
    _;
}

When would one user require this functionality?

1 Answer 1

1

It is used just to make sure the transaction is completed in the required time. Let's say you want to swap TokenA with TokenB. Now as we know transactions sometimes take time to complete, and in such cases, the prices of your tokens might fluctuate a lot, resulting in your inputs not being valid anymore.

So basically, this modifier makes sure the transaction is completed in a given time frame and the user doesn't have to wait long.

11
  • Isn't the price fluctuation taken care of by specifying the amountMin that we expect to receive?
    – Maanas O T
    Commented Mar 16, 2023 at 19:23
  • Yes, but it also makes sure that the waiting time is less for the transaction to be confirmed. Commented Mar 17, 2023 at 4:42
  • How is that done? If even after the deadline, the transaction has not been mined, one can be sure that the transaction will be reverted. But I couldn't find an use case for this.
    – Maanas O T
    Commented Mar 17, 2023 at 17:57
  • @MaanasOT If the transaction is mined after the deadline the uniswap contract will revert it immediately. The user still has to pay the transaction fee, but it won't touch the tokens involved.
    – Ismael
    Commented Mar 19, 2023 at 2:10
  • @Ismael Yes I do get that. But what I wanted to know is a use case for a user wanting his transaction to reverted based on time. It makes sense to me that a user would want his transaction to be reverted based on price fluctuation, and that is taken care of by the amountMin parameter.
    – Maanas O T
    Commented Mar 19, 2023 at 2:37

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.