Afonso_Diaz2023-06-17 02:30 AM
    Updated 2023-06-16
    with

    t as (

    select
    a.recorded_at::date as date,
    symbol,
    avg(a.price) as price_usd
    from osmosis.core.dim_prices a
    where a.symbol in('ATOM')
    group by 1, 2
    ),

    t2 as (
    select
    tx_id,
    'Cosmos' as chain,
    a.block_timestamp,
    tx_from as user,
    ((split(attribute_value,'uatom')[0]::numeric))/1e6 as amount_atom,
    amount_atom * price_usd as amount_usd
    from cosmos.core.fact_msg_attributes a
    join t on block_timestamp::date = t.date and symbol = 'ATOM'
    join cosmos.core.fact_transactions b
    using(tx_id)
    where msg_type = 'delegate'
    and a.tx_succeeded = 1
    and attribute_key = 'amount'
    )

    select
    count(distinct tx_id) as transactions,
    count(distinct user) as stakers,
    sum(amount_usd) as staked_volume_usd,
    avg(amount_usd) as average_staked_volume_usd,
    median(amount_usd) as median_staked_volume_usd,
    Run a query to Download Data