Scout Chart Creator
  • Overview
  • Get Started
    • Tutorial 1: NMR Daily Transaction Count
    • Tutorial 2: LPT Weekly Volume (USD)
    • Tutorial 3: NMR vs LPT Daily comparison
  • Pipeline
    • Filter
    • Project
    • Group
      • Accumulators
    • Sort
    • Unwind
    • Custom
  • Data Source
    • Transactions
    • States
    • Contracts
    • Aragon
    • Livepeer
    • dYdX
    • Set
    • Token holders
  • Operators
    • Math operators
    • Logic operators
    • Function operators
    • Array operators
    • String operators
  • Config
  • Protocols
    • Dodo
      • 24H trade volume
      • Deposit & Withdraw
    • Livepeer
    • dYdX
      • Making sense of the trade data
    • MakerDao
    • Pickle Finance
      • Example: Daily deposit and withdraw of jar 0.88
      • Example: Listing all borrows of a strategy
  • FAQ
    • Dealing with "logs" field in "Transaction"
    • How to handle "Query Timeout" error?
    • How to use a variable in a Pipeline
  • Research
    • The circulating supply of DODO tokens
    • How are bitcoins doing on Ethereum? (as of Jan 20th 2021)
Powered by GitBook
On this page

Was this helpful?

  1. Protocols
  2. Pickle Finance

Example: Listing all borrows of a strategy

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

PreviousExample: Daily deposit and withdraw of jar 0.88NextFAQ

Last updated 4 years ago

Was this helpful?

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

1. Choose data source

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).

  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...)

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

What data looks like now:

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.

2. Use instruction

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

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

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

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

4. Use 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 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 operator to go through every 'borrowlogs'

5. Use to add a clickable link of the transaction hash to the table chart.

6. Plug in the data to the right table columns and you are done!

🍾
Filter
Project
filter
Project
Project
Transaction
Selected logs of a transaction
here
filter
reduce
reduce