Skip to main content
What Are Flash Loans In Crypto?

What Are Flash Loans In Crypto?

Aave, Balancer, and Uniswap let a smart contract borrow for the length of one transaction, and the same design gives attackers cheap capital against weak price oracles and accounting.

Topic
DeFi
Level
Beginner
Reading time
10 min
Last updated
Automated DeFi system processing Bitcoin, Ethereum, and stablecoin transactions to illustrate how flash loans work in decentralized finance

Overview

Introduction

A flash loan lends crypto to a smart contract with no collateral and takes it back, plus any fee, before the same blockchain transaction ends. If the repayment falls short, the transaction reverts and the lender's funds never leave.

That rule lets developers borrow large sums for arbitrage, liquidations, and collateral swaps that repay themselves within the transaction. It also gives attackers temporary capital to exploit weak protocols, and copy-paste “flash loan bot” offers use the name to drain the wallets of people who fund them.

What Are Flash Loans in Crypto?

Lending protocols usually ask for collateral because a borrower might walk away with the funds. A flash loan closes off that possibility, because the loan opens and closes inside one transaction. No borrower holds the funds once the transaction ends, and no debt is left to secure.

The same limit means a flash loan can't pay a bill, fund a wallet for later spending, or move money off-chain. It only helps when borrowing, acting, and repaying all fit into one sequence of contract calls.

In practice, that sequence touches lending pools, exchanges, and liquidation contracts in decentralized finance (DeFi), and a developer writes it in advance. Outside that setting, a flash loan offers no credit line to draw on and no free money, only liquidity that exists for the length of a transaction.

How Flash Loans Work in One Transaction

A flash loan packs borrowing, use, repayment, and a final check into one atomic transaction. Atomic means the chain keeps the transaction only if every step in it succeeds. If any step fails, repayment included, the chain discards every change the transaction made, the loan transfer among them.

The funds go to a receiver contract written for the job, even when a regular wallet sends the request. On Aave V3, the Pool contract lends through two functions. flashLoanSimple() lends one asset, and flashLoan() can lend several in one call. When the receiver contract finishes its work, it has to approve the Pool to pull back the amount plus the fee, or the transaction reverts.

Infographic explaining how flash loans borrow, use, and repay assets within one blockchain transaction, including commit, revert, and attack variant flows
Infographic explaining how flash loans borrow, use, and repay assets within one blockchain transaction, including commit, revert, and attack variant flows

Each stage of a flash loan is on the left below, with what the contracts do at that point on the right.

Request

Borrower contract asks the lender for an asset and amount

Transfer

Lender sends the assets to the receiver contract

Action

Receiver makes its planned swaps, liquidation, or collateral change

Repayment

Receiver returns or approves the principal plus the fee

Validation

Lender checks repayment, and the chain commits or reverts

Borrowing takes a single function call. Every swap or liquidation between the loan and the repayment has to be written and tested in advance, and together they have to leave enough behind to repay the lender.

Why Take Out a Flash Loan?

A flash loan pays off when an action needs more capital than the borrower holds and earns enough inside the same transaction to repay it. Holding the money is never the point.

Crypto arbitrage is one such action. Say ether (ETH), the Ethereum network's native token, trades at $2,000 on one decentralized exchange (DEX) and $2,050 on another. To trade that $50 gap, you'd normally need ETH or dollars already. A flash loan covers the purchase, provided the buy, the sell, and the repayment all happen in one transaction, so you never hold ETH while waiting for the second leg.

If the second leg can't fill at a profitable price, the transaction reverts and you're never stuck with ETH at a loss. You still pay gas, the network fee for the computation the failed transaction used, and on Ethereum mainnet those fees add up across repeated failures.

Liquidators use the same pattern. They borrow to cover another user's undercollateralized debt, claim the collateral at a discount, sell it, and repay the flash loan, all without capital of their own. If the numbers fall short, gas is again the only loss.

So the lender takes no credit risk at all. The opportunity, and the gas bill for chasing it, both belong to the borrower.

Flash Loans vs. Traditional Crypto Loans

A traditional crypto loan stays open for as long as its terms allow. You post collateral, borrow, spend or move the funds as you like, and repay later. A flash loan has to finish inside the transaction that opens it, with no ongoing relationship and no collateral locked anywhere.

Each row below sets a flash loan, on the left, against a traditional or crypto-backed loan, on the right.

No upfront collateral

Collateral, credit checks, or account controls

Lasts one transaction

Lasts days, months, or years

Funds stay inside the transaction

Funds can be withdrawn, spent, or moved

Failure reverts the transaction

Failure can mean liquidation, collections, fees, or default

Both are called loans, but a flash loan only works as temporary liquidity for a contract action with its repayment already written in.

What Flash Loans Are Used For

