This is the second blog in the flash loan series. Please follow the link to read the first part – What are Flash Loans?
In our earlier blog, we discussed the concept of flash loans, flash providers, and how to do flash loans on Aave without coding. Today, we’ll have a look at the use-cases of flash and understand the need for flash loans in the first place.
As of now, there are three major use-cases of flash loans – arbitrage, swapping collateral, and self-liquidation. In the coming months, we’re likely to see even more use-cases of flash loans considering the pace of innovations in the DeFi ecosystem. So, let’s have a look at these three use-cases.
Arbitrage can be defined as a process of buying any asset from one market or exchange to another in order to book a profit. For example, if BTC is being traded at different prices on two different exchanges such as Crypto.com and Bitvavo. Therefore, traders can book a profit by buying BTC at cheaper prices from one exchange, moving the funds to another exchange, and selling it at a high price almost immediately. It’s also worth noting that to make a profit in arbitrage, the trader needs to buy and sell large amounts of assets.
Now, in the above example, a trader will need to make multiple trades in order to book a profit. However, when it comes to DeFi, the trader can leverage a flash loan to bundle all these trades in a single transaction to save on transaction fees and maximize profit. For example, if a crypto asset such as Ethereum is being traded at $3000 on Uniswap, whereas it is being traded at $2990 on Sushiswap.
In this case, a trader can book a profit using a flash loan on Aave and combining all these trades in a single block of transactions such as:
- Borrowing Dai from Aave using a flash loan
- Swapping the Dai for Eth on Sushiswap
- Again, Swapping the Eth for Dai on Uniswap
- Repaying the loan including the 0.09% fee on the borrowed amount.
Another use-case of flash loans is collateral swapping. Flash loans allow users to swap collateral or debt in a single block of transaction. If you had borrowed Dai using Eth collateral, you can easily swap the collateral from Eth to BAT leveraging the flash loan. Now, let’s understand this through another example. If you had borrowed Dai by using an Eth collateral on MakerDAO, you could swap the collateral using a flash loan.
Considering the example above, here’s how the steps would look like:
- Take a Dai flash loan.
- Close the MakerDAO position by repaying Dai and unlocking the Eth collateral.
- Selling Eth for BAT on Uniswap or any other DEX.
- Opening the BAT collateral MakerDAO position and borrowing Dai.
- Closing the flash loan by repaying Dai.
Self-liquidation is another important use-case of flash loans that could help traders to avoid their position from being liquidated. Here’s how it works:
For example, if you had borrowed Dai using Eth as collateral from a DeFi lending protocol. Now, if the price of Eth keeps falling downwards raising the fear of your position getting liquidated.
In the above case, a user can follow these steps using a flash loan to avoid getting liquidated:
- Take a Dai flash loan
- Close your collateralized debt position using Dai
- Unlock your eth and swap it for Dai
- Close the flash loan position and keep the rest of Eth