Flash Loans are one of the most useful Decentralized Finance (DeFi) building pieces since they allow users to borrow crypto assets from a defined smart contract pool without putting up any collateral.
What are Flash Loans?
A flash loan must be borrowed and repaid in the same Ethereum blockchain transaction.
The Marble Protocol pioneered the concept of Flash Lending, which allows users to borrow Ether and ERC-20 tokens on Ethereum and profit from arbitrage chances.
The goal was to allow a trader to borrow money from the Marble bank in order to buy a token on one DEX and then sell it for a higher price on another DEX. The borrower would then repay the bank and profit from the arbitrage — all in one atomic transaction.
Aave and DyDx protocols of DeFi later popularized Flash Loans.
Flash loans can be utilized for switching collateral and self-liquidation in addition to grabbing arbitrage opportunities.
Flash Loans vs Traditional Loans
In the classical sense, there are two types of loans: secured and unsecured.
Unsecured loans having no collateral (an asset that a lender might seize if a borrower fails to repay the loan), and are thus seen as a higher risk by lenders.
Secured loans, on the other hand, require the borrower to put up collateral.
Unsecured crypto loans (without collateral) are repaid instantly in the same transaction using Flash Loans.
How flash loans works
On Ethereum, a transaction is a collection of activities that must be completed in a single step.
It either signifies that all of the activities in a transaction were completed successfully or that the entire transaction was rolled back. There is no such thing as a middle ground in this situation.
All basic Ethereum actions, such as transmitting ETH or ERC-20 tokens and dealing with smart contracts, are carried out within a transaction scope.
Multiple stages can be found in transactions bundled and included in Ethereum blocks. So, what precisely are these steps?
Let's imagine you want to use Compound to deliver ETH and DAI. In one single Ethereum transaction, you can also swap half of the DAI you just borrowed for USDC on Curve and offer liquidity to the DAI/USDC liquidity pool on Uniswap.
If any of these steps fails, the entire transaction will be rolled back, and none of the stages will take place.
So, how do you go about getting a quick loan?
First and foremost, you must locate a quick loan supplier.
Smart contracts have been built by DeFi projects such as Aave and DyDx that allow users to borrow various assets from a predefined pool for a predetermined fee. The only requirement is that they be reimbursed in the same Ethereum transaction.
For example, Aave asks borrowers to repay the borrowed amount plus 0.09 percent of the total borrowed amount in fees.
By integrating Aave's flash loan API, this cost is divided between lenders and the platform that facilitates the flash loan. A portion of this fee is converted to Aave tokens and then burned.
The possibility of borrowers not repaying their borrowed amount is eliminated because the loan must be repaid in a single Ethereum transaction.
Why flash loans are important
There are three main applications for flash loans:
1. Arbitrage opportunities
If two Decentralized Exchanges (DEX) have different prices, flash loans can assist borrowers increase their profits by taking advantage of a successful arbitrage opportunity.
2. Collateral swap
A collateral swap is another application for flash loans. You can swap your collateral from ETH to another ERC-20 token like BAT if you borrowed DAI from Compound with ETH as collateral.
3. Self-liquidation
When the value of your collateral falls below a certain threshold and you're on the verge of liquidation, self-liquidation can help.
Let's imagine you borrowed DAI from Compound in exchange for your ETH. You're getting closer to the liquidation level as the price of ETH falls.
Consider a scenario in which you are unable to deposit additional collateral to enhance your liquidation level, and you also lack the DAI required to repay the loan.
In that instance, you may get a quick loan from, say, Aave. You must borrow the amount of DAI that you owe in order to return Compound and withdraw your ETH.
You may then use Uniswap to convert the ETH to DAI to repay the flash loan plus costs.
Although flash loans are a relatively new concept in the world of uncollateralized loans, they undoubtedly open up new possibilities in this new decentralized finance ecosystem.