Links
👻

Retrieve Aave's GMV data

TL;DR

You can query GMV data only when business_line and business_model are part of the aggregation.
Here's an example query to get you started. The query fetches Aave's historical GMV data on a daily granularity, aggregated on business line and business model-level.
cURL
Python
1
# Set your API Key here.
2
API_TOKEN="d3adb33f-c123-45b6-7890-c0ff33"
3
curl \
4
-H "content-type: application/json" \
5
-H "authorization: Bearer $API_TOKEN" \
6
"https://api.tokenterminal.com/v2/projects/aave/metrics?metrics=gmv&aggregate_by=business_line,business_model"
1
import requests
2
# Set your API Key here.
3
API_TOKEN="d3adb33f-c123-45b6-7890-c0ff33"
4
params = {"metrics": "gmv", "aggregate_by": "business_line,business_model"}
5
headers = {"Authorization": f"Bearer {API_TOKEN}"}
6
r = requests.get("https://api.tokenterminal.com/v2/projects/aave/metrics", params=params, headers=headers)
7
r.json()

Deep dive

Aave is a non-custodial lending & flash loan protocol built on Ethereum and other adjacent blockchains. Lenders deposit funds into Aave and receive interest payments from borrowers & trading fees from traders (supply-side fees). Aave takes a cut of the total interest paid by borrowers & trading fees paid by traders.
In traditional companies GMV (Gross merchandise volume) is the total value of merchandise sold over a period of time, usually through a marketplace. For Aave, the GMV depends on the business line in question:
  • Lending: the outstanding loans borrowers owe.
  • Flash loans: borrow volume of the flash loan trade.
  • Liquidations: amount liquidated.
If we were to aggregate the GMV across business lines, we would end up in summing apples and oranges: only two of the three business lines can cumulatively accrue value (Flash loans and Liquidations) and one of the three doesn't. This is due to the differentiating business models they have:
  • Flash loans & Liquidations (transaction-based): volume is tied to transaction counts. If there is no transactions there is no volume.
  • Lending (interest-based): the volume is tied to time. Even if there's no new loans taken, the existing loans sit and accrue interest.
How does this affect querying GMV data? Let's examine the following query querying Aave's GMV data, aggregated by chain-level:
cURL
Python
1
# Set your API Key here.
2
API_TOKEN="d3adb33f-c123-45b6-7890-c0ff33"
3
curl \
4
-H "content-type: application/json" \
5
-H "authorization: Bearer $API_TOKEN" \
6
"https://api.tokenterminal.com/v2/projects/aave/metrics?metrics=gmv&aggregate_by=chain"
import requests
# Set your API Key here.
API_TOKEN="d3adb33f-c123-45b6-7890-c0ff33"
params = {"metrics": "gmv", "aggregate_by": "chain"}
headers = {"Authorization": f"Bearer {API_TOKEN}"}
r = requests.get("https://api.tokenterminal.com/v2/projects/aave/metrics", params=params, headers=headers)
r.json()
If we were to query aggregate data across chains we would be summing data across transaction and interest-based business lines. This would be wrong and is also handled in the response:
{
"errors": [
"metric \"gmv\" requires \"aggregate_by\" to include \"business_line\" and \"business_model\""
]
}
Checking the error message clearly lets us know that also business_line and business_model fields need to be added to the query parameters under aggregate_by:
cURL
Python
1
# Set your API Key here.
2
API_TOKEN="d3adb33f-c123-45b6-7890-c0ff33"
3
curl \
4
-H "content-type: application/json" \
5
-H "authorization: Bearer $API_TOKEN" \
6
"https://api.tokenterminal.com/v2/projects/aave/metrics?metrics=gmv&aggregate_by=business_line,business_model"
1
import requests
2
# Set your API Key here.
3
API_TOKEN="d3adb33f-c123-45b6-7890-c0ff33"
4
params = {"metrics": "gmv", "aggregate_by": "chain"}
5
headers = {"Authorization": f"Bearer {API_TOKEN}"}
6
r = requests.get("https://api.tokenterminal.com/v2/projects/aave/metrics", params=params, headers=headers)
7
r.json()
And the response also yields valid results:
{
"data": [
{
"timestamp": "2022-10-12T00:00:00.000Z",
"project_name": "Aave",
"chain": "arbitrum",
"business_line": "lending",
"business_model": "interest",
"gmv": "11536953.353193684"
},
{
"timestamp": "2022-10-12T00:00:00.000Z",
"project_name": "Aave",
"chain": "avalanche",
"business_line": "lending",
"business_model": "interest",
"gmv": "601277037.389403703"
},
{
"timestamp": "2022-10-12T00:00:00.000Z",
"project_name": "Aave",
"chain": "ethereum",
"business_line": "lending",
"business_model": "interest",
"gmv": "1574550559.86438073"
},
...
]
}