Should Uniswap be an oracle protocol?

In May of this year, Vitalik created a post on the Uniswap Governance Forum titled “UNI Should Become an Oracle Token”. He believes that the oracle needs to provide off-chain data, and UNI is in a good position to provide an alternative to Chainlink for high-value, delay-tolerant use cases.

Although this is an interesting idea, as I recently reflected in this post, I have been thinking about how Uniswap is already an oracle protocol. It has provided price information from the largest DEX on Ethereum. UNI is already an oracle token, and UNI DAO has not done much on this fact, at least so far.

The history of Uniswap as an oracle

Since v1, Uniswap has been an oracle protocol, although it was a very crude protocol at the time. Uniswap v1 is a series of ETH-ERC20 mining pools with a simple x * y = k pricing mechanism. You can query the value of ETH and corresponding ERC20 tokens in any pool, and you have a spot price oracle machine.

However, v1 as an oracle protocol has many shortcomings. First, everything is priced in ETH. In order to obtain non-ETH quotes, such as the BAT price expressed in USDC, you need to link the prices together (in this case, BAT-ETH and ETH-USDC).

Second, the price is a simple point in time (more specifically, and more tragically, a point in a block) spot price. This can be easily manipulated because “unfortunately” liquidity withdrawals and large numbers of transactions can fluctuate prices significantly. I do not recommend relying on this price to perform sensitive tasks, such as determining whether a borrowed position is at the bottom.

v2 improves the usability of Uniswap as an oracle. First, v2 allows any ERC20-ERC20 pair. Second, before any transaction or liquidity change occurs, each mining pool will take a snapshot of the price of the starting block, which makes manipulation more difficult. Finally, its stored price value (a running accumulator of the price multiplied by the number of seconds since the last block) allows the user to calculate the time-weighted average price (TWAP), rather than a simple spot price.

However, getting TWAP from the v2 pool is not out of the box-it requires the integrator to store the past value of the running accumulator in a separate contract for calculation.

Uniswap v3 retains the benefits provided by v2, but also solves the above shortcomings by providing the ability to store a series of accumulator values ​​(only 1 value is stored by default, but anyone who is willing to pay the gas cost can expand the number of tracked values ​​up to 65,535 Observations, or prices for approximately 9 days).

Oracle (Oracle) Usage

Uniswap v3 has been used as an on-chain oracle in various environments. Many projects call Uniswap v3’s oracle functions from their contracts, including:

  • Popsicle Finance (LP Revenue Optimization Agreement)
  • keep3r network (decentralized task operation protocol)
  • Frax (an algorithmic stable currency)
  • Lixir Finance (LP Manager for Uniswap v3)
  • Rari Capital (the creator of the Fuse loan agreement)
  • Babylon Finance (Decentralized Asset Management)
  • Unipilot (LP Production Optimization Agreement)
  • Angle (a stable currency protocol)


Should Uniswap be an oracle protocol?

These oracle calls are made across multiple pairs. As we can see in the figure below, although USDC-WETH is the most frequently called currency pair, it only accounts for 17% of the oracle calls. Assets that use the oracle function have a long tail. Many of them are directly related to the aforementioned protocols (eg FRAX, KP3R). However, it is more that Uniswap may be one of the most important sources of liquidity assets (such as ENS, and of course ELON).

Should Uniswap be an oracle protocol?

Uniswap DAO as the guardian of the oracle

The oracle function has been used, despite the relative lack of material on the performance of Uniswap oracles (although I recommend to you the excellent thread written by Michael Bentley on the cost of attacking v3 oracle).

Should Uniswap be an oracle protocol?

The pastor who works with the oracle in Delphi will receive her words and spread the answers to the petitioners

However, where is the motivation to improve and maintain the oracle experience? The use of Oracle does not currently benefit the trader, LP or maintainer of the agreement.

Agreement transaction fees are already a possible source of DAO cash flow in v2 and v3 (although no fees have been charged so far).

It is worth considering the cost of using price oracles. Although this requires some changes to the protocol, this can be achieved as a fixed fee for ETH per call or a way to register a project contract on a series of approved oracle callers.

In exchange for these costs, Uniswap DAO can become the “guardian of the oracle”. What does this mean in practice? DAO can:

  • Acting as “the last liquidity provider”
  • Provide liquidity incentives to high-value mining pools as price oracles
  • Provide data and research on Oracle performance
  • Provide better documentation on best practices for oracle usage

By “the last liquidity provider”, I mean that the DAO can create an automated strategy or appoint an LP manager to provide a certain amount of passive liquidity for important oracles and under-liquid pools. This can prevent attacks and respond to attacks that span multiple blocks that involve extracting liquidity or affecting the liquidity balance of the pool.

Limitations of the current Uniswap oracle

Without acknowledging some of the limitations of using Uniswap oracles that exist today, this discussion will feel incomplete.

Although it is not recommended to use simple spot prices from AMM (instead of TWAP), TWAP reduces the freshness of the data (by definition, it adapts more slowly to changing market conditions). When choosing the length of time to measure TWAP, you face a dilemma:

  • The shorter the time window, the more easily TWAP is manipulated.
  • The longer the time window, the slower TWAP will adjust to changing market prices.

Take a loan agreement as an example. If the price of collateral suddenly drops, and TWAP does not reflect the insufficient collateralization of the position until 30 minutes after the downtrend begins, the spot price may be lower by then, which may cause the agreement to cause losses to the current possible underwater position.

Having said that, the appeal of Uniswap oracles lies in their relatively autonomous work. Even without the additional guarantees that DAOs can provide, they will continue to operate normally as long as there are incentives from market participants.

Going back to Vitalik’s post, it might be interesting to explore how DAO uses the current pool TWAP model as an ingredient in Oracle’s solution to add fresher off-chain price data sources.

The information provided in this article is for general guidance and information purposes only. The content of this article should not be regarded as investment, business, legal or tax advice under any circumstances. We do not take any responsibility for personal decisions made based on this article, and we strongly recommend that you conduct your own research before taking any action. Although every effort has been made to ensure that all information provided here is accurate and up-to-date, omissions or errors may occur.


Posted by:CoinYuppie,Reprinted with attribution to:
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.