What are DeFi flash loans? DeFi lending explained (2024)

Flash loans have made headlines in the crypto space for reasons both good and bad.

While they've been implemented to exploit many vulnerable DeFi protocols, they've also helped some users make a profit. Some enthusiasts even argue that they’re one of the most innovative blockchain technologies.

But what are flash loans exactly?

This article explains how flash loans work and outlines some of their most common applications.

What are flash loans?

Flash loans are uncollateralized loans in which a user borrows funds and returns them in the same transaction. If the user can’t repay the loan before the transaction is completed, a smart contract cancels the transaction and returns the money to the lender.

Why do flash loans exist?

To understand why flash loans were created, let’s look at existing lending systems in centralized and decentralized finance.

Centralized Finance (CeFi) lending systems

The most common loans in traditional finance are secured loans and unsecured loans.

Secured loans

A secured loan requires the borrower to provide a form of security called collateral to the lender for the repayment of a loan.

Collaterals usually apply to large sums of money and help the lender recoup their losses by selling the collateral if the borrower can’t repay the loan.

For example, if you’re taking out a mortgage, your home will become the collateral, and the lender will sell it to cover the mortgage if you default.

Unsecured loans

An unsecured loan, on the other hand, is one in which the borrower doesn't have to provide collateral to borrow funds.

What are DeFi flash loans? DeFi lending explained (1)

In both cases, the borrower has to pay interest. And in both cases, if the borrower defaults, the lender has to bear the brunt of the losses.

Decentralized Finance (DeFi) lending systems

DeFi lending systems operate differently than their traditional centralized counterparts. They pool capital from depositors into a “liquidity pool” to offer collateralized loans for borrowers.

Most of these loans are over-collateralized, meaning the borrower has to provide collateral in crypto that is worth more than the borrowed assets. This is to account for fluctuating crypto prices and ensure that the asset doesn’t become under collateralized.

What are DeFi flash loans? DeFi lending explained (2)

In other words, if the collateral’s value can no longer cover the debt, the platform will sell collateral at a discounted price to repay a part of the loan. This process is called liquidation.

Flash loans address the limitations of CeFi and DeFi lending

CeFi and DeFi loans also have some disadvantages that flash loans address.

In a traditional CeFi lending system, you might have to wait months to get your loan approved. But thanks to smart contracts, flash loans can be processed and approved instantly.

Also, if a borrower defaults, the burden of debt may fall on the lender. If a borrower defaults on a flash loan, however, the smart contract will cancel the transaction and return the funds to the lender.

As for DeFi lending, users have to provide collateral to get a crypto loan. Flash loans, on the other hand, are uncollateralized, making lending more accessible.

How do flash loans work?

There are two main entities in a flash loan: the lender and borrowers.

To interact with the flash loan lender, borrowers must develop a smart contract that consists of three parts:

  • Borrow loans from flash loan lenders (Aave, dYdX, and Uniswap)
  • Interact with smart contracts for other operations
  • Return the loans

The entire workflow consists of five steps:

1. Transfer loan

The flash loan provider transfers requested assets to borrowers.

2. Invoke

The borrower (user) invokes pre-designed operations.

3. Run operation

The user interacts with different smart contracts to execute operations (arbitrage, liquidation, etc.) with borrowed assets.

4. Repay loan

Once the operations are complete, the smart contract will return the assets to the flash loan providers with or without the borrowed assets.

5. Check state

Lastly, the flash loan providers will check their balance. If the user has submitted insufficient funds, the providers will reverse the transaction immediately.

What are DeFi flash loans? DeFi lending explained (3)

The 3 most common uses of flash loans

Flash loans have a wide variety of applications that range from paying off debts to attempting to generate profits from trading. Here, we discuss the three of the most common use cases.

1. Arbitrage

Arbitrage is the strategy of leveraging price differences for the same asset in different exchanges to make a profit.

Buyers and traders can buy crypto at low prices and run it through different cryptocurrency exchanges to end up with slightly more crypto than before. Although this price exploitation sounds harmful, it contributes to market efficiency.

