Afonso_Diaz2023-04-13 03:29 AM
    Updated 2023-04-13
    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
    block_timestamp::date as day,
    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,
    count(delegator_address) as users,
    sum(transactions) over (order by day) as cumulative_transactions,
    sum(volume_usd) over (order by day) as cumulative_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 > current_date - {{ days }}
    and action in ('undelegate')
    group by 1
    order by 1
    Run a query to Download Data