Flash Loans: The Good, The Bad, and The Billion-Dollar Reality
How borrowing millions in one transaction works and why it powers both innovation and exploits
Mohammad Musharraf
Borrow millions with zero collateral. Repay in the same transaction.
Flash loans processed over $7.5 billion on Aave alone in 2025, enabling arbitrage trades, collateral swaps, and protocol exploits that happen in seconds.
Flash loans are uncollateralized loans that must be borrowed and repaid within a single blockchain transaction. If the borrower can't repay the loan plus a small fee before the transaction completes, the entire operation reverts as if it never happened. This atomic execution model eliminates default risk, allowing protocols like Aave and dYdX to lend millions without collateral checks.
The same mechanism that powers legitimate arbitrage also enabled the $197 million Euler Finance attack in March 2023. Understanding flash loans means understanding both the innovation and the vulnerability they represent in DeFi infrastructure.
What Are Flash Loans?
Flash loans are uncollateralized loans available in DeFi that exist only within a single blockchain transaction. You borrow funds, use them for whatever operation you need (arbitrage, collateral swap, liquidation), and repay the loan plus a fee before the transaction completes. If any step fails or if you can't repay, the entire transaction reverts and no loan is issued.
Traditional loans require collateral because the lender needs protection against default over time. Flash loans eliminate time from the equation. The loan exists for milliseconds, not months. The blockchain guarantees repayment or cancellation through transaction atomicity, so no collateral is needed.
Aave and dYdX are the two dominant flash loan providers in crypto. Aave processed $7.5 billion in flash loan volume through 2025, consolidating its position as the leading platform for instant borrowing. dYdX offers similar functionality with a different fee structure and liquidity model.
The flash loan crypto market has grown significantly since Aave introduced the primitive in 2020. What started as a developer tool for arbitrage bots has become infrastructure that underpins billions in DeFi activity, from collateral optimization to protocol attacks.
How Flash Loans Work: Technical Mechanics
A flash loan follows a strict four-step sequence within one transaction:
1.
Borrow funds from a flash loan pool.
You call the flash loan function on a protocol like Aave, specifying the asset and amount. The protocol transfers the funds to your contract instantly with no credit check.
2.
Execute your operations.
Your contract uses the borrowed funds for arbitrage across DEXs, collateral swaps in lending protocols, self-liquidation to avoid penalties, or debt refinancing. This is where you extract value or manipulate state.
3.
Repay the loan plus fee.
Before the transaction ends, your contract must return the borrowed amount plus the protocol's fee (typically 0.05% to 0.09% on Aave V3 and V2 respectively).
4.
Transaction validates or reverts.
The blockchain checks the final state. If the repayment succeeded, the transaction commits and everyone gets paid. If your contract failed to repay, the entire transaction reverts. The loan never happened, the operations never executed, and you only lose gas fees.
This atomicity is what makes defi flash loans different from every other form of credit. The lender has zero default risk because the blockchain enforces repayment at the protocol level, not through legal contracts or collateral liquidation.
Flash loans are only possible because Ethereum and other smart contract platforms process transactions atomically. Either every operation in the transaction succeeds, or none of them do. There's no partial execution where you keep the borrowed funds but skip the repayment step.
Flash Loan Use Cases: Legitimate Applications
Flash loans enable financial operations that would be impossible or capital-inefficient through traditional borrowing. Here are the main legitimate applications:
Arbitrage across DEXs.
If ETH is trading at $3,000 on Uniswap and $3,020 on SushiSwap, you can flash loan 100 ETH, buy on the cheaper exchange, sell on the expensive one, repay the loan, and pocket the difference minus fees. No capital required. The entire arbitrage executes in one transaction or fails completely.
Collateral swaps.
Say you have ETH deposited as collateral on Aave and you want to switch to WBTC without closing your loan position. Flash loan enough ETH to repay your debt, withdraw your collateral, swap it for WBTC, deposit the WBTC as new collateral, borrow ETH again, repay the flash loan. Your collateral type changes without requiring you to have both assets simultaneously.
Self-liquidation.
When your loan position approaches liquidation, you normally pay a 5-13% penalty. Flash loans let you liquidate yourself. Borrow enough to repay your debt, withdraw your collateral, sell part of it to repay the flash loan, and keep the rest. You avoid the liquidation penalty and save more collateral.
Debt refinancing.
Move your loan from a high-interest protocol to a lower-interest one without needing capital to bridge the gap. Flash loan the debt amount, repay Protocol A, use your freed collateral to borrow from Protocol B at a better rate, repay the flash loan.
Flash loan arbitrage was the original use case and remains the most common. Bots monitor DEX prices across Ethereum, Arbitrum, Base, and Optimism, executing flash loan trades whenever price discrepancies exceed transaction costs. This activity contributes to market efficiency by narrowing spreads, even though the bots are purely profit-seeking.
Flash loan apps and developer tools have made these strategies more accessible. What once required custom Solidity code can now be executed through interfaces like Furucombo or DeFi Saver, though the most profitable arbitrage still requires technical expertise and fast execution.
Flash Loan Attacks: How They Work and Major Incidents
The same transaction atomicity that enables legitimate arbitrage also powers protocol exploits. Flash loan attacks manipulate on-chain state within a single transaction to drain funds from vulnerable DeFi protocols.
Attack mechanics:
Most flash loan hacks follow a pattern. The attacker borrows large amounts to manipulate an oracle price or exploit a contract vulnerability, extracts value through that distorted state, and repays the flash loan before the transaction ends. Because everything happens atomically, the attacker can test the exploit risk-free. If it fails, the transaction reverts and they only lose gas.
Euler Finance ($197 million, March 2023):
The largest flash loan attack targeted Euler Finance's lending protocol through a flaw in its donation function. The attacker took a 30 million DAI flash loan from Aave, deposited it into Euler, minted leveraged eTokens through recursive borrowing, then used the donation function to manipulate their health factor. This let them liquidate their own position at a massive discount, extracting $135.8 million in stETH, $33.8 million in USDC, $18.5 million in WBTC, and $8.7 million in DAI. The exploit took 15 minutes to execute.
What makes Euler unique is that the attacker voluntarily returned the funds three weeks later after on-chain negotiations. The vulnerability existed for eight months despite audits by Sherlock, which later paid a $4.5 million claim to Euler.
PancakeBunny ($200 million, May 2021):
Attacker flash loaned BNB, manipulated the BUNNY/BNB price oracle on PancakeSwap through massive trades, minted BUNNY tokens at the inflated price, and dumped them for profit. The flash loan hack crashed BUNNY's price by 96% within minutes.
bZx (February 2020):
One of the earliest flash loan attacks. Attacker borrowed 10,000 ETH via dYdX flash loan, used it to manipulate the price of wrapped BTC on Kyber and Uniswap, extracted $350,000 through arbitrage, and repaid the loan. This flash loan attack introduced the DeFi community to the risks of instant uncollateralized liquidity.
Chainalysis tracks that flash loan attack losses peaked in 2021-2022, then declined as protocols implemented better defenses. But new vulnerabilities still emerge. The flash loan code that enables these exploits is open source and well-documented, making it relatively easy for attackers to adapt existing patterns to new protocols.
Flash Loans and Jumper: DeFi Infrastructure Context
Flash loans interact directly with the liquidity infrastructure Jumper aggregates. When you use Jumper to swap or bridge assets, you're accessing the same DEX pools and bridge routes that flash loan arbitrageurs monitor and exploit for price inefficiencies.
routes swaps across 33 DEXs on 60+ chains, including Uniswap, Curve, Balancer, and SushiSwap. These are the exact venues where flash loan arbitrage happens. When a flash loan bot executes arbitrage between Uniswap and SushiSwap, it's using the same liquidity pools Jumper queries for optimal swap routes. The difference is timing and scale: Jumper optimizes for normal user swaps, while flash loan strategies execute millisecond trades with millions in borrowed capital.
aggregates 100+ yield pools from 15 DeFi protocols across 8 chains, including Aave, the largest flash loan provider. When you deposit USDC into Aave through Jumper, you're contributing to the same liquidity pool that flash loan borrowers tap. Your deposited assets become available for both regular loans and flash loans, earning you interest from both sources.
The bridge infrastructure Jumper aggregates also intersects with flash loan activity. Cross-chain arbitrage often involves flash loaning on one chain, bridging assets, executing trades on another chain, and bridging back before repayment. Jumper's 29 bridge integrations provide the same cross-chain routes these strategies rely on.
Understanding flash loans helps you understand how the DeFi ecosystem you access through Jumper actually works under the hood. The swaps, bridges, and yield opportunities Jumper surfaces are part of a larger liquidity network that flash loans both utilize and, occasionally, exploit.
Flash Loan Security: How Protocols Defend Against Attacks
DeFi protocols have developed multiple defense layers against flash loan attacks since the early exploit waves of 2020-2021.
Time-weighted average price (TWAP) oracles.
Instead of relying on the current price from a single DEX, protocols use TWAP oracles that average prices over minutes or hours. This makes single-transaction price manipulation through flash loans ineffective. Chainlink and Pyth provide TWAP data that many protocols now use as their primary price source.
Rate limiters and withdrawal delays.
Some protocols limit how much liquidity can be borrowed or withdrawn in a single block or transaction. If a flash loan tries to drain a pool beyond the limit, the transaction fails. This doesn't prevent flash loans but constrains their size and impact.
Multi-block MEV protection.
Protocols implement checks that span multiple blocks, making it impossible to execute an attack atomically. If a suspicious state change happens, the protocol can pause or require confirmation over several blocks before processing it.
Audit requirements and bug bounties.
After Euler, protocols increased audit frequency and bug bounty payouts. Immunefi and Code4rena run competitions where security researchers hunt for vulnerabilities before attackers find them. Aave maintains a $1 million+ bug bounty program.
Reentrancy guards.
Most flash loan hacks exploit reentrancy, where a contract calls back into itself before finishing execution. Reentrancy guards prevent this pattern at the code level. OpenZeppelin's ReentrancyGuard is now standard in audited contracts.
Flash loan premium (fees).
While 0.05-0.09% fees don't prevent attacks, they increase the capital efficiency threshold. The attacker needs to extract enough profit to cover both the flash loan fee and gas costs, which reduces the number of exploitable vulnerabilities that are economically viable.
No defense is perfect. New flash loan code patterns and protocol interactions create new attack surfaces. But the combination of TWAP oracles, rate limits, and rigorous audits has significantly reduced successful flash loan hacks since their peak in 2021.
FAQ
Protocols use TWAP oracles instead of spot prices, making single-transaction price manipulation ineffective. They implement rate limiters to cap how much can be borrowed or withdrawn in one block. Reentrancy guards prevent contracts from calling back into themselves mid-execution. Multi-block validation requires suspicious operations to span multiple transactions, breaking atomicity.
Rigorous audits and bug bounties catch vulnerabilities before attackers exploit them. Protocols like Aave maintain million-dollar bug bounty programs through platforms like Immunefi. After major flash loan hacks like Euler, the DeFi industry increased audit frequency and expanded the scope of security reviews to include flash loan attack scenarios specifically.
These defenses work cumulatively. No single protection is foolproof, but combining TWAP oracles, rate limits, reentrancy guards, and continuous auditing has reduced successful flash loan attacks significantly since their peak in 2021-2022.
Are flash loans illegal?
No. Flash loans are a neutral financial primitive. Using them for arbitrage, collateral optimization, or debt refinancing is legal and common. However, using flash loans to exploit protocol vulnerabilities or manipulate markets can be illegal depending on jurisdiction, similar to how a hammer is legal but using it to break into a house is not.
The Euler attacker faced potential legal consequences (though they returned the funds), and other flash loan hackers have been prosecuted when identifiable. The legality depends on what you do with the flash loan, not the flash loan itself.
Regulators have not specifically targeted flash loans as a mechanism. The focus is on the underlying actions, theft, fraud, and market manipulation, which are illegal regardless of the tool used.
How much does a flash loan cost?
Aave V3 charges 0.05% of the borrowed amount. Aave V2 charges 0.09%. dYdX typically charges no explicit fee but profits through spread and liquidations. So borrowing $1 million via Aave V3 flash loan costs $500, plus Ethereum gas fees.
Gas costs can exceed the flash loan fee itself. Complex operations involving multiple DEXs and protocols can cost $50-500 in gas during high network congestion. This is why flash loan arbitrage is only profitable above certain transaction sizes.
Some protocols offer flash loan fee waivers for approved contracts (managed through ACLManager on Aave), but this is rare and typically limited to protocol partners.
Can anyone take out a flash loan?
Yes, if you can write a smart contract. Flash loans have no credit checks, no collateral requirements, and no permissioning. You deploy a contract that calls the flash loan function, executes your operations, and repays the loan within the same transaction. Aave, dYdX, and other providers offer open flash loan interfaces that anyone can use.
Non-developers can access flash loans through platforms like Furucombo, DeFi Saver, and Instadapp, which provide interfaces for common operations like collateral swaps and debt refinancing. But profitable arbitrage still requires technical knowledge and often custom code.
What is flash loan arbitrage and is it profitable?
Flash loan arbitrage is borrowing assets, buying them on one exchange where they're cheaper, selling them on another where they're more expensive, repaying the loan, and keeping the difference. It's profitable when price discrepancies exceed transaction costs (flash loan fee plus gas).
Profitability depends on speed and information. Most flash loan arbitrage is executed by bots that monitor prices across dozens of DEXs and execute trades within milliseconds of spotting opportunities. Competition is intense. By the time a human notices a price gap, bots have usually already closed it.
Individual profitability is low for most users. Successful arbitrage requires capital for gas fees, technical expertise to write efficient contracts, and infrastructure to monitor prices in real-time. Dedicated MEV (maximal extractable value) firms and sophisticated DeFi traders earn the majority of flash loan arbitrage profits.
Mohammad MusharrafContent and Socials, Jumper Exchange
Subscribe to the JetSwap Newsletter to get the latest updates from JetSwap delivered to your inbox.
By signing up to our newsletter you are implicitly agreeing to JetSwap's terms of service and privacy policy. You can unsubscribe at any time from the link in the email footer.
Flash Loans: How They Work, Use Cases & Attack History | JetSwap Learn