As more crypto traders seek to exploit the same price discrepancy, the prices of these assets across different exchanges will converge, leading to uniformity of the crypto market.

What are DeFi flash loans? DeFi lending explained (4)

If you're just starting with crypto arbitrage, you probably don't have enough assets to make a significant profit.

But flash loans give you the ability to borrow as much as you want, so it might be possible to generate a decent profit if you find assets with a considerable price difference.​​ Here’s a transaction from Etherscan that shows how you can use a flash loan to profit from arbitrage:

What are DeFi flash loans? DeFi lending explained (5)

First, the user borrowed 2,048,000 USDC using dYdX’s flash loan. Then, they swapped the amount for 2,028,367 DAI on Curve y pool.

Next, they used the 2,028,367 DAI to purchase 2,064,182 USDC on Curve’s SUSD pool, after which they paid back the flash loan and kept the difference worth $16,182.

2. Wash trading

Like any other financial technology, flash loans can also be used to facilitate scams. Wash trading is one such use case.

Wash trading is the process of using a group of trades to create an illusion of higher trade volume. It misleads investors and other users into thinking that a cryptocurrency or NFT has high demand when it doesn't.

Some countries like the US have banned the practice of wash trading, but the practice has seen a revival in the crypto market because of the lack of centralized institutions and regulations.

Now, with the advent of flash loans, wash trading has become more rampant as traders can get hold of a large sum of crypto to manipulate the market.

Here’s a transaction from Etherscan that will help you understand wash trading better:

What are DeFi flash loans? DeFi lending explained (6)

First, the user borrows 0.01 Wrapped Ether (WETH) from dYdX. Then, they exchange it on Uniswap to get ~122.189 LOOM, which is converted back into ~0.0099 WETH.

After this step, the user pays back the flash loan to dYdX. What distinguishes this transaction from arbitrage or other types of legal transactions is that there was a loss while swapping tokens.

This indicates that the user’s main aim was to increase trading volumes, making it a trade that was solely done to manipulate the market and create artificial demand for assets.

3. Closing Collateralized Debt Position

A Collateralized Debt Position (CDP) is simply a crypto loan that’s backed by collateralized assets. Once the user borrows funds, the platform locks the collateral until the loan is repaid.

During this period, if the currency of the loan drops in value compared to the currency of the collateral, the user can’t repay the loan.

Flash loans allow you to pay back the loan and release the collateral so you can use it for other purposes. Here’s a transaction that explains the concept better:

What are DeFi flash loans? DeFi lending explained (7)

First, the user takes a flash loan equal to the debt (~262.17 DAI) from Aave. Next, they repay the loan on Maker, and the platform releases their collateral (2.09 WETH).

Then, they go to Kyber reserve to convert WETH into DAI and transfer the surplus amount (~2 DAI) to Uniswap for other purposes. Lastly, the user pays back the loan to Aave, which burns a fraction of its token for 0.07 DAI to increase the value of its tokens in circulation.

Can you make money with flash loans?

It is possible to make money with strategies that use flash loans but it is also possible to lose money with these same strategies.

Before engaging with flash loans, it is important you understand the risk.

One way some seek to generate a profit with flash loans is by becoming a liquidator. When a debt becomes undercollateralized, a class of users called liquidators will trigger a liquidation event to buy undercollateralized assets at discounted prices.

With flash loans, anyone can become a liquidator and profit from the discounted assets. For example, take a look at this transaction:

What are DeFi flash loans? DeFi lending explained (8)

First, the user borrows 12,940 DAI from dYdX and swaps it for 13,046 USDT. This USDT is then used to buy collaterals at a discounted price on Compound.

After exchanging the asset they bought, the liquidator gets 13,450 DAI. And once they paid back the flash loan, 510 DAI remained as profits, which is greater than the gas fees (~$172).

Flash loan risks: Flash loan attacks

Although DeFi flash loans have grown in popularity and liquidity, they also come with risks.

