How Does a Time-Weighted Average Price (TWAP) Oracle Mitigate Flash Loan Attacks on a Derivatives Contract?
A flash loan attack can temporarily manipulate the spot price on a DEX. A TWAP oracle mitigates this by calculating the average price over a period of time, rather than using the instantaneous spot price.
This averaging smooths out short-term, artificial price spikes caused by manipulation, making it much harder for an attacker to use a flash loan to trigger an unfair liquidation or settlement.