Menu
Close

What Are Flash Loans? Leveraging DeFi In New Ways

BlockchainNov 17, 2022
What are flash loans

If you have ever taken a loan from your local bank, then you must be familiar with the tediousness of the process. You have to render a bunch of documents, proof that you have the means to pay back, and fill out extensive forms. Let's not forget the dreadful wait for the approval. In some cases, you might be asked to drop a valuable item as assurance that you'll return the money.

Blockchain technology and DeFi platforms have introduced this new thing called flash loans that allows borrowers to take loans in an instant without having to endure the hassles and tardiness of traditional banks.

In this article, we'll be taking a deep dive into the concept of flash loans: what they are, how they work, and where you can get them.

What Are Flash Loans in DeFi?

A Flash loan is a collateral-free loan automatically issued by DeFi protocols using smart contracts. Applicants receive flash loans in an instant (hence the word 'flash'), making them highly appealing to quick-loan seekers.

But get this, the borrower has a very small time window to return all the funds—something between seconds to a couple of minutes

Flash loans and traditional loans have the same core concept. Whenever a lender offers a borrower money, they expect the borrower to eventually return the cash in full at some point in the future. Before the lender releases the funds, both parties agree on the terms of the loan like the maturity date and interest rate.

However, there's a marked difference between the two in terms of the methods used to issue them. Unlike bank loans which operate in a centralized system, a flash loan is purely decentralized, and that's what makes them so attractive.

With regular loans, the bank micromanages the issuance of loans using human personnel, who thoroughly review new applications before releasing loans to customers deemed fit. Even if the borrower has all the qualifications, they still have to wait for quite a while before the banks approves

On the other hand, a flash loan is issued by DeFi protocols which are basically software designed with computer code that can automate contracts. There's no staff reviewing every single loan request.

All DeFi platforms do is provide infrastructure for the lender and borrower to meet and make secure transactions. In short, they mostly serve as intermediaries between the two parties.

This model breaks a lot of barriers borrowers face in the process of securing loans.

Benefits of Using Flash Loans

Flash loans are patronized by millions of crypto users due to their several benefits.

Instantaneous Transactions

People who can't stand the delay and bureaucracy involved with securing bank loans embrace flash loans without a moment's thought. Besides the dreadful requirements to qualify for regular loans, applicants still have to wait long periods for approval.

The automation of smart contracts enables funds to change hands quickly in flash loans. Borrowers receive loans immediately and the flash loan lender also gets their money back in a matter of minutes.

Since the borrower only has the grace of a few minutes, they have to act quickly to put the borrowed funds to good use within those brief moments. Traders often take a flash loan to leverage positions and get in and out of trades quickly using smart contracts.

Smart Contracts

Smart contracts are codes that do not complete blockchain transactions unless the people involved fulfill certain conditions. They make all sorts of financial applications of blockchain technology possible, including DeFi platforms and flash loans.

In flash loans, they are skillfully employed to ensure that lenders always get their funds back in full. A flash loan transaction is only complete after the borrower returns the funds. If not, the smart contract reverts the funds to the lender like it never happened.

In doing so, flash loans offer uncollateralized debts with the safety of secure loans in the same breath.

Unsecured Loan

An unsecured loan is a debt taken without collateral and flash loans fall under the category. Although unsecured loans signal risk to lenders in traditional markets, they have become the golden goose of loan-taking in the crypto world.

Lenders usually prefer to give secure loans (debts with collateral) so they have something to hold on to in case the borrower ghosts.

With flash loans, the lender doesn't have to worry about a vanishing debtor because smart contracts automatically return their funds immediately after the duration for the loan expires.

Now that you know why flash loans are amazing, let's have a stab at what goes on under the hood in a complete flash loan transaction.

How Do Flash Loans Work?

Smart contracts are central to flash loan transactions. Without them, flash loans won't have speed, reactivity, and precision. They are responsible for:

  • Moving funds between the two main transacting entities (the lender and the borrower) and interacting with the flash loan provider

  • Helping the borrower use the loan to make quick moves on exchanges to yield profits

  • Returning assets to the lender if the borrower refuses to repay or something goes wrong

A borrower needs smart contracts capable of executing three vital functions to interact with the lending platform. Here's a high-level explanation of each function:

The first function collects the loan from the flash loan provider. Some of the most popular lending platforms are Aave, UniSwap, and dYdX.

The second fires transactions on a crypto exchange based on logic provided by the borrower. If that results in a profit, one more function returns the borrowed amount plus interests to the lender.

Workflow

From the perspective of a user trying to get a flash loans from Aave lending protocol, here's how it's going to unfold play-by-play:

  • The borrower takes a flash loan out of Aave
  • Configures a smart contract to place potentially profitable orders on a crypto exchange platform
  • Takes profits from the trade
  • Pays back the loaned capital plus transaction charges and keeps the profit margin. As of writing, Aave taxes borrowers 0.09%

Say something goes wrong like the trade ends up in a loss or the borrower just doesn't return the funds, the lending platform detects any inconsistencies and reverses the transaction.

A timed smart contract developed by the flash loan providers does a balance check on all transacting entities. If they find that the borrower returned less than the due principal plus agreed interests, the smart contract reverses the entire transaction. In effect, the lender's balance returns to its original state before the flash loan was initiated.

