Flash Loans Explained: How to Make One with Aave

A flash loan lets you borrow money with no collateral, as long as you pay it back inside the same blockchain transaction. If you can’t repay the loan plus a small fee before that transaction ends, the whole thing is cancelled and it’s as if the loan never happened.

That single rule is what makes flash loans possible. The lender takes no risk, so you don’t need a credit score, a deposit, or anyone’s permission. Aave is the protocol most people use to get one, and this guide walks through what a flash loan is, who actually uses them, what they cost, and how you’d build one yourself.

What Is a Flash Loan?

A flash loan is an uncollateralized loan that must be borrowed and repaid within one transaction. There’s no repayment schedule and no interest clock, because the entire loan opens and closes in the time it takes a single transaction to settle on-chain.

This works because of a property called atomicity. A blockchain transaction either completes in full or fails completely, with nothing in between. Aave’s smart contract hands your contract the funds, lets your code run, and then checks whether it got the money back plus the fee. If the check fails, the transaction reverts and every step inside it is undone.

Why there’s no collateral and no risk to the pool

With a normal crypto loan, you lock up assets worth more than you borrow so the lender is covered if you default. A flash loan skips that entirely.

The protocol doesn’t need collateral because repayment isn’t a promise you keep later, it’s a condition enforced by code before the transaction can finalize. You literally cannot walk away with the money. Either the loan is repaid in the same transaction, or the loan was never issued.

Why Do These Loans Exist?

Flash loans solve a specific problem: getting access to large amounts of capital you don’t have, for the few seconds you need it.

Plenty of profitable on-chain moves require size. Closing a price gap between two exchanges, or paying off someone’s bad debt to claim a reward, only works if you can move enough value to matter. Flash loans let a developer with a few dollars of gas borrow millions for one transaction, act, and return it, all without putting their own capital at risk. That keeps markets more efficient and lowers the barrier to strategies that used to need deep pockets.

Who Uses Them, and What For?

Flash loans are a developer tool, not something you tap through an app. The people using them are writing smart contracts, and most fall into a handful of camps.

  • Arbitrage traders. When the same token trades at different prices on two decentralized exchanges, a bot can borrow, buy low on one, sell high on the other, repay the loan, and keep the spread. This is the headline use case behind the phrase “flash loan arbitrage,” and it overlaps heavily with MEV (maximal extractable value) bots competing to capture these gaps.
  • Liquidators. DeFi lending markets reward anyone who repays undercollateralized positions. A flash loan supplies the capital to clear the debt and claim the liquidation bonus in one shot.
  • Position managers. Borrowers use flash loans to swap collateral, refinance debt, or move a position between protocols without first unwinding it. Aave’s own docs describe this as a “liquidity switch” feature.

Flash loans also have a darker reputation. They’ve been used to amplify attacks on other DeFi protocols, where a borrowed pile of capital is used to manipulate a price feed or governance vote. Worth being clear here: the flash loan isn’t the vulnerability. These attacks exploit weaknesses in the targeted protocol, and the loan just removes the need for the attacker to already be rich.

What Does Aave Charge?

Aave V3 charges a flash loan premium of 0.05% of the amount you borrow, paid back alongside the principal in the same transaction. That’s down from the 0.09% charged in Aave V2, and the fee is documented directly by Aave.

The rate isn’t carved in stone. It’s a parameter set per market and adjustable through Aave governance, which is why serious builders read the current fee from the pool at runtime rather than hardcoding it. Here’s a quick sense of the cost at different sizes:

Amount borrowedAave fee (0.05%)
10,000 USDC5 USDC
100,000 USDC50 USDC
1,000,000 USDC500 USDC

The protocol fee is only part of your real cost. You also pay network gas for the transaction, and if your strategy involves swaps, slippage eats into the result too. A useful way to think about it:

Net profit = gross profit − Aave fee − gas − slippage

That math is why most flash loan attempts are run by automated contracts: the window is tiny, and a strategy that looks profitable on paper can turn negative once fees and gas are counted.

Aave V3 vs V4: Where This Feature Lives Now

If you’re building today, Aave V3 is the home for flash loans. Its contracts are mature, widely audited, and deployed across Ethereum, Arbitrum, Optimism, Base, Polygon, Avalanche, and BNB Chain, among other EVM networks, with the same interface everywhere.

Aave V4 is newer. It went live on Ethereum mainnet on March 30, 2026 after more than two years of development, introducing a modular “Hub-and-Spoke” design that separates shared liquidity from individual lending markets. Aave founder Stani Kulechov has called V4 the “backbone of all finance.” At launch it rolled out cautiously with a limited set of markets, so V3 still carries most of the protocol’s liquidity and remains where flash loan tooling and documentation are best established.

Aave is the largest lending protocol in DeFi, holding roughly $24 billion in total value locked as of late March 2026. For a flash loan, that depth matters: the more liquidity sitting in a reserve, the larger a loan it can supply in a single transaction.

How to Build One with Aave

A flash loan isn’t a button in the Aave interface. You need a smart contract that both requests the loan and defines what happens while it holds the funds. The flow is always the same: your contract asks the Pool for money, the Pool sends it and calls your code back, your code does something useful, and then the Pool pulls back the principal plus fee.

Aave V3 gives you two entry points. flashLoanSimple() borrows a single asset and is the gas-efficient choice for most strategies. flashLoan() can borrow several assets in one call, which you’d reach for only when a strategy genuinely needs multiple reserves at once.

