📖 Term 🔰 Beginner

⚡ Flash Loan Flash Loan

A DeFi loan with no collateral that you borrow and pay back — plus a tiny fee — all inside a single blockchain transaction. If you can't repay it before that transaction finishes, the whole thing is automatically cancelled, as if it never happened.

💡
Common misconception — Is a flash loan free money you can use to get rich? No! The borrowed amount plus a fee must return in the same transaction, or it reverts. You only keep a profit if your strategy actually worked — and you need to write a smart contract to do it.
ONE transaction (all-or-nothing)💸Borrowno collateral⚙️Use ittrade / swapRepay + feesame transaction↩️ If repayment fails, every step reverts — no funds ever moved.
💸 Borrow → ⚙️ use the money → ✅ repay it plus a fee, all in one transaction. If the money doesn't come back, time rewinds and the loan never happened.

🔁 The simple version — a loan that can't go unpaid

A normal loan trusts you to pay it back later, so the lender asks for collateral in case you don't. A flash loan skips all of that with one trick: the borrowing, the using, and the repaying must all happen inside a single blockchain transaction. The smart contract only releases the money if it is guaranteed to come straight back. If the repayment doesn't happen, the whole transaction is cancelled and it's as though no money ever left. That's why no collateral is needed — and why the lender takes no risk.

⚛️ Why "atomic" is the whole secret

Blockchain transactions are atomic, which means all-or-nothing: every step succeeds together, or the entire transaction reverts and nothing changes. A flash loan stacks several steps — borrow, do something useful, repay — into one atomic bundle. So the loan can't be left half-finished. This is what makes flash loans a DeFi idea with no real equivalent in traditional banking: a bank can't rewind time if you fail to repay, but a blockchain can.

🛠️ What people actually use them for

UseWhat happens
🔀 ArbitrageBorrow funds, exploit a price gap between two exchanges, repay, and keep the difference — with no upfront capital
🔁 Collateral swapSwap the collateral backing a loan for a different asset in one step, without paying everything off first
📉 LiquidationsBorrow the funds needed to close out an unhealthy loan, then repay from the reward
♻️ RefinancingMove a position from one protocol to another to get better terms, all atomically

📐 Every one of these needs a smart contract you write and deploy yourself. That's why a flash loan is an advanced, programmer-level tool — not something you click "borrow" on.

🔀 A worked arbitrage example

Say arbitrage is the goal. In one transaction you borrow 1,000 USDC from Aave, buy ETH cheaply on one exchange, sell it for more on another, repay the 1,000 USDC plus Aave's small fee (about 0.05% on v3), and keep the spread. If any step fails or the trade isn't profitable, the whole thing reverts — so the worst case is just the gas fee. The fee is tiny, but the strategy has to genuinely work.

🚨 Flash loan attacks — the scary headline

Beginners often meet the term in two ways: "flash loan arbitrage" (legitimate) and "flash loan attack" news (exploits). In an attack, someone borrows a huge sum, uses it to manipulate a weak price oracle, drains a vulnerable protocol, then repays — all in one transaction. The Mango Markets exploit (2022) lost around $117M this way. The key point: the flash loan isn't the bug. The real weakness is the protocol that trusted a manipulable price. The loan only supplied the temporary firepower.

🚦 Things beginners should know

  • 🚫 Not free money — Everything borrowed, plus a fee, must return in the same transaction
  • 👨‍💻 Programmer-level — You must write and deploy a smart contract; there's no simple button
  • 🛡️ Lenders are safe — If repayment fails, nothing moves; the lender never loses on the loan
  • ⚠️ Attacks blame the protocol — The damage comes from weak oracles, not the loan itself

❓ FAQ

Is a flash loan free money or an easy way to get rich?
No. The amount you borrow, plus a small fee, has to come back inside the same transaction or the whole thing is cancelled. You only keep a profit if you ran a genuinely profitable strategy in those few seconds — and you have to write and deploy a smart contract to do it, so it's an advanced, programmer-level tool, not a click-button loan.
How can a loan have no collateral and still be safe for the lender?
Because of atomic transactions. The protocol only lets the money leave if it is guaranteed to return within the same transaction. If repayment doesn't happen, every step reverts and no funds ever move, so the lender takes no risk and no collateral is needed.
Are flash loans themselves a hack?
No. A flash loan is a neutral tool. In a flash loan attack, the real weakness is a vulnerable protocol — often a price oracle that's easy to manipulate. The loan just supplies the large, temporary capital. The lender never loses money on the loan itself.

🔗 Related