vegardFTX Wallet Balance per hour
    Updated 2022-11-10
    with ftx_labels as (
    select label, address
    from ethereum.core.dim_labels
    where (
    label like any ('ftx%') or
    address_name like any ('ftx%')
    )
    ),

    balances as (
    select
    date_trunc('hour', last_activity_block_timestamp) as hour,
    current_bal,
    contract_address,
    symbol
    from ethereum.core.ez_current_balances
    where 1 = 1
    and exists (select * from ftx_labels where address = user_address)
    )

    select last_hour, symbol, balance, balance_usd from (
    select
    a.hour as last_hour,
    balances.symbol,
    sum(current_bal) as balance,
    sum(price * current_bal) balance_usd,
    row_number() over (partition by balances.symbol order by a.hour desc) as n
    from ethereum.core.fact_hourly_token_prices a
    join balances
    on a.token_address = balances.contract_address
    where a.hour::date = current_date
    group by a.hour, balances.symbol
    having balance > 0 and balance_usd > 0
    qualify n = 1
    )
    order by balance_usd desc
    Run a query to Download Data