Quick answer

Flash loans are uncollateralized loans in DeFi that must be borrowed, used and repaid within a single blockchain transaction. If the money is not returned, plus any fee, by the end of that transaction, the blockchain reverts every step, so the lender never takes a loss.

This makes it possible for anyone with the technical skills to borrow very large sums for a few seconds. Developers use flash loans for arbitrage, refinancing and position management. Attackers have also used them to amplify exploits, which is why the term often appears in hack reports.

The key idea: atomic transactions

On Ethereum and similar networks, a transaction can call many smart contracts in sequence. The transaction is atomic: either every step succeeds, or the whole thing fails and the chain state goes back to how it was before. There is no half-finished outcome.

A traditional loan needs collateral or credit checks because the lender must trust that money given today comes back tomorrow. With an atomic transaction, there is no tomorrow. The lending contract sends the funds, lets the borrower's code run, and then checks its own balance. If the balance is not at least what it lent plus the fee, it throws an error and everything is undone, including the loan itself.

The result is an unusual product: an uncollateralized loan with essentially no default risk for the lender, available to anyone, limited only by the liquidity in the lending pool.

How a flash loan works step by step

  1. Write a contract. The borrower deploys a smart contract that contains the logic to run while holding the borrowed funds. Flash loans are not something you request in a normal wallet interface.

  2. Request the loan. The contract calls the lending protocol, specifying the asset and amount.

  3. Receive funds and execute. The protocol transfers the tokens and calls back into the borrower's contract, which runs its operations: swaps, deposits, repayments and so on.

  4. Repay. Before the callback ends, the contract returns the principal plus the protocol's fee.

  5. Final check. The lending protocol verifies repayment. If it fails, the transaction reverts and the borrower only loses the network fee paid for the failed attempt.

Aave popularized the term, and several lending protocols and DEXs offer similar features, for example flash swaps on some AMMs that let a trader receive tokens before paying for them within the same transaction. Fees and supported assets differ by protocol and version, so check current documentation rather than assuming.

Five-step flow from a liquidity pool through a swap and a split trade route to a coin stack and a shield, a flash loan arbitrage repaid within one transaction

Legitimate use cases

DeFi arbitrage

If a token trades at slightly different prices on two DEXs, a trader can borrow, buy where it is cheap, sell where it is expensive, repay and keep the difference, all in one transaction. Flash loans let traders without large capital compete, and the arbitrage helps keep prices aligned across venues. Competition is intense, so most simple opportunities are captured by bots within moments. For background, see how a DEX works.

Collateral swaps

A borrower on a lending protocol might want to change collateral from one token to another without first repaying the loan. A flash loan can repay the debt, withdraw the old collateral, swap it, deposit the new collateral and reborrow, all atomically.

Refinancing and self-liquidation

Debt can be moved from one protocol to another with a better rate in a single transaction. A borrower close to liquidation can also use a flash loan to repay part of the debt and unwind the position on their own terms, often more cheaply than being liquidated. Our guide to health factor and collateral ratio explains why that threshold matters.

Why flash loans appear in exploits

A flash loan attack is usually not an attack on the flash loan itself. The loan simply supplies enormous temporary capital, which turns a small design flaw into a large loss. Common patterns:

  • Oracle manipulation. A protocol reads the price of an asset from a single DEX pool. The attacker borrows heavily, makes a huge trade that skews that pool's price, uses the distorted price to borrow or withdraw too much from the vulnerable protocol, then reverses the trade and repays. Because an automated market maker sets price from pool balances, thin pools are easy to move.

  • Governance capture. If voting power is counted at the moment of a vote, an attacker can borrow governance tokens, pass a malicious proposal and return the tokens. Snapshot-based voting and time delays block this.

  • Logic and rounding bugs. Large amounts can magnify tiny rounding errors or unchecked edge cases in a contract's math.

The defenses are well known: time-weighted or multi-source price oracles, voting power measured before a proposal, timelocks on governance actions and careful audits. Protocols that skip them remain vulnerable whether or not flash loans exist; flash loans just remove the need for the attacker to own the capital.

What flash loans mean for ordinary users

Most people will never take a flash loan, but they still affect anyone using DeFi:

  • Check how a protocol gets prices. Documentation or audits should explain its oracle setup. A single spot price from one pool is a red flag.

  • Look at governance safeguards. Timelocks and snapshot voting reduce the risk of sudden hostile changes.

  • Do not expect easy profit. Running flash loan strategies requires writing and testing contracts, paying network fees on failed attempts and competing with specialized bots. Tools that promise effortless flash loan profits are a common scam pattern.

  • Remember the wider risks of DeFi. Our overview of DeFi lending and borrowing covers smart contract and liquidation risk in more detail.

DeFi carries real technical and market risk and crypto prices are volatile, so research any protocol before depositing funds.

FAQ

Can anyone take a flash loan?

In principle yes, because no collateral or identity check is needed. In practice you must write or use a smart contract that borrows, executes and repays within one transaction.

What happens if a flash loan is not repaid?

The entire transaction reverts, so the loan and every action inside it are cancelled. The borrower still pays the network fee for the failed transaction.

Are flash loans legal?

Flash loans are a standard feature of several DeFi protocols. Using them to exploit or manipulate a protocol is a different matter and may be treated as theft or market abuse depending on the jurisdiction.

Why are flash loans called uncollateralized if lenders are safe?

The borrower posts no collateral. The lender's safety comes from atomicity: repayment is enforced by the transaction logic rather than by assets held as security.

Do flash loans make DeFi less safe?

They make weak designs easier and cheaper to exploit, but the underlying flaws, such as manipulable oracles, exist without them. Well-designed protocols account for flash loan scenarios.