Time-Weighted Average Price
A time-weighted average price, or TWAP, is a mechanism used to calculate the average price of an asset over a specific period. By smoothing out short-term price fluctuations, it provides a more stable and less easily manipulated data point for smart contracts.
Instead of using the current spot price, which can be volatile, the system looks at the price at regular intervals and averages them. This makes it much more expensive for an attacker to manipulate the oracle, as they would need to maintain an artificial price for the entire duration of the averaging window.
TWAP is widely used in decentralized finance for liquidations and collateral valuation. While it is less reactive to sudden market shifts than a spot price, its resilience to manipulation makes it a safer choice for many applications.
It is a fundamental tool for reducing oracle complexity and increasing protocol safety. The choice of the time window is a critical parameter that must be carefully tuned.