What are Flash Loans?
Flash loans are uncollateralized loans that must be borrowed and repaid within a single blockchain transaction. If you don't repay the loan (plus fees) by the end of the transaction, the entire transaction reverts as if it never happened. This atomic property. All-or-nothing execution. Makes flash loans possible without requiring any collateral.
This might sound like magic, but it's actually a logical consequence of how blockchain transactions work. Since a transaction either succeeds entirely or fails entirely (with no in-between states), a lender can safely loan any amount because they're guaranteed to be repaid within the same atomic operation.
How Flash Loans Work
The Atomic Transaction
Here's what happens in a flash loan:
- Borrow: You receive tokens from the flash loan provider (e.g., Aave)
- Use: You perform operations with the borrowed funds
- Repay: You return the borrowed amount plus fee (typically 0.05-0.09%)
- Verify: The protocol checks if repayment is complete
If step 4 fails, the entire transaction reverts. The protocol never had any risk because an incomplete transaction means no funds ever left.
Technical Requirements
Flash loans require smart contract interaction. You can't execute them from a regular wallet. You need:
- A smart contract that receives the loan
- Custom logic that uses the funds profitably
- Code that repays the loan
Several tools make this easier for non-developers, but most flash loan users write custom contracts.
Flash Loan Use Cases
Arbitrage
The most common use case. Spot a price difference between exchanges and exploit it risk-free:
- Flash borrow $1M USDC from Aave
- Buy ETH on Exchange A (lower price)
- Sell ETH on Exchange B (higher price)
- Repay flash loan + fee
- Keep profit
Without flash loans, you'd need $1M in capital. With flash loans, you need only enough ETH for gas.
Collateral Swaps
Change your loan collateral without closing the position:
- Flash borrow enough to repay your loan
- Repay the existing loan, freeing your collateral
- Deposit new collateral
- Borrow again
- Repay flash loan
This saves gas and avoids potential liquidation during the swap.
Self-Liquidation
If you're about to be liquidated at a bad rate, liquidate yourself:
- Flash borrow enough to repay your loan
- Repay loan, retrieve collateral
- Sell collateral
- Repay flash loan
- Keep remaining funds (instead of paying liquidation penalty)
Leverage Adjustment
Increase or decrease leveraged positions in one transaction:
- Flash borrow
- Repay part of your debt OR deposit and borrow more
- Adjust to desired leverage
- Repay flash loan
Flash Loan Providers
| Protocol | Fee | Max Amount | Chains |
|---|---|---|---|
| . . . . . | . . - | . . . . . . | . . . . |
| Aave V3 | 0.05% | Pool liquidity | Multi-chain |
| Uniswap V3 | 0.05-0.3% | Pool liquidity | Multi-chain |
| dYdX | 0% (pre-V4) | Pool liquidity | Ethereum |
| Balancer | 0% | Pool liquidity | Multi-chain |
Fees are typically tiny relative to potential profits, making flash loans extremely capital-efficient.
Flash Loan Risks and Concerns
For Users
Smart Contract Risk: Flash loan contracts can have bugs. Use audited contracts and tested tools. Transaction Failure: If the arbitrage disappears during execution, the transaction reverts. You lose gas but not the borrowed funds. Complexity: Writing flash loan contracts requires Solidity knowledge. Bugs can lead to stuck funds or failed transactions.For DeFi Protocols
Flash loans have been used in several major exploits:
Attack Pattern:- Flash borrow large amount
- Manipulate a vulnerable protocol (oracle, governance, etc.)
- Extract value from the manipulation
- Repay flash loan
- Keep profits
Notable examples include bZx (2020), Harvest Finance (2020), and Cream Finance (2021).
This doesn't mean flash loans are malicious. They're neutral technology. But they amplify the impact of protocol vulnerabilities by giving anyone access to massive capital.
Building Flash Loan Applications
Using Aave
Flash loan contracts typically follow this pattern:
- Request Function: Calls pool.flashLoan() with asset, amount, and callback parameters
- Callback Function: executeOperation() receives the funds, performs your logic, then approves repayment
- Repayment: The protocol automatically withdraws the loan + fee after your callback
Key functions:
- executeFlashLoan(): Initiates the loan request
- executeOperation(): Your custom logic where you use the borrowed funds
- Must approve repayment (borrowed amount + premium) before function ends
No-Code Tools
Several platforms offer flash loan functionality without coding:
- Furucombo
- DeFi Saver
- Flash loan bots (use with caution)
FAQ
Can I use flash loans for personal trading?Technically yes, but in practice, the gas costs and complexity make flash loans most useful for large arbitrage opportunities. Small traders typically don't benefit.
Are flash loans only for exploits?No. Most flash loan volume is legitimate arbitrage, collateral swaps, and debt refinancing. Exploits are high-profile but represent a small fraction of flash loan usage.
Why would a protocol offer flash loans?Fees. Aave earns 0.05% on every flash loan. With billions in flash loan volume, this adds up. It's essentially risk-free income for the protocol.
Can flash loans move markets?Within a single transaction, yes. A flash loan can provide enough capital to significantly move prices on DEXs. However, this reverts if not properly arbitraged.
Related Topics
Learn about DeFi arbitrage strategies, understand smart contract security, and explore advanced yield farming techniques.
. -
Navigate DeFi complexity with Fensory. From flash loans to yield farming, understand your opportunities.[Explore Fensory →](https://www.fensory.com)