What are flash loans?
Flash loans—also called instant loans—are a feature of several popular DeFi protocols that allow users to borrow cryptoassets without collateral, provided the debt is repaid within the same transaction block.
They became one of decentralised finance’s defining developments in 2020, bringing profits to some market participants and losses to others.
How and when did flash loans emerge?
At the start of decentralised lending, all crypto loans required borrowers to post excess collateral. That changed in January 2020, when the British lending company Aave launched a decentralised lending protocol based on liquidity pools. It opened a flash-loan function for third-party DeFi-application developers.
The basic requirement for a flash loan is simple: the borrowing and repayment transactions, as well as any intermediate operations with the funds, must occur within a single block. As a result, only a few seconds elapse between taking and repaying the loan. Flash loans can reach tens of millions of dollars, and the fee is just 0.09% of the amount (plus gas costs for interacting with smart contracts).
DeFi developers quickly appreciated the potential once Aave published documentation for the feature. Demand truly took off a few months later as the number of DeFi users surged and Ethereum fees climbed. Ordinary interactions with DeFi protocols became expensive, while strategies built on flash loans cut transaction costs and opened new avenues for profit.
By the end of 2020 Aave had processed $2bn of flash loans; by mid-2021 the total had reached $4.2bn. According to AaveWatch, the largest single flash loan was $195m.
In the first half of 2020 the feature also became available on the decentralised exchange dYdX. An analogue is the flash-swap function introduced by Uniswap in May 2021 with version v2 of its protocol.
Users could borrow without collateral more than 100 tokens for arbitrage (for example, between Uniswap and SushiSwap) and other strategies. The function is accessible only via smart contracts, as there is no user interface. The loan costs 0.3% (excluding gas and Uniswap fees).
When should flash loans be used?
Cheap, unsecured borrowing opened myriad opportunities for DeFi users—both to exploit market inefficiencies and to cut the costs of lending and other operations. The most common scenarios are below.
Arbitrage trading
Profiting from price differences for the same asset across venues typically requires large amounts of capital. Flash loans provide cheap financing for such trades along the following lines:
- take out a flash loan for the asset from a DeFi protocol;
- use the borrowed funds to buy the asset on the DEX where it is cheaper;
- sell the asset on the DEX where it is more expensive;
- repay the flash loan with fees and interest.
Arbitrage trading is the most popular use case for flash loans.
Self-liquidation of debt positions
When collateral value falls below a borrower’s debt, lending protocols trigger automatic liquidation. Part of the collateral is sold to repay the debt, and a liquidation penalty is charged—on Aave 5% or 10% (depending on the collateral type) and 13% for MakerDAO Vaults.
Flash loans make it possible to perform a far cheaper self-liquidation without penalties, as follows:
- take a flash loan for the relevant asset;
- repay the debt with the borrowed funds, thus freeing the collateral deposit;
- use part of the collateral deposit to repay the flash loan with the relevant fees and interest.
Quick collateral replacement
Collateral may need to be swapped when its price falls and liquidation risk rises. In such cases it is sensible to replace a depreciating asset with a rising or less volatile cryptoasset.
A conventional replacement requires fully repaying the debt and opening a new position, which raises transaction costs and demands the full debt amount. Flash loans allow this to be done faster and cheaper by bundling all transactions in a single block.
Rapid refinancing
Lending rates across DeFi platforms constantly change with market conditions and available liquidity. Flash loans have become a handy tool for cheaply moving debt to platforms with lower rates, including swapping collateral to another asset.
How to use flash loans?
Initially the feature was open only to developers. There was no public user interface, and access was possible only via smart contracts. In 2020, however, third-party services appeared that exposed flash loans to users without Solidity skills.
This simple service currently works only with MakerDAO and performs two tasks:
- fast collateral swaps without repaying the outstanding debt (for example, swapping ETH for USDC);
- self-liquidation of a debt position without penalties.
In both cases CollateralSwap charges a 0.29% fee.
This DeFi application works with MakerDAO, Aave, Compound, dYdX and Reflexer, enabling flexible management of assets and loans. With its Recipe Creator option, users can build custom strategies using Aave and dYdX flash loans.
This application uses visual programming to make it easy to create DeFi strategies, called “combos”. Each transaction in a combo is shown as a cube. Users can set cube parameters and their order; the service then bundles all cubes into a single transaction and submits it. Aave flash loans underpin many of the template combos available in the app.
Are flash loans available in alternative ecosystems?
As EVM-compatible blockchains (Binance Smart Chain, Solana, Avalanche, Polygon, Fantom) gained popularity in the first half of 2021, flash loans also became available to users of these networks.
In April 2021 Aave was deployed on Polygon. From then on, users could take instant unsecured loans just as on Ethereum, with the same 0.09% fee—albeit with the difference that transactions on Polygon cost thousandths of a cent.
Also in April 2021, C.R.E.A.M. Finance introduced its version of flash loans on Binance Smart Chain. The feature later arrived on Polygon and Fantom. C.R.E.A.M.’s fee is just 0.03%.
Among other platforms offering flash loans on Polygon is UniLend Finance, which enables unsecured borrowing of the MATIC token with a 0.05% fee.
On Solana, the lending platform Solaris Protocol plans to offer flash loans. As of summer 2021 the app was still in alpha.
Flash loans are also in development at the Benqi Finance lending protocol, which is close to launching on Avalanche.
How risky are flash loans?
The advantages of flash loans have been exploited not only by developers and traders but also by attackers. In February 2020 two flash-loan-enabled attacks on DeFi protocols caused combined losses of $1m. They exploited a vulnerability in bZx that allowed price manipulation and artificial inflation to extract profit. Flash loans themselves had no vulnerabilities but provided very cheap financing for the attacks.
Throughout 2020 flash-loan-based attacks became one of the most frequently used ways to steal funds from DeFi protocols. Most exploited weak price oracles and the ability to manipulate asset prices.
In spring 2021 flash loans became available across several EVM-compatible networks—triggering a wave of attacks on DeFi protocols, above all on Binance Smart Chain (BSC).
In May 2021 alone, decentralised services on BSC lost a total of $167m to attacks. The biggest hits were on Belt Finance (a $50m loss) and Pancake Bunny (which lost $45m). Other victims included BurgeSwap, ApeRocket, bEarnFi and a number of other BSC-based DeFi projects.