Here’s the sequence for a single-asset loan:

  1. Write a receiver contract. It must inherit from FlashLoanSimpleReceiverBase and implement the executeOperation() callback. This is the function Aave calls after sending you the funds.
  2. Put your strategy inside executeOperation(). This is where you do the actual work, like buying on one exchange and selling on another, while holding the borrowed capital.
  3. Repay inside the same function. Before executeOperation() returns, your contract must hold the borrowed amount plus the premium and approve the Pool to pull that total back.
  4. Trigger the loan. Call flashLoanSimple() on the Aave Pool, pointing it at your receiver contract and the amount you want.
  5. Test before you ship. Simulate the transaction against a mainnet fork or a testnet, confirm it’s profitable after fees and gas, then send it on mainnet.

A stripped-down version of the receiver looks like this:

solidity

// Illustrative only — simplified Aave V3 flash loan receiver
import { FlashLoanSimpleReceiverBase } from
  "@aave/core-v3/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol";
import { IPoolAddressesProvider } from
  "@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol";
import { IERC20 } from
  "@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol";

contract SimpleArb is FlashLoanSimpleReceiverBase {
  constructor(address provider)
    FlashLoanSimpleReceiverBase(IPoolAddressesProvider(provider)) {}

  // Called by the Pool once it has sent you the funds
  function executeOperation(
    address asset,
    uint256 amount,
    uint256 premium,        // the fee Aave will pull back
    address initiator,
    bytes calldata params
  ) external override returns (bool) {
    // ... your logic here: e.g. buy on DEX A, sell on DEX B ...

    uint256 owed = amount + premium;               // principal + fee
    IERC20(asset).approve(address(POOL), owed);    // let the Pool reclaim it
    return true;
  }

  function run(address asset, uint256 amount) external {
    POOL.flashLoanSimple(address(this), asset, amount, "", 0);
  }
}

You’ll also need the @aave/core-v3 package and the IPoolAddressesProvider address for whichever network you’re deploying to. The official FlashLoanSimpleReceiver interface on GitHub spells out the exact callback signature your contract has to match.

Reliable access to the chains Aave runs on

Flash loan strategies are only as good as your view of the chain. Before you send a transaction, you want to read live prices, simulate the whole bundle, and submit it quickly, because the opportunity you spotted can vanish in a block or two. That requires stable, low-latency access to Ethereum and the other networks Aave is deployed on.

If you’d rather not maintain that infrastructure yourself, NOWNodes provides endpoints and dedicated nodes for Ethereum and a wide range of EVM chains, so your contract and your off-chain bot can read state and broadcast transactions reliably. Ethereum access in particular is where most flash loan activity still happens.

Mistakes That Wipe Out the Profit

Most failed flash loans don’t fail dramatically. They either revert, costing you gas for nothing, or they execute at a loss. A few recurring traps:

  • Hardcoding the fee. The premium is a governance parameter and can differ by market or change over time. Read it from the pool’s FLASHLOAN_PREMIUM_TOTAL() or use the premium passed into your callback, rather than assuming 0.05% forever.
  • Leaving funds on the contract. Aave’s docs warn that a receiver holding idle tokens is exposed to griefing attacks. Pull profits out and don’t park balances there.
  • Ignoring gas and slippage. A spread that covers the fee can still be wiped out by network costs and price impact on your swaps. Simulate the full transaction, including both, before going live.
  • Competition. The obvious arbitrage opportunities are hunted by sophisticated MEV bots that will often front-run a slower transaction. A profitable idea isn’t the same as a profitable execution.

Conclusion

Flash loans are one of the more genuinely novel things DeFi has produced: uncollateralized access to serious capital, made safe by the fact that the loan can’t exist unless it’s repaid in the same breath. Aave V3 is the proven place to get one, with a 0.05% fee and two clear entry points in flashLoanSimple() and flashLoan().

The hard part was never getting the loan. It’s writing a strategy that clears the fee, gas, and slippage, and executing it faster than everyone else chasing the same gap. If you’re experimenting, start on a testnet, keep your contract clean, and treat every opportunity as profitable only after the costs are subtracted.

FAQ

Can you take a flash loan without writing a smart contract?

Not in any practical sense. A flash loan has to borrow, act, and repay within a single transaction, which only a smart contract can orchestrate. Some platforms and bot frameworks wrap this in a friendlier interface, but under the hood a contract is still doing the work. If you can’t code it, you’d be relying on someone else’s deployed contract.

Is Aave the only protocol that offers flash loans?

No. Aave is the most widely used, but it isn’t alone. Balancer offers flash loans, and Uniswap supports a similar mechanism called flash swaps. Aave tends to be the default because of its liquidity depth, multi-chain deployments, and well-documented developer tooling.

Can beginners actually make money with flash loan arbitrage?

It’s much harder than tutorials suggest. The straightforward price gaps are contested by automated MEV bots running optimized contracts, and your profit has to survive the Aave fee, gas, and slippage. Flash loans are worth learning as a developer skill, but expecting easy returns as a newcomer is unrealistic.

Using a flash loan is not illegal in itself. It’s a standard DeFi tool used for arbitrage, refinancing, and liquidations every day. What can cross a legal line is using one to exploit or manipulate another protocol, which is the kind of activity that draws scrutiny, not the mechanism.

How long does a flash loan last?

A single transaction. There’s no term, no overnight period, and no way to extend it. The loan opens and closes within the same transaction, which settles in one block, so your entire strategy has to fit inside that window.