Flash loans or atomic loans offer the perfect tool to profit from arbitrage and other opportunities. Although crypto flash loans can be difficult to implement, some platforms provide user-friendly interfaces and make the tools available to anyone. Here is a comprehensive guide on how flash loans work and how you can use them to your advantage.
KEY TAKEAWAYS
► Flash loans are uncollateralized loans in decentralized finance (DeFi) that must be borrowed and repaid within the same transaction.
► They allow users to perform operations like arbitrage trading, collateral swapping, debt refinancing, and saving on transaction fees.
► Flash loans have gained popularity because of their accessibility and potential for quick profits, but they require technical knowledge.
► Despite their innovative uses, flash loans can be used to carry out flash loan attacks.
What is a flash loan?
A flash loan is an uncollateralized loan you can take out that needs to be repaid within the same transaction. Decentralized finance (DeFi) protocols offer these types of loans.
Flash loans are also known as atomic loans. We consider transactions atomic If the sequence of operations that make up a transaction are indivisible or irreducible. The atomic transaction must meet all conditions before the blockchain records it.
Got something to say about flash loans or anything else? Write to us or join the discussion in our Telegram channel. You can also catch us on Tik Tok, Facebook, or Twitter.
Atomic loan origins
The Marble Protocol introduced the flash loan, or flash lending, in 2019, on the Ethereum blockchain. The innovation is like a “smart bank” that allows users to take out zero-risk loans through a smart contract.
Marble created flash lending to combat the two risks taken by traditional lenders. The most obvious one is when the borrower takes the money and disappears. The second risk for a lender is illiquidity.
If a lender lends too much of its assets at inappropriate times or fails to receive timely repayments, it could become unexpectedly insolvent and be unable to fulfill its obligations. Atomic loans mitigate both risks. These loans work in the following way:
- Receiving a loan for as much money as you need for a transaction
- Repaying the lender at least the amount lent by the end of the transaction
- If unable to pay the amount, the transaction is rolled back
Atomic loans, revert if you can’t successfully pay back the loan in the same transaction. That is why atomic loans are a low-risk, easy way to access liquidity. It’s also important to understand that they can only take place on a blockchain.
Features of flash loans
Most individuals who have interacted with a traditional financial system before must have an idea of how a loan works. A lender loans money to a borrower, after which the borrower repays in full. The borrower owes the lender interest, which the borrower repays.
An atomic loan is useful for traders who want to profit from arbitrage opportunities in two different markets that are pricing a cryptocurrency differently.
The atomic loan concept has no corresponding service in real life. Aave, an Ethereum lending platform, pioneered this idea in early 2020. Since atomic loans use smart contracts, they have these unique features:
- Unsecured loans
- Smart contract
- Instantaneous
Unsecured loan
Most lending protocols require borrowers to provide collateral to guarantee that the lender can still get their money back if the borrower is unable to repay the loan. An unsecured loan does not require collateral.
The flash loan lender won’t lose its money if there is no collateral. It is just returned in a different manner. The borrower must pay the money immediately and not offer collateral.
Smart contracts
Smart contracts create atomic loans. These are bits of code programmed on the blockchain. The rule for a loan is that the borrower must repay the loan before the transaction ends. Otherwise, smart contracts are designed to reverse the transaction.
Using a smart contract to initiate an atomic loan is absolutely required, as regular externally owned accounts (EOA), at least on Ethereum, cannot create more than one transaction at a time.
Instant
Obtaining a loan is a difficult task. A loan approval typically means that a borrower must repay the loan over several months or years. However, a crypto flash loan is immediate. The smart contract that authorizes the loan requires that the borrower uses and then pays back the loan in a single transaction.
This means that the borrower must use other smart contracts to execute instant trades with the loan capital before the transaction on the blockchain ends. This is often a matter of a few seconds.
How do atomic loans work?
Let’s take a closer look at how crypto flash loans work. The borrower requests a flash loan on a platform. To make it a profitable transaction, the borrower must devise a strategy for using the funds.
Usually, individuals use these loans to profit from arbitrage opportunities present on decentralized exchanges. Some of the most popular platforms to receive flash loans from are Aave, Balancer, and Uniswap.
After the DEX trading is performed, the borrower must pay back the loan within the same transaction. There may also be a service fee that the user pays to the lending platform. However, note that if the funds aren’t repaid within the same transaction the funds are returned to the lender, and the transaction is retracted.
In the example below, we observe an arbitrage event using the Aave platform for an atomic loan. As you can see, the user borrowed USDC (by swapping their WETH debt), which they repaid (USDC) at the end of the transaction.
In reality, an arbitrage trade using atomic loans has more steps, but we have simplified the transaction for our demonstration.
It’s important to understand that to make a profit from using flash loans, the person initiating the flash loan has to have a solid understanding of Solidity, Ethereum’s programming language.
Why did flash loans become popular?
Flash loans became popular rather quickly due to their nature, allowing borrowers to make a profit quickly. One of the most popular lending platforms, Aave, offers the option to take out flash loans fairly easily. Some insight from Aave’s creator, Stani Kulechov, may hint at why the DApp became so popular:
I come from a very, well, relatively democratic background. So, from the Nordics, from Finland, and in Finland it’s a very democratic country. So, there’s a lot of belief in open and transparent systems, and schooling, and everthing has to be equal.
Stani Kulechov, Aave creator: YouTube
Aave’s loans are available to anyone and fully transparent. It also has a low fee of 0.05%, which makes it extremely competitive compared to other platforms.
Aave flash loans
Aave is an open-source, non-custodial liquidity protocol that helps investors earn interest on their crypto deposits and borrow various assets. The Aave protocol is known for its options to earn passive income, allowing users to deposit liquidity to earn a passive income.
You must first deposit your preferred asset to begin using the Aave protocol. You will receive passive income from the market’s borrowing demand once you have made deposits. At the same time, you can also borrow against your assets by depositing assets.
However, what’s attracting many new investors to Aave is its flash loan offer, which has many advantages over traditional loans.
How to get a flash loan
To get a flash loan in crypto on Aave, you require some coding skills. You might want to check out the flash loan documentation provided by Aave.
However, there are also user interfaces like that provided by Furucombo. This lets you use crypto flash loans without coding skills. You can set up a flash loan using the Furucombo interface. Here is an example:
- Connect your wallet to Furucombo
- Create a cube (Create > New Cube > Uniswap Swap Token) and select the token to swap (you need to know the price discrepancy to decide which tokens to swap. It can be any DEX.) Click Set after you choose the swap and the amount.
- Create a cube (New Cube > 1Inch Swap Token). Select the opposite trade to the one you made in the first cube to get the same token back. You will need it to repay the flash loan. Click Set when all the details are set.
- Create a cube (New Cube > Aave Flashloan) and select the same token and amount you used to start the trade at the first cube. Click Set. You will get two boxes and will need to move the first one on top of the other boxes. The first transaction is the one to borrow the funds, and the last transaction is to repay the loan and the 0.09% interest.
- Click Approve and approve the transaction from your wallet.
- Click Confirm and confirm the transaction from your wallet.
The entire flash loan through Furucombo should look like this:
Flash loan use cases
We’ve talked about the many upsides of flash lending. But there are a bunch of flash loan use cases that can provide benefits to investors. These are the most important use cases:
- Collateral swapping
- Arbitrage trading
- Saving transaction fees
- Debt refinancing
Collateral swapping
DeFi users can also use collateral exchanges to obtain loans through multi-collateral lending applications. If you have taken out a DAI loan from Compound and deposited ETH as collateral, you will need to trade the ETH collateral for DAI collateral via a DAI flash loan. This will balance the amount of the DAI you borrowed.
Arbitrage trading
Another interesting use of flash loans transactions is arbitrage. Crypto investors have many opportunities to make money from the price discrepancies between different markets. Crypto arbitrage is the process of performing trades on one or two different exchanges to make a profit.
Flash loan arbitrage is buying coins at lower prices and then selling them on another exchange at higher prices. They could also make quick profits and pay back the loan quickly. Effective arbitrage could be achieved by executing all transactions within a short time frame.
Savings transaction fee
Flash loan allows aggregating a list of complex transactions in one step. This is an improvement on traditional transactions, where implementing the flash loan concept would have required multiple steps. Flash loan transactions can be accessed with a minimal transaction fee. Flash loans can serve traders to purchase and sell digital tokens or coins.
Debt refinancing
When we think about loans, there is an interest rate associated with them. Investors can use flash loans not only for collateral swapping, but to swap the attached interest rate. Aave has an entire post dedicated to flash loans use cases. Here, debt refinancing is clearly described.
For instance, you can borrow funds from Aave’s liquidity pools. Then, you can pay the debt back on Compound and withdraw collateral from Compound. You can deposit the collateral on dYdX, and you can mint debt on dYdX, before returning the liquidity on Aave.
Flash loan attacks: what are they?
As with any technology, flash loan smart contracts come with some drawbacks, which are known as flash loan attacks. Because collateral is not necessary and the lending protocol entirely relies on smart contracts to ensure that you pay back the loan, what happens if that software begins to behave in a way that is unintended?
This might sound like an extreme and unlikely situation, but we have some examples of past flash loan attacks. In Jun. 2020, flash loans were used to exploit Balancer Pools, which resulted in a $500k wETH loss.
In Apr. 2021, $24 million was extracted from the xToken platform with the help of flash loans. Other flash loan exploits involve market manipulation by borrowing the same assets from multiple lending platforms and exploiting specific protocols and tokens.
What is the future of flash loans?
The flash loan concept is still in its infancy, and we will likely see it used for innovative purposes in the future. However, there are still many risks associated with flash loans, and some platforms have decided to act against them. For instance, some may use them to borrow specific tokens to participate in governance voting.
However, the benefit of using flash loans is bringing new investors into the market. With the development of ever more secure protocols, they have the potential for market efficiency and give everyone money for free.
Frequently asked questions
What is a flash loan exploit?
Do flash loans still work?
Do you need collateral for a flash loan?
Disclaimer
In line with the Trust Project guidelines, the educational content on this website is offered in good faith and for general information purposes only. BeInCrypto prioritizes providing high-quality information, taking the time to research and create informative content for readers. While partners may reward the company with commissions for placements in articles, these commissions do not influence the unbiased, honest, and helpful content creation process. Any action taken by the reader based on this information is strictly at their own risk. Please note that our Terms and Conditions, Privacy Policy, and Disclaimers have been updated.