Flash Loans in Defi: Everything to Know
By Beluga Research June 17, 2023
- A flash loan is an unsecured loan that allows a user to borrow large amounts of cryptocurrency for a short period of time
- Flash loans do not require that a user put up assets as collateral
- By being decentralized, transparent and accessible a flash loan is available to anyone with an internet connection
- Flash loans are made possible by smart contracts, which are special blockchain-based software that don't require a third party to run
A flash loan is a type of decentralized loan that allows users to borrow funds from a DeFi protocol without any collateral and allows users to borrow high amounts of cryptocurrency for limited periods of time. Like a wide range of financial products offered on DeFi platforms, flash loans are built on top of blockchain technology and executed via smart contracts. Like other DeFi products, flash loans are designed to be decentralized, transparent and accessible to parties with internet connections.
The unique feature of flash loans is that if the borrowed amount is not repaid within the same transaction, the entire transaction will be reversed, eliminating the debt.
Flash loans are frequently deployed for arbitrage between different exchanges or markets. By using flash loans, a user can quickly capitalize on profitable trading opportunities without using their own funds. They also support liquidity provision in that users can temporarily borrow funds to provide liquidity to a decentralized exchange or liquidity pool, earning fees and rewards during the loan's duration. Further, flash loans enable quick and cost-efficient token swaps, allowing users to trade between assets without the need for upfront capital. Lastly, traders can execute complex DeFi strategies involving multiple steps in a single transaction, optimizing their returns without tying up their own capital.
A key example of a common use of flash loans is in order to unwind leverage on DeFi lending books - by using a flash loan you can increase your collateral to then withdraw your entire position. This gives protection against inadvertently liquidating yourself. Like when users were in the process of closing FTX positions on Aave, liquidators did not use flash loans and got their own positions liquidated.
In essence, flash loans offer a powerful tool for users to access significant amounts of liquidity instantly, unleashing a wide range of financial possibilities in the decentralized finance ecosystem.
A Brief History
Flash loans are a relatively new development in the cryptocurrency industry. They are closely tied to the rise of decentralized finance or DeFi, which started to gain traction in 2020. The concept quickly became one of the most exciting areas of the cryptocurrency industry. The ecosystem has grown rapidly as developers have built more DeFi products.
One of the first flash loan platforms to emerge was Aave. This decentralized lending platform launched its flash loan product in January 2020. Aave allows users to borrow and lend cryptocurrency without the need for intermediaries. Its flash loan product was an instant hit. Aave's flash loans quickly became one of the most popular DeFi products on the market.
Since then, a number of other flash loan platforms have emerged. These include Compound, dYdX, and Uniswap. Each of these platforms offers slightly different features and benefits. They all allow users to borrow large amounts of cryptocurrency without collateral.
What are Flash Loans?
Flash loans are a type of unsecured loan that allow users to borrow large amounts of cryptocurrency for a short period of time. The users do not need to put up collateral. Flash loans are made possible by smart contracts, which are self-executing contract software that run on the blockchain.
When a user takes out a flash loan, the smart contract automatically checks to see if the user has enough collateral to cover the loan. If the user does not have enough collateral, the loan is automatically canceled. If the user has adequate collateral, the loan is executed. The funds are then transferred to the user's wallet.
Flash loans are commonly used for arbitrage opportunities. These are situations in which a user can profit from price discrepancies between different cryptocurrency exchanges. For example, say a user sees that the price of bitcoin is higher on one exchange than on another. They can use a flash loan to buy bitcoin on the cheaper exchange. They can then sell bitcoin on the more expensive exchange and keep the difference.
- Use a flash loan to make money. A user can trade on an exchange with borrowed cryptocurrency. They can also use the borrowed cryptocurrency to provide liquidity to a DeFi protocol.
- Repay the flash loan to remain in good standing. After the user has made a profit with the flash loan, they can repay the flash loan to keep in good standing.
- Obtain financial services without the need for banks. To take out a flash loan, a user sends a transaction to a smart contract that handles the loan. The user specifies the amount of cryptocurrency they want to borrow and the conditions of the loan, like the interest rate and the time limit for repayment.
- No need to put up assets with a financial institution. The user must have enough assets to repay the loan. The smart contract verifies this by checking to see if the user can repay the loan within the same transaction block as the receipt of transaction. If the user cannot repay the loan, the smart contract automatically reverses the entire transaction. If the user is able to repay the loan, the smart contract releases the funds to the user's wallet.
- No requirement to put up collateral. In traditional lending, borrowers must put up some form of collateral, like a house or car. The lender demands assurance that the institution will be able to recover its money if the borrower defaults. With flash loans, the user does not put up any collateral. This means borrowers can access large amounts of cryptocurrency without having to put up any assets.
- Execution within a single transaction block. Borrowers have to be able to repay the loan within a few seconds or the smart contract will reverse the entire transaction. This can be both a benefit and a drawback. This rule allows borrowers to access funds quickly and easily. Yet it also means borrowers have to be very careful and precise when using flash loans. Any mistake could result in the loss of the borrowed funds.
- Enable innovative new use cases for cryptocurrency. Some traders use flash loans to arbitrage price differences between different exchanges. They borrow cryptocurrency on one exchange, sell it on another exchange where the price is higher, and repay the loan within the same transaction block. This allows them to make a profit without having to put up any collateral.
- Speed. Flash loans are executed almost instantly. This allows users to access funds quickly and efficiently. Speed is especially useful for traders who need to make quick decisions based on market conditions.
- No collateral required. Unlike traditional loans, flash loans do not require users to put up any collateral. This means that users can borrow large amounts of money without having to post up any assets.
- Low fees. Flash loans typically have lower fees than traditional loans. There are no intermediaries involved in the process. This means users can save money on interest and other fees.
- Programmable. Flash loans are programmable, which means that developers can create custom applications that make use of the loans. This allows for a wide range of use cases, from arbitrage trading to liquidity provision.
- High risk. Flash loans are high-risk loans. They are not backed by collateral. Further, they must be repaid within a single transaction block. If the borrower is unable to repay the loan, they may lose all of the funds they borrowed and the fees paid for the transaction.
- Limited use cases. Flash loans are not suitable for all use cases. They are primarily used for short-term trading and arbitrage. They are less useful for longer-term investments and financing.
- Complex. Flash loans are a relatively complicated concept. They may be difficult for novice users to understand. This can lead to mistakes and losses for users who are not careful.
- Vulnerable to attacks. A "flash loan attack"occurs when a malicious actor takes out a large flash loan. The actor then uses the money to manipulate the price of a particular asset. This can cause significant losses for other users trading that asset.
- Used in high-profile hacks. In March 2021, the DeFi protocol bZx was hacked for the second time in a year. The attacker used a flash loan to borrow a large amount of cryptocurrency. They then used the money to manipulate the price of a token on the bZx platform. The attack resulted in a loss of $8 million for bZx.