Uniswap / Uniswap/interface

Can't unwrap WETH/WMATIC using smart contract wallets

Open
#3,890 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
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

  1. Create wallet on sequence.app
  2. Fund with some WMATIC
  3. Connect to Uniswap
  4. Try to exchange WMATIC for MATIC
  5. 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:

  1. Use the wallet provided rpc endpoint to do the gas estimation.
  2. 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.