Afonso_Diaz2023-04-16 09:13 PM
    Updated 2023-04-16
    with
    t as (
    select
    recorded_hour::date as date,
    currency,
    symbol,
    avg(price) as price_usd
    from osmosis.core.ez_prices
    group by 1, 2, 3
    )

    select
    delegator_address as user,
    count(distinct tx_id) as transactions,
    sum(((amount * price_usd) / pow(10, decimal))) as volume_usd,
    avg(((amount * price_usd) / pow(10, decimal))) as average_volume_usd,
    median(((amount * price_usd) / pow(10, decimal))) as median_volume_usd
    from osmosis.core.fact_staking a
    join t on a.currency = t.currency and a.block_timestamp::date = t.date
    where block_timestamp >= '2023-01-01' and block_timestamp < '2023-04-01'
    and action = 'delegate'
    group by 1
    order by 3 desc
    limit 10
    Run a query to Download Data