DeFi, or decentralized finance, continues to enable entirely new and convenient financial models for the masses. One we’re choosing to focus on in this post – is the concept of flash loans. Flash loans allow you to take credit worth millions of dollars, without any collateral, to be paid back within the duration of a single transaction. Before understanding what flash loans are, and knowing how they’re useful, it is important to know how they’re even possible in the first place.
If you’ve traded in cryptocurrency derivatives before, chances are you have a good understanding of how Etherum transactions work. For the uninitiated, Ethereum works on a concept called “state machine.” The Ethereum blockchain knows the state of every single transaction that has happened in the chain. With every new transaction, a new state is created, which is processed by all of the nodes in the network, for the transaction to even take place.
An important feature, directly arising from the way that transactions work on Ethereum, is that it is possible to determine each of the transactions’ validity before the transaction is executed. This essentially allows you to test a wide variety of transactions and hypotheticals, which, if proved wrong, would render the transaction void and revert back to the original state.
This feature gave birth to the concept of flash loans, which allows you to borrow millions of dollars, without any collateral, to be paid back within one single transaction.
What are flash loans, and how do they work?
We’ve noted time and time again that flash loans are loans that are borrowed and repaid in a single Ethereum transaction. It is important to understand that a single Ethereum block can consist of multiple smart contracts, enabling you to squeeze in multiple smart contracts before the loan is repaid. There is no collateral requirement for such loans because the transactions are atomic (the entire block, including the repayment, happens in a single swoop, or the whole block is rendered void). What this means is – you take your loan, use it for your purposes, and return it, all within a single transaction.
This guarantees that there is no risk of default to the lenders, removing the need for collateral. This grants every single person considerable amounts of liquidity, which was previously inaccessible, potentially making every single person a “whale.”
Flash loans were introduced by the DeFi “money market protocol” called Aave, built on Ethereum. In this case, Aave allows its users to borrow its liquidity, use it with other protocols (including swaps and trades), repay the loans (along with a small fee, currently at 0.09%) while keeping the profits. If the transaction is not profitable, or can’t be executed with the given set of conditions, it is rendered void and is reverted back to the original stage.
In the latter case, the transaction only costs the “gas fee” to power the machine to run the contract. This makes the downsides to such flash loans next to none, making it one of the most important and essential innovations in the DeFi ecosystem.
While flash loans can be used to a wide degree of things (the sky’s the limit), the most popular use cases of flash loans identified so far can be broadly categorized into two types.
Arbitrage allows you to capitalize on the difference in prices of crypto-assets across different exchanges. Since the advent of flash loans, users can now take advantage of massive liquidity to really profit on the price difference.
To help understand how this works, say ETH is priced at US$200 at exchange A, and US$200.02 at exchange B. This means that you would be able to buy ETH for $200 from exchange A, and sell it for $200.02 in exchange B, essentially making you a profit of $.02 per coin sold. By using flash loans, you can acquire thousands of coins thanks to the liquidity from the flash loans, and sell them immediately at the second exchange. This will multiply your profits a lot, potentially earning you thousands of dollars, for quite a little effort, and at a minimal cost.
Of course, in practice, the process of arbitrage involves routing transactions through multiple smart contracts and is not as simple as the example mentioned.
#2 Debt Refinancing
This is another commonly floated use case for flash loans. Flash loans will allow you to shift from a higher-cost loan to a lower-cost loan, all for almost no charge. Take the example of a loan you’ve currently availed an 8% loan from a debt protocol. You find out later that another protocol offers you the same loan for 6%. Usually, you will not be able to borrow the money directly from the second protocol (since the initial debt has a claim on your collateral), forcing you to look for other options. Here are the steps to switch from one protocol to the other:
- Borrow the flash loan
- Pay off the 8% loan
- Borrow the second loan at 6% protocol
- Pay off the flash loan in the same transaction.
This ensures that you save a lot of money, which would be otherwise wasted on interest payments for a small fee set by the loan provider.
There have been certain “attacks” by a group of people wiping off close to US$954,000 from the lending platform Bzx. However, these can hardly be called “attacks” or “hacks” since the “hackers” didn’t break any of the rules, but exploited some vulnerabilities in the system.
At the end of the day, these flash loans prove to be extremely useful to the DeFi ecosystem, as they act as the market makers and ultimately make prices of the assets equal across all platforms and exchanges.