What it is
A flash loan is a loan that exists only for the duration of a single blockchain transaction. A lending pool hands funds to a borrowing contract with no collateral and no credit check, on the strict condition that the principal plus a fee is returned before that same transaction finishes. Blockchain transactions are all-or-nothing: if any step fails, everything in it — including the initial disbursement of funds — is undone, so the lender is never actually exposed if repayment doesn't happen.
How it works
- A developer writes a smart contract that, in one transaction, requests a flash loan from a lending pool.
- The pool immediately sends the requested tokens to the borrower's contract, before any repayment has occurred.
- Execution passes into the borrower's own logic, which can now use the borrowed capital freely within that same transaction: swapping across markets, unwinding and reopening a position, repaying one debt to take a cheaper one elsewhere, or exploiting a price discrepancy between two venues.
- Near the end of the transaction, the borrower's contract must transfer back at least the original amount plus the lender's fee.
- The lending pool's contract checks its own balance as a final condition of the transaction.
- If the balance check passes, the transaction commits and every intermediate action becomes real and permanent.
- If the balance check fails, the entire transaction — every action taken with the "borrowed" funds, and the loan itself — reverts as though it never happened, so no capital is ever actually at risk for the lender.
- Because the only real risk is "did the code correctly repay," not "will this borrower default," no collateral or identity check is needed.
Why designers use it
- Provides capital-efficient access to large sums for arbitrage and liquidations without requiring the actor to hold that capital themselves.
- Lets any developer, not just well-funded traders, execute strategies that need temporary access to large amounts of capital.
- Enables self-service tools like collateral swaps or debt refinancing that would otherwise require users to have idle funds on hand.
- Generates fee income for a lending pool from a use case that carries no default risk to the pool itself.
Failure modes
- Oracle manipulation attacks: a borrower uses the loan to temporarily distort the price on a thin market that another protocol reads as its price feed, exploiting the artificial price elsewhere in the same atomic transaction.
- Governance takeover attempts: temporarily acquiring enough voting tokens to pass a proposal within one transaction, then repaying the loan immediately, effectively renting governance power for seconds.
- Cross-protocol composability cascades: because a flash loan can chain calls across many contracts in one transaction, a weakness in any single integrated protocol can be exploited at far larger scale than the attacker's own capital would allow.
- Reentrancy through loan callbacks: the callback the pool invokes on the borrower's contract is a common vector for reentrancy bugs if state isn't locked properly during the callback.
- Underestimated attack surface: teams sometimes assume "no capital changes hands lastingly" means low risk, missing that this exact property is what makes large-scale attacks cheap to attempt, repeatedly and at no cost to the attacker if they fail.
What to check before using it
- Never rely on a single on-chain spot price or reserve ratio as a price oracle; use manipulation-resistant sources like time-weighted averages or external oracle networks.
- If voting power is token-weighted, require snapshots taken before a proposal becomes visible, or holding periods that a flash loan cannot satisfy.
- Audit reentrancy protections around any function your protocol exposes to external callbacks, including flash-loan borrower callbacks.
- Model the largest amount an attacker could borrow across all available pools when estimating worst-case exposure to a single atomic transaction.
- Weigh the fee revenue a flash-loan feature generates against the systemic risk it introduces to any protocol that reads your prices, balances, or governance state.