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.
Glossar
Price Feed
Feed ⎊ A price feed is a continuous stream of real-time pricing data from various sources used to determine the fair value of an asset.
Flash Loan Attack
Exploitation ⎊ A flash loan attack represents a market manipulation technique enabled by decentralized finance (DeFi) protocols, specifically leveraging the ability to borrow substantial capital without collateral requirements, contingent upon full repayment within a single transaction block.
Twap Calculation
Calculation ⎊ Twap Calculation determines the Time-Weighted Average Price of an asset over a specified interval by averaging prices recorded at frequent, fixed intervals, irrespective of volume traded during those intervals.
Flash Loan
Mechanism ⎊ A flash loan is a unique, uncollateralized loan mechanism in decentralized finance that allows users to borrow assets for a very short duration, typically within a single blockchain transaction.