Here's a short five-step guide to getting familiar with a protocol and figuring out how to query around it. Assuming you've chosen a protocol to look into...

  1. Look at the protocol app page/docs and try to figure out what the main user entry point function is. Sometimes this is straightforward, but different contract patterns on more complex protocols will make this confusing.

    Dune Utility Queries

    Table Mapping Guide

  2. Once you figure out the entry point, run a basic LIMIT query on it and look at some example transactions in etherscan for data hints (i.e. what protocols did the tx interact with besides the main one)

    SELECT * FROM protocol_name."Contractname_evt_EventEmitted"
    LIMIT 10
    
  3. If you already have a question in mind, then skip this step. If you don't have a question yet, think through the flow chart of contract interactions. Here are some starter questions to help you find something interesting to look into:

    1. What other protocols did the entry function touch?
    2. If there is yield/interest being generated, where and when did the tokens get swapped?
    3. How many tokens went in and how many were burned/minted by the end?
    4. Is it possible that anything from the last three questions would lead to some sort of imbalance or accumulation? i.e. a DEX pool ending in low liquidity, or depositing so much into one pool that the yield/interest rate falls from supply imbalance. Or if this involves NFTs, what were the effects on future bid/sale behavior (or were there behaviors in bid/sale that led up to this transaction)?
  4. Now that you have settled on a question, the real fun begins. I'm sure you'll quickly notice that the function call data and event log data don't always have all the parameters you're looking for. The usual culprits that are missing are the transaction signer (found in ethereum."transactions" ) and the ETH value transferred (found in ethereum."traces"). Typically you'll have to work with the base tables (transactions, traces, logs) and possibly tables from other protocols (like DEX/exchange protocols) to complete the data you need for your query.

    1. Figuring out which tables to pull what data from takes a while to learn, and the best way to get started is usually to query for existing dashboards or queries that have attempted something similar. Dune has been around long enough that most query patterns aren't too hard to find somewhere else.
  5. Lastly, you should visualize the query in a chart by clicking "New visualization" next to "Query Results".

    Untitled

    If you're showing token amounts, you likely have to fix for decimals or multiply by token price (in prices.usd or dex.trades) to get to a USD value which is more interpretable.

Now If this makes sense to you, take a look at the PoolTogether dapp and try going through this flow. Your goal is to answer the question (or come up with another one):

If you get stuck, take a look at the focus group recording (this is extra content, linked in the Mirror post).