What are Flash Loans & How to Use Them?

Written By
Erik
First Published
November 9, 2022
Last Updated
April 19, 2023
Estimated Reading Time
4 minutes
Flash Loans
In this article...

Flash Loans are a form of uncollateralized lending in DeFi. A flash loan allows you to borrow potentially huge sums for the duration of one transaction. But on the condition that the trade you execute with your loaned coins allows you to repay the funds as the final step. This form of loan doesn’t exist in traditional finance (tradfi) but it does make certain tradfi activities easy, such as price arbitrage. Let’s unpack.

Flash loans began on Aave. They are an incisive instrument in the MEV toolkit: smart traders can benefit in a flash from their insight in what’s going on in the mempool. When they spot a good trade, they loan money, execute the trade, and repay the loan. They don’t have to carry around the funds: the trade happens in the time it takes to execute an Ethereum transaction. That’s a flash indeed.

what are flash loans

Why Flash Loans Seem Risky But Aren’t

If I say loan, you say leverage trading. Sure, but you would be wrong to think flash loans come with a risk of margin calls and lenders going broke. Because consider the following. Flash loans are also called atomic loans. Meaning that the sequence of operations that make up a transaction can’t be broken up. And this means that all the conditions must be met to record that atomic transaction on the blockchain.

In other words the series of transactions that makes up the trade must be profitable, or you don’t get the loan (or, at least, if your trade loses money, you need to have enough funds to repay the loan). If, somehow, the conditions change during the trade and it’s no longer possible for you to repay, the transaction gets rolled back on-chain.

By now you’ve probably guessed that flash loans don’t happen on centralized exchanges: it’s smart contract/blockchain stuff. It happens in DeFi.

The 5 Steps of a Flash Loan

There are 5 main steps in a flash loan transaction, all predetermined in code or for non-coders (at the bottom of this article) in a nice interface:

  1. Flash loan providers (decentralized platforms such as Aave and UniSwap) send requested assets to users.
  2. The network calls pre-designed operations.
  3. Users deploy their loaned tokens in other smart contracts, putting their assets to work.
  4. After the execution of the trade, users need to return the borrowed assets.
  5. Flash loan providers check their balance. Is the loan not returned? The smart contract rolls back the transaction.

 Example: A flash loan to arbitrage trade

What’s so alluring about flash loans is how they can bootstrap nearly broke traders to make money – at least in theory and, of course, only the competitive and disciplined ones. Even though flash loans are not free – you pay gas fees and in some cases a trading fee – they are extremely cheap relative to the amount you could loan.

How could you pull off a profit through a flash loan? Let’s say you see that the price of ETH differs between decentralized exchanges. Most likely, this price difference will be small – after all, you won’t be the only person to try to arbitrage it (pocketing the difference). 

So you’ll need let’s say 100 ETH to make any meaningful chunk of change. But since we’re talking about uncollateralized loans here, it’s possible. 

What’s the Catch?

What’s the catch? Nothing in life is free, right?. So why on earth would a DeFi exchange say: ‘No problem, broke trader’, here is a 100 ETH loan. Go have fun with it!’ Well, the exchange doesn’t exactly do that. It will assess if your trade is profitable enough for you to repay the loan. Requests for flash loans that are not profitable enough, will be rejected. 

So here’s the order of things?

  1. You take out a 100 ETH loan
  2. You swap that 100 ETH for USDT on (for example) Uniswap
  3. You rebuy that 100 ETH with USDT on (for example) Sushiswap
  4. You repay the 100 ETH

In this example, if the ETH is a dollar cheaper on Sushiswap, you make hundred dollars in a single transaction (not accounting for gas fees though) without running any risk.

Through flash loans, traders without much capital can access arbitrage, liquidation, and asset swapping opportunities. They can discover price differences among tokens between decentralized exchanges (DEXes), borrow tokens by flash loans, and maximize their profit.

What Does it Cost to Execute a Flash Loan?

So is there a catch? Well, some platforms, for example Aave, will charge you a fee: currently 0.09%. This will obviously prevent you from arbitrage trades where the price difference is lower than that. And in any case you will have to pay the Ethereum gas fees, which can easily amount to tens of dollars for a series of transactions that you need. 

Examples of Highly Profitable Flash Loans

Here are two examples of spectacularly profitable flash loans:

Example 1: Arbitraging Fat Fingers: Bored Ape for 10 ETH

In May 2022, a Bored Ape owner made a mistake and offered his Ape for a price of 10 ETH (he had meant to set 105 ETH as the minimum). A trader saw the bid but didn’t have 10 ETH at hand. You guessed it. He took out a flash loan for 10 ETH. He then bought the Ape, immediately sold it for 78 ETH in the same transaction (some bids for Apes are ‘any Ape’ kind of bids, so there are generally bids around for these Apes).

Example 2: Clever Trader Borrowed 5 Apes to Claim Airdrop

In early 2022, an anonymous trader was able to claim over 50,000 ApeCoins by flash loaning 5 Bored Apes. (This was right around the Apecoin airdrop: For each Bored Ape you owned, you got 10.000 Apecoins.) For this smart trader to be able to get 50k Apecoins, he only needed to buy 1 Ape. That’s because of another form of leverage in this trade: this one Ape acted as collateral for a “vault” containing the 5 Apes of which nobody had claimed the airdrop yet. 

The trader, who cleverly exploited a vulnerability in the airdrop system, then sold his ApeCoins for about $1 million.

how to use flash loans

Easy Flash Loans, Without Coding

Developers have always had a big edge using flash loans. It used to require technical knowledge to execute one. But there is an upcoming market of DeFi tools for the masses. The money lego variant of creating flash loans. 

Furucombo is such a tool: a bot that is friendly to use on the front end. Here is an example from Finematics, building a (non-profitable!) trade.

no code flash loans

Example of a flash loan on Furucombo: lending 1000 DAI on Aave, swapping it for USDC on Uniswap, buying it back on Curve (for a loss, in this example of an unprofitable flash loan), repaying the loan plus fee to Aave. Source: Finematics

Erik started as a freelance writer around the time Satoshi was brewing on the whitepaper.
As a crypto investor, he is class of 2020. More of a holder than a trader, but never shy to experiment with new protocols.

Discussion on "What are Flash Loans & How to Use Them?"
You must Subscribe or Login to post a comment.
Additional Resources
Wealth Mastery
Subscribe Today!
Join the Wealth Mastery Investor Report

Join the Wealth Mastery Investor Report

By Lark Davis
Privacy Policy

Who we are

Our website address is: https://thewealthmastery.io.

Comments

When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection.

An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.

Cookies

If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.

If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.

When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select “Remember Me”, your login will persist for two weeks. If you log out of your account, the login cookies will be removed.

If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.

These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.

For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where we send your data

Visitor comments may be checked through an automated spam detection service.

Join the Wealth Mastery Investor Report

By Lark Davis