What Are Flash Loans In Defi?

Ever heard of Flash loans? What are flash loans in DeFi?

There’s so much going on in the cryptocurrency space about having a look-alike of the legacy financial system, but on the blockchain.

Skeptics may want to disagree with the idea.

The whole purpose of DeFi (Decentralized Finance) is to make transactions permissionless, decentralized, and transparent financial ecosystem built on the blockchain networks.

Bitcoin is used as a means of payment all over the world

This shows that Cryptocurrency has proved that it is possible to do it with money.

The DeFi technologies is not left out in this evolution.

In today’s economy, you can decide to take out crypto-backed loans, trustlessly exchange digital assets, and store wealth in coins/tokens that are worth the same as the price of fiat currencies.

Let’s explore further, How do regular loans work?

Guess we all have an idea of how a regular loan works but is it worth reiterating?

Let’s explain these classes of loan:

Unsecured loans

They are loans that don’t need you to put forward any collateral.

Here, there is no laid down asset you agree that the lender can have if you don’t repay the loan.

For instance, let’s say that that you want to buy a coin and you want to invest $3,000 on that coin.

You decided to speak to your friend Andrew about it.

You told Andrew how badly you want to invest in this coin, how it will improve your Crypto portfolio by at least 20%, and Andrew agrees to lend you the money.

On the condition that you repay him as soon as your paycheck comes in.

Andrew is your very good friend, so he didn’t leverage a fee when he lent you the $3,000.

You should know that not everyone will be so kind but, why should they be?

Your friend Andrew trusts you to pay him back.

Another person might not, so they don’t know if you’re going to run off with their money.

Just like the instance above, unsecured loans from institutions may require some kind of credit check.

These institutions may have to look at the track record of your borrowings to measure your ability to repay.

If eventually, they discover that you’ve taken out several loans and paid them back on time, they might consider giving you the loan and think of you as being pretty reliable.

After all the findings they will decide, let’s lend him some money.

The institution gives you the money, but it will come with conditions. Those conditions are known as interest rates.

For you to get the money, you will have to accept that you’ll be paying back a higher amount much later.

If you have ever used a credit card, you should be familiar with this model.

And If you fail to pay the loan for a given period, you will be charged an extra interest until you repay the full balance including the additional fees.

Secured loans

Under secured loans, having a good credit record is not enough.

It doesn’t matter if you have repaid all of your loans on time for decades.

You will have a tough time borrowing large sums of money when it’s only based solely on your creditworthiness.

In the case of secured loans, you need to put up collateral.It is very risky to accept an offer from someone asking for a big loan.

To reduce their risk, they will demand that you put down a deposit or collateral or an asset of yours.

It could be anything because it will become what the lender will fall back to if you fail to pay them back in time.

Let’s say for instance you now want to invest $50,000 in a project and your friend Andrew trusts you, but he doesn’t want to give you the money in the form of an unsecured loan.

What Andrew will request from you under secured loans is collateral.

If you fail to repay the loan, Andrew can seize your collection and sell it off to get back his money.

How does a Flash Loan in DeFi work?

A flash loan in DeFi is more like an unsecured loan.

The reason is that you don’t provide any form of collateral and you also don’t need to pass a credit check or anything like that.

All that is required of you is to ask the lender if you can borrow $1,000 in ETH, they respond yes! Here you go! and you’re off.

So what’s the catch? It has to be repaid in the same transaction.

It doesn’t sound intuitive at all, but that’s only because you are used to a typical transaction format where funds move from one user to another.

Just like paying for goods or services, or when you deposit tokens into an exchange.

If you are familiar with Ethereum, you will know that it is a flexible platform, that’s why some call it programmable money.

So, when it comes to flash loans, you can think of your transaction “program” from three parts:

1: Receive the loan

2: Do something with the loan

3: Repay the loan.

And everything happens in a flash!That’s the magic of blockchain technology.

Your transaction gets submitted to the network, temporarily lending you those funds.

As long as you do some stuff in part two which is “do something with the loan.

Carry out any transaction you wish to as long as the funds are back in time for part three “Repay the loan”.

If you don’t play these three parts, the network rejects the transaction, which means the lender gets their funds back.

Well, no doubt they always had the funds.

This explains why the lender doesn’t have to stress the requirements for collateral from you, because the contract to repay the loan is enforced by code.

What’s the point of Flash loans in DeFi?

At this point, you may be wondering whats the point of taking out a flash loan, if all of this occurs in a single transaction?

Can I purchase a Lambo?

Well, purchasing a Lambo is not the goal of Flash loans.

The main catch of Flash loans is on part two of the transaction, where you do something with the loan.

Flash loans are designed to feed funds into a smart contract or chain of contracts, flip a profit, and return the initial loan at the end of the transaction.

The main goal of flash loans is to make profit.

Where do Flash loans in DeFi come in handy?

