How Flash Loans Work
How a loan can be borrowed and repaid within a single transaction, and what it's actually used for.
What to remember
- A flash loan must be borrowed and fully repaid within a single transaction, or it's automatically reversed.
- This is possible because a blockchain transaction is all-or-nothing (atomic).
- Legitimate uses include arbitrage, collateral swaps, and self-liquidation.
- Flash loans have also been a tool used in real, major DeFi exploits.
The core idea
A flash loan lets a borrower take out a loan with no upfront collateral, on the condition that it's borrowed and fully repaid within the same single blockchain transaction — if repayment doesn't happen by the transaction's end, the entire transaction (including the loan) is automatically reversed as if it never happened.
Why this is possible
Because a blockchain transaction either fully completes or fully fails as one atomic unit, a smart contract can safely lend funds with no collateral, knowing that if the borrower's code doesn't repay in full, the whole transaction — loan included — simply never took effect.
Borrow, use, and repay all happen inside one atomic transaction — if repayment fails, the entire transaction, loan included, automatically reverts.
Legitimate uses
- Arbitrage: borrowing funds to exploit a price difference between two markets, repaying the loan from the arbitrage profit.
- Collateral swaps: replacing one form of loan collateral with another without needing separate upfront capital.
- Self-liquidation: proactively closing a risky lending position on more favorable terms than waiting for automatic liquidation.
Flash loans have also enabled real, large exploits
Because they provide large, uncollateralized capital for a single transaction, flash loans have been used as a tool in several major, well-documented DeFi exploits, typically combined with oracle manipulation or other protocol vulnerabilities.
What to remember
- A flash loan must be borrowed and fully repaid within a single transaction, or it's automatically reversed.
- This is possible because a blockchain transaction is all-or-nothing (atomic).
- Legitimate uses include arbitrage, collateral swaps, and self-liquidation.
- Flash loans have also been a tool used in real, major DeFi exploits.