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

  • Yield Optimization

    Yield Optimization: Maximizing Investment ReturnsYield optimization involves strategically managing cryptocurrency investments to maximize returns through automated rebalancing and strategy switching. It's like having a financial advisor that works 24/7 to find the best returns.Yield optimization refers to automated strategies and protocols that maximize returns on cryptocurrency investments by continuously monitoring and switching between different yield-generating…

  • Data Marketplace

    Data Marketplace: Trading Information AssetsA data marketplace enables buying and selling of data assets using cryptocurrency payments and blockchain verification. It's like eBay for information where data providers monetize their datasets.A data marketplace is a platform where data providers can sell access to information assets while buyers purchase data using cryptocurrency or token payments. Blockchain technology…

  • Appchain

    Appchain: Application-Specific Blockchains Appchains are blockchains designed for single applications or use cases rather than general-purpose smart contracts. They’re like having a dedicated highway for one type of vehicle instead of mixed traffic. An appchain is a blockchain optimized for a specific application or use case rather than supporting general-purpose smart contracts. This specialization enables…

  • Gas Limit

    Gas Limit: Setting Your Transaction Budget Gas limit is the maximum amount of gas you’re willing to spend on a transaction. Set it too low and your transaction fails. Set it too high and you overpay for simple operations. Gas limit is the maximum amount of computational work (measured in gas units) that a user…

  • Over-Collateralization

    Over-Collateralization: Excess Security DepositsOver-collateralization requires borrowers to deposit assets worth more than their loan amount as security against default. It's like putting down a $15,000 deposit to borrow $10,000, ensuring the lender is protected even if asset values decline.Over-collateralization refers to requiring collateral deposits that exceed the value of loans or borrowed assets, providing additional…

  • Blockchain Oracle Network

    Blockchain Oracle Network: Decentralized Data Feeds Blockchain oracle networks provide external data to smart contracts through decentralized systems rather than single data sources. It’s like having multiple weather stations instead of relying on one thermometer. A blockchain oracle network is a decentralized system of nodes that collectively provide external data to blockchain networks, reducing single…