Flash Loan
A flash loan is an uncollateralised DeFi loan that must be borrowed and repaid within the same blockchain transaction; if it is not repaid, the whole transaction is reversed. Flash loans are used for arbitrage, and also in attacks that borrow huge sums to manipulate a vulnerable protocol.
A flash loan lets a smart contract borrow crypto with no collateral, as long as it pays it back in the same transaction. If repayment fails, everything is undone. Flash loans power arbitrage and collateral swaps, and they have also funded well-known DeFi attacks.
- Category
- Cryptocurrency and Blockchain
- Reading time
- 4 min
- Also called
- Flash lending, Uncollateralized atomic loan, Flash swap
- Updated
Flash loans in plain words
A flash loan lets a smart contract borrow tokens with no collateral, as long as it pays them back within the same transaction.1
If the money isn't returned, the whole transaction is cancelled as if it never happened.2
Before the transaction ends, the lender gets its tokens back, sometimes with a fee.1
How a flash loan runs
Write the contract
The borrower is a smart contract, not a person clicking a button.1
Borrow
The contract requests tokens from a lending pool with no collateral.
Use the funds
It trades, swaps collateral or repays debt; flash loans have been used for debt swaps and collateral swaps.2
Repay plus fee
The tokens plus an optional fee go back before the transaction ends.1
Or revert
If repayment fails, the whole transaction reverts.2
Pay gas either way
The network still charges for the attempt, so failed tries cost money.
Worked examples
Example 1 — Arbitrage with a flash loan
+$1,910 before gasHypothetically a token trades at $1.00 on DEX A and $1.02 on DEX B. A contract borrows 100,000 stablecoins with a 0.09% fee.
| Buy on A | 100,000 ÷ $1.00 = 100,000 tokens |
| Sell on B | 100,000 × $1.02 = $102,000 |
| Fee | 100,000 × 0.0009 = $90 |
| Profit before gas | $102,000 − $100,000 − $90 = $1,910 |
Gaps like this are typical targets — three-way arbitrage chances come up often in DeFi.2
Example 2 — The gap closes first
Reverted, gas lostSame trade, but by execution the DEX B price is $1.00.
| Sale proceeds | 100,000 × $1.00 = $100,000 |
| Owed | $100,000 + $90 = $100,090 |
| Shortfall | $100,000 − $100,090 = −$90 |
Repayment failed, so the entire transaction was cancelled; only the gas fee was lost.2
Example 3 — Collateral swap
Collateral switchedHypothetically a user has a loan backed by 10 ETH and wants to switch it to a different collateral token without first raising cash.
| Flash borrow | Enough to repay the old loan |
| Release and swap | 10 ETH swapped into new collateral |
| Reopen and repay | New loan repays the flash loan |
This is a collateral swap: close one position and reopen it with different collateral, all in one atomic transaction.2
Flash loan vs ordinary crypto loan
| Aspect | Flash loan | Collateralized loan |
|---|---|---|
| Collateral | None | Required, often over 100% |
| Duration | One transaction | Days to months |
| Default risk for lender | Removed by reverting | Covered by liquidation |
| Who can use it | Smart contracts | Any account |
Common flash loan uses
Arbitrage
Close price gaps across venues to tighten Bid-Ask Spread differences.
Self-liquidation
Repay debt to avoid a costly Liquidation.
Collateral swaps
Change Exposure without unwinding by hand.
Testing liquidity
Check how much Slippage a large trade would face.
Advantages and disadvantages
Advantages
- No collateral needed.
- Lender faces no default risk.
- Enables complex trades in one step.
- Failed attempts are reverted.
Disadvantages
- Requires smart contract skills.
- Gas is paid even if it fails.
- Competition makes profits thin.
- Used in price and governance attacks.
Going deeper
Read as far as you need. Each level builds on the one before it.
Common mistakes
Forgetting gas
A reverted loan still costs network fees.
Ignoring the fee
Thin gaps vanish after the loan fee.
Assuming free money
Bots compete for the same gap.
Trusting unaudited code
A bug can lose the profit or more.
Check your understanding
Test yourself before moving on. Each answer comes with an explanation.
Key points to remember
- Flash loans need no collateral.
- They must be repaid in the same transaction.
- Failure reverts everything except gas.
- Main uses are arbitrage and collateral swaps.
- They have also funded DeFi attacks.
Frequently asked questions
Can anyone take a flash loan?
Are flash loans risky for lenders?
Are flash loans illegal?
Further learning
- Liquidity
Why pool depth limits loan size.
- Liquidation
How flash loans help avoid it.
- Slippage
Costs inside a flash trade.
- Counterparty Risk
Why atomicity removes default risk.
Sources
This article is written in our own words. The sources below support the specific facts, rules and figures marked with a number in the text. Links open the original publisher’s page.
- Ethereum Improvement Proposals. ERC-3156: Flash Loans (opens in a new tab) Checked .
- Bank of Canada. Risk-Free Uncollateralized Lending in Decentralized Markets: An Introduction to Flash Loans (Staff Discussion Paper 2025-6) (opens in a new tab) Checked .
- European Securities and Markets Authority (ESMA). Decentralised Finance in the EU: Developments and risks (TRV, Oct 2023) (opens in a new tab) Checked .
Educational content, not financial advice. Examples use hypothetical prices and simplified costs; actual fees, margin rules and regulations vary by broker, market and country. We are not affiliated with any publisher linked above. Last reviewed . Report an error or request a source credit.