interface icon indicating copy to clipboard operation
interface copied to clipboard

Can't unwrap WETH/WMATIC using smart contract wallets

Open Agusx1211 opened this issue 3 years ago • 1 comments

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.

Agusx1211 avatar Jun 07 '22 09:06 Agusx1211

I met the same bug when trying to unwrap ETH (connect this interface by wallet-connect)

SnakeMM avatar Aug 31 '22 07:08 SnakeMM