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.