Example: Daily deposit and withdraw of jar 0.88
Demo: https://scout.cool/picklefinance/mainnet/dashboards/jar-0.88a
Last updated
Demo: https://scout.cool/picklefinance/mainnet/dashboards/jar-0.88a
Last updated
Let's build a bar chat to display the daily deposit and withdraw that happens in the Jar 0.88
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.
What the data looks like now after using the Filter instruction:
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:
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:
Use sumC
operator to get the cumulative value of the amount. You use sum
if you don't need a cumulative chart.
Total = (depositamount - withdrawamount)
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.
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 !