h4wkHolders Histogram
    Updated 2024-06-17
    with base_raw as (
    select block_timestamp,
    case when from_address = '0x0000000000000000000000000000000000000000' then 'Deposit'
    else 'Withdrawal' end as type,
    raw_amount_precise::float/1e18 as token_amount,
    origin_from_address,
    tx_hash
    from avalanche.core.fact_token_transfers
    where 1 = 1
    and contract_address = lower('0xd39016475200ab8957e9c772c949ef54bda69111')
    and (from_address = '0x0000000000000000000000000000000000000000'
    or to_address = '0x0000000000000000000000000000000000000000')
    -- and origin_to_address not in(lower('0x001E3BA199B4FF4B5B6e97aCD96daFC0E2e4156e'))
    )
    , net_in as (
    select user,
    'Deposit' as type,
    sum(token_amount) as token_vol
    from (
    select origin_from_address as user,
    token_amount
    from base_raw where type = 'Deposit'
    UNION
    select to_address as user,
    raw_amount_precise::float/1e18 as token_amount
    from avalanche.core.fact_token_transfers
    where contract_address = lower('0xd39016475200ab8957e9c772c949ef54bda69111')
    and tx_hash not in (select tx_hash from base_raw) -- remove duplicate txs
    )
    group by 1
    )
    , net_out as (
    select user,
    'Withdrawal' as type,
    sum(token_amount) as token_vol
    QueryRunArchived: QueryRun has been archived