Flash Loans Explained: Borrow Millions With No Collateral

Flash loans let you borrow crypto for a single transaction at almost no cost. Learn how they work, why they're useful, and the exploits they've enabled.

Ramy Morton Learn

Flash Loans Explained: Borrow Millions With No Collateral

A flash loan lets you borrow any amount of cryptocurrency for a single transaction. Repay it by the end of that same block and you pay almost nothing. Fail to repay, and the transaction reverts as if it never happened. This mechanism exists on most major blockchains and has been exploited for billions.

The mechanic is simple. A loan in this form is not really a loan at all. It is a temporary transfer of tokens within one atomic transaction. The pool that supplies the tokens requires repayment plus a fee before the block closes. If you cannot deliver both by the transaction's end, the entire sequence of events unwinds and gets erased from the blockchain.

This creates a unique primitive. For one transaction, a trader or contract with zero capital can access millions. Most of DeFi has been built around the assumption that this would be harmless. It mostly is. Sometimes it is catastrophic.

How They Work in Practice

The simplest such transaction has five steps.

First, a smart contract requests tokens from a lending pool. The pool transfers the requested amount, say 100,000 Ether. Second, the contract executes whatever strategy it wanted. It might sell on one exchange, buy on another, capture the price difference.

Third, the contract sells the borrowed tokens back into another pool. Fourth, it pays the fee to the original lender. Fifth, the transaction closes.

If any step fails. If the contract does not have enough tokens to repay, or the arbitrage lost money instead of making it. The entire transaction reverts. The lender gets the tokens back as if the loan never existed. The borrower pays nothing. No loss, no permanent debt, no liquidation.

Aave was the first mainstream protocol to offer this feature on Ethereum in early 2020. dYdX followed. Uniswap v3 added borrowing within its pools. These protocols charge a small fee, usually 0.05 to 0.09 percent of the borrowed amount. On a 100,000 Ether borrow, that is 50 to 90 Ether, a real cost but tolerable for profitable trades.

The atomic nature matters. Everything must happen in a single block. A blockchain explorer seeing such a transaction logs something unusual: tens of millions of dollars moving in a single second, leaving no debt behind. The wallet that borrowed has zero tokens before and zero tokens after. The only evidence is a fee transfer and whatever trades happened in the middle.

What These Loans Are Actually Used For

The legitimate uses cluster into a few categories. Arbitrageurs use them to capture price differences between pools without needing to hold inventory. If Curve has Ether at $2000 and Aave has it at $2010, a borrower takes the loan at Curve, sells at Aave, and nets the $10 spread per token on potentially millions of tokens. Risk is near-zero because the transaction is atomic.

Liquidations are another real use. A protocol's collateral value drops and a loan approaches insolvency. A liquidator must bid against other liquidators, usually with capital already on hand. Flash loans let smaller teams compete. Borrow the collateral, liquidate the bad loan, repay, and keep the spread. This has made markets more competitive and liquidations more efficient. Lenders keep better parameters.

Debt swaps use this approach to transfer risk. An Aave borrower with bad collateral can borrow the debt amount, repay it, deposit better collateral, and reborrow in one transaction. It looks like magical refinancing. The blockchain does not care about intent, just about token movements and repayment.

Whale angling uses flash loans for NFT bidding. A whale borrows a million dollars, wins an NFT auction, and immediately sells it or uses it as collateral elsewhere. This is rarer and more speculative but it happens.

Why Exploits Are Possible

Exploits exist because early DeFi contracts often checked token balances at the end of a transaction. If a contract saw that a user held collateral, it assumed the collateral was real. With borrowing like this, a user could appear to have collateral for exactly one block.

In April 2020, bZx was exploited twice in one day. An attacker took a loan of sUSD from dYdX, manipulated the sUSD price on Curve, took out an oversized loan of Ether on bZx by providing sUSD as collateral at a manipulated price, repaid the loan, and walked away with millions. The entire attack was one transaction. bZx saw collateral. The protocol did not know that collateral price had been artificially inflated moments before.

This led to a shift in how protocols verify collateral. Many now use oracle prices instead of pool prices. Chainlink, Uniswap TWAP, and similar time-weighted averages made price manipulation harder. But it did not eliminate the risk.

The bridge security model revealed similar atomic issues. When a bridge mints assets on a new chain, it usually does not check whether the asset was already minted elsewhere. A borrower could mint a bridge token, trade it, and immediately burn it without repaying the original chain. Some bridge protocols have fallen to similar logic errors.

Defense Mechanisms

Protocols defend using a few patterns.

Checks-effects-interactions is the simplest: verify everything before transferring tokens, not after. If you check the user's collateral before giving out a loan, borrowing cannot inflate it. This is standard practice now.

Time-weighted oracles prevent price manipulation. Instead of reading the current spot price, a protocol reads the average price over the last several blocks or minutes. One transaction cannot move it. Uniswap's time-weighted average price (TWAP) is the standard.

Re-entrancy guards prevent a contract from calling itself recursively during a transaction. Earlier exploits used re-entrancy to drain pools. Guards block re-entrant calls, making the flow sequential.

Some protocols add a separate check: calculate an expected output before the transaction, compare to actual output during execution, and revert if they differ more than expected (slippage protection). Slippage tolerance becomes a firewall.

Pausing is the emergency button. When an exploit is detected, some protocols can pause deposits and withdrawals. It stops the bleeding while developers investigate.

The Current Landscape

Flash loans are now routine. Liquidations on Aave, dYdX, and Compound run continuously. A 100 million dollar liquidation costs about 50,000 to 100,000 dollars in fees and gas. Without this mechanism, liquidations would require capital reserves. Smaller liquidators would be excluded. The market would be less efficient. Spreads would widen.

Solana's flash loans work slightly differently. Solana's single-slot finality means atomic transactions have less room for manipulation. Exploits are rarer, though not impossible. The principle is the same: borrow within a block, repay by the block's end.

Newer EVM chains have built defenses against flash loans in from the start. They learned from Ethereum's exploits. Protocols check prices before transactions, not after. Oracle manipulation is harder.

The flash loan risk is not gone. It has moved. Early flash loan attacks targeted naive price checks. Later attacks exploited oracle dependencies. The pattern repeats: find an assumption in the contract, violate it in one block, extract the difference, repay, and disappear.

Why They Will Not Go Away

These loans are a feature of atomic transactions, not a bug. Any blockchain that lets one transaction do multiple things will allow borrowing that gets repaid in the same transaction. You cannot remove flash loans without removing atomic composability. You cannot remove composability without breaking DeFi.

Flash loans have become too useful to ban. Liquidators depend on them. Arbitrageurs depend on them. Refinancing protocols depend on them. They have made capital more efficient.

Flash loan defenses have shifted toward better oracle design and contract structure. Protocols now design for this reality. They assume hostile transactions will attempt manipulation. This assumption is making newer smart contracts more reliable and harder to fool with one-block tricks. The history of flash loans is the history of DeFi's maturation. Early protocols were naive. They assumed all collateral was real and all prices were stable. Flash loans exposed these assumptions in brutal detail.

Better protocols emerged. The market learned. Flash loans now shape how protocols build security from the start.

Disclaimer The information provided on Coinliva is for informational purposes only and does not constitute financial or investment advice. Cryptocurrency investments are highly volatile and involve risk. While we strive to provide accurate and up-to-date information, some details may change over time. Always conduct your own research before making any financial decisions.