jackguyOsmo Staking
    Updated 2022-05-27
    with id as (
    select block_timestamp::date as date,
    attribute_value as proposal,
    row_number() over(partition by proposal order by date) as day,
    tx_id
    from osmosis.core.fact_msg_attributes
    where msg_type = 'proposal_vote' and attribute_key = 'proposal_id'
    and attribute_value between 222 and 227
    ),tab2 as (
    select
    date_trunc('day', block_timestamp) as day,
    msg_type,
    sum(get(array_slice(Split (ATTRIBUTE_VALUE, 'u'), 0, 1), 0) * 0.000001) as value,
    SUM(case when msg_type LIKE 'delegate' THEN get(array_slice(Split (ATTRIBUTE_VALUE, 'u'), 0, 1), 0) * 0.000001 ELSE -1 * get(array_slice(Split (ATTRIBUTE_VALUE, 'u'), 0, 1), 0) * 0.000001 END) as staking_diffrence
    --count(try_parse_json(attribute_value):option) as votes
    --DISTINCT msg_type
    from osmosis.core.fact_msg_attributes
    where( msg_type LIKE 'delegate' or msg_type LIKE 'unbond')
    AND attribute_key LIKE 'amount'
    GROUP by 1,2
    )
    SELECT
    *,
    sum(staking_diffrence) over (order by day) as total_osmo_staked
    from tab2
    Run a query to Download Data