Flash loans have a short list of uses, each a capital-heavy move that liquidators, active borrowers, or protocol teams would otherwise need their own funds for.

  • Arbitrage between pools, when the price gap covers fees, slippage, and gas
  • Liquidating unhealthy DeFi loans, when the collateral bonus covers the cost of the liquidation
  • Self-liquidation, where a borrower uses temporary liquidity to close or shrink a risky position before someone else liquidates it at a penalty
  • Collateral swaps, which change the asset backing a loan without closing the position
  • Debt refinancing, which repays a loan on one protocol and reopens it on another in one step
  • Batch operations, where grouping several DeFi actions into one atomic transaction costs less or fails more safely

All of these depend on liquid markets. In a thin pool, the trade itself moves the price far enough for slippage to eat the expected profit before the transaction settles. A flash loan strategy can't be more reliable than the pools, oracles, and protocols it touches.

Why Flash Loan Arbitrage Is Not Easy Money

Bot sellers pitch flash loan arbitrage as a simple loop. Borrow free capital, keep the spread, repeat. In practice, any profitable gap on a public chain is visible to every bot watching the same pools, and those bots compete it away fast.

Whatever gap survives still has to pay for itself. Gas, lender fees, slippage, and failed transactions all eat into a paper profit. So does maximal extractable value (MEV), the profit that bots and block builders take by reordering pending transactions or trading just ahead of them.

The strategies that do make money come from developers who understand contract execution, gas pricing, private order flow, and pool liquidity. A script posted in a video description has none of that behind it.

How Flash Loan Attacks Happen

A flash loan attack exploits a flaw in some other protocol. The flash loan supplies the capital that turns the flaw into a large loss, and the lender's contract works as designed throughout.

In outline, the attacker borrows a large sum, uses it to break an assumption in the target protocol, takes value out, and repays the loan in the same transaction. None of the capital is the attacker's own, so the attempt costs little more than gas and fees.

The Open Worldwide Application Security Project (OWASP) lists flash loan attacks as SC07 in its Smart Contract Top 10 for 2025 and says they often end in drained liquidity, altered prices, or exploited business logic. Price oracle manipulation sits at SC02 on the same list.

Each weak assumption is on the left below, with the way borrowed capital breaks it on the right.

Spot price equals fair price

Attacker moves a thin pool, triggers a bad valuation, then lets the price settle back

Share accounting can't be skewed quickly

Deposits, withdrawals, or rounding paths pushed at unusual scale

Governance weight reflects lasting ownership

Voting power or balance borrowed for a short window

Liquidation math covers every edge case

An extreme position routed through a profitable liquidation

Another protocol's instant state can be trusted

External state changed just long enough for the target to read it

Euler Finance lost roughly $197 million in a flash loan attack on Mar. 13, 2023, according to a Chainalysis report, which says the attacker later returned the stolen funds. The same report traces that loss to one logic flaw in Euler's DonateToReserve function, which burned the attacker's deposit tokens without burning the matching debt tokens.

Price attacks go through the oracle, the service that feeds price data into a protocol. One that reads a single pool's spot price takes whatever the pool shows at that moment, even if a borrowed trade put it there earlier in the same transaction. Uniswap V2's whitepaper describes that risk, and its answer is a time-weighted average price (TWAP). Each pool records its price before the first trade of every block and weights it by how long it stood, so a price pushed and pulled back inside one transaction never enters the average.

Shifting a TWAP means holding the price off-market across whole blocks while arbitrage traders trade against it, and a flash loan can't pay for that because it ends with its transaction. Uniswap's documentation says the cost of manipulation rises roughly in line with pool liquidity and with the length of the averaging window. Combining several independent price sources and rejecting stale or extreme values makes the attack harder still.

A borrowed trade can push the spot price to $4 while a 30-minute TWAP still reads $1

A flash-loaned swap can move a pool's spot price inside one transaction. A Uniswap V2 style time-weighted average records each block's opening price, so the pushed price gets no weight unless it lasts whole blocks.

A spot oracle sees whatever the pool shows mid-transaction. A time-weighted average only moves as the price holds across whole blocks, which a flash loan alone cannot pay for.

Hypothetical prices on Uniswap V2's arithmetic time-weighted average. Other oracle designs average differently, and real manipulation costs depend on pool liquidity and arbitrage. Missed slots stretch the block count. Not a description of any specific exploit.

Flash Loan Risk Checks for DeFi Users and Builders

You don't need to take a flash loan to lose money to one. Deposits in a protocol with a weak oracle, fragile accounting, or no emergency pause are exposed whenever an attacker finds the flaw, however carefully the depositor behaved.

On the user side, a few habits cut that exposure.

  • Choose protocols with audit reports you can read, active bug bounties, and a record of responding to incidents
  • Avoid new or thinly traded pools where one large trade can move the price sharply
  • Treat a vault that promises automated flash loan yield without explaining the strategy as a warning sign

