A flash loan is an uncollateralized loan that is borrowed and repaid within a single blockchain transaction. If the borrowed amount plus a fee is not returned before the transaction ends, the entire transaction reverts as if it never happened, so the lender never bears credit risk. Flash loans exist only in DeFi, because they depend on the atomic execution of smart contracts on programmable blockchains such as Ethereum.
In the Crypto & blockchain ecosystem, flash loans give anyone temporary access to very large amounts of liquidity, which enables arbitrage, collateral swaps and self-liquidation. The same property has also made them a common tool in protocol exploits, where attackers borrow millions to manipulate prices for a few seconds.
How a flash loan executes atomically
A flash loan relies on transaction atomicity: every step of a blockchain transaction either completes or none of it does. The borrower deploys a contract that requests funds from a lending pool, receives them, runs arbitrary logic and returns the principal plus a fee, all in one call sequence. At the end, the pool checks its balance; if it is short, it throws an error and the network discards every state change.
The steps below show the standard sequence used by large lending protocols such as Aave and by the flash swap feature of Uniswap.
| Step | Action | Who performs it |
|---|---|---|
| 1. Request | Borrower contract calls the pool’s flash loan function | Borrower contract |
| 2. Transfer | Pool sends the requested tokens | Lending pool |
| 3. Callback | Pool calls the borrower’s receiver function | Lending pool |
| 4. Execute | Borrower runs trades, swaps or repayments | Borrower contract |
| 5. Repay | Borrower approves or returns principal plus fee | Borrower contract |
| 6. Verify | Pool checks balance and reverts on shortfall | Lending pool |
Because a failed loan costs the borrower only the gas fee of the reverted transaction, the lender’s capital is never exposed to default. This is why no collateral, credit score or identity is required.
Key parameters and costs
Flash loan economics depend on a small set of parameters: the fee charged by the pool, the liquidity available, the gas consumed and any slippage incurred during the trades. A strategy is profitable only when its gain exceeds the sum of all of these.
| Parameter | Typical range | What it affects |
|---|---|---|
| Pool fee | 0 to 0.09 percent of principal | Fixed cost per loan |
| Available liquidity | Limited by pool reserves | Maximum loan size |
| Gas cost | Hundreds of thousands to millions of gas | Cost even when the loan fails |
| Slippage | Grows with trade size versus pool depth | Erodes arbitrage margin |
| Block competition | Varies with network activity | Risk of being outbid by others |
Fees differ by protocol and can be changed through governance, so the ranges above are indicative rather than fixed. The maximum size of a flash loan equals whatever the pool holds at that moment, which on deep pools can reach hundreds of millions of dollars.
Legitimate uses in DeFi
Flash loans make capital efficiency available to anyone who can write a contract, not only to large holders. Their legitimate uses share one feature: the borrowed funds create value that can be realized and repaid in the same transaction.
| Use case | What the loan funds | Outcome |
|---|---|---|
| Arbitrage | Buying on one DEX and selling on another | Captures price differences between pools |
| Collateral swap | Repaying a debt to release collateral | Replaces one collateral asset with another |
| Self-liquidation | Repaying a risky position before liquidators do | Avoids the liquidation penalty |
| Debt refinancing | Moving a loan between lending protocols | Obtains a lower interest rate |
| Leverage loops | Repeated deposit and borrow cycles | Builds a leveraged position in one step |
Arbitrage also helps the wider market, because it pulls the prices of automated market makers back into line. Many liquidation bots use flash loans as well, which keeps crypto lending markets solvent without requiring the bot operator to hold large reserves.
Flash loans compared with other crypto loans
A flash loan differs from ordinary crypto lending in duration, collateral and risk distribution. Standard DeFi loans are overcollateralized and can stay open for months; centralized loans add counterparty and custody risk.
| Feature | Flash loan | Overcollateralized DeFi loan | Centralized crypto loan |
|---|---|---|---|
| Duration | One transaction | Open-ended | Fixed or open term |
| Collateral | None | Typically 120 to 200 percent | Varies by lender |
| Default risk for lender | None by design | Managed by liquidation | Counterparty credit risk |
| Required skill | Smart contract programming | Wallet and interface | Account and verification |
| Typical user | Bots, developers, traders | Holders seeking liquidity | Retail and institutions |
Flash loan attacks and protocol risks
Flash loans do not create vulnerabilities by themselves, but they remove the capital barrier to exploiting existing ones. An attacker who needs one hundred million dollars for ten seconds can obtain it for a small fee, which turns a theoretical weakness into a practical attack.
The most common pattern is oracle manipulation. A protocol reads an asset price from the spot reserves of a single liquidity pool; the attacker borrows a large amount, distorts that pool, borrows or mints against the inflated price, restores the pool and repays the loan. Other attacks combine flash loans with governance tokens to pass a malicious proposal, or with reentrancy and rounding errors.
- Use time-weighted average prices or decentralized oracle networks instead of spot reserves.
- Require governance tokens to be held for several blocks before voting.
- Limit how much value can move in a single block or transaction.
- Commission a smart contract audit that models flash loan scenarios explicitly.
A frequent misconception is that banning flash loans would end these exploits. In practice, well-funded attackers could use their own capital; the root cause is the flawed price or logic, and robust design is the only durable defense.
The idea in brief
Imagine borrowing a large sum of money on the condition that you return it before you leave the bank counter. If you cannot return it, the bank simply rewinds time so the loan never happened. Nobody loses anything except a small processing cost.
A flash loan works like that on a blockchain. Borrowing, using and repaying all happen in one step, so the lender needs no guarantee. People use it to profit from price differences or to reorganize their loans, and occasionally to attack poorly designed systems.
A practical scenario
A trader notices that a token trades at 1.000 USDC on one decentralized exchange and at 1.012 USDC on another, a gap of 1.2 percent. The trader’s contract takes a flash loan of 2,000,000 USDC from a lending pool with a 0.05 percent fee.
Within the same transaction, the contract buys the token on the cheaper exchange, sells it on the more expensive one and receives about 2,016,000 USDC after slippage. It repays 2,001,000 USDC, including the 1,000 USDC fee, and keeps roughly 15,000 USDC before gas.
If another bot had closed the gap first, the sale would have returned less than the loan, the repayment check would have failed and the transaction would have reverted. The trader would have lost only the gas fee, which illustrates why flash loans shift risk from capital to speed and execution accuracy.