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

  • Counterparty Risk

    Counterparty Risk: Trusting Others with Your MoneyCounterparty risk is the chance that the other party in a financial transaction won't fulfill their obligations. In crypto, it's the difference between self-custody and hoping someone else doesn't lose your money.Counterparty risk refers to the probability that the other party in a financial transaction will default on their…

  • Credentials

    Credentials: Proof of Identity and QualificationsCredentials are verifiable proofs of identity, qualifications, or achievements that can be digitally verified without contacting issuing authorities. They're like diplomas that anyone can instantly authenticate.Credentials refer to digital or physical documents that prove identity, qualifications, achievements, or authorizations, increasingly being tokenized and verified through blockchain technology. These enable trustless verification…

  • Network Decentralization

    Network Decentralization: Distributed Control ArchitectureNetwork decentralization refers to distributing control and operation of blockchain networks across many independent participants rather than concentrating power. It's like having a town where decisions are made by all residents voting together instead of a single mayor controlling everything.Network decentralization describes the distribution of control, validation, and governance functions across…

  • 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…

  • Order Matching

    Order Matching: Connecting Buyers and SellersOrder matching is the process of pairing buy and sell orders to execute trades on exchanges. It's like a digital matchmaker that finds the perfect trading partners for each transaction.Order matching refers to the algorithmic process that pairs compatible buy and sell orders to execute trades at agreed prices on…

  • Validator Jailing

    Validator Jailing: Temporary Network Punishment Validator jailing temporarily removes misbehaving validators from consensus participation while allowing them to return after penalties. It’s like being sent to the penalty box in hockey. Validator jailing is a punishment mechanism that temporarily excludes validators from consensus participation and rewards due to violations like extended downtime or rule infractions….