Repository navigation
"execution reverted" when using make_trade() #329
Copy link
Copy link
Open
Description
Hello!
When trying to execute a swap using the make_trade() method I consistently get "web3.exceptions.ContractLogicError: execution reverted" error
This is the code that can be used to reproduce the error:
import os
from uniswap import Uniswap
weth_address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" # WETH
token_address = "0x4d224452801ACEd8B2F0aebE155379bb5D594381" # APE
uniswap = Uniswap(
address=os.environ.get('WALLET_ADDRESS'),
private_key=os.environ.get('WALLET_PRIVATE_KEY'),
provider=os.environ.get('PROVIDER_URL'),
version=3
)
tx = uniswap.make_trade(weth_address, token_address, qty=9000000000000000, slippage=0.3, fee=10000000)
print(tx)
Checking the APE/WETH pair on the Uniswap UI it seems to exist and also has good amount of liquidity.
Am I doing something wrong there?
Here is the full trace of the error:
File "/home/example/example.py", line 17, in <module>
tx = uniswap.make_trade(weth_address, token_address, qty=9000000000000000, slippage=0.3, fee=10000000)
File "/home/example/venv/lib64/python3.10/site-packages/uniswap/decorators.py", line 38, in approved
return method(self, *args, **kwargs)
File "/home/example/venv/lib64/python3.10/site-packages/uniswap/uniswap.py", line 476, in make_trade
return self._token_to_token_swap_input(
File "/home/example/venv/lib64/python3.10/site-packages/uniswap/uniswap.py", line 766, in _token_to_token_swap_input
* self._get_token_token_input_price(
File "/home/example/venv/lib64/python3.10/site-packages/uniswap/uniswap.py", line 340, in _get_token_token_input_price
).call()
File "/home/example/venv/lib64/python3.10/site-packages/web3/contract/contract.py", line 461, in call
return call_contract_function(
File "/home/example/venv/lib64/python3.10/site-packages/web3/contract/utils.py", line 96, in call_contract_function
return_data = w3.eth.call(
File "/home/example/venv/lib64/python3.10/site-packages/web3/eth/eth.py", line 255, in call
return self._durin_call(transaction, block_identifier, state_override)
File "/home/example/venv/lib64/python3.10/site-packages/web3/eth/eth.py", line 274, in _durin_call
return self._call(transaction, block_identifier, state_override)
File "/home/example/venv/lib64/python3.10/site-packages/web3/module.py", line 68, in caller
result = w3.manager.request_blocking(
File "/home/example/venv/lib64/python3.10/site-packages/web3/manager.py", line 232, in request_blocking
return self.formatted_response(
File "/home/example/venv/lib64/python3.10/site-packages/web3/manager.py", line 197, in formatted_response
apply_error_formatters(error_formatters, response)
File "/home/example/venv/lib64/python3.10/site-packages/web3/manager.py", line 73, in apply_error_formatters
formatted_resp = pipe(response, error_formatters)
File "cytoolz/functoolz.pyx", line 666, in cytoolz.functoolz.pipe
File "cytoolz/functoolz.pyx", line 641, in cytoolz.functoolz.c_pipe
File "/home/example/venv/lib64/python3.10/site-packages/web3/_utils/method_formatters.py", line 766, in raise_contract_logic_error_on_revert
raise ContractLogicError("execution reverted")
web3.exceptions.ContractLogicError: execution reverted
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
starascendin commentedon Apr 24, 2023
you might have to double check on the router abi vs the ones from this package
ggiv commentedon Apr 24, 2023
Thanks @starascendin ! The ABI and the router address looks correct to me. I am testing this on mainnet.
liquid-8 commentedon Apr 27, 2023
Not sure if
feeparam should be like that, more like 10,000 for 1% pools. I would recommend checking docs just in case.sitwano commentedon May 30, 2023
tx = uniswap.make_trade(weth_address, token_address, qty=9000000000000000, slippage=0.3, fee=10000000)
Also it looks like your slippage is also calculated wrong. It should be 0.3/100 as far I understand the docs.
Lv5Electro commentedon Sep 6, 2023
I got the same error,this is my args
this was traded on polygon
Lv5Electro commentedon Sep 6, 2023
I solved this problem. I set in the constants.py ETH_ADDRESS = "0x0000000000000000000000000000000000001010"
but I have a new problem #346