What are Flash Loans in DeFi

Flash Loans in DeFi: A Comprehensive Guide

As the name suggests need to be executed in a flash i.e. instantly.

A feature on some DeFi protocols

Flash loans are instant, unsecured, uncollateralized cryptocurrency borrowing option designed for DeFi participants. Flash loans, as the name suggests need to be executed in a flash i.e. instantly. Generally, to borrow on decentralized platforms, just as in traditional finance, participants need to deposit collateralized assets like tokens or digital cash. Flash loans do away with collaterals.

This protocol was first introduced in 2018 by an open source bank known as Marble and is currently popularized and made possible by smart contract based lending platforms like AAVE (who has first mover advantage) and to a lesser extent DYDX and UniSwap.

Only condition is it must be repaid instantly

Technically, flash loans are recorded and therefore secured on a smart contract (so no rule can be changed). The entire transaction of lending and borrowing is recorded in a single smart contract. Participants have to borrow and repay the loaned out currency in the same transaction block. Since this is carried out on the Ethereum blockchain and a block on this chain takes 13 seconds to be validated, a borrower of flash loan has to return the borrowed amount in 13 seconds.

If the user is unsuccessful in repaying, the transactions will be deemed unsuccessful and the smart contract will instantly reverse the entire transaction. To elaborate further, in flash loans all the transactions are ‘atomic’ in nature which means they are short lived and based on principle of all or nothing.

The smart contract lays down the terms and conditions and performs instant trades on behalf of a participant using the lent currency. Typically, since the borrowing is for a very short time, the fee charged is very small. For example, Aave charges 0.09% as fee. By the end of 2021, Aave had issued flash loans worth approximately $5 billion.

Now let’s discuss the steps involved in a flash loan borrowing:

Step 1: The participant initiates a flash loan transaction and borrows, for instance, 1000 Basic Attention Token (BAT) from Aave lending pool

Step 2: The borrower then exchanges the BAT tokens for 6 Ethers on Uniswap

Step 3: Next, the participant then trades 5 Ethers for 1000 BAT tokens on DYDX platform

Step 4: Lastly, the borrower pays back the loan of 1000 BAT tokens along with the 0.09% fee charged by Aave

This full circle process of flash loans allowed the borrower in this illustration to make 1 Ether as profit. Note here that if and only if step 4 is fulfilled then the entire transaction is successful and is added to the Ethereum blockchain.

In the above instance, the participant noticed and exploited the price discrepancy on the two platforms and used flash loans to make instant profit. This process is almost free as the participants need no assets and are merely required to pay gas fees and a small commission.

Arbitrage Opportunities

Flash loans are building blocks of decentralized finance and has multiple use-cases. Only thing required for using flash loan is a web3 wallet. They are used largely for exploiting arbitrage opportunities. But are also used for swapping collateral and self-liquidating a DeFi loan.

The most prevalent use of flash loan is arbitrage trading, it allows participants on the chain to exploit price discrepancy of a currency across multiple platforms. For example: arbitragers can borrow money using flash loan to buy Ether on Uniswap and then sell it at a higher price on DYDX, booking a profit and then repaying the flash loan as explained in the above example.

Quick Check

Flash loans despite their raging popularity have its disadvantages, the malicious uses of flash loans have been observed on multiple occasions where hackers have misused contract vulnerability and robbed the participants of their hard earned money. For example two years back a lending protocol bZX faced two flash loan intrusions as a participant tricked a lender into believing that the loan had been reimbursed by manipulating the price of the stablecoin which was being used for loan repayment.

To conclude, many developers have been demanding removal of the flash loans offering altogether and some supporters believe it should be improved on but not removed completely as they believe devoid of flash loans, DeFi cannot technically call itself a self-driving bank. Flash loans are the force that influences most protocols, and decentralized world would not be the same without them.

For more such knowledge bytes please explore the various courses offered by 3.0 University.

Leave A Reply

Your email address will not be published. Required fields are marked *