Multistep tranasctions should always check deadlines in the first step.
Nobody has claimed this yet.
- 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:
createAndInitializePoolIfNecessarymintrefundETH
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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