About $500 million worth of assets were stolen from DeFi platforms between 2020 and 2021. And one of the most common attacks that caused millions to be wiped off the protocols were carried out using flash loans.

Oracles are third-party services that allow smart contracts to get data from outside their ecosystem. In most cases, this data is the real-time price of assets.

Oracle manipulation is the practice of manipulating the asset price data in these oracles to buy or sell above or below the fair market price on the platform.

Here’s how this attack is carried out using a flash loan:

  • Borrow a large amount of token A from a flash lending provider.
  • Use a DEX to trade token A for token B (this lowers the price of token A and increases the price of token B on the DEX).
  • Utilize the purchased token B as collateral on a DeFi protocol that relies solely on the DEX (mentioned above) as its price feed, and use the rigged pricing to borrow a larger amount of token A.
  • Profit from the protocol's manipulated price feed by using a portion of borrowed token A to fully repay the original flash loan and keep the remaining tokens.
  • The values of tokens A and B on the DEX will be arbitraged back to the true market price. But the DeFi protocol is left with an undercollateralized position (debt worth more than collateral), which directly harms other users such as the liquidity pool providers.

For example, in May 2020, the Binance Smart Chain protocol Pancake Bunny lost over 7 million BUNNY tokens and 114,000 BNB in a flash loan attack.

As a result of the attack, BUNNY plummeted by 96% and the platform incurred a loss of more than $200 million.

How can you help protect yourself better from flash loan attacks?

Protocols that use on-chain centralized price oracles, such as a single DEX, are vulnerable to attacks carried out using flash loan vulnerabilities.

Why?

When a single on-chain exchange is used as a price feed, an asset's data is extremely limited because it only reflects the market condition of that one exchange.

An oracle like Chainlink, however, is powered by a decentralized network of oracles, so while an attacker can carry out a single flash loan transaction, it still won’t affect the price feed as the exchange gets pricing data from multiple sources.

Concluding thoughts on flash loans

Flash loans have taken the decentralized finance world by storm as they let users instantly borrow assets without collateral.

They’re a double-edged sword, however, as flash loans come with significant risks and can have unfavorable consequences on the crypto ecosystem depending on what they’re used for.

Many crypto enthusiasts are currently using flash loans to try to make profits and hedge themselves against liquidation risks. But malicious parties are also using them to engineer attacks on smart contracts and drain them of funds.

It’s also worth remembering that flash loans are relatively new to the DeFi space, so the possibilities for innovation are endless.

Frequently asked questions (FAQs) about DeFi flash loans

How do I get a crypto flash loan?

To get a crypto flash loan, you can use a drag and drop tool like Furucombo and create a pipeline with cubes which are akin to building blocks.

Alternatively, you can also use smart contracts to execute flash loans on platforms like Aave, dYdX, and Uniswap.

Since smart contracts are pieces of code, you can find many open source flash loan codes on sites like GitHub.

Do flash loans need collateral?

No. Flash loans are unsecured and uncollateralized, meaning anyone can borrow funds to make profits.

What happens if you don’t pay your flash loan?

If you don’t pay your flash loan, the smart contract cancels the loan and returns the funds to the lenders.

How long does a flash loan last?

As the name suggests, a flash loan only lasts for a few seconds or minutes as the loan is taken and repaid within the same transaction.

Are flash loans risk free?

No. As discussed in this article, flash loans come with risks and you should make sure to educate yourself about these risks before engaging with flash loans.

Begin your DeFi journey with MoonPay

Flash loans are just one of the many ways you can engage with the DeFi ecosystem. To get started with DeFi, simply buy cryptocurrency via MoonPay using your credit card or any other preferred payment method.

MoonPay's widget offers a fast and easy way to buy Bitcoin, Ethereum, and many other cryptocurrencies.

MoonPay also makes it easy to sell crypto when you decide it's time to cash out, including several tokens mentioned in this article like ETH, USDT, and USDC. Simply enter the amount of the token you'd like to sell and enter the details where you want to receive your funds.

What are DeFi flash loans? DeFi lending explained (2024)

