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.
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:
- Flash loan providers (decentralized platforms such as Aave and UniSwap) send requested assets to users.
- The network calls pre-designed operations.
- Users deploy their loaned tokens in other smart contracts, putting their assets to work.
- After the execution of the trade, users need to return the borrowed assets.
- 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?
- You take out a 100 ETH loan
- You swap that 100 ETH for USDT on (for example) Uniswap
- You rebuy that 100 ETH with USDT on (for example) Sushiswap
- 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.
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.
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.