veda.ng
Back to Glossary

Time-Weighted Average Price

Time-Weighted Average Price (TWAP) calculates the average price of an asset over a specified time period, weighted by how long the asset spent at each price level rather than by trading volume. This makes TWAP resistant to spot price manipulation: an attacker who briefly pushes the price to an extreme level has minimal impact on TWAP because the manipulation duration is short relative to the averaging window. To significantly move TWAP, an attacker would need to sustain the price manipulation for the entire window, typically hours or days, which is prohibitively expensive. Uniswap v2 and v3 implement TWAP oracles by accumulating price*time products that can be queried to compute average prices over arbitrary historical windows. These on-chain TWAP oracles provide manipulation-resistant price feeds without external dependencies, making them valuable for DeFi protocols needing reliable price data for liquidations, collateral valuation, or other critical operations. TWAP is also a trading execution strategy: large orders split across time, executing small portions at regular intervals, achieve an average price close to the period's TWAP. This reduces price impact compared to executing all at once. TWAP orders are common in both traditional finance and crypto, offered by algorithmic trading platforms and some DEX interfaces. The trade-off is execution speed: TWAP sacrifices immediacy for better average pricing.