What are flash loans? DeFi Loans

Qué es Flash Loans? Préstamos DeFi
6 min read

While in the traditional financial world transactions are governed by contracts enforced by law, in the blockchain world “the code is the law“. 

 

This is a major paradigm shift from a centralized model (with trust in third parties) to a decentralized one (the code is self-executing). By using a blockchain with the flexibility of smart contracts that Ethereum has, we will be able to find interesting financial uses.

 

One of those concepts that used to be impossible to conceive is that of “flash loans“. In this type of loan there is no collateral (funds that you leave as a guarantee), nor is it necessary, because it is repaid in the same transaction. How can this be possible, a loan that lasts one second? 

Typical types of loans

First of all, let’s take a look at how loans work, starting by differentiating between 2 types of loans.

Loans without collateral

One type of loan is unsecured or uncollateralized. A person borrows money and the lender will accept, or not, depending on your trust in him and his credit history. For example, if this person has repaid all his previous loans on time, he will have a higher reputation and the possibility of receiving more loans. As with any loan, interest is added to the amount to be repaid.

 

But these loans are usually limited to small amounts and can be risky.

Qué es Flash Loans? Préstamos DeFi

Loans with guarantee

In secured lending, the borrower leaves a property or asset (or several assets) as collateral or security to back his creditworthiness. In case he fails to repay the loan, the lender keeps the collateral. The collateral can be a house, gold, or even Bitcoin.

Flash Loans

Now we enter the world of DeFi (Decentralized Finance). In Ethereum and smart contract blockchains you can make smart contract calls, and even link their executions, in a single transaction.

 

Flash loans are quick loans that do not require collateral or a credit check to be granted.

You may wonder how this is possible, and why would a lender give us cryptocurrencies with the risk that they will not be repaid?

The answer is simple: flash loans are repaid in the same transaction (and this is a necessary condition).

What does this mean? That a flash loan can be programmed as a single transaction that happens in 3 stages. 

1) You receive the loan.

2) You do something with the loan.

3) You repay the loan.

All in the same transaction and in a fast way.


If you don’t pay back the loan in the agreed time, the network will reject the transaction, and the lender will get its funds back. In fact, as far as the blockchain is concerned, the funds will never leave the lender’s control.

Because of this, they have very little risk from the point of view of the lender and the borrower (the borrower). The pioneer platform in these loans is Aave.


But how can I make quick profits that will allow me to pay back the money I borrowed in the flash loan? A common use is to exploit arbitrage opportunities. 


Example of the use of a Flash Loan 


Imagine that a token is trading on a decentralized exchange “X” at $1 and on another one called “Y” at $0.98. You can take advantage of this situation by asking for a flash loan to finance a purchase of, say, $1 million worth of tokens on exchange Y to sell on X. All this can happen in the same transaction and generate a large profit with little risk (because the money is borrowed). In this case you would generate a profit of $20,400 thanks to the large amount of money you borrowed, and you would have enough to pay interest and gas costs.

16,000 dollars in 13 seconds: a very profitable flash loan

In order for you to understand even better how a flash loan works, I will tell you a real case of a person who earned 16,182 USDC (stablecoin that tracks the value of the dollar).

It happened in August 2020 and the procedure performed was:

    • He borrowed USDC 2,048,000 using a flash loan.
    • He exchanged these USDC for 2,028,367 DAI in Curve and Pool.
    • He exchanged the DAI for USDC 2,064,182 in Curve’s sUSD group.
    • He paid the 2,048,000 of the flash loan and obtained the rest as profit.
Qué es Flash Loans? Préstamos DeFi

Attacks

The fact that the risk is so low in these loans opens up the possibility of sophisticated attacks with little risk and very profitable. Flash loans allow an attacker to finance attacks without risking his own money.

 

In fact this type of attack became popular in 2020 following the hack of bZx, a decentralized lending platform.

DeFi is experimental

These kinds of events remind us that, like cryptocurrencies, DeFi is an experimental technology. And while there are ways to combat flash loan attacks, such as using decentralized oracles in existing protocols, we don’t know if it will be completely solvable in the long run.

Even so, we can say that flash loans and their attacks are here to stay, and in the future we will be able to witness innovative ways of using these loans, impossible in a traditional financial system.