A flash loan is an uncollateralized loan that must be borrowed and repaid within the same blockchain transaction. If the borrower fails to repay by the end of the transaction, the entire transaction reverts as if it never happened, meaning the lender faces zero risk. This enables arbitrage, liquidation, collateral swaps, and other complex operations without any upfront capital.

What Is a Flash Loan?

3 min read

The short version

A flash loan is like borrowing a million dollars from a bank, using it to buy something, selling it for a profit, repaying the bank, and keeping the difference, all in the time it takes to blink. If your plan does not work out, time reverses and the loan never happened. The bank never risked anything because either you pay back in the same instant or the whole thing is undone.

How It Works

Flash loans exploit the atomic nature of blockchain transactions, either ALL operations in a transaction succeed, or NONE do (it reverts). Protocol: (1) Borrow from a flash loan provider (Aave, dYdX, Uniswap). (2) Execute any sequence of operations with the borrowed funds within the same transaction. (3) Repay the loan + fee (typically 0.05-0.09%) before the transaction ends. (4) If repayment fails: the EVM reverts the entire transaction including the borrow, it is as if nothing happened. Gas is still consumed for the failed attempt. This is possible because the EVM executes an entire transaction atomically before committing state changes. Common uses: arbitrage between DEXs, self-liquidation to avoid penalties, collateral swaps (replace one collateral with another without unwinding a loan), governance attacks (borrow tokens, vote, return).

Arbitraging a price difference between two DEXs

ETH trades at $3,000 on Uniswap and $3,015 on SushiSwap (a 0.5% gap). Without a flash loan, you need capital to exploit this. With a flash loan: (1) Borrow 1000 ETH from Aave ($3M), flash loan, no collateral needed. (2) Sell 1000 ETH on SushiSwap for 3,015,000 USDC. (3) Buy 1000 ETH on Uniswap for 3,000,000 USDC. (4) Repay Aave: 1000 ETH + 0.9 ETH fee ($2,700). (5) Net profit: 15,000 USDC minus gas (~$50) minus fee ($2,700) = ~$12,250 profit. All in one transaction. If prices move before execution and the arb disappears, the transaction simply reverts, you lose only the gas cost of the failed attempt.

What People Get Wrong

  • Flash loans are inherently malicious

    Flash loans are a neutral tool. They enable legitimate activities (efficient arbitrage that equalizes prices, self-liquidation, capital-efficient collateral management) as well as exploits. The loan itself is not the attack, it is capital amplification that makes existing vulnerabilities exploitable at larger scale.

  • Anyone can profit from flash loans easily

    In practice, profitable flash loan opportunities are competed for by sophisticated bots (MEV searchers) that execute faster than humans can act. Simple arbitrage opportunities close in milliseconds. You need custom smart contract code, deep DeFi knowledge, and fast execution infrastructure.

  • Flash loans can steal from individuals

    Flash loans cannot directly take funds from your wallet. They exploit vulnerabilities in smart contracts (protocols with price manipulation weaknesses, governance flaws, etc.). Your personal wallet is not at risk from flash loan attacks.

Sources & Further Reading

Questions People Also Ask

How much does a flash loan cost?
Aave charges 0.05% on V3 (0.09% on V2). Uniswap V3 flash swaps charge the standard pool fee (0.01-1%). dYdX charges 0 (or near-zero). Plus gas for the transaction itself. For a $1M borrow: Aave fee = $500, gas = $20-$100.
Do I need to write code to use a flash loan?
Yes. Flash loans require a smart contract that the flash loan provider calls back into (the receiver contract). You must code the logic for what to do with the borrowed funds. There is no "click a button" interface for arbitrary flash loan usage, it requires Solidity development.
Can flash loans work across multiple blockchains?
No. Flash loans are atomic within one chain's transaction. Cross-chain operations cannot be rolled back atomically because different chains have different finality and no shared transaction context. Each chain requires its own flash loan provider.

More in Smart Contracts & Ethereum

See all →
Was this page helpful?

Page last checked