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

  • State Channel

    State Channel: Off-Chain Interaction Highways State channels enable instant, low-cost transactions between parties by moving interactions off-chain while maintaining blockchain security. It’s like having a private highway between two cities. A state channel is a two-way communication channel between blockchain users that enables off-chain transactions with on-chain security guarantees. Participants can transact instantly and cheaply,…

  • Batch Verification

    Batch Verification: Efficient Bulk ProcessingBatch verification processes multiple transactions or proofs together to improve efficiency and reduce computational costs. It's like grading a stack of tests all at once instead of one by one.Batch verification refers to techniques that verify multiple cryptographic proofs, transactions, or operations simultaneously rather than processing each individually. This approach significantly improves…

  • Gas Refund Token

    Gas Refund Token: Optimizing Transaction Costs Gas refund tokens exploit Ethereum’s gas refund mechanism to reduce transaction costs by clearing unused storage. They’re like getting paid to clean up the blockchain. A gas refund token uses Ethereum’s gas refund mechanism to partially offset transaction costs by clearing unused contract storage during token transfers. The protocol…

  • DeFi Aggregator

    DeFi Aggregator: Finding the Best Yields DeFi aggregators automatically find the best rates across multiple protocols for lending, borrowing, or trading. They’re like Expedia for decentralized finance. A DeFi aggregator is a platform that searches multiple protocols to find the best rates, yields, or liquidity for users’ specific needs. Instead of manually checking dozens of…

  • Market Manipulation

    Market Manipulation: Artificial Price ControlMarket manipulation involves artificially influencing cryptocurrency prices through coordinated trading, false information, or abusive practices. It's financial fraud adapted for the digital age.Market manipulation refers to illegal or unethical activities designed to artificially inflate or deflate cryptocurrency prices for personal gain. These activities harm other investors and distort natural price discovery mechanisms.How…

  • Back Running

    Back Running: Following Profitable TransactionsBack running involves placing transactions immediately after profitable transactions to capture secondary opportunities. It's like following successful traders to pick up the crumbs they leave behind.Back running is a MEV extraction strategy where bots place transactions immediately after profitable transactions to capture residual value or secondary opportunities. This technique exploits the predictable…