A flash loan lets you borrow any amount of assets from a DeFi protocol with no collateral — as long as you repay the full amount (plus a small fee) within the same blockchain transaction.
If repayment doesn't happen, the entire transaction reverts as if it never occurred.
How It's Possible
In a normal loan, a lender takes on credit risk — the borrower might not repay. Flash loans eliminate this risk through atomicity: a blockchain transaction either completes entirely or reverts entirely. There's no in-between state.
The protocol's logic says: "At the end of this transaction, the balance must be ≥ what it was at the start." If it isn't, the whole transaction fails and no funds move.
You never actually "hold" the loan in the traditional sense — you borrow, use, and repay all within a single atomic operation.
Legitimate Uses
Arbitrage
Price differences exist across DEXes momentarily. With a flash loan:
- Borrow 100,000 USDC
- Buy SOL on DEX A where it's priced at $150
- Sell SOL on DEX B where it's priced at $151
- Repay loan + fee, keep the profit
No capital required. The arbitrage profit pays the flash loan fee.
Collateral Swapping
You have a position on Aave with ETH collateral, but want to switch to BTC collateral without closing the position:
- Flash loan to repay your ETH-backed loan
- Withdraw your ETH collateral
- Deposit BTC as new collateral
- Re-borrow to repay the flash loan
One transaction, no liquidation risk from temporary uncollateralization.
Self-Liquidation
Your position is near liquidation. Rather than waiting for a liquidator to take a penalty:
- Flash loan to repay your debt
- Retrieve your collateral
- Sell a portion to repay the flash loan
- Keep the rest
You avoid paying the liquidation penalty to external liquidators.
Flash Loans in Exploits
Flash loans have been used as an amplification tool in many DeFi attacks:
Price oracle manipulation: Borrow massive amount → move price on a low-liquidity DEX used as an oracle → exploit a protocol that trusts that oracle → repay loan → keep profits.
Governance attacks: Borrow governance tokens → vote on a malicious proposal → repay tokens. Requires governance with no time-lock — most modern protocols prevent this.
The flash loan itself isn't the exploit — it just lets attackers operate with more capital than they own, amplifying vulnerabilities that already exist.
Technical Requirements
Flash loans require custom smart contract code. You can't use them from a standard wallet UI — you write a smart contract that:
- Calls the flash loan function
- Implements the callback with your logic
- Approves repayment before the callback returns
Major providers:
- Aave (Ethereum/Base): Most used, 0.09% fee
- dYdX: Solana perpetuals platform
- Balancer: Flash loans with 0% fee (just repay principal)
What This Means for Regular Users
Flash loans don't directly affect non-developer DeFi users — they're a developer primitive. But understanding them matters because:
- Flash loan attacks are a common DeFi exploit vector — knowing this helps you evaluate protocol risk
- Flash loan arbitrage keeps prices aligned across DEXes, which benefits all traders through better rates