DeFi Basics
What Are the Risks of DeFi?
Learn about the key risks of decentralized finance (DeFi), including smart contract vulnerabilities, protocol risk, systemic risk, and how to protect your assets.
Learn what flash loans are, how they work within a single transaction, their legitimate use cases like arbitrage and collateral swaps, and the risks of flash loan attacks in DeFi.
Flash loans are one of the most novel financial primitives to emerge from decentralized finance. They allow anyone to borrow an unlimited amount of cryptocurrency with zero collateral, provided the loan is repaid within the same blockchain transaction. If repayment fails, the entire transaction is reverted atomically — as though it never occurred.
This concept has no equivalent in traditional finance. It exists only because of the unique properties of smart contracts and blockchain execution environments, where transactions are processed as indivisible units.
To understand flash loans, you need to understand atomic transactions. On blockchains like Ethereum, a transaction either succeeds completely or fails completely — there is no partial execution. Flash loans exploit this property:
Because all four steps happen within a single transaction, the lender faces zero default risk. The funds are never truly "at risk" because the blockchain's execution model guarantees repayment or complete reversal.
Flash loans are typically implemented through callback patterns. The lending protocol calls a function on the borrower's smart contract, passing the requested funds. The borrower's contract performs its logic and then approves repayment. The lending contract verifies the returned amount before the transaction finalizes.
Protocols like Aave, dYdX, and Uniswap V3 all offer flash loan functionality, each with slightly different interfaces and fee structures. Aave charges a 0.05–0.09% fee, while Uniswap V3 flash swaps charge the pool's swap fee.
Flash loan fees are minimal compared to traditional lending:
These low fees make flash loans economically viable for even small arbitrage opportunities.
The most common use of flash loans is arbitrage — profiting from price discrepancies across decentralized exchanges. Without flash loans, arbitrage required significant capital. With flash loans, anyone can borrow millions of dollars worth of tokens, execute a multi-step arbitrage trade, repay the loan, and pocket the profit — all in a single transaction.
For example, if ETH is priced at $3,000 on Uniswap and $3,010 on SushiSwap, a flash loan allows a trader to borrow ETH, sell on SushiSwap, buy back on Uniswap, repay the loan, and keep the difference. This activity actually benefits the ecosystem by keeping prices consistent across venues.
Suppose you have a collateralized loan position backed by ETH and you want to switch to wBTC collateral without closing the position. Without flash loans, you would need to repay the debt, withdraw collateral, swap assets, re-deposit, and re-borrow — a multi-step process requiring spare capital and exposing you to price movement.
With a flash loan, you can atomically: borrow stablecoins via flash loan, repay your existing debt, withdraw your ETH collateral, swap ETH for wBTC, deposit wBTC as new collateral, borrow stablecoins against wBTC, and repay the flash loan. Platforms like Borrow help users manage collateralized positions, and flash loan-based collateral swaps streamline these operations.
When your collateralized loan approaches its liquidation threshold, a third-party liquidator would normally close your position and claim a liquidation bonus — a penalty that comes out of your collateral. Flash loans enable self-liquidation: you borrow enough to repay your debt, withdraw your collateral, sell just enough to cover the flash loan, and keep the rest. This avoids the liquidation penalty entirely.
Flash loans enable instant refinancing between lending protocols. If Protocol A offers a 5% borrow rate and Protocol B offers 3%, you can use a flash loan to repay your debt on Protocol A, withdraw your collateral, deposit it on Protocol B, borrow on Protocol B, and repay the flash loan. Aggregators like Borrow already help users find optimal rates across protocols — flash loans are the mechanical backbone that enables instant protocol-to-protocol migration.
Flash loans have been used to temporarily accumulate governance tokens, pass malicious proposals, and return the tokens — all within one transaction. This represents a misuse of flash loans but highlights why governance systems need time-locked voting and snapshot-based quorum mechanisms.
A flash loan attack occurs when someone uses flash-borrowed funds to exploit a vulnerability in a DeFi protocol's economic design. Because the attacker needs zero capital, the barrier to exploiting protocol weaknesses is dramatically lowered.
Oracle Manipulation: Many early DeFi protocols relied on spot prices from a single AMM pool as their price oracle. An attacker could flash-borrow a large amount, execute a massive swap to move the pool price, exploit a protocol that reads this manipulated price (e.g., borrowing at an artificially favorable rate), reverse the swap, and repay the flash loan. Modern protocols mitigate this with time-weighted average price (TWAP) oracles and decentralized oracle networks like Chainlink.
Economic Design Exploits: Some protocols have reward distribution or share-price calculations that can be gamed with large, temporary deposits. An attacker flash-borrows tokens, deposits into the protocol to inflate their share, triggers a reward distribution or accounting update, withdraws their inflated share, and repays the flash loan.
Reentrancy Combined with Flash Loans: Flash loans amplify the damage of reentrancy bugs. An attacker with $10 million in flash-borrowed funds can drain far more than one who only has $10,000 of their own capital.
The DeFi ecosystem has seen numerous high-profile flash loan attacks:
Robust DeFi protocols employ several defensive strategies:
Flash loans are closely related to MEV (Maximal Extractable Value). MEV searchers frequently use flash loans to fund arbitrage and liquidation strategies without tying up capital. The relationship works both ways — flash loan-funded arbitrage is one of the primary sources of MEV on Ethereum.
This creates an ecosystem where:
Understanding both flash loans and MEV is essential for grasping how DeFi markets maintain (or fail to maintain) efficiency.
For most users, conventional collateralized borrowing — the kind aggregated by Borrow — is far more relevant than flash loans. Here is how they compare:
| Feature | Flash Loans | Collateralized Loans |
|---|---|---|
| Collateral required | None | 110–200% of loan value |
| Duration | One transaction | Indefinite |
| Use case | Arbitrage, swaps, liquidations | Leverage, liquidity, spending |
| Risk | Transaction reverts if unprofitable | Liquidation if collateral drops |
| Audience | Developers, MEV searchers | Any DeFi user |
| Capital required | None (just gas fees) | Significant (collateral deposit) |
While flash loans are powerful tools for developers, they are not a substitute for the collateralized borrowing that most users need. If you are looking to borrow stablecoins against your Bitcoin holdings, a platform like Borrow aggregates the best rates across lending protocols — no flash loan knowledge required.
Flash loans continue to evolve alongside DeFi infrastructure:
Flash loans represent a uniquely blockchain-native financial instrument — impossible in traditional finance and made possible by the atomic execution model of smart contracts. While they enable powerful applications like arbitrage and collateral swaps, they have also been weaponized in flash loan attacks that have cost protocols hundreds of millions of dollars.
For everyday DeFi users borrowing against their crypto assets, flash loans are background infrastructure. Understanding their existence and risks, however, helps you evaluate the security posture of the protocols where your funds reside. The protocols aggregated by Borrow implement robust oracle and accounting designs that mitigate flash loan attack vectors, but staying informed about these DeFi risks is always advisable.
Common Questions
A flash loan is an uncollateralized loan that is borrowed and repaid within a single blockchain transaction. If the borrower cannot repay the loan plus fees by the end of the transaction, the entire operation is atomically reverted as if it never happened. This atomicity guarantee is what makes flash loans possible without requiring any collateral.
Related Questions
DeFi Basics
Learn about the key risks of decentralized finance (DeFi), including smart contract vulnerabilities, protocol risk, systemic risk, and how to protect your assets.
DeFi Basics
Learn what smart contracts are, how they work on blockchain networks, and why they are the foundation of DeFi applications like lending protocols and decentralized exchanges.
Advanced Topics
Learn what rehypothecation means in DeFi, how it differs from traditional finance, and the risks and benefits of collateral reuse in crypto lending protocols.
Advanced Topics
Understand how DeFi protocol governance works, including governance tokens, DAOs, voting mechanisms, and how governance decisions affect lending and borrowing rates.