Time-Weighted Average Price (TWAP)
Time-Weighted Average Price (TWAP) is the average price of an asset over a set period, where each price counts in proportion to how long it lasted. DeFi protocols use TWAP oracles to get prices that are harder to manipulate than a single instant reading.
A TWAP oracle records an asset's price at regular points, often every block, and averages those readings over a window such as 30 minutes, an hour or several days. Some decentralized exchanges built on an automated market maker keep a running cumulative price on-chain, so any smart contract can work out the average between two moments. Traders also use the term for an execution method that splits a large order into equal pieces filled at regular intervals to reduce price impact.
TWAP matters because lending platforms and other DeFi apps need a price to decide how much users can borrow and when to liquidate positions. If a protocol reads only the spot price, an attacker can use a flash loan to push a pool's price sharply for a single block and exploit the distorted value. With a one-hour TWAP, that brief spike is averaged with an hour of normal prices and barely moves the result.
The trade-off is lag. Because a TWAP looks backward, it reacts slowly when the market genuinely moves. NFT lending protocols using multi-day TWAP floor prices have seen liquidations stall during sharp sell-offs, because auction minimums tied to the outdated average stayed above what buyers would pay. A TWAP is also not manipulation-proof. An attacker who can hold a price in a thin, low-liquidity market for long enough, or who targets a very short window, can still shift it.