Lab: free tools · size first · stock scanner · crypto scanner · journal
TWAP — Time-Weighted Average Price
TWAP (Time-Weighted Average Price) is both an execution algorithm and a benchmark price calculation. As an algorithm, it breaks a large order into equal-sized smaller orders executed at regular time intervals, minimising market impact and achieving an average entry price close to the period's average market price. As a benchmark, it represents the average price of an asset over a specified time window and is used in DeFi protocols and on-chain oracle systems to resist price manipulation.
TWAP, time-weighted average price, is the average price of an asset over a period. Traders use TWAP orders to split a large trade into smaller pieces over time, reducing market impact. DeFi protocols use TWAP oracles from DEX pools to make price manipulation harder, since moving an average over many blocks costs far more than moving one price for one block.
TWAP as an execution method
A TWAP order splits a large trade into equal slices sent at regular intervals over a chosen period, for example buying a position in 30 pieces over three hours. The aim is to match the average price over that window instead of pushing the price with one large order. Many exchanges and trading platforms offer TWAP orders, and some DEX aggregators offer on-chain versions.
TWAP is simple and predictable, and that is also its weakness: a steady stream of same-size orders can be spotted and traded against. Better implementations randomize slice size and timing. Compared with VWAP execution, which trades more when the market is busier, TWAP ignores volume and can trade too much in quiet hours. See VWAP vs TWAP execution.
When it helps and when it hurts
- It helps when your order is large relative to order book depth and you are not in a hurry.
- It hurts in a strong trend: if price is running away, buying slowly means paying up on every later slice.
- It cuts slippage per slice but adds timing risk over the whole window.
TWAP as a price oracle
DeFi protocols need prices they can trust. A single DEX trade can move a pool's spot price for one block, which is how many oracle manipulation attacks worked, often funded by flash loans. A TWAP oracle averages the pool price over many blocks, so an attacker has to hold a distorted price for the whole window while arbitrageurs trade against it. Uniswap v2 and v3 pools record cumulative prices that make these averages cheap to compute.
TWAP oracles have limits. They lag real prices during fast moves, which can delay liquidations or let positions run past safe levels. On thin pools, moving the average over a short window can still be affordable. Many lending protocols use external oracle networks instead of, or alongside, DEX TWAPs.
TWAP as a benchmark
Traders also use TWAP to grade execution: if your average fill beats the TWAP over the same period, you did better than a mechanical schedule would have. For automated tools, see grid, TWAP and VWAP bots.