Flash Loan

An uncollateralized DeFi loan that must be borrowed and repaid within a single blockchain transaction.

What Is a Flash Loan?

A flash loan is an uncollateralized loan that must be borrowed and repaid within a single blockchain transaction. If the borrower fails to return the full amount plus any fees before the transaction finalizes, the entire operation reverts automatically — as if it never happened. This unique mechanism, made possible by the atomic nature of blockchain transactions, allows anyone to borrow millions of dollars in capital without putting up a single dollar in collateral, provided they can use and repay the funds within that one transaction.

Flash loans are one of the most innovative and uniquely DeFi-native financial instruments, with no direct equivalent in traditional finance.

How Flash Loans Work

To understand flash loans, you need to understand transaction atomicity. On blockchains like Ethereum, a transaction either completes entirely or fails entirely — there is no partial execution. A smart contract can execute dozens of operations within a single transaction: borrow tokens, swap them on a DEX, deposit them into a lending protocol, withdraw different tokens, and repay the original loan. If any step fails — including the final repayment — the entire sequence of operations reverts.

This atomicity is what makes flash loans risk-free for the lender. The protocol does not need to assess the borrower's creditworthiness, check their collateral, or trust them in any way. The blockchain's consensus rules mathematically guarantee that either the loan is repaid or the transaction never happened. There is no state in which the lender is left without their funds.

The Technical Flow

  1. The borrower deploys or calls a smart contract that requests a flash loan from a lending protocol (such as Aave or dYdX).
  2. The protocol transfers the requested tokens to the borrower's contract.
  3. The borrower's contract executes its programmed logic — arbitrage trades, collateral swaps, liquidations, or any other on-chain operations.
  4. At the end of the transaction, the contract repays the original loan amount plus a small fee (typically 0.05% to 0.09%).
  5. The protocol verifies repayment. If the balance check passes, the transaction confirms. If not, every operation in the transaction reverts.

Common Use Cases for Flash Loans

Flash loans unlock strategies that would otherwise require enormous capital reserves. The most common legitimate applications include:

Arbitrage

When the same token trades at different prices on two decentralized exchanges, a flash loan allows a trader to borrow the capital needed to exploit the price difference, buy low on one DEX, sell high on another, repay the loan, and pocket the profit — all in a single transaction. Before flash loans, arbitrage required significant upfront capital, limiting it to well-funded traders. Flash loans democratize this activity, which in turn helps keep prices consistent across markets.

Collateral Swaps

A borrower on a lending protocol might want to switch their collateral from one asset to another — for example, from ETH to wBTC — without closing their loan position. Without a flash loan, this would require either depositing additional collateral or repaying the loan entirely. With a flash loan, the borrower can borrow enough to repay the loan, withdraw the original collateral, swap it for the new collateral, redeposit, re-borrow, and repay the flash loan — all atomically.

Self-Liquidation

When a borrower's position approaches the liquidation threshold, they face losing their collateral at a discount to third-party liquidators. A flash loan allows the borrower to repay their own debt, withdraw their collateral, sell enough to cover the flash loan, and keep the remainder — avoiding the liquidation penalty entirely.

Debt Refinancing

Borrowers can use flash loans to move their position from one lending protocol to another in a single transaction. If Protocol A charges 5% APR and Protocol B offers 3%, a flash loan enables the borrower to repay their debt on Protocol A, withdraw their collateral, deposit it on Protocol B, borrow against it, and repay the flash loan — effectively refinancing at a lower rate with zero downtime.

Flash Loan Fees

Flash loans are not free. Protocols charge a small fee for each flash loan, which is collected regardless of what the borrowed funds are used for. Aave charges 0.05% of the borrowed amount for standard flash loans (with a discounted 0% fee for flash loans used to repay Aave positions). Other protocols have similar fee structures. While these fees are small in percentage terms, they can be significant in absolute terms for large loans — a 0.05% fee on a $10 million flash loan is $5,000.

Flash Loan Attacks: The Dark Side

While the flash loan mechanism itself is secure for lenders, it has been used as a tool to exploit vulnerabilities in other protocols. Flash loan attacks typically follow a pattern:

  1. The attacker borrows a large amount of a specific token via flash loan.
  2. They use the borrowed tokens to manipulate a price oracle, governance vote, or liquidity pool.
  3. They exploit the manipulated state to extract value from a vulnerable protocol.
  4. They repay the flash loan and keep the profit.

Notable flash loan attacks have drained hundreds of millions of dollars from DeFi protocols. The bZx attacks in 2020 were among the first high-profile incidents, and they have continued to be a persistent attack vector. Common targets include protocols that rely on spot DEX prices as oracles (instead of time-weighted averages or decentralized oracle networks) and governance systems that allow voting with borrowed tokens.

It is important to note that flash loans do not create vulnerabilities — they expose existing ones. A protocol that is vulnerable to a flash loan attack has an underlying design flaw (such as a manipulable oracle) that the flash loan merely provides the capital to exploit.

Flash Loans and Protocol Security

The existence of flash loans has fundamentally changed how DeFi protocols approach security. Developers and auditors now assume that any attacker has access to unlimited capital within a single transaction, which has led to more robust oracle designs (using time-weighted average prices rather than spot prices), stricter governance voting mechanisms (requiring token locking or time delays), and more conservative protocol parameters.

Who Can Use Flash Loans?

Flash loans require technical knowledge to use directly, as they involve writing or interacting with smart contracts. However, several tools and platforms have made flash loans more accessible. Furucombo and DeFi Saver provide no-code interfaces for common flash loan operations like collateral swaps and debt refinancing. For developers, Aave's flash loan documentation provides straightforward integration guides.

Why Flash Loans Matter

Flash loans represent a financial primitive that simply cannot exist outside of blockchain technology. The concept of an instant, uncollateralized loan with zero counterparty risk is only possible because of the atomic, deterministic execution model of smart contract platforms. They have made DeFi markets more efficient (through democratized arbitrage), given borrowers powerful tools for managing their positions, and raised the security bar for the entire ecosystem.

Related Terms