What Is a Time-Weighted Average Price (TWAP) Oracle and How Does It Use AMM Price Data?
A TWAP oracle calculates the average price of a token pair over a specific time interval by taking snapshots of the AMM's instantaneous price at regular intervals. This is used by protocols to get a robust and manipulation-resistant price feed.
By averaging the price over time, it mitigates the impact of sudden, large trades (like flash loan attacks) that temporarily spike the instantaneous price, making the price feed safer for lending protocols and derivatives.