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

  • Flash Loan Attack

    Flash Loan Attack: Exploiting DeFi with Borrowed CapitalFlash loan attacks use uncollateralized loans to exploit vulnerabilities in DeFi protocols for profit extraction. They're like using borrowed money to pull off elaborate heists in seconds.A flash loan attack is an exploit that uses flash loans to manipulate DeFi protocols, typically by borrowing large amounts, executing complex…

  • Liquidity Pool

    Liquidity Pool: The Fuel That Powers DEX Trading Liquidity pools are why decentralized exchanges work. They’re shared pots of tokens that enable trading without traditional buyers and sellers. A liquidity pool is a collection of tokens locked in a smart contract that provides liquidity for decentralized trading. Instead of matching buy and sell orders, traders…

  • EigenLayer

    EigenLayer: Ethereum Restaking ProtocolEigenLayer enables Ethereum validators to restake their ETH to secure additional protocols and earn extra rewards. It's like using the same security deposit to protect multiple different services simultaneously.EigenLayer is a protocol that allows Ethereum validators to restake their staked ETH to provide security for additional protocols and services beyond Ethereum itself. This…

  • Monetary Policy

    Monetary Policy: Controlling Money SupplyMonetary policy refers to how money supply, interest rates, and economic incentives are managed within a currency system. In crypto, it's usually controlled by code instead of central banks.Monetary policy encompasses the rules and mechanisms that control cryptocurrency supply, inflation rates, and economic incentives within blockchain networks. Unlike traditional currencies, crypto monetary…

  • Consensus Mechanism

    Consensus Mechanism: How Networks Agree Consensus mechanisms solve the fundamental problem of getting thousands of independent computers to agree on a single version of truth without central authority. A consensus mechanism is the process by which a distributed network of nodes agrees on the validity of transactions and the current state of the blockchain. It…

  • Rollups

    Rollups: Scaling Through Bundling Rollups process hundreds of transactions off-chain then bundle the results into single on-chain transactions. It’s like carpooling for blockchain transactions – everyone shares the gas costs. Rollups are Layer 2 scaling solutions that execute transactions off the main blockchain but post transaction data on-chain for security. They inherit the security of…