There are a couple of use cases where flash loans could come in handy.

You can utilize DeFi protocols to make more money using your loan.

The most popular applications of Flash loans is arbitrage, because you have to take advantage of price differences across various trading venues.

Let’s say a token trades for $100 at DEX A, but $100.50 at DEX B with zero fees, buying a hundred tokens on DEX A before reselling them on DEX B would yield a profit of $5.

Doing this over time will not buy you the luxury you desire anytime soon, but it has shown you how you could make some money by trading large volumes.

If you purchased 50,000 tokens for $500,000 and you flipped them for $510,000, you will be left with a profit of $10,000.

If you get a flash loan through the Aave protocol , for example, it is easy to take advantage of arbitrage opportunities like this on decentralized exchanges.

This is an example of what that flash loan will look like:

1. Take out a $5,000 loan

2. Use the loan to buy tokens on DEX A

3 Resell the tokens on DEX B

4. Return the loan plus any interest charged

5. Keep the profit

And all of this happens in one transaction!

Ethereum Blockchain fees to transact when combined with high competition, interest rates, and slippage, make the margins for arbitrage razor-thin.

You have to find a way to navigate the price differences to make the activity a profitable one for you.

Especially when you are competing against thousands of other users who wants to do same, you won’t have much luck.

How Secured is Flash Loans on Defi?

DeFi is a highly experimental field.

With so much money at stake, it’s only a matter of time before vulnerabilities are detected.

Ethereum has experienced quite some attacks and a typical example of this with the iconic DAO hack.

Two high-profile flash loan attacks witnessed their attackers making off with almost $1,000,000 in value at the time.

And these attacks followed a similar pattern.

The first flash loan attack

In the first attack, the borrower took out an Ether flash loan on dYdX which is a lending DApp.

These borrowers divided that loan and sent it to two other lending platforms which are Compound and Fulcrum.

The flash loan attack on Fulcrum was built on the bZx protocol.

Here the attacker used part of the loan to short ETH against wrapped Bitcoin (WBTC), which means that Fulcrum had to acquire WBTC.

Kyber was another DeFi protocol that suffered an attack on Uniswap.

Uniswap is a popular Ethereum-based DEX.

Because of the low liquidity on Uniswap, the price of WBTC rose significantly, making Fulcrum overpay for the WBTC it purchased.

Similarly, the attacker went ahead to take out a Compound loan of WBTC using the rest of the dYdX loan.

Price pumped, and they flipped the borrowed WBTC on Uniswap and made off with a good amount of profit.

These attackers repaid their loan from dYdX and held on to the leftover ETH.

The attacker was able to leverage five different DeFi protocols to manipulate the markets.

This happened the same time they took the original flash loan to be confirmed.

Did you identify where the problem was?

Yes, you are right;

The bZx protocol used by Fulcrum caused it.

When they manipulated the market, they were able to trick it into thinking that WBTC was worth a lot more than it was.

The second flash loan attack

bZx was hit by another attack.

The attacker took out a flash loan and converted part of the loan into a stablecoin (sUSD).

When the attacker filled in a huge order to buy sUSD with borrowed ETH, the price doubled on Kyber.

bZx was not aware sUSD stablecoins are worth $1 thought it was $2.

The attacker took out a much bigger ETH loan than would have been normally allowed on bZx.

bZx weren’t aware sUSD was a $1 coin thinking the purchasing power was $2.

The attacker was able to repay the initial flash loan but ran off with the rest.

Are flash loans risky?

Anyone can become a whale for a few seconds with Flash Loans.

As we have seen, a few seconds is all you need to make off with hundreds of thousands of worth of ether.

But let’s look on the bright side, the rest of the crypto space will learn from these two attacks.

You may be asking, Is it possible that someone else may likely successfully pull one off again, now that everyone knows about it? Perhaps.

Oracles are not perfect, they have several weaknesses.

A good amount of work is needed to get rid of vulnerabilities.

Flash loans in DeFi weren’t at fault.

The vulnerabilities were exploited by other protocols, while the attack was financed by flash loans.

When given the low risks for both borrowers and lenders, this form of DeFi lending could have many interesting use cases in the future.

Wrapping it up

Flash loans coming into existence are beginning to display signs of future potential to the DeFi space.

But they have certainly made a lasting impression.

Uncollateralized loans, enforced by code, will open up a world of possibilities in a new financial system.

With limited use cases, flash loans have laid the foundation for innovative new applications in decentralized finance (DeFi).

Leave a Reply

Your email address will not be published. Required fields are marked *

Saffy lisafi
I am a Crypto Content Writer, Content Markerter for ABiT Network, Affiliate Markerter and a DeFi tutor.

Related Posts

DAO: How it Works

With the blockchain came decentralization. This opens the door to a whole

DeFi for Beginners

DeFi is a very interesting part of the ongoing cryptocurrency revolution. With