When we talk about the improvements that decentralized finance (DeFi) offers over traditional finance, we don’t talk enough about flash loans.
Flash loans are special DeFi transactions that allow anyone to borrow funds without collateral as long as they repay the borrowed sum before within the same block time.
The instant execution, high leverage, composability across DeFi apps, and zero collateral requirement offered by flash loans introduce arbitrage trading opportunities to retail investors— something that is difficult to execute in the world of traditional finance.
In this article, we explain how flash loans are used to profit from arbitrage trading opportunities.
Key Takeaway
- Flash loans are special DeFi transactions that allow anyone to borrow funds without collateral.
- Flash loans offer instant execution, high leverage, DeFi composability, and zero collateral requirement, which introduces arbitrage trading opportunities to retail investors.
- Arbitrage opportunities typically last only for a few seconds and are generally minute in size.
- Flash loans are advanced DeFi tools and are designed for developers.
- To access the liquidity pool of flash loan providers, you will need to set up a smart contract that interacts with flash loan protocols.
What Is Flash Loan Arbitrage?
Flash loan arbitrage refers to the use of instant zero-collateral crypto loans to profit from price discrepancies for the same asset across different crypto exchanges.
A key advantage of flash loans is that if a flash loan transaction is unsuccessful (due to lack of balance or approval), the transaction is reverted.
According to crypto flash loan protocol Aave (AAVE), flash loans are designed for developers.
If you do not know how to code, you can learn how to create smart contracts using no-code tools. Other options include hiring a developer or using flash loan arbitrage bots.
How to Use Flash Loans for Arbitrage?
Flash loans are advanced strategies that are only suitable for traders with a good understanding of concepts such as smart contracts and programming.
In order to access the liquidity pool of flash loan providers such as Aave v2 and v3, you will need to set up a smart contract that interacts with Aave’s flash loan protocol.
Note that Aave v2 charges a flash loan fee of 0.07% while Aave v3 charges 0.05%.
On Aave v3, users have two options:
- flashLoan (): This function allows users to access liquidity across multiple reserves on Aave in a single transaction.
- flashLoanSimple (): This function allows users to access the liquidity of a single reserve pool.
Here is a simplified example of how a flash loan smart contract executes arbitrage trading:
- Your smart contract can use either flashLoan () or flashLoanSimple () to request a flash loan for a specified amount.
- After verification, the Aave pool will transfer the requested amount to your smart contract.
- Thereafter, the executeOperation () function in your smart contract will execute custom logic that defines your arbitrage operation (Eg. buy 10,000 ETH on Uniswap and sell it on SushiSwap).
- Next, you approve the repayment of the flash loan plus fee.
- The entire process is carried out in one transaction. If a flash loan transaction is unsuccessful, the entire transaction is reverted.
How to Make Money With Flash Loans?
Here is a step-by-step example of how to make money using flash loans for arbitrage trading.
Identifying Price Discrepancies
You use arbitrage software and tools that allow you to monitor prices on various markets and detect arbitrage opportunities. Let’s say you find DOGE trading at $0.5 on Uniswap and at $0.6 on SushiSwap.
Flash Loan Initiation
Using a smart contract or flash loan arbitrage bot you initiate a flash loan where you borrow $500K USDC stablecoins.
Buying Low
As coded, your flash loan smart contract will buy $500K worth of DOGE at $0.5 from Uniswap totaling 1 million DOGE tokens.
Selling High
Your flash loan smart contract will immediately sell the 1 million DOGE tokens at $0.6 per token on SushiSwap, netting you a profit before the expense of $100K.
Repaying Loan
You approve the repayment of the flash loan and fee. Aave v3 charges a fee of 0.05% on the loan amount, which equals $25,000 in this case. You repay $525K and pocket the remaining $75K as your net profit.
Making Money Using Flash Loans by Liquidating Loans
You can also make money using flash loans by liquidating loans.
Decentralized crypto lending protocols incentivize third-party market participants to liquidate unhealthy loans by paying off the loan on behalf of the borrower.
When the market value of a loan collateral drops below a certain threshold, crypto lending protocols allow third-parties to purchase the collateral and liquidate the loan.
Liquidators are incentivized to do so as they receive the opportunity to buy the collateral at a discounted price. They also receive a fee called a “liquidation bonus.”
Liquidators leverage the access to large amounts of capital provided by flash loans to execute the liquidation of unhealthy loans.
The Bottom Line
Flash loans are special DeFi tools that do not have a counterpart in the world of traditional finance. What’s special about flash loans is that they are permissionless, meaning that anyone can access these tools for their benefit.
Having said that, flash loans have also earned a notorious reputation for their use in funding attacks on DeFi protocols.