Cryptocurrencies have received some of the most significant fanfare of any innovation in recent history. One of the attractions of this invention is decentralization, the possibility of entirely trustless but highly advanced applications.
There’s been increasing dissatisfaction with the legacy financial infrastructure. Thanks to blockchain technology, cryptocurrencies are turning many traditionally centralized operations on their head.
Want an exchange using no order books, incentivizing users to provide liquidity and not ask you for your private data? We have DEXs (decentralized exchanges) for that. Want to borrow funds using your crypto holdings without any credit checks or filling in lengthy paperwork? We have decentralized lending services for that.
Arguably, we see the most innovation within the DeFi (decentralized finance) space. Developers have upped the ante with the addition of flash loans.
To the layman, it sounds outlandish; anyone can receive an instant unsecured loan that needs to be paid back immediately. Funny enough, flash loans achieve this very premise with, of course, some caveats.
So, let’s explore more about this unusual yet fascinating sphere of DeFi.
What is a flash loan?
As the name suggests, a flash loan is an innovative form of uncollateralized lending mechanism with instant settlement. Marble, the open-source, Ethereum-based bank, was the first to introduce flash loans in 2018.
Flash loans allow one to borrow instantly and effortlessly without providing any collateral (but with payable interest).
In the world of credit, a loan is typically secured or unsecured. Most traditional lending is unsecured, though the funding financial institution provides rigorous creditworthiness and personal checks to assess your likelihood to default.
Of course, a secured loan is less risky from the lender’s perspective since they take possession of a valuable asset which they can sell later should the borrower fail to repay.
Fortunately, flash loans fall in the former bracket, but with a catch: you must return the loan within the same transaction.
How do flash loans work?
Flash loans work primarily on the Ethereum network or platforms using Ethereum-based tokens. They utilize smart contracts on the blockchain offered by Aave, Maker, Compound, and many other platforms.
The smart contract is just pieces of code executing an operation once certain conditions have been fulfilled. A flash loan consists of three parts, receiving the credit, utilizing the credit, and repaying the loan.
Presently, you pay a 0.09% fee for this facility. Most may be confused about how all this activity occurs ‘within a flash’ where users are supposed to repay the loan within the time it takes for Ethereum to form a new block (around 15 seconds).
This structure boils down to the blockchain’s atomicity or, put simply, its ability to execute the entire transaction or no part of it. So, if you fail to pay back, the deal is reversed, and the funds are returned to the lending platform.
Amazingly, smart contract technology effectively doesn’t move the funds until they’ve been paid back. It is the primary reason why flash loans don’t require any collateral. As we can tell, flash loans are unconventional and not meant for long-term, off-chain activities as with traditional lending.
The main purposes of flash loans
The most prevalent use for flash loans is arbitrage, though we’ll also briefly cover the other common use cases.
- Arbitrage: Arbitrage is where traders exploit price discrepancies between two exact markets by buying and selling them concurrently for a quick profit.
As expected, this practice is only for the most skilled arbitrageurs who understand the risks, trade with large volumes of money, and find a way to profit despite the razor-thin margins.
Let’s look at a simplified example (disregarding fees, slippage, interest, etc.) of how you can use a flash loan for arbitrage. Assume you saw a coin priced at $200 on one exchange (let’s call it DEX 1) and $200.60 at another (DEX 2).
One may buy ten tokens of the cryptocurrency from DEX 1 and resell them immediately to DEX 2 for a $60 total profit ($260 – $200). The gains would be amplified if you could buy hundreds or thousands of the tokens.
- Collateral swaps: This refers to a collateralized position a borrower
can replace with another borrowed asset. Such activity occurs across two different platforms and is used primarily for liquidation purposes.
Conventional crypto lending services employ a price volatility liquidation mechanism to their loans, a target at which they liquidate the borrowed assets once their value depreciates beyond a particular point.
Typically, users will close their initial loan with borrowed funds and open a new collateralized position with another asset. For instance, let’s assume someone uses ‘crypto 1’ as collateral for a loan on ‘DEX 1’ but fears its value will drop eventually.
They can exchange the collateral through another token from the same platform to prevent liquidation with a flash loan.
- Loan refinancing: This practice takes advantage of interest rates through an active loan between different lending platforms. This technique is popular on Maker and works with its stablecoin, DAI.
Let’s use a simple example of a scenario where you borrow DAI and lock ETH as security. We should note standard crypto loans are over-collateralized, meaning you deposit more as collateral than the value of the credit you’ll eventually receive.
For your ETH collateral, let’s assume you got a loan of 50 DAI, leading to a $50 net position (as stablecoins are priced on a 1:1 basis on average). However, at some point during the loan, you see a better interest rate on Aave.
Rather than repaying the Maker loan, users can ‘flash-borrow’ 50 DAI on Maker, close out their position there to receive their ETH back. With the ETH, they can deposit this into Aave and use the newly acquired DAI to pay back Maker’s DAI.
Of course, all these examples have been simplified to illustrate the diverse applications of flash loans without considering all the nitty-gritties regarding fees and other price anomalies.
Final word
Sadly, like any new invention, flash loans have made the headlines for bad reasons as criminals have exploited some of their vulnerabilities, siphoning millions of dollars in the process.
Flash loans offer threat actors the ability to borrow substantial amounts of money with no upfront capital, relatively low risk, and potentially high rewards. As recently as May 2021, a flash loan attack occurred on PancakeBunny, a yield farming aggregator.
An attacker borrowed large amounts of the BNB (Binance Coin) token through PancakeSwap, a DEX. Their purpose was to manipulate the USDT/BNB and BUNNY/BNB markets, causing a flash crash of sorts which drove prices down by more than 95%.
It’s reported the perpetrator walked away with $3 million in profits. It’s fair to assume flash loans require experienced traders who understand their complexities. Nonetheless, they are an intriguing addition to the ever-increasing DeFi stack.