Can't unwrap WETH/WMATIC using smart contract wallets
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
The gas estimation fails when trying to unwrap tokens using some smart contract wallets, this leads to the transaction never being sent to the wallet, making the user unable to unwrap these assets.
Steps to Reproduce
- Create wallet on sequence.app
- Fund with some WMATIC
- Connect to Uniswap
- Try to exchange WMATIC for MATIC
- Nothing happens
Expected Behavior
The transaction request should be sent to the wallet.
Additional Context
As far as I can tell this happens because the dapp assumes the wallet to be an EOA, and performs the gas estimation call using it's own RPC. in smart contract wallets the receive method may access storage slots, and if these slots are "cold" when accessed then the limited gas available (when receiving MATIC or ETH) may not be enough, and the estimation fails with out of gas.
When these transactions are executed from the smart contract wallet, the execute entrypoint moves the access slots to the access list, allowing the unwrapped tokens to be received without running out of gas.
Possible solutions:
- Use the wallet provided rpc endpoint to do the gas estimation.
- Use a mapped gas limit when unwrapping native assets, avoiding estimation.
I could replicate this using Sequence, but the issue should exist on any smart contract wallet that needs to access storage when receiving native tokens.
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 by tracing the WMATIC-to-MATIC unwrap flow through gas estimation and the wallet RPC path, then compare it with the smart contract wallet's execute entrypoint. Check whether the estimation failure is avoided for the described wallet case, and verify that the transaction request reaches the wallet instead of stopping with an out-of-gas error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100