TWAP Oracle
An on-chain price feed that reports a time-weighted average price over a recent window, making it harder for a single large trade to manipulate the reported price.
A TWAP oracle calculates and reports a time-weighted average price (see Kaavon's "Time-Weighted Average Price (TWAP)" glossary definition) over a recent window — rather than the instantaneous current price — by tracking an asset's price continuously on-chain and averaging it across that period. This makes the reported price meaningfully harder to manipulate with a single large, brief trade, since a manipulator would need to sustain an artificial price distortion across the entire averaging window to meaningfully move the reported figure, not just for one block.
TWAP oracles are commonly built directly from an automated market maker's own on-chain trading activity, making them a convenient, fully on-chain price feed (see Kaavon's "Price Feed" glossary definition) option that doesn't depend on any external data source. The tradeoff is responsiveness: because a TWAP oracle smooths price over its averaging window by design, it reacts more slowly to genuine, fast-moving price changes than an instantaneous price feed would, which protocols must account for when choosing an appropriate averaging window length for their specific use case.
Examples
- A lending protocol using a 30-minute TWAP oracle is far more resistant to a single-block flash loan price manipulation attempt than one relying on an instantaneous spot price.
- A TWAP oracle's smoothing effect that resists manipulation also means it lags behind genuinely fast-moving real-time price changes, which protocols must weigh when choosing the averaging window.