Example: Listing all borrows of a strategy

Demo: https://scout.cool/picklefinance/mainnet/dashboards/jar-0.88a

Let's build a table chat to display all the actions that the strategy contract of Jar 0.88 does.

1. Choose Transaction data source

2. Use Filter instruction

List all the transactions which came from (0xf00D9) and involved the strategy contract (0xCd892). The reason why it must be from the address (0xf00D9) is based on our observations on Etherscan. It could be removed in the future when this is no longer true.

What the data looks like now:(this transaction has too many logs to list it all here. So I only include a few relevant logs here).

3. Use Project instruction to split the borrow and collect COMP logs into two variables.

Since each transaction can contain multiple different logs, we use filter operator to gather all the logs of borrow into the variable "borrowlogs".

As explained here, a log of borrowing DAI from Compound is identified by:

  1. A Borrow(borrower, borrowAmount, accountBorrows, totalBorrows) log can be found in the transaction.

  2. The address of the log is cDAI(0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643)

  3. The borrower parameter (params.0.value) is the address of the strategy contract(0xCd892...)

In the same step, we also use filter operator to gather the logs of collecting COMP tokens into the variable "complogs"

Don't forget to carry over both blockTimestamp and transactionHash fields since we will need them later.

What data looks like now:

4. Use Project instruction to sum up the amount of the borrows and collected COMP tokens

Since we do not know whether a transaction could have multiple logs of borrowing DAI or collecting COMP tokens, we will play safe here. We will use reduce operator to go through every element of "borrowlogs" and sum up the value of the borrowed amount which is the second parameter borrowAmount (params.1.value) of Borrow(borrower, borrowAmount, accountBorrows, totalBorrows). Then we divide the value with 1e18 (DAI has 18 decimals).

and "complogs" 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. Use reduce operator to go through every 'borrowlogs'

Same way, we use reduce operator to go through every "complogs" and sum up the value of the borrowed amount

What data looks like now:

So people can cross reference the data with Etherscan.

Last updated