Uniswap / Uniswap/interface

Multistep tranasctions should always check deadlines in the first step.

Open
#2,320 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.5k
Forks
5.4k
PR merge metrics
No merged PRs in 30d

Description

Bug Description
When issuing a multicall transaction with multiple steps, if the first step doesn't check a deadline but later steps do then the transaction will unnecessarily burn a large amount of gas and then revert.

Steps to Reproduce
https://etherscan.io/tx/0x6da942398b522165efe28432259ff67606f615852fe6de5da7fb11cdc6262cfe
Notice that this is a multicall with:

  1. createAndInitializePoolIfNecessary
  2. mint
  3. refundETH

createAndInitializePoolIfNecessary costs over 4,000,000 gas and has no deadline check.
mint has a deadline checked that is checked as one of the very first things it does.

Expected Behavior
Any transaction with a deadline will check the deadline first, and fail out immediately without wasting much gas.

Additional Context
With a router update, you could add a deadline check to every function where some allow it to be 0.

With a router update, you could add a deadline to the multicall itself. This would save gas on any transaction that has multiple steps with a deadline check, as well as save gas for failures in scenarios like this.

With a router update, you could add a new function that only does a deadline check that can be included at the start of any multicalls that need to do deadline checks.

Without a router update, you could find a function that already exists on the router that has a deadline and can be called in a no-op way and add it as a first transaction in the multicall as a mechanism for checking if the deadline is passed or not and failing fast. This would cost a bit of extra gas, but it has potential to save users millions of gas like in the linked example. I'm not sure what functions would be eligible for such a thing, or if there is a way to add new multicall entrypoints without doing a full router update.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Etherscan transaction and trace the multicall steps through createAndInitializePoolIfNecessary, mint, and refundETH. Compare the proposed router update, multicall-level deadline, and no-op deadline-check alternatives; done requires an agreed design that fails before the expensive first step when a later deadline has expired.

Written by the indexing model from the issue text.

Assessment

Domain
blockchain
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.