Skip to main content

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.

What Is the Role of Time-Weighted Average Price (TWAP) in DeFi Oracles?
How Does Lengthening the Settlement Window Mitigate the Risk of an Attack?
What Is a “Settlement Window” and Why Is Its Duration Important?
What Is a “Time-Weighted Average Price” (TWAP) Oracle and Its Anti-Front-Running Benefit?