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

  • Peg Mechanism

    Peg Mechanism: Maintaining Price StabilityPeg mechanisms are systems designed to maintain stable exchange rates between cryptocurrencies and reference assets like fiat currencies. They're like autopilot systems that keep stablecoins flying at steady altitudes.A peg mechanism is a system that maintains the exchange rate of one asset relative to another through automatic adjustments, reserves, or market…

  • Private Mempool

    Private Mempool: Protected Transaction PoolsPrivate mempools keep pending transactions hidden from public view until they're included in blocks, preventing front-running and MEV extraction. It's like having a VIP lane that bots can't see.A private mempool is a non-public pool of pending transactions that are not visible to other network participants until they are included in…

  • Fee Market

    Fee Market: Transaction Cost EconomicsA fee market determines transaction costs through supply and demand dynamics between users and network capacity. It's like surge pricing for blockchain transactions during busy periods.A fee market is an economic system where transaction fees are determined by competition between users for limited blockchain processing capacity. Higher demand relative to supply drives…

  • Fair Distribution

    Fair Distribution: Equitable Token AllocationFair distribution refers to token allocation methods that avoid excessive concentration among founders, early investors, or privileged groups. It's like ensuring everyone gets an equal chance to participate in a community project rather than giving all the benefits to insiders.Fair distribution describes token allocation strategies that provide broad, equitable access to…

  • Data Availability Layer

    Data Availability Layer: Ensuring Information Access Data availability layers ensure that blockchain data remains accessible for verification without requiring full nodes to store everything. It’s like having a library system where you can verify any book exists without storing them all. A data availability layer guarantees that blockchain transaction data is published and remains accessible…

  • Smart Contract Risk

    Smart Contract Risk: Code-Based VulnerabilitiesSmart contract risk encompasses potential losses from bugs, exploits, or unexpected behavior in automated blockchain programs. It's like the risk that the software controlling your digital money might malfunction or be hacked.Smart contract risk refers to potential vulnerabilities, bugs, exploits, or failures in smart contract code that could result in loss…