Flash Loans

Borrow any amount with zero collateral - as long as you repay within the same transaction. If you can't repay, the entire transaction reverts as if nothing happened. This impossible-sounding mechanic exists because Ethereum transactions are atomic: they either fully succeed or fully fail.

Flash Loan Transaction Lifecycle

Watch a flash loan execute step by step. The entire sequence happens in a single block - ~12 seconds of real time, but instant in EVM execution.

1. Borrow

Call flashLoan() on Aave/dYdX/Uniswap. Pool transfers tokens to your contract.

-1,000 ETH from pool
2. Execute Strategy

Your contract does whatever it wants: arbitrage, liquidation, collateral swap, self-liquidation...

Arb: buy on DEX A -> sell on DEX B
3. Repay + Fee

Return borrowed amount + fee (0.05-0.09%). If balance insufficient -> entire tx reverts.

+1,000.9 ETH back to pool
4. Profit (or Revert)

Keep the difference. If the strategy lost money, the repayment fails and everything unwinds.

Net: +3.2 ETH profit

Flash Loan Use Cases

*

Arbitrage

Buy cheap on one DEX, sell expensive on another. Flash loans mean you don't need capital - just a smart contract and a price discrepancy.

~60% of all flash loans

Liquidations

Liquidate undercollateralized positions without owning any DAI/USDC. Borrow -> liquidate -> sell collateral -> repay.

~25% of flash loans

Collateral Swaps

Switch your Aave collateral from ETH to WBTC in one transaction. Flash loan pays off debt -> withdraw collateral -> deposit new -> re-borrow -> repay flash loan.

~10% of flash loans
?

Exploits & Attacks

Flash loans enable governance attacks (borrow voting tokens), oracle manipulation (inflate prices), and reentrancy exploits at scale.

~$1B+ lost to flash loan attacks

Flash Loan Profit Calculator

Gross Revenue
$15,000
Flash Loan Fee
$2,700
Gas Cost
$150
Net Profit
$12,150

Flash Loan Providers

Aave V3
Fee: 0.05% (0% for same-block repay of own debt)
Max: Full pool liquidity (~$10B+)
Best for: Liquidations, collateral swaps
Uniswap V3
Fee: Pool's swap fee (0.01-1%)
Max: Full pool TVL
Best for: Token-pair arbs, flash swaps
Balancer
Fee: 0% (yes, free!)
Max: All vault tokens
Best for: Large arbs, multi-token
MakerDAO
Fee: 0% for DAI flash minting
Max: Debt ceiling (500M DAI)
Best for: DAI-denominated arbs