GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — "execution reverted: Insufficient WETH9" on Polygon · Issue #346 · uniswap-python/uniswap-python

"execution reverted: Insufficient WETH9" on Polygon #346

New issue
Copy link
New issue
Copy link
Open
Open
"execution reverted: Insufficient WETH9" on Polygon#346
Copy link
Labels
bugSomething isn't workingSomething isn't working

Description

@Lv5Electro
Lv5Electro
opened on Sep 6, 2023
Issue body actions

Describe the bug
I want to transfer AMP to MATIC(not WMATIC),but I got a error

Traceback (most recent call last):
  File "D:\uniswap-python\examples\qyx_test.py", line 29, in <module>
    data = uniswap.make_trade(amp, matic, qty=qty, slippage=0.1, fee=3000)
  File "D:\uniswap-python\uniswap\decorators.py", line 38, in approved
    return method(self, *args, **kwargs)
  File "D:\uniswap-python\uniswap\uniswap.py", line 473, in make_trade
    input_token, qty, recipient, fee, slippage, fee_on_transfer
  File "D:\uniswap-python\uniswap\uniswap.py", line 690, in _token_to_eth_swap_input
    self._get_tx_params(),
  File "D:\uniswap-python\uniswap\uniswap.py", line 1443, in _build_and_send_tx
    transaction = function.build_transaction(tx_params)
  File "D:\uniswap-python\venv\lib\site-packages\web3\contract\contract.py", line 340, in build_transaction
    **self.kwargs,
  File "D:\uniswap-python\venv\lib\site-packages\web3\contract\utils.py", line 232, in build_transaction_for_function
    prepared_transaction = fill_transaction_defaults(w3, prepared_transaction)
  File "cytoolz\\functoolz.pyx", line 263, in cytoolz.functoolz.curry.__call__
  File "D:\uniswap-python\venv\lib\site-packages\web3\_utils\transactions.py", line 132, in fill_transaction_defaults
    default_val = default_getter(w3, transaction)
  File "D:\uniswap-python\venv\lib\site-packages\web3\_utils\transactions.py", line 72, in <lambda>
    "gas": lambda w3, tx: w3.eth.estimate_gas(tx),
  File "D:\uniswap-python\venv\lib\site-packages\web3\eth\eth.py", line 293, in estimate_gas
    return self._estimate_gas(transaction, block_identifier)
  File "D:\uniswap-python\venv\lib\site-packages\web3\module.py", line 74, in caller
    method_str, params, error_formatters, null_result_formatters
  File "D:\uniswap-python\venv\lib\site-packages\web3\manager.py", line 251, in request_blocking
    response, params, error_formatters, null_result_formatters
  File "D:\uniswap-python\venv\lib\site-packages\web3\manager.py", line 209, in formatted_response
    apply_error_formatters(error_formatters, response)
  File "D:\uniswap-python\venv\lib\site-packages\web3\manager.py", line 85, in apply_error_formatters
    formatted_resp = pipe(response, error_formatters)
  File "cytoolz\\functoolz.pyx", line 680, in cytoolz.functoolz.pipe
  File "cytoolz\\functoolz.pyx", line 655, in cytoolz.functoolz.c_pipe
  File "D:\uniswap-python\venv\lib\site-packages\web3\_utils\contract_error_handling.py", line 139, in raise_contract_logic_error_on_revert
    raise ContractLogicError(message, data=data)
web3.exceptions.ContractLogicError: execution reverted: Insufficient WETH9

To Reproduce
this is my code

w3 = Web3(Web3.HTTPProvider('https://rpc-mainnet.maticvigil.com',
                            request_kwargs={"proxies": proxies}))
w3.middleware_onion.inject(geth_poa_middleware, layer=0)

uniswap = Uniswap(address=address, private_key=private_key, version=3, web3=w3)

qty = 5 * 10 ** 18

amp = w3.to_checksum_address("0x0621d647cecbFb64b79E44302c1933cB4f27054d")
matic = w3.to_checksum_address("0x0000000000000000000000000000000000001010")

data = uniswap.make_trade(amp, matic, qty=qty, slippage=0.1, fee=3000)
print(data)

Additional context
I set in the constants.py ETH_ADDRESS = "0x0000000000000000000000000000000000001010"

Activity

  1. Lv5Electro
    added
    bugSomething isn't workingSomething isn't working
    on Sep 6, 2023
  2. liquid-8 commented on Sep 7, 2023

    @liquid-8
    liquid-8
    on Sep 7, 2023
    Member
    More actions

    Hi! Does it work as intended if you swap the token for a wrapped matic? I haven't touched alt networks for aeons, but I remember some weird issues regarding swaps from/to native tokens.

  3. Lv5Electro commented on Sep 7, 2023

    @Lv5Electro
    Lv5Electro
    on Sep 7, 2023
    Author
    More actions

    Hi! Does it work as intended if you swap the token for a wrapped matic? I haven't touched alt networks for aeons, but I remember some weird issues regarding swaps from/to native tokens.

    I tried, but it transferred to WMATIC instead of MATIC

  4. liquid-8 commented on Sep 7, 2023

    @liquid-8
    liquid-8
    on Sep 7, 2023
    Member
    More actions

    I would just swap token<->wmatic then unwrapping manually when needed. Basically, uni v2/v3 router calls don't swap for native tokens directly, but for wrapped first and then unwrap, so it's pretty the same. IIRC, there is a call for wrapping/unwrapping native tokens in router's contract, check ABI out.

  5. liquid-8 commented on Sep 7, 2023

    @liquid-8
    liquid-8
    on Sep 7, 2023
    Member
    More actions

    Btw, try to set WETH9_ADDRESS in ./constants.py to 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270

  6. zaneran9 commented on Aug 6, 2024

    @zaneran9
    zaneran9
    on Aug 6, 2024
    More actions

    I tried to execute my transaction using multicall(exactInputSingle, unwrapWETH9), and it returned "execution reverted: Insufficient WETH9". Obviously, the first step was successful, and the problem was with unwrapWETH9;

    I tested using the WETH9 contract to execute the withdraw method, and it was able to be withdrawn, but I used the Router contract unwrapWETH9 method to execute it, and then it returned the above error (here is my transaction record https://sepolia.etherscan.io/tx/0xfd28c046a6e41a4ac0cbf1be7219a9bcf3c2c125ae9af2ac5129c9f8f36100b1), any suggestions? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.