Difference between revisions of "Time Weighted Average Price (TWAP)"

From CryptoWiki

m (Grand Master Pepe moved page TWAP to Time Weighted Average Price (TWAP))
 
(No difference)

Latest revision as of 04:55, 9 February 2023

Basics

  • Abbreviation for Time-Weighted-Average-Price oracles.
  • Used mainly in Uniswap.
  • A comparison between TWAP and Chainlink oracles can be read here (8-5-2021).
  • From Bankless (20-1-2023):

"TWAP is a pricing algorithm used to calculate the average price of an asset over a specific period of time. Typically, these prices are created using on-chain data. Prices are collected over this period of time and averaged to create a final price result.

For example, suppose we want to determine the price of an asset using TWAP. If we choose 1 minute intervals over the course of 60 minutes. However, in order to construct such a pricing mechanism, we need to use a price feed to get samples. Such a TWAP oracle feed can be constructed using prices provided by Uniswap’s constant product pricing function, offering a cumulative price that can be used to calculate a TWAP of any time interval. TWAP is simple to calculate, but there are fundamental tradeoffs between price accuracy and security. Because TWAP oracles use price history to calculate the current price, the accuracy of the price decreases during periods of high volatility.

  1. Long periods: Hard to manipulate; Inaccurate during high volatility. TWAP is a lagging indicator of price because it takes previous prices to calculate the current price.
  2. Short periods: Accurate during high volatility; but easy to manipulate.

However, this oracle would only represent prices and liquidity on Uniswap."