Visualizing MakerDAO Data Using Chainbase Api and Livequery

Visualizing MakerDAO Data Using Chainbase Api and Livequery

Pyours

Pyours

Chainbase Intern

Table Of Content

  • Introduction
  • Example1: Market Health Analysis
  • Example2: Analysis of Liquidation
  • Conclusion

Introduction

In the world of decentralized finance (DeFi), the importance of data analysis and visualization cannot be overstated. These tools not only help in understanding market dynamics but are also pivotal in gauging the health and trends of projects. While we can extract a wealth of raw data from Chainbase, this data often requires further cleaning and processing to provide us with more intuitive and specific information. This is where Flipside comes into play, offering a powerful data visualization platform that allows us to effortlessly transform the raw data extracted from Chainbase into vivid and insightful charts and analyses.

This article, using two illustrative examples, will walk you through the process of extracting MakerDAO data from Chainbase and visualizing it effectively with Flipside, enabling you to uncover the deeper insights and value hidden within the data.

Relevant links for this article:

Market Health Analysis

To assess the health of the MakerDAO market, we first need to focus on the following key indicators:

  • cumulativeBorrowUSD: Represents the accumulated borrowing amount.
  • cumulativeDepositUSD: Represents the accumulated deposit amount.
  • totalValueLockedUSD: Indicates the total value locked within the market.
  • isActive: Denotes whether the market is active or not.

We can extract this information using the following Chainbase query:

# chainbase
query MyQuery {
   ilks {
    marketAddress
  }
  markets {
    createdTimestamp
    cumulativeBorrowUSD
    cumulativeDepositUSD
    isActive
    totalValueLockedUSD
  }

To delve deeper into the analysis, we can import this data into Flipside and query for specific marketAddress values.

# filpside
SELECT
     round(VALUE:"cumulativeBorrowUSD",2)  AS "cumulativeBorrowUSD" ,
     round(VALUE:"cumulativeDepositUSD",2)  AS "cumulativeDepositUSD" ,
     round(VALUE:"totalValueLockedUSD",2)  AS "totalValueLockedUSD" ,
     VALUE:"isActive"::string AS "isActive"

FROM
  (
      SELECT
      chainbase_utils.post('/v1/subgraphs/ethereum_makerdao/1.0.0',
      {
        'operationName':'MyQuery',
        'query':
      'query MyQuery {
  ilks(where: {marketAddress: "{{marketAddress}}"}) {
    marketAddress
  }
  markets {
    cumulativeBorrowUSD
    cumulativeDepositUSD
    isActive
    totalValueLockedUSD
}
}'}) :: variant AS resp
  ) AS subquery,
LATERAL FLATTEN(input => resp:data:data:markets)
Where isActive = “TRUE”

## eg.
marketAddress: 0x24e459f61ceaa7b1ce70dbaea938940a7c5ad46e

Through visualization, we can get some insight from the data:

1-MakerDAO Data.png

  1. Borrow-Lend Balance: By comparing cumulativeBorrowUSD with cumulativeDepositUSD, we can assess whether the market is in a healthy borrowing-lending equilibrium. In Flipside, we use a dual Y-axis chart to display the variations of these two indicators over time.
  2. Total Value Locked (TVL): By analyzing totalValueLockedUSD, we can gauge the market's liquidity and attractiveness. A high TVL typically indicates a healthier and more appealing market. In Flipside, we can use a time series chart to showcase the evolution of TVL over time.

Analysis of Liquidation

Liquidation events are a crucial metric in the DeFi market, helping us understand the risk conditions of the market. Here are the key data points we can analyze:

  • **amountUSD**: Represents the amount in USD associated with the liquidation event.
  • lastPriceUSD: Indicates the most recent price of the asset in USD. This could be used to determine the asset's current market value at the time of liquidation.
  • name: The name of the asset being liquidated. For example, it could be "Ethereum" or "DAI".
  • symbol: The ticker symbol or abbreviation for the asset. For instance, "ETH" for Ethereum or "DAI" for DAI stablecoin.
query MyQuery2 {
  liquidates {
    amountUSD
    asset {
      lastPriceUSD
      name
      symbol
    }
    timestamp
  }
}

To delve deeper into the analysis, we can import this data into Flipside (similar to the first example).

2-MakerDAO Data.png

We can conduct the following two analyses:

  1. Time Series Chart

Display the changes in amountUSD over time to observe the frequency and scale of liquidation events. A high frequency of liquidation events might indicate market instability or high risks.

  1. Analysis of Liquidated Assets

Using pie charts, showcase the average liquidation amounts and counts for different assets. This can help identify certain assets that might be more prone to liquidation, possibly due to their market volatility or liquidity.

After creating the dashboard, the final presentation is as shown below:

3-MakerDAO Data.png

Link:https://flipsidecrypto.xyz/pyours/makerdao-1vJUeJ

Conclusion

MakerDAO stands as a pivotal player in the DeFi landscape. Analyzing and visualizing its data offers profound insights, proving indispensable for investors and market researchers alike. Through the analysis methods mentioned above, we can delve deeper into the market's vitality, potential risks, and liquidation patterns. We hope this guide offers valuable insights and guidance for you.

About Chainbase

Chainbase is an open Web3 data infrastructure for accessing, organizing, and analyzing on-chain data at scale. It helps people to better utilize on-chain data by combining rich datasets with open computing technologies in one data platform. Chainbase’s ultimate goal is to increase data freedom in the crypto.

More than 5,000 developers actively interact with our platform and over 200Mn data requests per day as their data backend and integrate chainbase into their main workflow.  Additionally, we are working with ~10 top-tier public chains as first-tier validators and managing over US $500Mn tokens non-custodially as a validator provider. Find out more at: chainbase.com

Want to learn more about Chainbase?

Sign up for a free account, and Check out our documentation.

WebsiteBlogTwitterDiscordLink3