Uniswap V2 TWAP

Mechanism

Uniswap V2 TWAP (Time-Weighted Average Price) is an on-chain oracle mechanism that calculates the average price of an asset pair over a specific time interval. The mechanism works by recording the cumulative price at the beginning and end of a period, then calculating the difference to determine the average price. This approach prevents instantaneous price manipulation by requiring an attacker to sustain a price change over a longer duration to influence the oracle feed.