How Does a TWAP Calculation Protect against a “Flash Loan Attack” on a Price Feed?

A flash loan attack on a price feed involves a malicious actor borrowing a massive amount of capital in a single transaction, using it to briefly manipulate the price on a single DEX, and then executing a trade or liquidation against a vulnerable protocol. Since the TWAP averages the price over a time window, the momentary spike from the flash loan attack has minimal impact on the final averaged price, thus preventing the manipulation from succeeding.

How Can a Time-Weighted Average Price (TWAP) Oracle Mitigate Flash Loan Price Manipulation?
How Does a TWAP Oracle Specifically Defend against Flash Loan Price Manipulation?
What Is a “Time-Weighted Average Price” (TWAP) Oracle and Its Anti-Front-Running Benefit?
Why Is the Time-Weighted Average Price (TWAP) Often Preferred over a Spot Price for Options Oracles?
Does the Length of the TWAP Calculation Window Affect Its Resistance to Manipulation?
How Does Lengthening the Settlement Window Mitigate the Risk of an Attack?
What Is a “Settlement Window” and Why Is Its Duration Important?
How Does the Chosen Time Window for TWAP Impact the Final Settlement Price’s Stability?

Glossar