A time-weighted average price (TWAP) is a price reading averaged over a defined time window, 30 minutes, 4 hours, 24 hours.
TWAPs are the standard mitigation for oracle manipulation in low-liquidity environments. Manipulating a TWAP requires holding the manipulated price across the entire averaging window, which costs orders of magnitude more capital and exposes the attacker to arbitrage from outside actors.
Trade-offs:
- TWAPs lag. During a real, fast price move, a TWAP-based protocol values assets at stale prices. For lending protocols this can prevent timely liquidation; for derivatives it can produce mispriced trades.
- The choice of window is the design trade-off: short windows are responsive but more manipulable; long windows are robust but stale.
A protocol that uses spot price for normal operation and TWAP only for sanity-checking is using both, and that's usually the right answer.