What is flash loan and how does it work in DeFi?

TrippleCard
3 min readMar 23, 2023

--

Flash loans are a type of loan where no collateral is required, which means that the borrower doesn’t have to provide any personal assets as security. These loans involve borrowing crypto assets that are then returned in a single, instant transaction. Although AAVE, a DeFi protocol, introduced this feature in 2020, it has been adopted and improved by various other DeFi projects. While there are still some issues to be resolved, as they are a relatively new option in the crypto industry, flash loans are an exciting development.

A flash loan is a loan that capitalizes on the price discrepancies between different crypto protocols. For instance, if exchange X sells a particular token for $100 while exchange Y sells the same token for $101, a trader could buy the token from exchange X and sell it on exchange Y, earning a profit of $1. While this might seem insignificant, when scaled up, the profit could be substantial. However, accessing the initial capital required to purchase the tokens can be a challenge.

This is where flash loans come in. They are custom-made smart contracts that allow anyone to identify an arbitrage opportunity and create a loan to exploit it on a large scale. Flash loans facilitate instant loans based on specific trading conditions. If the terms of the contract do not guarantee immediate repayment with interest, the agreement will not execute.

What sets flash loans apart is that they are not based on the borrower’s profile, documents, or collateral, unlike traditional finance and some DeFi loans. Instead, the loan is granted based on the borrower’s ability to demonstrate an immediate yield from the transaction, as per the smart contract they have created.

When discussing flash loans, we are essentially referring to a smart contract. Each flash loan represents a customized smart contract that specifies that X should be executed if Y occurs. In the case of flash loans, the smart contract functions in the following manner:

If X+10 can be repaid within seconds, which is dependent on the specific details of the arbitrage opportunity, then X can be borrowed immediately.
Thus, to receive a flash loan, you must identify a price disparity and quickly write a contract to match it before the gap disappears.

While flash loans may possess some similarities with traditional loans, they also exhibit specific characteristics that distinguish them from other loan types:
Zero collateral — In traditional loan systems, borrowers are typically required to provide collateral as security before receiving a loan. However, flash loans do not necessitate collateral, as the agreement will only be executed if immediate repayment with interest can be ensured.

Instantaneous transactions — Flash loans are completed and repaid within seconds to capitalize on rapidly changing price movements, thereby enabling immediate execution.

Application of smart contracts — Flash loans rely on smart contracts to oversee the transaction and guarantee that the loan is reimbursed prior to finalizing the transaction.

Risks and limitations

One of the most interesting aspects of the technology is the autonomy provided by flash loans, which allows you to create your own bespoke loan contract. However, the ease of automation also makes it a fertile environment for bots. Some bots scour the DeFi landscape for arbitrage opportunities, capturing them promptly. Automated systems absorb many money-making opportunities, leaving little chance for ordinary traders.

As with any new technology, opportunists are constantly seeking ways to manipulate flash loans for their gain. Flash loans are discovering more imaginative ways to take advantage of vulnerabilities in lending protocols. Since vulnerabilities in protocols are common, the ability of flash loans to exploit them on a grand scale makes them an excellent instrument for vigilant hackers. These sorts of scams will probably dwindle as the sector becomes aware of these new attack vectors, but for the time being, they are a fairly well-known drawback of flash loans.

Originally this post was published on Tripple Card blog

--

--