jonestrinhCOSMOS Stake
    Updated 2023-01-08
    select
    dt,
    sum(stake) over (order by dt) as amount
    from (
    select
    date_trunc('day', block_timestamp) as dt,
    sum(attribute_value / 1e6) as stake
    from cosmos.core.fact_msg_attributes
    where msg_type = 'delegate'
    and attribute_key = 'new_shares'
    group by 1

    union all

    select
    date_trunc('day', block_timestamp) as dt,
    (-1)*sum(attribute_value / 1e6) as stake
    from cosmos.core.fact_msg_attributes
    where msg_type = 'unbond'
    and attribute_key = 'new_shares'
    group by 1

    union all
    select
    date_trunc('day', block_timestamp) as dt,
    sum(attribute_value / 1e6) as stake
    from cosmos.core.fact_msg_attributes
    where msg_type = 'redelegate'
    and attribute_key = 'new_shares'
    group by 1

    union all
    select
    date_trunc('day', block_timestamp) as dt,
    Run a query to Download Data