FAQs

What are DeFi flash loans? DeFi lending explained? ›

Flash loans are uncollateralized loans in which a user borrows funds and returns them in the same transaction. If the user can't repay the loan before the transaction is completed, a smart contract cancels the transaction and returns the money to the lender.

How does DeFi lending work? ›

What is Defi lending? Defi lending platforms aim to offer crypto loans in a trustless manner, i.e., without intermediaries and allow users to enlist their crypto coins on the platform for lending purposes. A borrower can directly take a loan through the decentralized platform known as P2P lending.

What is the difference between traditional loan and flash loan? ›

Obtaining approval for a traditional loan is usually a long procedure. But, a flash loan is expedited instantly, implying that the smart contract of the loan should be fulfilled during the transaction for which it is lent out.

Can you make money with flash loans? ›

Is flash loan arbitrage still profitable? While it's possible to make a profit through flash loan arbitrage, it can be difficult to make money when you account for fees, competition, and other factors.

What is an example of a flash loan? ›

Flash loans represent essentially risk-free arbitrage opportunities; for example, if a cryptocurrency is being traded for $1 on one exchange and for $2 on another, a savvy trader can use smart contracts to take out a flash loan of $100 worth of the cryptocurrency on the first exchange, sell it for $200 on the second ...

What are the risks of DeFi lending? ›

Unlike traditional finance markets, many DeFi markets don't have customer service teams. A simple mistake, like sending money to the wrong address, could result in huge losses. You could contact the receiver at that wrong address and ask them to return the funds.

How do flash loans work? ›

Flash loans are uncollateralized loans in which a user borrows funds and returns them in the same transaction. If the user can't repay the loan before the transaction is completed, a smart contract cancels the transaction and returns the money to the lender.

What happens if you don't pay back a flash loan? ›

If you don't pay back a flash loan within the same transaction, your transaction will fail - as though it never happened at all. All that will remain is a record of a failed transaction on the blockchain.

Are flash loans safe? ›

Security Risks: Flash loan protocols are susceptible to various security vulnerabilities, including smart contract bugs, oracle manipulation, and price manipulation attacks. Developers and users must exercise caution and conduct thorough audits to mitigate these risks effectively.

How much can you borrow with a flash loan? ›

Flash Loans allow you to borrow any available amount of assets without putting up any collateral, as long as the liquidity is returned to the protocol within one block transaction.

Do flash loans need collateral? ›

Flash loans differ significantly from traditional loans. They are unsecured, meaning no collateral is needed. Instead, smart contracts on the blockchain enforce the loan. If the loan is not paid back immediately, the blockchain does not confirm the transaction, and the loan does not proceed.

What is the largest flash loan? ›

8 Biggest Crypto Flash Loan Attacks of All Time
  • Euler Finance $197M Stolen in 2023.
  • $130M Cream Finance Exploit in 2021.
  • Beanstalk $80M Stolen in 2022.
  • $45M PancakeBunny Exploit in 2021.
  • Alpha Finance $37M Stolen in 2021.
  • $25M Attack on dForce in 2020.
  • Elephant Money $22.2M Exploit in 2022.
Jun 3, 2024

What is the flash loan strategy? ›

Arbitrage Opportunities

Through a flash loan, the trader can instantly borrow Ether, buy it at a lower price on Exchange A, sell it at a higher price on Exchange B, and repay the loan, all within the same transaction, pocketing the price difference as profit.

What is a flash loan hack? ›

In flash loan attacks malicious actors use the temporary uncollateralized liquidity provided by flash loans to manipulate the price of a crypto currency,exploit vulnerabilities in a DeFi smart contract, or steal funds from a protocol.

How much is the fee of a flash loan? ›

Further evaluation of how profitable the Aave flash loans can be shown that the 0.09% fee set as the service charge is excessive and needs a review in some cases. When doing arbitrage trading, profit levels are usually below 0.5%, and splitting that amount will leave the borrower with little to nothing.

Who offers flash loans? ›

Top flash loan providers include Aave, Equalizer, dydx and uniswap.

