Flash loans are smart contracts that create loans and pay them back with interest within a single Ethereum block. These funds are borrowed with no collateral because the transactions occur instantaneously. Thus, there is no need for collateral to enter a vault.
Flash loans are possible in DeFi because of the atomic nature of Ethereum transactions. Essentially, flash loans are feasible because for an Ethereum transaction to be successful, all parts of the transaction must be valid. Thus, if one part of the transaction fails, the entire transaction fails.
The most common protocols for flash loan lending are AAVE and dYdX. These protocols allow developers (receiving a flash loan requires a fair amount of technical skill) to code and execute contracts that request a flash loan. Loans can be worth millions of dollars.
There are three common use cases for flash loans: trading arbitrage, collateral swapping, and self-liquidation. This post will detail the benefits and risks associated with each use case.
Smart contract and platform risks will always be present in DeFi use cases, including flash loans.
The original and likely most profitable use of flash loans was to take advantage of different arbitrage opportunities across markets. Essentially, traders would take out a flash loan to borrow 100,000 DAI because they notice a price discrepancy between the Uniswap and Sushiswap DAI/USDC pools.
For example, on Uniswap, traders can swap .99 DAI for 1 USDC, and on Sushiswap, 1 DAI can be exchanged for 1 USDC. A clever trader would take advantage of this using a flash loan by taking out 1,000,000 DAI and swapping it on Uniswap for 1,010,101 USDC. Finally, they would convert the USDC back to DAI on Sushi to pay off the loan (keep in mind this all took place in the same transaction).
After the AAVE fee of 0.09% (other providers like dYdX do not take flash loan fees) is taken, the arbitrageur receives a profit of 1,101 DAI. Be aware that this example does not account for gas fees. Ethereum fees could negate the profit made in a flash loan transaction.
Flash loan arbitrage is an intricate way for traders to take advantage of market inefficiencies. Once developers discovered this opportunity, they began creating bots that could profit from these opportunities nearly instantaneously. Additionally, bots were made that could copy an arbitrage trade, but send more gas so that the bot transaction is approved and the trader’s transaction is not.
Capitalizing on arbitrage trades using flash loans is still possible, however, the use of bots has made the practice far more challenging.
There are situations where a trader may want their collateral posted in a different currency. A trader may have a loan backed by their ETH, but they prefer to have the collateral in a new currency such as LINK.
Collateral Swapping is a 5-step process:
- Borrow DAI using ETH as collateral
- Take a flash loan for DAI
- Repay loan from 1 using DAI borrowed in step 2 and receive ETH used as collateral
- Swap ETH received in the previous step for LINK and borrow DAI using LINK as collateral
- Repay flash loan using DAI borrowed in step 4
*Reminder that steps 2-5 are occurring within the same Ethereum block*
Once these steps are complete, the trader will have a DAI loan just as they did before, but instead of using ETH as collateral, they are using LINK. DeFi users may put this into practice if they are less bullish on the asset being used as collateral initially.
There are no-code required solutions for receiving flash loans for collateral swapping using DeFiSaver and Collateralswap.
Flash loans can come in handy when a borrower is at risk of getting liquidated because the price of their collateral asset is tanking, and they do not have the money required to pay back the loan. Taking a flash loan to self-liquidate may be a borrower’s best option in this scenario.
Let us say a borrower received DAI in exchange for ETH as collateral. And now, they are at risk of getting liquidated because the ETH price keeps dropping, and they do not have enough DAI available to repay the loan.
To self-liquidate, the borrower needs to take out a flash loan in DAI, pay off the original loan and receive the ETH collateral. Finally, they pay off the flash loan using the ETH.
Leave a Reply