What Is a “Time-Weighted Average Price” (TWAP) Oracle and Why Is It Used?
A TWAP oracle calculates the average price of an asset over a specific time interval, rather than providing a single snapshot price. It is used to mitigate the risk of price manipulation, specifically "flash loan attacks." By averaging the price over time, short, sharp price spikes caused by manipulation have less impact on the final reported price.
This makes the contract execution more robust and secure.