How does DeFi really work? ›

Through peer-to-peer financial networks, DeFi uses security protocols, connectivity, software, and hardware advancements. This system eliminates intermediaries like banks and other financial service companies.

How do DeFi owners make money? ›

DeFi lending platforms enable you to earn interest by lending out your crypto holdings to borrowers in need. These borrowers can access crypto loans at competitive rates compared to traditional financial institutions. Platforms like Aave and Compound are leading examples of DeFi lending and borrowing protocols.

Is DeFi trustworthy? ›

The decentralized nature of DeFi creates potential opportunities for scammers to exploit unsuspecting users. Honeypot scams, fake accounts, and other deceitful tactics are prevalent.

What happens if you default on a DeFi loan? ›

In TradFi, when someone defaults on a loan, the creditor has the right to seize assets or garnish wages. In DeFi, when someone defaults on a loan it isn't possible to take assets from their wallet. To enforce repayment, users must deposit a larger notional value of cryptocurrency than they are borrowing.

Top Articles
Elite Status, Fancy Lounge Access, Free Hotel Nights, and More: We Rank the Best Credit Card Perks
[Registrations Closed] AmEx Statement Credits: IKEA Spend $150 or More, Get $30 Back (25000 Offers Available)
Cars & Trucks - By Owner near Kissimmee, FL - craigslist
Room Background For Zepeto
Craigslist Vans
Stadium Seats Near Me
Mcfarland Usa 123Movies
30 Insanely Useful Websites You Probably Don't Know About
Meer klaarheid bij toewijzing rechter
360 Training Alcohol Final Exam Answers
P2P4U Net Soccer
Craigslist Pets Southern Md
Wordscape 5832
Pvschools Infinite Campus
Minecraft Jar Google Drive
National Weather Service Denver Co Forecast
State HOF Adds 25 More Players
Hocus Pocus Showtimes Near Amstar Cinema 16 - Macon
Plan Z - Nazi Shipbuilding Plans
Unterwegs im autonomen Freightliner Cascadia: Finger weg, jetzt fahre ich!
Loves Employee Pay Stub
Mahpeople Com Login
Invitation Homes plans to spend $1 billion buying houses in an already overheated market. Here's its presentation to investors setting out its playbook.
Selfservice Bright Lending
Globle Answer March 1 2023
Wood Chipper Rental Menards
Paris Immobilier - craigslist
Temu Seat Covers
130Nm In Ft Lbs
Revelry Room Seattle
Spy School Secrets - Canada's History
Shaman's Path Puzzle
Worlds Hardest Game Tyrone
Whas Golf Card
Agematch Com Member Login
Jefferson Parish Dump Wall Blvd
Kelly Ripa Necklace 2022
Topos De Bolos Engraçados
Xxn Abbreviation List 2023
Danielle Ranslow Obituary
10 Rarest and Most Valuable Milk Glass Pieces: Value Guide
20 Mr. Miyagi Inspirational Quotes For Wisdom
From Grindr to Scruff: The best dating apps for gay, bi, and queer men in 2024
St Anthony Hospital Crown Point Visiting Hours
Benjamin Franklin - Printer, Junto, Experiments on Electricity
Www.homedepot .Com
Marion City Wide Garage Sale 2023
How To Find Reliable Health Information Online
One Facing Life Maybe Crossword
San Pedro Sula To Miami Google Flights
Latest Posts
Article information

Author: Prof. An Powlowski

Last Updated:

Views: 6442

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Prof. An Powlowski

Birthday: 1992-09-29

Address: Apt. 994 8891 Orval Hill, Brittnyburgh, AZ 41023-0398

Phone: +26417467956738

Job: District Marketing Strategist

Hobby: Embroidery, Bodybuilding, Motor sports, Amateur radio, Wood carving, Whittling, Air sports

Introduction: My name is Prof. An Powlowski, I am a charming, helpful, attractive, good, graceful, thoughtful, vast person who loves writing and wants to share my knowledge and understanding with you.