What Is a “Time-Weighted Average Price” (TWAP) Oracle and Why Is It Preferred over a Spot Price Oracle?
A TWAP oracle calculates the average price of an asset over a period of time, typically by sampling the price at the beginning and end of each block. It is preferred over a spot price oracle because it is highly resistant to price manipulation, such as flash loan attacks, which can temporarily spike or crash the spot price in a single block.
The averaging effect smooths out volatility and makes manipulation economically infeasible.