Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing chain #331

Open
1220moritz opened this issue May 11, 2023 · 3 comments
Open

Missing chain #331

1220moritz opened this issue May 11, 2023 · 3 comments

Comments

@1220moritz
Copy link

I tried to use the package for the Metis Blockchain.
RPC: https://andromeda.metis.io/?owner=1088
ID: 1088
https://chainlist.org/chain/1088

`from uniswap import Uniswap

address = None # or None if you're not going to make transactions
private_key = None # or None if you're not going to make transactions
version = 2 # specify which version of Uniswap to use
provider = "https://andromeda.metis.io/?owner=1088" # can also be set through the environment variable PROVIDER
uniswap = Uniswap(address=address, private_key=private_key, version=version, provider=provider)`

Error:
raise Exception(f"Unknown netid: {self.netid}") # pragma: no cover Exception: Unknown netid: 1088

How can I add the Metis Blockchain or is it even possible to use this package for the METIS Blockchain?

@liquid-8
Copy link
Member

Check constants.py it has quite a straightforward syntax. Not sure if Uniswap or its fork was deployed there though.

@1220moritz
Copy link
Author

1220moritz commented May 13, 2023

Thanks, got rid of this error. But now I have new ones

These are the contracts:
UniswapV3Factory: 0xf5fd18Cd5325904cC7141cB9Daca1F2F964B9927
UniversalRouter 0x749E46034618c6Cbf64938b8DE10092523228235
Permit2: 0x2EE5407017B878774b58c34A8c09CAcC94aDd69B
SwapRouter02: 0x07Da720AD5E434971dbe77C7fC85b7b44d5aC704
QuoterV2: 0x2db8b665CE6928F9D1a7f83F4C6aCEA64Af6a6f6

I added the chainId 1088 to the constants.py _netid_to_name dict.
This solved the error: Exception: Unknown netid: 1088

When I try to call the get_price_input(token1, token2, amount) method I get
web3.exceptions.BadFunctionCallOutput: Could not transact with/call contract function, is contract deployed correctly and chain synced?
The get_price_input() uses the _get_token_token_input_price(token0, token1, qty, fee, route) which for my usecase (no routes set, no fee set->default 3000, uniswap version 3) calls :

sqrtPriceLimitX96 = 0
price = self.quoter.functions.quoteExactInputSingle(token0, token1, fee, qty, sqrtPriceLimitX96).call()

self.quoter uses the quoter_addr "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6" which does not exist on Metis.
I switched it with QuoterV2 from aboves list, but now I get web3.exceptions.ContractLogicError: execution reverted

@liquid-8
Copy link
Member

The quoter contract address is hardcoded here:

https://github.com/uniswap-python/uniswap-python/blob/47ae05d24622d5565fb938b5fb7c3959c07973ab/uniswap/uniswap.py#L178

Just replace it with a Metis address. Feel free to create PR which fixes mentioned hardcoding - it would be strongly appreciated. Check, as well, if a proper pool (token0, token1, fee) is deployed/has liquidity there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants