Time-Weighted Average Price (TWAP)

Time-Weighted Average Price (TWAP): Manipulation-Resistant Pricing

TWAP calculates asset prices over extended time periods to resist manipulation and provide more stable price references for protocols. It’s like taking your temperature every hour instead of just once.

Time-Weighted Average Price (TWAP) is a pricing mechanism that calculates the average price of an asset over a specific time period, reducing the impact of short-term price manipulation. TWAP oracles provide more stable price feeds for DeFi protocols.

How TWAP Works

Continuous sampling records asset prices at regular intervals throughout the measurement period rather than relying on single point-in-time prices.

Weighted averaging gives equal weight to each time period, preventing large trades or manipulation attempts from skewing the overall price calculation.

Manipulation resistance makes it expensive and difficult for attackers to influence TWAP prices since they would need to sustain artificial prices over extended periods.

TWAP calculation flow showing price sampling, weighted average, manipulation resistance, and stable price feed

Real-World Examples

  • Uniswap V2/V3 provides TWAP oracles that many protocols use for price feeds
  • MakerDAO uses TWAP prices to prevent flash loan attacks on collateral valuations
  • Compound leverages TWAP pricing to resist oracle manipulation in lending markets

Why Beginners Should Care

Protocol security depends on manipulation-resistant price feeds to prevent flash loan attacks and other exploitation attempts.

Stable liquidations using TWAP prevents users from being liquidated due to temporary price spikes or manipulation.

Lagging prices mean TWAP feeds may not reflect rapid legitimate price movements, potentially affecting trading efficiency.

Related Terms: Oracle, Price Manipulation, Flash Loan Attack, Price Feed

Back to Crypto Glossary

Similar Posts

  • Compound Interest

    Compound Interest: Exponential Growth ReturnsCompound interest is earned on both the initial investment and previously accumulated interest, creating exponential growth over time. It's like planting a tree where each year's growth makes the tree bigger, which then grows even more the following year.Compound interest refers to earning returns not only on the original principal amount…

  • State Channel

    State Channel: Off-Chain Interaction Highways State channels enable instant, low-cost transactions between parties by moving interactions off-chain while maintaining blockchain security. It’s like having a private highway between two cities. A state channel is a two-way communication channel between blockchain users that enables off-chain transactions with on-chain security guarantees. Participants can transact instantly and cheaply,…

  • Modular Blockchain

    Modular Blockchain: Specialized Building Blocks Modular blockchains separate core functions like consensus, execution, and data availability into specialized layers. It’s like having a restaurant where different teams handle cooking, serving, and cleaning instead of one person doing everything. Modular blockchain architecture separates blockchain functions into distinct layers that can be optimized independently. This allows specialization…

  • Sybil Attack

    Sybil Attack: Fake Identity Manipulation Sybil attacks involve creating multiple fake identities to gain disproportionate influence in networks that assume one person equals one vote. It’s like stuffing the ballot box with imaginary voters. A Sybil attack is when an individual or entity creates multiple fake identities to gain unfair influence over a network, voting…

  • Liquidity Mining

    Liquidity Mining: Earning Tokens for Providing LiquidityLiquidity mining rewards users with tokens for providing liquidity to decentralized exchanges and protocols. It's like getting paid to be a market maker in the digital asset ecosystem.Liquidity mining is an incentive mechanism where DeFi protocols distribute tokens to users who provide liquidity to trading pools, lending markets, or…

  • Anti-Sybil Mechanism

    Anti-Sybil Mechanism: Preventing Fake Identity Attacks Anti-Sybil mechanisms prevent individuals from creating multiple fake identities to gain unfair advantages in voting, airdrops, or governance systems. They’re like requiring photo ID to prevent ballot stuffing. Anti-Sybil mechanisms are systems designed to prevent or detect when single entities create multiple fake identities to manipulate voting, governance, or…