Uniswap TWAP

Algorithm

Uniswap’s Time-Weighted Average Price (TWAP) represents a methodology for determining an asset’s average price over a specified period, mitigating manipulation inherent in point-in-time valuations. This calculation involves accumulating the price of an asset at regular intervals, subsequently dividing by the number of intervals to derive a smoothed average; it’s fundamentally a discrete-time integration of price data. Within decentralized finance, TWAP serves as a crucial reference price for various operations, including liquidations and oracle price feeds, offering a more robust valuation than simply observing the current market price. Its design inherently resists short-term price fluctuations, making it valuable for strategies requiring price stability and reducing the impact of front-running.