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

Deposit & Withdraw

Previous24H trade volumeNextLivepeer

Last updated 4 years ago

Was this helpful?

Let's build a bar chart to show the daily deposit and withdraw of the WBTC-USDC pool.

1.Choose data source.

Search all the transactions which have Withdraw(payer, receiver, isBaseToken, amount, lpTokenAm) and Deposit(payer, receiver, isBaseToken, amount, lpTokenAm) logs. You also want to limit the logs.address to the address of WBTC-USDC trading pair which is 0x2109F78

depositbase (deposit WBTC),

withdrawbase (withdraw WBTC),

depositquote (deposit USDC),

withdrawquote (withdraw USDC).

Below is what a Deposit log looks like. If the value of the 3rd parameter isBaseToken is true , it's a WBTC token; Otherwise, it's a USDC token.

What the data looks like now:

Don't forget to bring the blockTimetamp with you since we need it to show data over time.

Since we don't know how many Withdraw or Deposit actions could exist in a single transaction, this is the safest way to make sure we don't miss any one of them. Similar to our naming convention the previous step, we will call them depositbase_amt, withdrawbase_amt, depositquote_amt, withdrawquote_amt. Here is an example of depositbase_amt

In the same Project, we will do the same for withdrawbase_amt, depositquote_amt, withdrawquote_amt:

What the data looks like now:

In the above screenshot, we also took care of the decimals. If it's the base token WETH, we will divide the amount by 10^18; If it's the quote token USDC, we will divide the amount by 10^6.

What data looks like now:

2. Use instruction.

3. Use and the operator to put the logs into four buckets:

Now let's use to form the first bucket: depositbase : gather all the Deposit logs from WBTC-USDC pair (0x2109F78b4) and also make sure the 3rd parameter isBaseToken ($$this.params.2.value) is true. The logic is demonstrated in the below screenshot.

In the same , you will do the same thing for withdrawbase, depositquote, withdrawquote

4. Use a new instruction and operator to sum up the value of the 4th parameter amount from all the logs in every transaction.

The operator iterate through the depositbase (based on the previous step, this is an array that contains all the Deposit logs whose 3rd parameter isBaseToken is true) and sum up the value of the 4th parameter amount ($$this.params.3.value). This basically gives you the total amount of base token deposit in one transaction.

5. Use a new instruction and to convert the values to USD:

6. Use to organize the data by day:

7. Plug the data into the charts and you are golden

🍾
Filter
Project
Project
tokenExchange
Group
Transaction
Project
Project
filter
filter
reduce
reduce
Deposit 2000 USDC tokens into the WBTC-USDC pool
withdrawquote
depositquote
withdrawbase
withdrawbase_amt
depositquote_amt
withdrawquote_amt