What are flash loans in DeFi?

How did flash loans originate?

Unlike regular loans, flash loans do not require the borrower to provide typical requirements, such as proof of income, reserves or collateral.

While it may seem favorable to the borrower, there are pros and cons. Decentralized Finance Protocols (DeFi) have contributed to the popularity of flash loans. And most of them are on the Ethereum network.

Aave, an Ethereum lending platform, introduced the idea of ​​flash loans in 2020. As such, the concept is still relatively new and still has many problems to solve. According to Aave, flash loans "have no real-world analogies" and are "an advanced concept aimed at developers."

In this article, we will discuss the basics of so-called DeFi flash loans, as well as the security issues and use cases typically associated with them. Let's dive in.

What are flash loans?

Like traditional loans, flash loans are expected to be repaid in full over time. However, there are also marked differences.

In typical lending processes, a borrower lends money from a lender. The amount should be paid in full at the end, with interest, depending on the terms discussed between the lender and the borrower.

Flash loans operate in a similar framework but have some unique terms and conditions:

Use of smart contracts

A smart contract is a tool used on most blockchains to ensure funds don't change hands until a specific set of rules are met. When it comes to flash loans, the borrower has to pay off the full loan amount before completing the transaction.

If this rule is not followed, the smart contract cancels the transaction and the loan is forfeited as if it never happened.

Unsecured loan

Unlike a traditional loan, a flash loan is an unsecured loan, which means no collateral is required.

However, this does not imply that the flash loan lender will not get their money back in the event of a default. In a traditional loan, a guarantee is usually provided to ensure that the lender receives the money in the event of a default. 

However, flash loans happen in a very short period of time (usually a few seconds or minutes). This means that although the guarantee is not required, the borrower must repay the entire borrowed amount immediately.

Instantaneous transactions

Unlike the longer processes of traditional loans, flash loans are processed faster thanks to smart contracts.

Getting approved for a traditional loan is often a lengthy process. A borrower must file documents, await approval and repay the loan in agreed increments within a set period which can be days, months or years.

On the other hand, a flash loan is accelerated in an instant, which means that the loan smart contract must be fulfilled during the loan transaction. Therefore, the borrower has to resort to other smart contracts, using the borrowed capital to make instant transactions.

 The trick: this all has to be done a few seconds before the transaction ends. Hence the name: flash loans.

How do flash loans work?

Simply put, in a quick loan, the funds are borrowed and returned in seconds and in a single transaction.

The smart contract sets the terms and executes instant transactions on behalf of the borrower using the borrowed capital. If the flash loan makes a profit, you are usually charged a 0.09% fee.

On a platform like Aave, flash loans usually work like this:

  1. The borrower applies for a flash loan on Aave.
  2. The borrower creates a logic of operations to try to make a profit, such as sales, DEX purchases, operations, etc.
  3. The borrower repays the loan, earns a profit and pays a 0.09% commission.
  4. If any of the following is true, the transaction is canceled and the funds returned to the lender:
  • The borrower does not repay the principal.
  • Trading does not lead to a profit

The above conditions suggest that the provisions of the smart contract have not been met. As such, the funds are returned to the lender immediately. In theory, flash loans are a low-risk option for both the borrower and the lender. Flash loans are generally seen as an easy, low-risk way to play with cash.

Can You Make Money With Flash Loans? Aave recommends having a good understanding of Ethereum, programming, and smart contracts to get the most out of flash loans. Ideally, you can make money with flash loans as long as you don't fall victim to flash loan attacks. It would be helpful if you had thoroughly researched the protocols you want to borrow from and also want to trade with.

Uses of flash loans

Flash loans are used in DEFI protocols, which are based on the Ethereum network and Binance Smart chain. 

A part from Aave Flash loans, DYDX flash loans, Dex Flash Loans and Uniswap Flash Loans have also increased popularity. In Uniswap, for example, "Flash Swaps" allows users to withdraw or recover Ethereum-based tokens paired with other tokens. 

While they may have originally been designed for developers, as of August 2020, Flash loans without coding are easily accessible to less technology expert users. The credit for this goes to the platforms such as Furucombro and Defi Saver, among others, who eliminated the need for technical coding skills. 

Flash loans can be used for the following:

Flash loan arbitrage

Flash loan arbitration A way that traders make money. 

For example, if two markets price in a cryptocurrencia differently, a merchant can use a flash loan. The merchant can call separate intelligent contracts to buy and sell from both markets, which benefits from the price discrepancy between the two. 

Collateral swaps

This involves a quick swap of the collateral in support of a user's loan for another type of collateral.

Collateral swaps allow DeFi users to exchange collateral they used to get a quick loan on a loan app. For example, if a trader used his Ethereum (ETH) as collateral on a platform, he can get a quick loan to pay off the previous loan and withdraw his Ethereum (ETH).

Debt refinancing

In addition to collateral swaps, flash loans can also be used for "interest rate swaps".

Aave cites an example on his blog:

  1. Borrow assets from Aave liquidity
  2. Payback debt on Compound
  3. Withdraw collateral from Compound
  4. Deposit collateral on Dydx
  5. Mint debt on Dydx
  6. Return liquidity to Aave

What are flash loan attacks?

Flash loans are a relatively new technology and therefore are prone to attacks by hackers and malicious users who try to trick the system and use it to their advantage.

In a flash loan attack, a borrower can trick the lender into thinking that the loan has been fully repaid, even if it has not been.

Technically, the thief poses as a borrower and takes a quick loan from a loan protocol. The protocol is then used to manipulate the market and deceive lenders. In some cases, attackers create arbitrage opportunities to exploit vulnerable smart contracts. In this way, attackers can buy tokens inexpensively or sell them at higher prices for drawn contracts.

Community Sentiments

Live Comments