On this task, we will deploy the same subgraph as in task 1, but this time, before deploying, you will add one field that is missing in the Market entity.
Let's focus again on the cDAI contract. If we navigate to the "Read as Proxy" page on the Contract tab of the cDAI contract page on Etherscan, we can query for the contract's public variables. Two of these variables are:
totalBorrows
: Total amount of outstanding borrows of the underlying in this market
totalReserves
: Total amount of reserves of the underlying held in this market
Note that the values of totalBorrows
and totalReserves
, respectively 3727663687228451100688943191
and 15641451739681235557887116
, are denominated in the underlying asset before correcting for decimals. This means that to convert these values to the native units of the underlying, which is Dai, we need to divide them by 10^decimals. Dai is represented with 18 decimals (which can be confirmed reading the Dai contract on etherscan):
Therefore:
totalBorrows
= 3727663687228451100688943191/10^18 = ~3727663687 DAItotalReserves
= 15641451739681235557887116/10^18 = ~15641451 DAI
Querying for these variables in the Token Terminal Compound subgraph, we see:
Which as we can see matches the values seen on etherscan (figures above).
In this directory, we have the same source code that was used to deploy Token Terminal Compound subgraph, except that the code necessary to index totalReserves
was removed. Your goals for this task are:
- Change the subgraph code to enable indexing the
totalReserves
variable as a field in theMarket
entity. (Tip: looking at howtotalBorrows
was implemented will help you) - After 1, deploy the resulting subgraph code in
https://thegraph.com/hosted-service/subgraph/<YOUR-GITHUB-NAME>/task-2
, following the same series of steps you did on task 1. Note this will be a separate deployment to task 1's subgraph.
A tip on syncing speed and using etherscan as a benchmark: You will notice that the subgraph you will deploy takes a long time to sync, so the results of the queries to your subgraph will only match etherscan when your subgraph finishes syncing. Therefore, to benchmark your subgraph before it finishes syncing (to ensure your implementation works) you can use the Token Terminal Compound subgraph and query it for a block for which your subgraph has already sync'd (recall that we used filter syntax on task 1 to query specific blocks).