Seigniorage, rebasing, and fractional designs compared, and why every algorithmic peg has failed under real redemption pressure.
Flash Loan is an innovative DeFi primitive allowing users to borrow millions without collateral , provided the loan is repaid within the same transaction . If not repaid, the entire transaction reverts as if it never happened.
How Flash Loans Work
The Process
Borrow : Take loan (millions of dollars)
Use : Arbitrage, refinance, liquidate
Repay : Return principal + fee
All in one transaction : Must complete in single block
Key Feature
Transaction start: Borrow $10M
↓ Use funds (arbitrage, etc.)
Transaction end: Repay $10M + fee
If fail → Everything reverts
Copy link
Why No Collateral?
Atomic Transactions
All steps happen in one transaction
If loan not repaid, transaction fails
Lender gets money back automatically
No risk to lender
function flashLoan(uint amount) {
// 1. Lend money
transfer(borrower, amount);
// 2. Borrower uses it
borrower.execute();
// 3. Must repay
require(balance >= amount + fee);
// If not, entire tx reverts
}
Copy link
Flash Loan Providers
Aave
Fee : 0.09%
Max amount : Unlimited (pool size)
Most popular flash loan platform
Multi-chain : Ethereum , Polygon , etc.
dYdX
Fee : 0%
More complex to use
Less accessible
Solo margin
Uniswap V3
Fee : Varies
Pool-specific
Flash swaps
Others
Euler Finance : 0 fee
Balancer : Flash loans
MakerDAO : Flash mint
Use Cases
Arbitrage
1. Borrow 1M USDC
2. Buy ETH on Uniswap (cheap)
3. Sell ETH on Sushiswap (expensive)
4. Repay 1M USDC + fee
5. Keep profit
Copy link
Collateral Swap
1. Borrow DAI
2. Repay ETH loan
3. Withdraw ETH collateral
4. Deposit ETH as collateral elsewhere
5. Borrow DAI
6. Repay flash loan
Copy link
1. Borrow DAI
2. Liquidate underwater position
3. Receive discounted collateral
4. Sell collateral
5. Repay flash loan + profit
Copy link
Self-Liquidation
1. Borrow DAI
2. Repay own loan
3. Withdraw collateral
4. Swap to stablecoin
5. Repay flash loan
Copy link
Flash Loan Example
Arbitrage Opportunity
Uniswap : 1 ETH = 2,000 USDC
Sushiswap : 1 ETH = 2,050 USDC
Gap : $50 per ETH
Execution
1. Flash borrow 1,000,000 USDC (Aave)
2. Buy 500 ETH on Uniswap: 1,000,000 USDC
3. Sell 500 ETH on Sushiswap: 1,025,000 USDC
4. Repay flash loan: 1,000,000 + 900 (0.09% fee)
5. Profit: 1,025,000 - 1,000,900 = $24,100
Copy link
Costs
Fees
Platform Fee Example Aave 0.09% $1M loan = $900 fee dYdX 0% Free (complex) Uniswap Varies Pool-specific Euler 0% Newer platform
Flash loans expensive in gas
Complex logic = high gas
Need $50-500 in ETH for gas
Must account for in profit calc
Risks
For Borrowers
Gas costs : Lose money if fail
Timing : Compete with bots
Execution risk : Code bugs
MEV : Frontrunning
For Protocols
Exploits : Flash loans used in attacks
Oracle manipulation : Price manipulation
Complexity : More attack surface
For Lenders
Minimal risk (atomic)
Smart contract risk
Economic attacks possible
Famous Flash Loan Attacks
bZx Attack (2020)
Borrowed ETH via flash loan
Manipulated prices
Extracted value
$8M+ lost
Harvest Finance (2020)
Flash loan price manipulation
$24M stolen
Used USDT/USDC pool
Oracle exploit
Cream Finance (2021)
$130M exploit
Flash loan + price manipulation
| Alpha Homora attack
Largest flash loan hack
Flash Loan Bots
How They Work
Monitor mempool for opportunities
| Calculate profit in real-time
Submit transactions with high gas
Compete with other bots
Profitable arbitrage
Bot Requirements
Fast : Milliseconds matter
Capital : Need ETH for gas
Smart : Optimal routing
Connected : Good RPC nodes
MEV + Flash Loans
Bots use flash loans
| Extract MEV (Miner Extractable Value)
Sandwich attacks
Frontrunning
Developer Guide
Using Aave Flash Loans
import {IFlashLoanSimpleReceiver} from "./IFlashLoanSimpleReceiver.sol";
contract MyFlashLoan is IFlashLoanSimpleReceiver {
function executeOperation(
address asset,
uint256 amount,
uint256 premium,
address initiator,
bytes calldata params
) external returns (bool) {
// Your logic here
// Must repay amount + premium
return true;
}
function flashBorrow(address asset, uint256 amount) external {
POOL.flashLoanSimple(
address(this),
asset,
amount,
"",
0
);
}
}
Copy link
Best Practices
Test extensively on testnet
Account for gas costs
Handle failures gracefully
Consider frontrunning
Monitor competition
Flash Loan vs Traditional Loans
Feature Flash Loan Traditional Collateral None Required Duration 1 transaction Days to years Risk None (atomic) Liquidation risk Use cases Arbitrage General Access Technical Anyone
Future of Flash Loans
Improvements
Lower fees
More protocols
Better tooling
Cross-chain flash loans
Regulation
Scrutiny increasing
KYC requirements possible
AML concerns
Legal frameworks developing
Innovation
Flash mints (Maker)
Layer 2 flash loans
Cross-protocol composability
Advanced strategies
Getting Started
Prerequisites
Solidity knowledge
DeFi understanding
Testing framework
Gas optimization skills
Resources
Aave docs: docs.aave.com
| Flash loan examples: GitHub
| Furucombo: No-code flash loans
| DeFi Saver: Advanced strategies