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

  • Tokenization

    Tokenization: Converting Assets into Digital Tokens Tokenization transforms real-world assets into blockchain-based tokens that can be traded, divided, and managed digitally. It’s like turning everything into tradeable game pieces. Tokenization is the process of converting ownership rights to assets into digital tokens on a blockchain. This enables fractional ownership, easier trading, and programmable functionality for…

  • Encrypted Mempool

    Encrypted Mempool: Private Transaction Pools Encrypted mempools hide transaction details until inclusion in blocks, preventing front-running and MEV extraction. It’s like sending sealed bids instead of announcing your strategy publicly. An encrypted mempool contains pending transactions that are cryptographically hidden from public view until block inclusion. This prevents sophisticated actors from front-running or extracting MEV…

  • Gaming Token

    Gaming Token: In-Game Digital CurrencyGaming tokens are cryptocurrencies designed specifically for use within video games and virtual worlds. They enable player ownership, trading, and monetization of in-game assets and achievements.Gaming tokens are cryptocurrencies created for specific video games or gaming ecosystems, enabling player ownership of in-game assets, rewards, and economic participation. These tokens bridge traditional gaming…

  • Session Keys

    Session Keys: Temporary Wallet Permissions Session keys provide temporary, limited permissions for applications to perform specific actions without exposing main wallet private keys. It’s like giving valet keys instead of your full car keys. Session keys are temporary cryptographic keys that grant limited permissions to applications for specific time periods or transaction types. They enable…

  • Optimistic Rollup

    Optimistic Rollup: Trust but Verify Scaling Optimistic rollups assume transactions are valid by default but allow challenges during dispute periods. It’s like innocent until proven guilty for blockchain transactions. An optimistic rollup is a Layer 2 scaling solution that assumes transactions are valid by default and only verifies them if someone submits a fraud proof…

  • Scalability

    Scalability: Handling Growing Network DemandScalability refers to a blockchain network's ability to handle increasing transaction volumes without degrading performance or significantly increasing costs. It's like building highways that don't get congested as more cars use them.Scalability describes how well blockchain networks can accommodate growing user bases and transaction volumes while maintaining reasonable fees and confirmation…