0xHaM-dDaily Top 10 Swapped Pairs by Holders
    Updated 2023-01-22
    with inflowTb as (
    SELECT
    date_trunc('day', block_timestamp) as in_date,
    to_address as receiver,
    sum((raw_amount / 1e18)) as inflow_vol
    FROM ethereum.core.fact_token_transfers t LEFT JOIN ethereum.core.dim_labels l on t.TO_ADDRESS = l.ADDRESS
    WHERE contract_address LIKE lower('0x92D6C1e31e14520e676a687F0a93788B716BEff5')
    AND LABEL_TYPE is NULL
    GROUP by 1,2
    )
    , outflowTb as (
    SELECT
    date_trunc('day', block_timestamp) as out_date,
    ORIGIN_FROM_ADDRESS as sender,
    sum((raw_amount / 1e18))*-1 as outflow_vol
    FROM ethereum.core.fact_token_transfers t1 LEFT JOIN ethereum.core.dim_labels l on t1.FROM_ADDRESS = l.ADDRESS
    LEFT join inflowTb t2 on t1.ORIGIN_FROM_ADDRESS = t2.receiver
    WHERE contract_address LIKE lower('0x92D6C1e31e14520e676a687F0a93788B716BEff5')
    and t1.block_timestamp > t2.in_date
    AND LABEL_TYPE is NULL
    GROUP by 1,2
    )
    , holderTb as (
    SELECT in_date as date, receiver, inflow_vol FROM inflowTb
    UNION
    SELECT out_date as date, sender, outflow_vol FROM outflowTb
    )
    , finalHoldersTb as (
    SELECT receiver as holder, sum(inflow_vol) as balance FROM holderTb
    WHERE date < CURRENT_DATE - INTERVAL '{{Past_Months}} Month'
    GROUP by 1
    HAVING balance > 100
    order by 2 DESC
    )
    -- , swaps AS (
    SELECT
    Run a query to Download Data