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

  • Digital Securities

    Digital Securities: Blockchain-Based Financial InstrumentsDigital securities are traditional financial instruments like stocks and bonds represented as tokens on blockchain networks. They're like digitizing paper stock certificates to work on the internet.Digital securities are blockchain-based tokens that represent ownership in traditional financial instruments such as stocks, bonds, or real estate, subject to securities regulations. These bridge conventional…

  • Wallet Address

    Wallet Address: Your Cryptocurrency Bank Account NumberA wallet address is a unique identifier that enables receiving cryptocurrency payments. It's like a bank account number that others can send money to, but it's generated from your private keys.A wallet address is a unique alphanumeric string that serves as a destination for cryptocurrency transactions. These addresses are derived…

  • Slashing Conditions

    Slashing Conditions: Validator Penalty Rules Slashing conditions define specific behaviors that result in validators losing staked funds as punishment for malicious or negligent actions. They’re the rules of engagement for network security. Slashing conditions are predetermined criteria that trigger automatic penalties for validators who violate network consensus rules or behave maliciously. These penalties involve destroying…

  • Smart Contract Audit

    Smart Contract Audit: Code Security ReviewSmart contract audits involve professional security reviews of blockchain code to identify vulnerabilities before deployment. It's like having building inspectors for digital architecture.A smart contract audit is a comprehensive security review of blockchain application code conducted by experts to identify vulnerabilities, bugs, and potential attack vectors before public deployment. These reviews…

  • Block Building

    Block Building: Transaction Assembly ProcessBlock building is the process of selecting and organizing transactions into blocks that will be added to the blockchain. It's like a chef choosing ingredients and assembling them into a complete meal that satisfies both taste and nutritional requirements.Block building refers to the process where miners or validators select, order, and…

  • Price Feed

    Price Feed: Real-Time Market DataPrice feeds provide real-time cryptocurrency market data to applications and smart contracts that need current asset values. They're like financial news tickers that continuously update with the latest stock prices, but for digital assets and automated systems.Price feed refers to continuous streams of current market prices and trading data that supply…