GeezerVison is showing github.com — web3.exceptions.ContractLogicError: execution reverted: Unexpected error uniswapv3 EUROC USDC pair · Issue #355 · uniswap-python/uniswap-python
web3.exceptions.ContractLogicError: execution reverted: Unexpected error uniswapv3 EUROC USDC pair #355DescriptionDescribe the bug
A pool exists for EUROC/EURC and USDC on Eth newtwork
https://info.uniswap.org/#/pools/0x95dbb3c7546f22bce375900abfdd64a4e5bd73d6
I can call USDC to ETH but for rate = uniswap.get_price_input on EUROC I get the below error
address used is
"0x1abaea1f7c830bd89acc67ec4af516284b1bc33c"
To Reproduce
from uniswap import Uniswap
from web3 import Web3
# EUROC==> USDC
def rates1():
uniswap = Uniswap(
version=2,
provider="https://mainnet.infura.io/v3/xxxxx",
address=None,
private_key=None,
)
exchange_fee = Decimal(from_wei(250000 * uniswap.w3.eth.gas_price, 18))
amount = to_wei(1, 6)
rate = uniswap.get_price_input(
Web3.to_checksum_address(
"0x1abaea1f7c830bd89acc67ec4af516284b1bc33c"
), # EUROC Add
Web3.to_checksum_address(
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
), # USDC Add
amount,
)
rate = Decimal(from_wei(rate, 6))
print("Fee: ", exchange_fee)
print("Rate: ", rate)
def to_wei(amount, decimal_places):
return amount * 10**decimal_places
def from_wei(amount, decimal_places):
return amount / 10**decimal_places
```
Steps to reproduce the behavior. Ideally, you can provide a code example demonstrating the issue (including the Uniswap version, tokens/route, and network used).
**Expected behavior**
expect to get the price
**Additional context**
Add any other context about the problem here, such as a transaction ID demonstrating the problem.
full stack trace is below
0|lightecho | [2023-10-27 09:30:31,775 api.py:458 ERROR] Exception raised by task: <coroutine object as_completed.._wait_for_one at 0x7f60b6712b20>
0|lightecho | Traceback (most recent call last):
0|lightecho | File "/home/lightecho/lightecho/./api/api.py", line 456, in ws_rates
0|lightecho | result = await task
0|lightecho | File "/usr/lib/python3.10/asyncio/tasks.py", line 571, in _wait_for_one
0|lightecho | return f.result() # May raise f.exception().
0|lightecho | File "/home/lightecho/lightecho/./api/api.py", line 167, in cached_rates
0|lightecho | result = await mod.rates(
0|lightecho | File "/home/lightecho/lightecho/api/integrations/uniswap_v3.py", line 118, in rates
0|lightecho | rate = await get_rate(
0|lightecho | File "/home/lightecho/lightecho/api/integrations/uniswap_v3.py", line 165, in get_rate
0|lightecho | rate = uniswap.get_price_input(
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/uniswap/uniswap.py", line 247, in get_price_input
0|lightecho | return self._get_token_token_input_price(token0, token1, qty, fee, route)
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/uniswap/uniswap.py", line 351, in _get_token_token_input_price
0|lightecho | ).call()
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/contract/contract.py", line 305, in call
0|lightecho | return call_contract_function(
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/contract/utils.py", line 96, in call_contract_function
0|lightecho | return_data = w3.eth.call(
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/eth/eth.py", line 256, in call
0|lightecho | return self._durin_call(transaction, block_identifier, state_override)
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/eth/eth.py", line 275, in _durin_call
0|lightecho | return self._call(transaction, block_identifier, state_override)
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/module.py", line 75, in caller
0|lightecho | result = w3.manager.request_blocking(
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/manager.py", line 321, in request_blocking
0|lightecho | return self.formatted_response(
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/manager.py", line 282, in formatted_response
0|lightecho | apply_error_formatters(error_formatters, response)
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/manager.py", line 99, in apply_error_formatters
0|lightecho | formatted_resp = pipe(response, error_formatters)
0|lightecho | File "cytoolz/functoolz.pyx", line 666, in cytoolz.functoolz.pipe
0|lightecho | File "cytoolz/functoolz.pyx", line 641, in cytoolz.functoolz.c_pipe
0|lightecho | File "/home/lightecho/lightecho/.venv/lib/python3.10/site-packages/web3/_utils/contract_error_handling.py", line 161, in raise_contract_logic_error_on_revert
0|lightecho | raise ContractLogicError(message, data=data)
0|lightecho | web3.exceptions.ContractLogicError: execution reverted: Unexpected error
Activityliquid-8 commented on Oct 28, 2023 That's V3 pool, but you set version param to 2. I don't think that should work out. yuriescl commented on Nov 1, 2023 This is happening in V3 as well. The line that raises the error:
|
price = self.quoter.functions.quoteExactInputSingle( |
Debug info:
350 -> price = self.quoter.functions.quoteExactInputSingle(
351 token0, token1, fee, qty, sqrtPriceLimitX96
352 ).call()
353 else:
354 raise ValueError("function not supported for this version of Uniswap")
355 return price
(Pdb) token0
'0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c'
(Pdb) token1
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
(Pdb) fee
3000
(Pdb) qty
1000000
(Pdb) sqrtPriceLimitX96
0
(Pdb)
ErikBjare commented on Nov 1, 2023 @yuriescl It's a 0.05% pool, so you have the wrong fee set.
We should probably catch such exceptions and rethrow them with better error message telling users to check the (version, token0, token1, fee) params. Reacted by Yuri Escalianti yuriescl commented on Nov 1, 2023 The fee is being set by the uniswap library:
|
logger.warning("No fee set, assuming 0.3%") |
yuriescl commented on Nov 1, 2023 In this scenario, is it expected that my code sets the fee, or is the uniswap library setting the wrong default fee? yuriescl commented on Nov 1, 2023 Indeed setting fee to 500 fixes the issue. ErikBjare commented on Nov 1, 2023 @yuriescl There is no "default" fee in V3, you need to check the fee of the pool you want to use and set it appropriately (which is what the warning is about).
Perhaps we should stop assuming a 0.3% fee and just raise an exception if not explicitly set. liquid-8 commented on Nov 2, 2023 Back in the days 0.3% fee was pretty much standard as total majority of pools had it. Now it doesn't coz there are tons of stable pools with .05 fee; memecoins have 1% quite often as well. Tend to agree, these methods need to require explicit fee specification. Reacted by Erik Bjäreholt
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|