Example: Daily deposit and withdraw of jar 0.88
Demo: https://scout.cool/picklefinance/mainnet/dashboards/jar-0.88a
Let's build a bar chat to display the daily deposit and withdraw that happens in the Jar 0.88

1.Choose Transaction data source.

2. Use Filter instruction.

Search all the transactions which contain the log Transfer(from, to, value) and the address of the log needs to be the address of the Jar 0.88a. And to be completely safe, the contract address that the transactions interact with must be the jar 0.88a as well.
Filter instruction
What the data looks like now after using the Filter instruction:

3. Use Project instruction to split deposit and withdraw logs into two variable.

Since each transaction can contain multiple different logs, we use filter operator to gather all the logs of deposits into the variable "depositlogs". In the
👆
screenshot, the first log is a log of deposit.
As explained here, log of deposit is identified by
  • A Transfer(from, to, value) log is found in the transaction and the address of the log is DAI (0x6B175...).
  • The to parameter (params.1.value) of Transfer(from, to, value) is the recipient of the DAI transfer which should be the address of the jar 0.88 (0x6949B...)
  • The from parameter (params.0.value) is the sender of the DAI transfer which is user's wallet that is stored in the from field of the transaction.
Do not confuse the two "from" here. One is the from field of the transaction and the other is the name of the parameter of a log.
In the same step, we will do the same for the logs of withdraws.
What the data looks like now:

4. Use another Project to sum up the amount of the deposits and withdraws.

Since we do not know whether a transaction could have multiple deposit or withdraw logs, we will play safe here. We will use reduce operator to go through every element of widthdrawlogs and depositlogs respectively and sum up the 3rd parameter value ($this.params.2.value) of Transfer(from, to, value) which is the amount transferred. In that way, we can make sure that we do not miss any potential deposits or withdraws.
What the data looks like now:
We are getting close!!

5. Finally use Group to organize the data by day:

Use sumC operator to get the cumulative value of the amount. You use sum if you don't need a cumulative chart.

6. Use Project to add a new field to show the total amount

Total = (depositamount - withdrawamount)
Now you just need to assign _id to the X axis and depositamount, withdrawamount and total to the Y axis. Your job is done. Go have a
🍷
!
Last modified 1yr ago
Copy link
Contents