Flash Loans in DeFi

17 July 2023

8m read

TL;DR
A loan from strangers without the user having to give up any of their own money? It is feasible, provided that people pay back the lender in the same transaction that they received the funds. Doesn't it sound strange? How can you use a loan that must be repaid moments later?
It turns out that calling smart contracts within the same transaction is possible. If you can use your loan to earn additional money, you can quickly repay the debt and keep the extra cash. But it's not really that simple. Continue reading to discover more about the DeFi ecosystem's most recent additions.

Introduction * How do regular loans function?unprotected loansLoans that are secured, unsecured, and secured

  • How do flash loans function?What's the point, though?
    What's the point, though?
  • Flash loan assaultsThe initial flash loan assaultThe second incident of a flash loanDo flash loans pose a risk?
    Attacks on flash loans: * The first * Attacks on flash loans: * the second Do flash loans pose a risk?
    Conclusion: Unsecured loans, secured loans, and the question: What's the point?
    The first flash loan was a failure, but the second was a success.

Introduction ##

How do standard loans operate?
Most of us are aware of how a typical loan operates. However, it bears repeating so that we can subsequently draw a parallel.

Unsecured loans ####
You converse with your pal Bob. He agrees to lend you the money after hearing how much you desire this chain and how it will enhance your trading performance by at least 20%. Naturally, provided that you pay him back as soon as your paycheck arrives.
Bob lent you the $3,000 without charging you a fee because he is a good friend of yours. Some people won't be as generous, but why should they? Bob has faith in you to repay him. Someone else could not be familiar with you, in which case they are unsure if you will steal their money.
If you make use of a credit card, you might be acquainted with this model. You will be charged interest (and with additional costs) if you don't pay your account within a certain time frame.

Loans with collateral
It's perilous for someone to agree to a large loan request. They will insist that you put some money on the line in order to reduce their risk a little. If you don't make your payments on time, the lender will come into possession of a valuable possession of yours, such as jewels or real estate. The goal behind this is to allow the lender to eventually recoup part of the value they've lost. That is collateral, to put it briefly.
Let's say you now desire a $50,000 vehicle. Despite his faith in you, Bob is unwilling to give you an unsecured loan for the money. Instead, he requests that you provide collateral in the form of your jewelry collection. Now, Bob has the right to confiscate and sell your collection if you don't pay back the debt.

How does a flash loan function?
That explains why the lender does not demand that you provide collateral. Code is used to enforce the contract to repay.

What's the point, though?

You may be questioning why you would obtain a fast loan at this point. You can't exactly buy a Lambo if all of this happens in one transaction, can you?

Take out a $10,000 loan, use it to buy tokens on DEX A, then sell them on DEX B. Then, pay back the loan, plus interest. Keep your earnings
One transaction, total! However, in reality, the margins for arbitrage are razor-thin due to transaction fees, strong competition, interest rates, and slippage. To make the activity viable, you would need to figure out how to take advantage of price discrepancies. You won't have much luck competing against thousands of other users who are trying to do the same thing.

Attacks on payday loans

In 2020, thieves stole about $1,000,000 in worth from two high-profile flash loan attacks. Both attacks had the same format.

The initial flash loan assault
The attacker used the remaining funds from the dYdX loan at the same time to take out a WBTC compound loan. When the price spiked, they sold the borrowed WBTC on Uniswap and profitably fled. Finally, they paid back the loan they received from dYdX and kept the remaining ETH.
It looks like a lot of work and can possibly be challenging to understand. The attacker utilized five separate DeFi protocols, in the end, to influence the markets. Amazingly, everything took place while the initial flash loan was being confirmed.
Have you located the issue's source? It was in the Fulcrum's bZx protocol. The attacker was able to deceive the market into believing that WBTC was worth much more than it actually was by manipulating the market.

The second attack involving payday loans
Smart contracts aren't really that intelligent, despite their name. They are unaware of the intended price of stablecoins. Therefore, the price on Kyber doubled when the attacker placed a sizable order to buy sUSD (with ETH that was borrowed).
BZx believed that sUSD was worth $2 as opposed to $1. The attacker then borrowed a far larger amount of ETH than would have been typically permitted on bZx because their $1 coin was worth $2. Finally, the assailant paid back the first flash loan and fled with the remaining sum.

Flash loans: Are they dangerous?
Overall, this isn't a problem with flash loans in particular because other protocols' flaws were exploited, and the flash loans only served to finance the attack. Given the low risks for both borrowers and lenders, this type of DeFi financing may have a variety of intriguing use cases in the future.

Concluding remarks

Although flash loans are a newcomer to the DeFi market, they have left a significant influence. A whole new world of possibilities in a new financial system are made possible by the idea of uncollateralized loans, which is only enforced by code.
Although there are currently only a few use cases, flash loans have eventually set the stage for cutting-edge new decentralized finance applications.

O

Latest Releases