From the above demonstration, It's easy to confer that flash loans are trustless, low-risk instruments with benefits for both borrowers and lenders. It is a financial tool that offers traders better leverage and rewards lenders for providing market Liquidity.

Where Can You Use Flash Loans? Years after inventing flash loans in 2020, Aave remains the most sought-after lending platform for securing flash loans. Other competing platforms in the DeFi space are UniSwap, dYdX, and Decentralized Exchange (DEX).

Let's talk about the inventors of the flash loan product: text

Aave

By creating such an ingenious loan system, Aave quickly stood out from the crowd of DeFi protocols as a major innovator in the blockchain industry.

Aave is a purely decentralized, open-source lending platform that enables users to earn by lending digital assets to borrowers at an interest rate. Aave is friendly with several decentralized finance (DeFi) protocols and offers easy access to a wide variety of cryptocurrencies.

The Aave protocol filled a big gap in the DeFi space by introducing the first uncollateralized loan instrument.

Before then, decentralized finance relied on secure or collateralized loans in the absence of any alternatives. There weren't any generally accepted means to certify integrity like credit scores, credit history, and credit checks. Unfortunately, collateralized DeFi Loans are not convenient for borrowers.

Firstly, they are actually over-collateralized. That means the borrower has to deposit something of more value before they can take out a loan. For example, to borrow $100 worth of DAI, a user may be asked to render a $150 equivalent of ETH as collateral.

And that leads to another big problem…

Due to their high volatility, digital assets make terrible collateral. Let's say the market crashed and ETH lost a lot of value, the loan provider instantaneously sells a big portion of the borrower's ETH to service the debt.

Why Use a Flash Loan?

As staple decentralized financial tools, these are the most common use cases of flash loans:

Arbitrage Opportunities

Price arbitrage is a slight difference in the price of an asset in two different exchanges. Price slippage in exchanges with low liquidity is the major cause of inconsistencies across the market.

Slippage occurs when a trading platform doesn't have enough liquidity to meet a sell order. In effect, the value of that particular asset gets reduced to lower prices to make it more affordable. People that spot these discrepancies and exploit them are called arbitrageurs.

Since exchanges with high market volume will be quoting the standard price, arbitrageurs can turn a profit by selling assets bought from other exchanges at cheaper rates there. With Flash loans, these opportunists can acquire more capital to amplify their profit margin.

You can play arbitrageur by leveraging flash loans to make a quick buck.

Collateral Swaps

Collateral swaps sound exactly like what they mean. It is the act of replacing existing collateral on a lending platform with another asset.

To illustrate, let's say you loaned some stablecoins from a DeFi protocol and deposited ETH as collateral. Then you later decided to change the crypto to your collateral to say MATIC. Here's how you would go about it:

  1. Return the money you borrowed and redeem your collateral (ETH)
  2. Trade ETH for MATIC
  3. Go back and borrow stablecoins from the platform again but this time using MATIC as collateral

That's a collateral swap! But I know you're probably wondering where the use of flat loans comes in here.

Well, imagine if you had your stablecoins locked in some DeFi protocol yielding periodic interests. It would kill you to forfeit your earnings because you have to swap your collateral.

By taking a flash loan, you can settle your debt and swap the collateral without having to touch your locked stablecoins at all.

Reduced Transaction Fee

Even though flash loans incorporate multiple on-chain activities, they are treated as the same transaction on Ethereum. Subsequently, the charges are added to the loan amount, further lowering the service fees. That way, the borrower saves some coins on gas fees.

Debt Refinancing

Debt refinancing is quite similar to collateral swaps. But instead of switching collateral on a DeFi protocol, the user transfers their loan balance from one platform to another with more affordable interest rates.

Are Flash Loans Safe?

Several DeFi platforms have suffered losses worth millions of dollars as a result of flash loan hacks. Cyber attackers occasionally manage to find loopholes in smart contracts and exploit them to drain jaw-dropping amounts of digital assets from compromised platforms.

Until decentralized apps get to the point where their codes are foolproof, we cannot rule out the possibility of more cyber attacks in the future.

Decentralized applications will have to double down on security measures to cover potential vulnerabilities. Some good steps in that direction include allocating more budget to the security research team and sponsoring generous bug bounty programs.

What Are Flash Loan Attacks?

As mentioned in the preceding section, decentralized apps have chinks that malicious actors exploit to illicitly withdraw assets in bulk. Additionally, the face-paced nature of transactions in flash loans favors the antiques of these fraudsters. Usually, attackers simultaneously raid several smart contracts at the same time.

Fake arbitrage opportunities are the most rampant flash loan attacks in DeFi. Malicious actors choose this form of attack because it is easy to pull off and doesn't require any in-depth technical knowledge.

Attackers manipulate the price of assets on crypto exchanges by taking hefty trades funded with flash loans. This causes slippage and artificially creates arbitrage opportunities in the market.

Editorial Note:

This text is informative in nature and should not be considered an investment recommendation. It does not express the personal opinion of the author or Sensorium. Any investment or trading is risky, and past returns are not a guarantee of future returns. Risk only assets that you are willing to lose.

Matias Lapuschin
Matias Lapuschin
Head of Content Marketing

Stay up to date

*By subscribing to our newsletter, you agree to receive marketing emails from Sensorium.