Skip to main content
1 of 2
null
  • 13
  • 3

Using quoter to estimate price impact for UniswapV3 Pools

I'm currently trying to retrieve the price impact of a swap on a UniswapV3 pool. Uniswap itself seems to suggest the use of its quoter contract.

I see that the quoter contract has the "quoting" functions as write functions so I suppose a simulation of those is necessary to get the value over sending a transaction for every result needed. Unfortunately I seem unable to accomplish a simulation using Web3py.

My current code looks like this:

async def get_uniswap_v3_buy_impact(self, dex: Dex, amount_in_against: Decimal) -> Decimal:
    quoter = self.contracts.quoter_contract
    try:
        res = await quoter.functions.quoteExactInputSingle(
            dex.token.address,
            dex.token_against.address,
            dex.fee_tier,
            int(amount_in_against * 10 ** dex.token_against.decimals),
            0
        ).call()
        print(res)
    except Exception as e:
        print(e)
    return Decimal(0)

An error of execution reverted is always received with no data in the payload. I tried to integrate Web3py OffChainLookup by setting ccip_read_enabled=True in .call() but the result stays the same. This python library seems to do what I do as well. I'm sure I'm missing something here.

null
  • 13
  • 3