Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

TWAP Oracle

1 min read
Pronunciation
[tee-dub-uhl-ay-pee awr-uh-kl]
Analogy
Think of a TWAP oracle like averaging the temperature at each hour to smooth out sudden spikes and get a stable reading.
Definition
An oracle that provides a time-weighted average price for an asset over a predefined window to mitigate short-term volatility and manipulation.
Key Points Intro
TWAP oracles smooth price data over time to reduce susceptibility to flash manipulation.
Key Points

Time window: defines interval for averaging

Cumulative metrics: uses cumulative price or tick data

On-chain logic: computes average from stored cumulatives

Manipulation resistance: dampens short-term price swings

Example
A lending protocol queries Uniswap V2’s TWAP every 15 minutes to set collateral ratios, preventing flash-loan price attacks.
Technical Deep Dive
TWAP uses `priceCumulativeLast` stored on AMM pools. When updating, contracts record a timestamp and cumulative value. Average price = (cum2 – cum1) / (t2 – t1). Regular updates via keeper bots ensure fresh data and guard against stale readings.
Security Warning
Infrequent updates or long windows can lag true market prices; very short windows may still be manipulated.
Caveat
Choosing the optimal window length balances responsiveness with robustness.

TWAP Oracle - Related Articles

No related articles for this term.