Research Summary: Towards A first step to understand flash loan and its application in Defi Ecosystem

TLDR

  • The researchers explore what flash loans are, how they work, which platforms provide this service, and their overall impact to the defi ecosystem.
  • They identify four major applications (arbitrage, wash trading, flash liquidation, and collateral swap) by studying over 76,000 transcations.
  • Flash loans open up opportunities for financial activities that were previously unavailable without access to large amounts of capital. They are growing in popularity.

Core Research Question

What is a flash loan and what are its applications?

Citation

Dabao Wang, Siwei Wu, Ziling Lin, Lei Wu1, Xingliang Yuan, Yajin Zhou, Haoyu Wang, and Kui Ren https://yajin.org/papers/flashloan.pdf

Background

Lending Platform: A platform (usually in the DeFi ecosystem) that allows depositors to lock their capital (“collateral”) to borrow assets.

Collateralization Ratio: The minimal ratio of collateral value to the value of the debt borrowed, which once reached will trigger the lending platform to sell the collateral and clear the loan (“liquidate”).

Flash Loan: A new functionality that enables loan borrowing without collateral, allowing users to take out huge loans they wouldn’t otherwise be able to have without sufficient collateral, so long as they return the funds within a single transaction.

Transaction: In the paper, a transaction unless noted otherwise refers to an external transaction, which is an action invoked by accounts controlled by private keys (“Externally Owned Accounts (EOA)”), and will contribute to a state change on the Ethereum blockchain. EOAs are different than accounts that are governed by smart contracts as they are controlled by user actions.

Arbitrage: Taking advantage of price differences between markets by buying low from one place and selling high in another.

Wash Trading: Trading to create artificial activity with the intention to lead people to perceive a platform or asset as more popular that it actually is. This controversial behavior is widely banned in traditional markets.

Flash Liquidation: A liquidation backed by flash loans. Once a loan reaches its collateral ratio, the collateral becomes available for anyone (“liquidator”) with capital to trade in via a fixed discount or by auction (“liquidation”).

Collateral Swap: To avoid liquidation at severe price changes, the loan taker redeems the collateral from the old loan and opens a new position with a different asset.

Summary

Flash loans revolutionize a specific type of loan-taking by locking an entire lend-and-borrow workflow within a single transaction.

First, flash loan providers transfer requested assets to users. Then they invoke users’ pre-designed operations. Users interact with other contracts to execute operations with borrowed assets. Once the execution is completed, users return the borrowed assets with or without the extra fee charged by flash loan providers. Finally, flash loan providers will check their balance. If they discover that no or non-sufficient assets are returned by users, they will revert the transaction immediately.

The figure below (Figure 1) shows the workflow of a Flash Loan transaction.

The authors design three patterns to identify flash loan transactions. Based on the patterns identified, 76,303 transactions were found within the Ethereum ledger. The numbers suggest that flash loan services are becoming increasingly popular over time.

Flash loans can be applied to other purposes such as arbitrage, wash trading, flash liquidation and collateral swap.
Malicious users may capitalize on flash loans function to launch operations with large amounts of assets that they do not have.

Method

The researchers use both qualitative and quantitative methods to explore the nature of flash loans and their applications.

They consult existing literature on flash loans generally and specifically to the Aave, dYdX and Uniswap V2 platforms to study the nature of flash loans and to identify flash loan transactions.
Under the quantitative approach, the researchers collected over 1,000,000,000 transactions from the Ethereum blockchain ledger, identified flash loan transactions by the patterns found qualitatively, and conducted a time series analysis to understand the application’s popularity.

Results

The research identified over 76,303 Flash Loan transactions and 1,454 receivers; their distribution among Flash Load providers is detailed in table 1.

They’ve also quantified how popular flash loans have become over time.

Arbitrage opportunities are enabled by flash loans because they allow users to take on price differences without pre-owning collateral.

Wash trading, used to create trading volume, requries huge amounts of capital, and are enabled by flash loans taken out to contribute to this activity.

Flash liquidation enables people without capital to seek profit by buying undercollateralized assets at discount.
Collateral swaps powered by flash loans would solve users’ need for swapping by providing capital for them to pay back their loan and swap collateral.

Discussion and Key Takeaways

