Flash Loans & Advanced Lending
How flash loans work, practical use cases (arbitrage, collateral swaps, liquidations), and understanding the lending protocol landscape.
From Thrive on YouTube
Watch the matching Thrive video
VWAP Explained: How to Use VWAP and Anchored VWAP in Crypto
Part of Charting and Market Structure. Education only. Not financial advice.
What Are Flash Loans?
Flash loans are one of DeFi's most extraordinary innovations, and they have no equivalent in traditional finance. A flash loan lets you borrow an unlimited amount of capital with zero collateral, as long as the loan is repaid within the same blockchain transaction. If the loan is not repaid by the end of the transaction, the entire transaction reverts as if it never happened. No risk to the lender. No collateral needed from the borrower. It is theoretically unlimited leverage compressed into a single atomic operation.
This is possible because of how blockchain transactions work. A transaction on Ethereum is an all-or-nothing operation. If any step in a complex multi-step transaction fails, every step is reversed. Flash loans exploit this property: the lending protocol gives you $50 million, you execute a series of operations, and if the last step does not include repaying $50 million plus a small fee (typically 0.05–0.09%), the entire transaction is invalid. The lender never actually risks funds.
Flash Loan Use Cases
Flash loans have legitimate, powerful applications beyond the attack vectors they are often associated with. Understanding these use cases reveals the creative potential of programmable money.
| Arbitrage | Borrow $10M, buy an asset where it is cheap, sell where it is expensive, repay the loan, keep the profit. All in one transaction. No capital needed. |
| Collateral swaps | Swap your lending collateral from one asset to another without closing the position. Flash borrow to repay debt, withdraw collateral, deposit new collateral, re-borrow to repay flash loan. |
| Liquidations | Flash borrow stables, liquidate an undercollateralized position, receive collateral at a discount, sell collateral, repay flash loan, keep the liquidation bonus. |
| Self-liquidation | If you are about to be liquidated, flash borrow to repay your own debt, withdraw your collateral, sell enough to repay the flash loan, and keep the rest. You avoid the liquidation penalty. |
| Leverage adjustment | Increase or decrease your looped lending position in a single transaction instead of executing multiple loops manually. |
How Flash Loans Changed DeFi
Before flash loans, capital was a barrier. Only well-funded actors could execute arbitrage, perform liquidations, or exploit pricing inefficiencies. Flash loans democratized access to large capital: anyone who can write a smart contract can borrow $100 million for a fraction of a second. This has had profound consequences.
Markets became more efficient. Pricing discrepancies across DEXs are corrected faster because any developer can flash-borrow millions to arbitrage them. Liquidation efficiency improved dramatically because liquidators no longer need to maintain capital on hand. But the flip side is that flash loans also enabled attacks that would be impossible with limited capital: manipulating prices on low-liquidity pools, exploiting oracle designs, and draining protocol treasuries in a single transaction.
Borrow $50M in a flash loan
Execute the strategy
Repay the flash loan
Zero capital risk
Flash Loan Attack Vectors
Flash loans are a tool. Like all tools, they can be used constructively or destructively. Flash loan attacks exploit vulnerabilities in protocols that were not designed to withstand an actor wielding $100 million+ in a single transaction.
Oracle Manipulation
The most common attack vector. If a lending protocol uses a single DEX pool as its price oracle, an attacker can flash borrow a massive amount, trade aggressively on that DEX to spike the price, then exploit the mispricing in the lending protocol (e.g., borrow more than their collateral is worth at the manipulated price). After the transaction, the DEX price reverts, but the attacker has already extracted value from the lending protocol.
Governance Manipulation
Flash borrow governance tokens, vote on a malicious proposal, return the tokens. Some protocols have been attacked this way because they allowed single-block voting without requiring tokens to be held for a minimum period. Most governance systems now include vote-locking periods and snapshot-based voting to prevent this.
Reentrancy Amplification
Flash loans amplify reentrancy vulnerabilities. A reentrancy bug that might allow extracting $10,000 with normal capital can extract $10 million with a flash loan providing the initial trigger. The capital amplification makes previously marginal vulnerabilities catastrophically exploitable.
Flash loans as a risk factor
Practical Flash Loan Example
Here is a realistic collateral swap scenario. You have a lending position with WBTC as collateral and a USDC borrow. You want to switch your collateral to ETH without closing the position and incurring slippage on a large trade.
Flash borrow USDC
Repay your lending debt
Withdraw and swap collateral
Re-borrow and repay the flash loan
Flash Loans as a Risk Factor
As a DeFi user depositing capital into protocols, flash loans represent a systemic risk you must account for. Any protocol you deposit into could theoretically be targeted by a flash loan attack. Your due diligence should include understanding whether the protocols you use are flash-loan-resistant.
Does the protocol use Chainlink or multi-source TWAP oracles? Or does it rely on a single DEX pool that can be manipulated with a large trade?
Does the protocol use reentrancy guards (checks-effects-interactions pattern)? Has it been audited for reentrancy vulnerabilities?
Are there caps on how much can be borrowed in a single transaction or block? Caps limit the damage from flash loan attacks.
Does governance require vote-locking, time delays, and snapshot-based voting? These prevent flash loan governance attacks.
Has the protocol survived through multiple market cycles without being exploited? Battle-tested protocols have a better track record than new ones.
Flash loans are a feature, not a bug
1.What happens if a flash loan is not repaid within the same blockchain transaction?
2.A borrower has $10,000 ETH collateral on Aave with a liquidation threshold of 82.5% and $7,000 in outstanding debt. What is their health factor?
3.Why is the 'looping' strategy on lending protocols considered high-risk?
4.What is the most common flash loan attack vector?
5.What advantage does borrowing against crypto collateral provide over selling the crypto directly?
Put this lesson to work
Free on Thrive, no account needed.