When you want to take a traditional loan, you need to provide lots of information such as proof of reserves, income, etc. What about flash loans? Actually, they wouldn’t be that flash if they asked for so many personal details.
How did that become possible to take such loans and how do they work? That’s a really interesting thing to learn about, so let’s go deeper.
What Is at the Core?
A flash loan doesn’t have a long history but it definitely became popular across much decentralized finance (DeFi) platforms that are based on the Ethereum network.
These types of loans have been in many financial scandals recently because they were used to exploit a number of vulnerable DeFi protocols, leading to millions of dollars in losses. Despite that, many people consider such loans introduce an innovative and helpful way of having quick trades that weren’t possible before blockchains.
Everybody knows how normal loans can be got. A lender gives money to a borrower to be paid back in full and with an interest.
Flash loans are something alike, but no wonder they still have their unique features we must reveal:
- Smart contracts
Flash loans run on smart contracts, that are enabled by a blockchain, so the transaction won’t be processed once certain prearranged terms aren’t met. Speaking of a flash loan, the main term is that the borrower must pay back the loan before the transaction finishes, otherwise the smart contract overturns the transaction – as if the loan never existed in the first place.
- Unsecured loan
Often lenders ask borrowers to set up some guarantee (or collateral) to ensure that in case the borrower can't give the loan back, the lender can get their money back anyway. Unsecured loan doesn't need any collateral at all. It doesn't mean the flash loan lender can't get their money back. It means that instead of offering collateral, the borrower needs to pay back the money immediately.
Getting a usual loan is a long process. Once a borrower is approved for a loan, they have to pay it back continuously over a period of months or years. On the contrary, a flash loan is instant. The smart contract for the loan must be executed in the same transaction that it is given away. This means the borrower has to request other smart contracts to accomplish instant trades with the loaned money before the transaction ends, which is usually a few seconds.
Such loans could be pretty helpful for traders looking to quickly profit from arbitrage opportunities when two markets have different prices for a particular cryptocurrency.
Aave's first platform to adopt flash loans, which introduced a new feature in early 2020. They declared that there is no such thing as a flash loan in the real world.
How Can Flash Loans Be Used?
Traders can profit from flash loans by monitoring price differences across a number of various exchanges. Imagine two markets are pricing DOGE differently. It's priced at $0.5 on Exchange I and $1 on Exchange II. A trader uses a flash loan and calls a separate smart contract to buy 100 DOGE coins for $100 at Exchange I, then sell them for $200 at Exchange II. The borrower gives the loan back and saves the difference.
- Flash swaps
Quickly swapping the collateral sponsored the user's loan for another collateral. If you have borrowed Tether from an exchange followed by pledging Ethereum as collateral, then you need to exchange the ETH collateral for Tether collateral through a Tether flash loan for offsetting the borrowed Tether.
For instance, Uniswap allows users to get Ethereum-based tokens paired with other tokens, do whatever they need, and then give them the equivalent amount back.
- Lower fees
Basically, flash loans wrap up several transactions fees into one. Each transaction has a fee so flash loans mean lower fees.
- Debt refinancing
They can also be used for “interest rate swaps.” Aave has an example of that in their blog:
- Borrow assets from Aave liquidity
- Return the debt on Compound
- Take collateral from Compound
- Deposit collateral on Dydx
- Mint debt on Dydx
- Give liquidity back to Aave
A trader can profit from other platforms with the help of flash loans. They need to pay off the interest rate on the original loan, let’s say, 10%, and borrow 5% from the second loan at the cheaper lending platform. By paying back the flash loan, a trader ends up having the loan with a better interest rate.
Is It secure?
Flash loans are comparably new technology, and it’s still sensitive to attacks by hackers and malicious users who try to trick the system and use gain profit.
In a flash loan attack, a borrower can trick the lender into believing that the loan was totally repaid, even if it is not.
Mainly, the fraudster pretends to be a borrower and takes out a flash loan from a lending platform. The platform is then used to manipulate the market and cheat lenders. Sometimes, attackers create arbitrage opportunities to exploit vulnerable smart contracts. In that case, the attackers can buy tokens for cheap or sell them at higher prices to manipulate contracts.
Tips to Prevent the Attacks
- Use decentralized oracles for price data
You can reduce the attack simply by using decentralized pricing oracles like Chainklink instead of depending on a singular DEX.
- Use flash loan attack detection tools
OpenZeppelin launched a program OpenZeppelin Defender that helps project managers to detect smart contract unusual activity, which allows them to respond right away and reveal the attacks.
- Make transactions go through two blocks
Force a flash loan to go through two blocks instead of one. It’s not 100% medicine but it can be pretty helpful.
Flash loans are still young and unknown. They have some downsides, such as being a real treat for attackers, and they’re still presented on a few platforms. They aren't that simple to understand, as well.
It seems flash loans could be an additional source of passive income once you’re good at making quick decisions and counting. The field is growing and developing despite all the attacks and serious money loss, but you should be fully armed if you want to gain money using flash loans as a tool.