Flash Loans: The research sheds a light on the function of flash loans and their application using real world examples.
Malicious operation: The research identifies potential manipulation that can occur during flash loans transactions and proposes future research on it.
Applications: Flash loans can be applied to arbitrage, wash trading, flash liquidation and collateral swap.

Implications and Follow-ups

The researchers suggest two potential research directions: arbitration and DeFi attacks. Flash loans have enabled arbitration bots, which take on price differences in a timely manner to maximize profits. DeFi attacks are proliferating. Effective countering strategies are an open question. These attacks are sometimes powered by flash loans.

Applicability

  • Flash loans enable financial activities that were before not possible without large amounts of capital. They are a double-edged sword in this ecosystem and should be studied carefully.
  • The research could be useful to DeFi operators. Anyone transacting with DeFi can use this research to understand the what a flash loan is, the problems associated with them, and how best to overcome them.
8 Likes

@Samuel94 thanks so much for contributing this summary – I’m curious, what are the positive applications for a flash loan? Are there constructive things that one could do having a million dollars for a microsecond?

3 Likes

Flash Loan functionality will be very useful for small medium enterprise and startups that require loan to establish their business ideas with little or no collateral most especially in the developing countries

5 Likes

Would having a loan for a moment be much use though? I thought a flash loan was a single transaction worth of value. I guess there could be legitimate uses of flash loans like in defending a DAO from a governance attack or punishing a sandwich attacker. Do you have any other suggestions for potential use cases? I’m sure I’m missing something big and obvious.

2 Likes

Flash loan plays an important role or aids arbitrage traders. So for instance, where two trading platforms offer different prices for same token, the instantaneous nature of flashloan could aid a trader access loan to sell in one platform and purchase in another platform thereby taking advantage of low and high prices in the different platforms.

2 Likes

@Samuel94 on balance do you think that the crypto community should take steps to counter flash loan based arbitrage? Or do you see them as a vital part of the ecosystem? They definitely seem to help make sure that oracles are accurate.

3 Likes

Good summary here Samuel. I was excited reading and learning about flash loan for the first time.

As someone who has used a borrowing platform to borrow crypto fund for trading, I was curious about a lot of things on flash loan. Specifically, I wanted to understand the differences between flash loan and the traditional borrowing in DeFi. Here are my findings:

  1. Flash loan has four specific end use for any user intending to maximise it. You could either use the loaned fund for arbitrage, flash liquidation, wash trading or collateral swap. But traditional DeFi borrowed funds could be used for staking, spot trading, etc.

  2. Flash loans are executed using smart contracts where all intended actions have been written to be performed by the contract once it has been executed. But traditional borrowing on DeFi is done manually by pressing buttons on DeFi platforms. In otherwords, the actions are not automatic.

  3. Flash loan providers might or might not charge transaction fees. Flash loan does not also require a collateral, but DeFi traditional borrowing comes with both collateral and transaction fees charged by the loan providers.

  4. Flash loan, like the name implies, begins and gets completed in one single transaction executed by a smart contract, but Traditional DeFi loans involves series of actions that could last as long as the borrower can afford or the initial time fixed for termination before borrowing.

PS: I am intrigued that Compound (Aave) charges a transaction fee of 0.25% , Uniswap charges 0.3%, but dydx charges nothing for flash loans. What then incentivizes dydx to operate the flash loan function?

3 Likes

Thank you Mathew for taking time to read my summary and doing further research on it.

For your question, I will start with a premise that the essence of Flash loan is to reduce fees payable in borrowing or lending money. dYdX embodies this feature. It doesn’t charge gas fee for facilitating the transaction but requires bortowers to return the borrowed amount in addition to 2wei. The 2wei that accompanies the borrowed sum is their gain or profit.

Let me know if i answered you question

3 Likes

Thank you @Samuel94. This, sure, answers my question.

1 Like

Great and well-detailed summary Samuel.

I first read about flash loans from an email I got from Luke Willis, of Koinos blockchain.

He talked about how users can initiate loan transactions worth millions of dollars with zero collateral to do anything they please, so long as they return the loan in the same transaction.

The concept went over my head a little then even though he used a trading and arbitrage analogy, but I get it now.

I for one think flash loans are a great feature in DeFi. It would definitely provide more unbanked people with financial services and ease.

