Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

"execution reverted" when using make_trade()

未關閉
#329 6 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
python

研究方向

Start with make_trade() in uniswap/uniswap.py, then follow the call into _token_to_token_swap_input() and _get_token_token_input_price() shown in the traceback. Reproduce the call against the reported WETH and APE pair and inspect the fee argument and pool lookup. Done when the cause is identified and the example either completes the swap or returns a clear explanation of the revert.

由索引模型根據 Issue 內容生成。

描述

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
主要語言
Python
星號
1k
分支
373
平均合併
4 天 11 小時
30 天內合併 PR
3

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

uniswap-python/uniswap-python 的其他 Issue

查看 uniswap-python/uniswap-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。