Builders face a different problem, since their code is the attack surface. Protocol design has to assume an attacker can bring flash-loan-sized capital to any call.

  • Price assets from TWAPs and several independent sources, with no single-pool spot reads
  • Cap how much state can change inside one transaction
  • Test liquidation paths, share math, collateral ratios, and rounding at flash-loan-sized inputs
  • Add circuit breakers that trip on abnormal price moves or sudden liquidity shifts
  • Commission audits that simulate economic attacks alongside the code review
  • Keep pause controls and an incident response plan ready before material funds arrive

None of these remove DeFi risk. They shrink the gap between temporary borrowed capital and permanent protocol damage.

Flash Loan Platforms, Fees, and Standards

Flash loan providers differ on supported assets, fees, and contract interfaces, and any of those can decide whether a strategy works. Aave's documentation says its V3 fee can change by governance vote and is waived on flashLoan() for approved flash borrowers, while flashLoanSimple() always charges it.

As of Nov. 19, 2026, the fees below come from each protocol's own contracts or documentation, with the provider or Ethereum Request for Comments (ERC) standard on the left.

Aave V3 Pool

0.05% on the core Ethereum pool

Balancer V2 Vault

0% on Ethereum, drawn from the Vault’s pooled balances

Uniswap V2 flash swaps

0.30%, the same fee as a trade

ERC-3156

Set by each lender and returned by flashFee()

dYdX

Older SoloMargin examples only

Uniswap's flash swaps can withdraw up to the full reserves of a pool, the kind of liquidity traders tap when they swap on Uniswap or a rival DEX. The borrower can repay in the token it took, plus the fee, or pay in the pair's other token and complete a swap.

ERC-3156, a finalized standard, gives lenders and borrowers one shared callback pattern. The lender sends the assets, calls the receiver's onFlashLoan() function, then pulls back the amount plus the fee or reverts. One integration written to that interface can work with any lender that follows it.

Older dYdX examples built on its SoloMargin contract assume an interface from an earlier product version. Check them against dYdX's current documentation before reusing any code.

No table can rank providers by profit, which depends on pool liquidity, gas, block ordering, contract design, and whether the opportunity still exists when the transaction lands.

How to Use Flash Loans Without Falling for Bot Scams

Many “flash loan crypto bot” offers online borrow nothing at all, because they're built to drain wallets. A typical offer asks you to paste Solidity smart contract code into Remix, a browser-based code editor, fund the contract with some ETH to “activate” it, and approve token permissions. The deposit then moves to the scammer's wallet, and no flash loan ever happens.

The approval step can cost more than the deposit. Once a contract holds permission to spend your tokens, it can move them later without asking again. Walk away from any offer that shows these signs.

  • Source code copied from a video, with no explanation of what it does
  • A deposit required before the strategy will “activate” or “start”
  • A request for unlimited token approvals
  • A profit estimate that leaves out gas and failed attempts
  • No named DEXs, tokens, or repayment path
  • The same contract on several throwaway websites or Telegram channels

If you want to learn the tool itself, keep funded wallets out of it until you understand every call the contract makes.

  • Read the official protocol documentation before any third-party tutorial or video
  • Practice on a testnet or a local fork of mainnet first
  • Never paste unknown Solidity into Remix with a funded wallet connected
  • Skip any contract that promises fixed or “guaranteed” profit
  • Check your token approvals regularly and revoke the ones you no longer need
  • Learn how gas, DEX pool pricing, slippage, and transaction reverts work before you look at any bot

Flash loans themselves are a legitimate tool, and the scams live in the wrappers built around them.

FAQs

Can anyone get a flash loan?

Any address can call the flash loan function on a permissionless lender. Aave’s documentation lists three ways in, from a regular wallet, from another contract, or from the receiver contract itself, and each one names a receiver contract that must repay. Aave also warns never to leave funds sitting on that receiver contract, because an attacker can use them in a griefing attack.

What happens if a flash loan is not repaid?

Usually the whole transaction reverts, with one exception on Aave V3. With flashLoan(), a borrower can open a variable-rate debt position for an asset in place of repaying it, but only with enough collateral or credit delegation behind it. flashLoanSimple() offers no such option.

Are flash loans a scam?

No. Flash loans are functions in open-source lending contracts, such as Aave V3’s Pool and Balancer V2’s Vault, and anyone can read that code on-chain. The scams are bot offers that borrow the name, and a look at a contract’s verified code on a block explorer shows whether it ever calls a lender at all.

Can you make money with flash loan arbitrage?

Some developers do, but profit has to be counted across every attempt. A strategy that clears the lender’s fee, gas, and slippage on one trade can still lose money over a hundred tries once the failed ones have paid their gas.

What is the difference between a flash loan and a flash loan attack?

A flash loan is the borrowing function itself. In an attack, the exploited flaw sits in a different protocol, so the fix belongs in that protocol’s code or oracle, and the lender has nothing to patch.

Do flash loans require coding?

Any custom strategy does, since the receiver contract holds the logic. Some apps put a flash loan behind a button, and Aave’s documentation says Aave V3 uses flash loans for its own liquidity switch feature. In that case, the app’s contracts do the borrowing.

Loading image…

The Catalyst

Know what’s moving crypto.