However, just like you said, they are double edged swords. The possibility of malicious actors getting into the transactions and stealing funds remains.

So our focus going forward should also be on security measures and minimizing losses.

4 Likes

You are on point. Attack on flash loan seems to be the worst in DeFi ecosystem

2 Likes

Thank you @Samuel94 for this take on Flash Loan. It’s my first time of learning about it and I am excited I did.

Just as you said, it’s a double-edged sword. Is there a possible security measure in flash loan applicability to minimize any attack associated with it in Defi ecosystem?

2 Likes

Thank you @Chrisarch for your kind words. Just as i pointed out in the research, flash loan attacks and preventive mechanisms are still subject of research. However, some authors have pointed out that using custodial wallet and decentralised lending system could minimise the attacks. Also, a research summary here suggested using Flashsyn which could help detect flaws in smart contract that is capable of leading to an attack

2 Likes

Thank you @Samuel94 for the clarification.

1 Like

I have some personal contributions which I’d like to share :slightly_smiling_face: though I’d make it as a summary

→ When taking flash loans you must pay back almost immediately let’s say within 13 second

→ Flashloans in Trading arbitrage involves borrowing for trading and profit purpose, for example We can borrow $100 flash loans from a lender and use it to buy crypto from Coinbase at $100 then sell it to Gemini at $101 thereby making $1 profit.
But with flashloans we can borrow $2,000,000 and buy the crypto then resell the Gemini thereby making $202,000,000 which is a profit of $2m.

→ The fee charged by Flash loan lenders is only a little amount, I think 0.09% which is cool to go with cause a reasonable profit is made.

→ Collateral swap has less potential for profit but it’s a useful tool for those borrowing and lending out.

→ Flash loan attacks happen as a result of bugs and exploits. (Most developers believe the exploitation is ethical and should be allowed, do you think this is correct) @Samuel94

1 Like

Thank you @Freakytainment for further explaining this concept in a simpler terms. To your question, as an attorney I will start my response by providing the definition of the word “ethical” from Merriamwebster which defines “ethica” as

  1. of or relating to ethics

2: involving or expressing moral approval or disapproval//ethical

3: conforming to accepted standards of conduct

Attack as defined by same dictionary means:

  1. to set upon or work against forcefully

2 to assail with unfriendly or bitter words

3 to begin to affect or to act on injuriously

Therefore, i will say that a combined reading of the definitions of the two words shows contradiction and two poles that can never meet. Manipulation is never ethical. So an undue advantage taken over a defect system can never been seen as ethical since such is not generally acceptable by the society or even Blockchain ecosystem.

Therefore, i do not agree with the views of the developers.

3 Likes

Thanks @samuel94 for this, I was making a research an hour ago on it after waiting for your point of view on this, well I’d also agree with you that it’s never ethical.
After taking advantage of the bug in the system and taking a flash loan for maybe a trading arbitrage, those supporting this action pay back the flash loan to the lenders but never with the little fee attached to it, this is unfair and therefore an act of dishonesty.

1 Like

I agree with you @Freakytainment

@Samuel94, on the 7th of September, some attackers stole about $370,000 from Avax through a flash loan attack. Again, today about $1.25 million was stolen from New Free DAO, a recent DeFi project. Much more money has been lost to flash loan attacks, but I picked on these two as they are the most recent cases.

DeFi platforms charge these little percentages in fees which I see as the only incentive for enabling flash loans on their platforms. Except you want to include generating trading activities as an added advantage. In fact, some platforms do not even charge a fee. So considering the losses incurred during flash loan attacks, is enabling flash loan functionality a good return on investment for these platforms?

Also, are there other gains or incentives that obligates them to provide the service? Are they just being “patriotic” to blockchain technology innovation?

3 Likes

Thank you @Ulysses for this brilliant question.

Every Flash loan protocol makes money from the transaction either during the act of borrowing or inform of interest, albeit very small amount.

The act of charging small amount in my understanding is a sort of business strategy which every business devises to scale up. Very unfortunate there is now attack here and there but that is not sufficient to see flash loan as a failed project. The series of Flash loan attacks will propel developers to create a solution. For protocol that hasn’t suffered attack, it will still be a very good business strategy.

Also the desire to develop and grow web 3 is a motivating factor which won’t be bad if you term it patriotism.

1 Like