Exploring Ethereum, Polygon, and Avalanche Flash Loan Data on Aave for 2021

Dmitriy
5 min readDec 8, 2021

--

A flash loan is an uncollateralized loan for virtually unlimited amounts of money on the blockchain. It’s called a flash loan because it happens in a “flash” — you get the loan, do something quickly with it, and return it in a single transaction which usually lasts a few minutes max.

In this post, I’ll ask a few general questions about flash loans on Aave and answer them with data. I’ll be using the wonderful defi-crawler library to grab data from Aave for all three blockchains that flash loans are available on — Ethereum, Polygon, and Avalanche.

It works like this:

from deficrawler import Lendingdef get_api(protocol, chain, version=2)
return Lending(protocol,chain,version)

We import the “Lending” class from deficrawler, wrap it into a function, and grab data from Aaave on flash loans.

chains = ['Avalanche','Ethereum','Polygon']
data = []
for chain in chains:
api = get_api('Aave',chain)
d1 = '01/01/2021 00:00:00'
d2 = '06/12/2021 00:00:00'
d = pd.DataFrame(api.get_data_from_date_range(d1, d2, "flashloans"))
d['chain'] = chain
data.append(d)

Next, we concatenate the data from each chain to get 78,230 rows.

df = pd.concat(data, ignore_index=True)
df.shape
(78230, 8)

Now we can do the EDA.

How much was borrowed this year in USD?

Figure 1. The cumulative amount of flash loans for USD-pegged stable coins on 3 different blockchains on Aave for 2021 — nearly $4 billion.

Stable coins such as tether and dai are easy ways to measure the overall magnitude of flash loans since you don’t have to back-adjust them for price differences (they’re always 1–1 with the dollar). The cumulative charts in Figure 1 let us see the sharp growth rates in dollar amount lent out throughout the year as well as totals for the year.

How many tokens that are not stable coins have been lent out?

Figure 2. The total amount of tokens flash loaned on each chain.

In Figure 2, we can see that CRV, LINK, and BAT tokens were lent out the most on Ethereum— just over 3 million tokens were lent out this year. The average price of CRV is roughly $30 per token this year, so that’s almost a billion dollars lent out in Curve DAO token alone. Over 70 million WMATIC tokens were lent out on the Polygon chain and 158,155 WAVAX tokens on the Avalanche chain. The charts and tables above illustrate the magnitude of flash loans in the defi ecosystem. To dip a little deeper, let’s look at distributions of user wallets that are getting the loans.

Which users are getting the most loans?

Figure 3. Top 20 flash loaders (borrowers) by % counts and raw counts of flash loans per wallet address.

Figure 3 shows us that the wallet with the longest bar accounts for ~5800 flash loans or 7.5% of all loans in our dataset of roughly 80,000 observations.

Who had the largest sum of stable coin loans?

Figure 4. Addresses that borrowed the most amount of USD stable coins.

Fig 4 tells us that a single address borrowed nearly $1 billion. Just behind that address is someone who managed to borrow $590 million. Again, this highlights the potential of these sorts of loans.

How many transactions did it take for the top user to borrow that much money?

In just 6 transactions, the user was able to borrow over a billion dollars.

What did the user do with the borrowed money?

To answer this one, we go on etherscan and input the tx_id into the search.

You’ll see under the transaction action that the user is using a flash loan to borrow USDC and then supply USDC pool on Aave.

What is the average flash loan used for?

The amounts for flash loans have a high & variable spread, so for average, we use median here. Get the“average” amount of flash loan for stable coins:

Inspect a few (3) randomly sampled transaction ids around that range:

Look them up on a blockchain explorer such as etherscan or polygon scan.

Transaction 1 happened on etherscan:

Transaction 2 on polygon:

Transaction 3 on polygon:

Conclusion:

Flash loans are a relatively new and innovative feature of the defi ecosystem. They are still highly inaccessible to the general population. A few platforms are changing this, but with very limited use cases. The main providers of flash loans are currently Aave (0.9% fee) and Dydx (~no fee). One thing is certain: flash loans are an emerging defi innovation with the potential to make extremely large amounts of capital accessible to anyone.

For more content on trading bots and crypto data, check out my other posts below.

--

--