noanuman-1x1vZpyeasty-orange
    Updated 2024-11-03
    -- we'll be using the NounsDao treasury address (0x0bc3807ec262cb779b38d65b38158acc3bfede10)

    with min_timestamp as ( -- gets the earliest date where there is a nonzero balance
    select
    min(block_timestamp)::date as min_date
    from ethereum.core.ez_balance_deltas
    where user_address = '0x0bc3807ec262cb779b38d65b38158acc3bfede10'
    ),

    dates as ( -- gets a list of dates
    select
    date_day
    from ethereum.core.dim_dates
    where date_day between '2021-06-01' and current_date()
    -- change the date above here ^ to any date of your choice. This has to match the other date below
    and date_day >= (select min_date from min_timestamp)
    ),

    contract_address_list as ( -- gets the list of token addresses
    select
    distinct (iff(contract_address is null, 'ETH', contract_address)) as full_contract_address,
    symbol as full_symbol
    from ethereum.core.ez_balance_deltas
    where user_address = '0x0bc3807ec262cb779b38d65b38158acc3bfede10'
    ),

    dates_x_contract_address as (
    select
    date_day as full_dates,
    full_contract_address,
    full_symbol
    from dates
    cross join contract_address_list
    ),

    balance_changes as ( -- gets the latest (in case there are multiple changes in a single day) usd balance and previous usd balance for each token for each day there is a change
    QueryRunArchived: QueryRun has been archived