Uniswap / v3-periphery

🦄 🦄 🦄 Peripheral smart contracts for interacting with Uniswap v3
https://uniswap.org
GNU General Public License v2.0
1.17k stars 1.09k forks source link

Static-Callable Opinionated Oracle #252

Closed nchamo closed 2 years ago

nchamo commented 2 years ago

TL;DR: attempt to do https://github.com/Uniswap/v3-periphery/issues/186

Intro

The launch of Uniswap v3 innovated in many different ways, and one of them was the addition of built-in oracles. The fact that all pools can also work as an oracle enables many different use cases. At Mean Finance, we heavily rely on these oracles to support the execution of DCA positions, so we know by experience that even though they are amazing, it's very hard to work with them. In particular, since a pair can have many different pools, it can be hard to aggregate all different prices and present them in an easy way. In the past we’ve built a library (https://github.com/Uniswap/v3-periphery/pull/146) that helps in that sense, but it still could be easier to use. That's why we believe that the development of the static-callable oracle contract that hides these difficulties is so important.

We are now presenting a contract that would allow anyone to easily calculate a quote between a pair of tokens that has one or more Uniswap v3 pools. This oracle will:

Technical Details

The contract has two main functions: quote and prepare. The first one actually calculates a quote for a given pair, and the second one can increase the observations cardinality across the pair’s pools if needed. Now, when asking for a quote between two tokens, there are basically two possible different parameters than can affect said quote:

Our oracle presents a public function where anyone can specify both these parameters (pools and period) and get the requested quote. But, we would also like to make things a little bit easier for everyone. So each function (quote and prepare) has 6 different versions:

  1. Specifying pools and time period
  2. Specifying fee tiers and time period
  3. Specifying a time period, but no pools or fee tiers are specified, so that all possible tools are used
  4. Same as (1), but using manipulation resistance enum
  5. Same as (2), but using manipulation resistance enum
  6. Same as (3), but using manipulation resistance enum

Last Comment

There is still work to be done, such as adding the necessary tests. But we wanted to get some early feedback from you and the community first, and then we can start iterating as soon as possible :smile:

nchamo commented 2 years ago

@moodysalem, there is no hurry, just tagging you since you created https://github.com/Uniswap/v3-periphery/issues/186 in the first place.

Just don't want this to fall through the cracks 😄

nchamo commented 2 years ago

Hey @Yorkemartin , @NoahZinsmeister !

Any chance we can get some early feedback on this pull request this week?

Thanks! 😊

nchamo commented 2 years ago

Hey everyone!

Closing this PR since after discussing with @NoahZinsmeister , we decided it would be better if we published and maintained the oracle ourselves. The oracle is now live in Ethereum, Polygon, Optimism and Arbitrum under 0xB210CE856631EeEB767eFa666EC7C1C57738d438

The repository is at https://github.com/Mean-Finance/uniswap-v3-oracle

And you can read more about it in our Twitter announcement