1inch / spot-price-aggregator

Liquidity-weighted dex price oracle for offchain price discovery
MIT License
277 stars 79 forks source link

Cant price AMBO on polygon #158

Closed blakearnold closed 4 months ago

blakearnold commented 4 months ago

Seeing issues pricing AMBO (0x9B8B6A1298d34B3c4bBDDce8a7fF0149121592C1) on polygon. There is a quickswap pool (AMBO/USDC native) - https://dexscreener.com/polygon/0x6e8e0683e3e98302e2d44c44e191e4c47a72590e but getting a 0 price back even after adding native as a custom connector

Screenshot 2024-06-26 at 12 41 13 PM
zZoMROT commented 4 months ago

Thank you for highlighting the issue.

The problem lies in the QuickSwap factory used in SpotPriceAggregator. This factory is a contract that is a fork of UniswapV2, and indeed, the pool with AMBO is not present in this factory. This pool is in a different factory, which likely belongs to a newer version of the QuickSwap. Therefore, a new oracle needs to be added for QuickSwap. I have created a task for this.

If you have the time and willingness, you are welcome to contribute to this update.

blakearnold commented 4 months ago

This pool is quickswap v3, where it looks like the current oracle is quickswap v2.

Might be as simple as deploying a uniswap v3 like oracle with the correct params. I'll can take a stab at finding these params

blakearnold commented 4 months ago

Quickswap v3 actually forks Algebra Integral contracts, docs on the difference between uniswap v3.

2 important differences:

Thinking I need to create a new AlgebraLikeOracle.sol, which will look similar to UniswapV3LikeOracle.sol, but with an updated _getPool function and getRate wont need to loop through fees[].

zZoMROT commented 4 months ago

Thank you for your research! This saved me time! This is my cry of the soul - why they changed slot0() to globalState() in pools 😭 I will do this in the coming days as soon as I decide the best approach – whether to add a separate oracle with duplicate code or to make changes to the UniswapV3LikeOracle.

blakearnold commented 4 months ago

Great! Thanks for building and maintaining this repo, these contracts are amazing at getting accurate reference prices

zZoMROT commented 4 months ago

It's already fixed. Thank you for the improvement suggestion!

Screenshot