What is flash loan?

An uncollateralized loan that must be borrowed and repaid inside a single transaction, which the protocol enforces by reverting everything if repayment fails.

Not yet verifiedHow we verify

3 min read

In this entry

An uncollateralized loan that must be borrowed and repaid inside a single transaction, which the protocol enforces by reverting everything if repayment fails.

Because the loan cannot survive the transaction, no collateral is needed and anyone can borrow large sums for arbitrage, collateral swaps, or refinancing. The same property makes flash loans the standard tool for exploiting a protocol whose pricing depends on a manipulable spot source, since an attacker can borrow enough to move a market and repay within one block.

The thing to understand is that a flash loan is not a credit product. Nobody assesses you, nobody can lose money lending to you, and there is no default. It is a temporary reallocation of capital inside one atomic operation, and it exists only because blockchain transactions are all-or-nothing.

How it works

Transactions on an evm chain are atomic: either every state change in them sticks, or none does. A flash loan uses that guarantee as its only security.

  1. Your contract calls the lending protocol and asks to borrow an amount.
  2. The protocol sends the funds and hands control back to your contract.
  3. Your contract does whatever it planned, which must end with enough to repay the principal plus the protocol's fee.
  4. The protocol checks its balance. If it is short, the entire transaction reverts and it is as though nothing happened.

The fee is set by each lending protocol and published in its documentation. Nothing else is required, because the lender's risk is eliminated by step four rather than by underwriting.

Legitimate uses are real. Arbitrage between venues, swapping the collateral backing a loan without unwinding it first, and refinancing a position from one protocol to another all become possible without holding the capital.

The abuse case is equally real. Where a protocol prices an asset from a spot source it does not control, an attacker borrows enough to move that price, exploits the mispricing, and repays. The vulnerability is the price source, not the loan, which is why the standard defense is a time-weighted or multi-source oracle rather than a limit on borrowing.

Example

Illustrative arithmetic. The same asset trades at $1,000 on one venue and $1,010 on another. You borrow $1,000,000 in a flash loan, buy 1,000 units on the cheap venue, sell them on the expensive one for $1,010,000, repay the $1,000,000 plus a $500 fee, and keep the remainder less gas and price impact. In practice the price impact of a trade that size closes most of the gap, which is why real arbitrage margins are far thinner than the quoted spread suggests.

Why it matters when you buy

Flash loans are not something a buyer uses, and they are something a buyer is exposed to indirectly. A token whose protocol relies on a weak price source can be drained in a single block, and holders bear that outcome. Where a token depends on a lending or pricing protocol, treat the oracle design as part of the asset; see the coin pages.

oracle — the usual attack surface, defi — where these exist, smart contract — what executes them, liquidity pool — the market being moved, price impact — what erodes the arbitrage, reentrancy — a related contract vulnerability.

Questions

Can I take a flash loan without writing code?

Not meaningfully. The loan must be borrowed and repaid within one transaction, which requires a contract to orchestrate it. A few interfaces wrap common cases, but the mechanism remains contract-to-contract.

Do flash loans put my funds at risk?

Not directly. The risk reaches you through protocols you hold tokens in or supply liquidity to, if their pricing can be manipulated within a single block.

Why would a lender offer an uncollateralized loan?

Because it cannot lose. If repayment plus fee does not arrive by the end of the transaction, the whole transaction reverts and the funds never left. The fee is pure income on capital that was never at risk.