SKIP TO CONTENT
Conceptdefi basicsAdvanced

Flash Loans Explained

Understanding uncollateralized instant loans that are repaid within a single transaction.

12 min read

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:

  1. Borrow: You receive tokens from the flash loan provider (e.g., Aave)
  2. Use: You perform operations with the borrowed funds
  3. Repay: You return the borrowed amount plus fee (typically 0.05-0.09%)
  4. 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:

  1. A smart contract that receives the loan
  2. Custom logic that uses the funds profitably
  3. 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:

  1. Flash borrow $1M USDC from Aave
  2. Buy ETH on Exchange A (lower price)
  3. Sell ETH on Exchange B (higher price)
  4. Repay flash loan + fee
  5. 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:

  1. Flash borrow enough to repay your loan
  2. Repay the existing loan, freeing your collateral
  3. Deposit new collateral
  4. Borrow again
  5. 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:

  1. Flash borrow enough to repay your loan
  2. Repay loan, retrieve collateral
  3. Sell collateral
  4. Repay flash loan
  5. Keep remaining funds (instead of paying liquidation penalty)

Leverage Adjustment

Increase or decrease leveraged positions in one transaction:

  1. Flash borrow
  2. Repay part of your debt OR deposit and borrow more
  3. Adjust to desired leverage
  4. Repay flash loan

Flash Loan Providers

ProtocolFeeMax AmountChains
. . . . .. . -. . . . . .. . . .
Aave V30.05%Pool liquidityMulti-chain
Uniswap V30.05-0.3%Pool liquidityMulti-chain
dYdX0% (pre-V4)Pool liquidityEthereum
Balancer0%Pool liquidityMulti-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:
  1. Flash borrow large amount
  2. Manipulate a vulnerable protocol (oracle, governance, etc.)
  3. Extract value from the manipulation
  4. Repay flash loan
  5. 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:

  1. Request Function: Calls pool.flashLoan() with asset, amount, and callback parameters
  2. Callback Function: executeOperation() receives the funds, performs your logic, then approves repayment
  3. 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.

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)

Frequently Asked Questions

Ready to apply what you learned? See live yield data.

Track live yields, compare protocols, and build your DeFi portfolio with Fensory.

GET EARLY ACCESSArrow right