ComScore
nft

An Introduction to Flash Loans

MOBILE 12 2
Michael Caloca / ONNE37pm

Imagine being able to take out a loan instantly, the only catch being that you have to pay it back immediately. That’s the exact concept of a flash loan. In order to make sense out of this particular scenario, we first need to understand exactly what a flash loan is.

What is a flash loan?

A flash loan allows you to take out an unguaranteed loan with the obligation to repay the loan in the same transaction. If it’s determined that you can’t repay the loan, the loan is reversed as if it never occurred. Flash loans are popular across several decentralized finance (DeFi) protocols established on the Ethereum blockchain.

How do flash loans work?

When it comes to the properties of a flash loan, it can be somewhat complicated to wrap your mind around. After performing some in-depth research, here’s what I uncovered about flash loans and how they work.

Flash loans use smart contracts to carry out the loan process. The smart contract does not exchange funds unless the specific criteria that are written into the contract have been met.

In the case of a flash loan, the criteria is that the borrower is obligated to pay back the loan before the transaction ends. If it’s determined the borrower can’t repay the loan, the transaction is reversed instantly.

With a traditional loan, such as the one used to purchase a house, the lender requires that the borrower offers collateral, the collateral being the house. In addition to the collateral, the borrower is generally required to pay off the loan over a long period of time, with interest on top of the original loan amount. 

Now, with flash loans the lending process is instantaneous. Thanks to the terms written in the smart contract, the loan must be repaid in the same transaction in which it’s lent out.

When a flash loan is initiated, it only takes a few seconds to perform the trade called on by the borrower with the loaned capital before the transaction ends, resulting in an ultra-quick loan.

Why use a flash loan?

A flash loan is commonly used by traders who are looking to quickly profit from arbitrage opportunities. As well, it’s a way to potentially make huge profits without the need to risk your own money.

Here are some common uses for flash loans:

  1. Arbitrage is the process of simultaneously buying and selling assets from different exchanges. Essentially, you can make money by searching for price discrepancies across numerous exchanges.

    For example, let's say I buy some theoretical alexcoin from two different exchanges. On exchange A, alexcoin is priced at $1 and on exchange B, it’s price at $2. As a borrower, you can call on the smart contract to purchase 100 alexcoin for $100 from exchange A, then turn around and sell your 100 alexcoin to exchange B for $200, pocketing the difference and paying back the lender all in one swoop.
  2. Saving on transaction fees are a potential use case when it comes to flash loans considering they combine what would usually take several transactions, into a single transaction.
  3. Currency swaps allow users to swap their borrowed currency for another type of currency.

As this technology advances, I believe the use-cases for flash loans will evolve as well.

Are flash loans safe?

Flash loans are somewhat safe, however, they do come with a risk. Flash loans have been attacked before, resulting in millions of dollars in losses. Here are some ways in which flash loans have been compromised:

  • Data entering the smart contract has been corrupted or exploited
  • Smart contracts have been manipulated if they are not written correctly

A flash loan attack can happen when the borrower manipulates the markets at the same time the loan is being initiated, decreasing the value of the loan, which allows the borrower to pay back the loan at a deflated price, while still being able to sell the tokens on other markets for the actual price and keep the profit.

Keep in mind, as a borrower, you aren’t subject to liability for the loan itself, however, you do have to pay a single gas fee to initiate a flash loan. If the transaction were to fail, you would lose the gas fee.

How to avoid flash loan attacks

One way to help lessen the possibility of a flash loan attack is by using a decentralized pricing oracle such as Chainlink (decentralized blockchain oracle network) to fetch price feeds, opposed to relying on a DeX platform (decentralized exchange) which is more vulnerable to attacks.

How to get a flash loan

Flash loans are still rather new. Without the knowledge of coding smart contracts, it can be rather difficult to get a flash loan.

One of the most popular platforms for getting your own flash loan is Aave. Aave is an open-source and non-custodial liquidity protocol for earning interest on deposits and borrowing various assets. Users can choose to be a depositor or borrower.

Depositors put liquidity into the market to earn passive income, while the borrowers can take advantage of borrowing in an over-collateralized or under collateralized manner.

To start using the Aave protocol, you must deposit your preferred asset and amount. After depositing, you will earn passive income based on the borrowing demand of the market. Furthermore, depositing assets enables you to borrow using your assets as collateral. 

Overall, flash loans have several advantages compared to traditional loans. That being said, flash loans are also extremely risky at this point in time due to the lack of user interface and the unknown risks involved.

We can only assume that as time goes on, the technology and user-friendliness will develop into something simple and secure.

Did you like this article?
Thumbs Up
Liked
Thumbs Down
Disliked