Aave is a leading decentralized lending/borrowing platform with a huge valuation. See https://defipulse.com/aave. There is also a cool website that provides comprehensive data: https://v2.aavewatch.com/. However I find it hard to parse and I'd like to have a more graphical view of what's happening.

Goals

Some questions I'd like to answer:

  • how much money gets borrowed every day?
  • in which major currencies does that money get borrowed?
  • how popular are these currencies over time?

Fetching the data

Data sources

There are multiple ways to get information on Aave loans:

  • Web3 events. All loans fire an event, so one could read those and figure out loans. The drawback is that other useful information such as the coin metadata is missing. So one would need an additional source of information to find that out.
  • Aave's The Graph subgraph. This is a GraphQL database that has coin metadata, loan information and much more.
  • Some third-party API. These are usually paid services.

Since Aave's GraphQL database is the most complete, I initially tried to fetch the data from Aave's GraphQL database in Dart and it went horribly wrong. Then I tried it in React and TypeScript and it went much better.

Formatting it into a Vega friendly format

In order to build the charts, I plan to use Vega. So once I had access to GraphQL's somewhat raw data on loans, I had to convert it into a format that I could easily feed to Vega. Something like rows of data points such as { date: Date, amount: in a chosen currency, coinSymbol: symbol of the coin }. Aave converts amounts into Ether, but for simplicity we'll convert everything to USDs. Can you count in Ether? Neither can I.

See how I did it here.

Line Chart

See how I built the chart.

What we can learn from this is that USD Coin (USDC) (Wikipedia), Tether (USDT) (Wikipedia) and Dai (DAI) (Wikipedia) are the currencies in which most of the money borrowed is:

  • USD Coin: between $10m and $200m being borrowed every day.
  • Tether: between $10m and $30m being borrowed every day.
  • Dai: between $1m and $20m being borrowed every day.

Some rarely used currencies total to only $1000 dollars being borrowed per day, and sometimes as low as $100. Read about KNC on Coinbase.

Stacked Bar Chart

When I switched to stacked bar charts, I realized that it was no longer possible to use a logarithmic scale, and that in the end, a few of the biggest currencies, namely USD Coin, Tether, Dai and Fei USD (see Fei USD on coinmarketcap) dwarf everything else.

The insight is that there's a peak in volume on Sunday/Monday, up to $200m borrowed. Other days it can go as low as $20m. I've only shown the data for the past week, so I don't know if it's a cyclic trend.

Pie Chart

Based on the Stacked Bar Chart, we know that USDC, USDT, DAI and FEI are the major currencies being borrowed on Aave. Let's use a pie chart to visualize their relative sizes better.

Now we know the percentage size of USDC, USDT, DAI, FEI and WETH (Wrapped Ether. See official site and WETH on coinmarketcap). The others are insignificant. After building this, I realized a bar chart would have been better.

Loan size

To figure out loan size, I'll build a histogram where I bin the loans by size.

See how I built it here.

What we can learn from this histogram is that most loans are between $2k and $200k, with a few rare outliers as low as $2 and as high as slightly over $100m. That's for 1000 transactions from Dec 21, 2021 to Dec 29, 2021.

Loans per day

Perhaps I should have started with this:

This shows that between 100 and 200 loans are being made every day on Aave.