What Is TWAP?
TWAP or Time-weighted Average Price is a calculation that defines the weighted average price over a specified period.
The real-time price of decentralised exchanges is subject to quite easy manipulation, especially within the range of one block. A manipulator can use flash loans to access large amount of capital and make trades that a normal trader would not do.
These kind of attacks may cause very high/low price candles. Using the TWAP price mitigates the risk of performing e.g. an unnecessary stop loss trigger on a manipulated price.