Afonso_Diaz2023-10-21 06:46 PM
    Updated 2023-10-16
    select
    'Flow' as chain,
    sum(iff(action like '%TokensCommitted', amount, null)) as total_staked_volume,
    sum(iff(action like '%UnstakedTokensWithdrawn', amount, null)) as total_unstaked_volume,
    total_staked_volume - total_unstaked_volume as netflow_staked_volume,
    1036200000 as circulating_supply,
    (netflow_staked_volume / circulating_supply) * 100 as staked_to_circulating_supply_ratio_percent
    from flow.gov.ez_staking_actions
    where tx_succeeded = 1

    union all

    select
    'Osmosis' as chain,
    sum(iff(msg_type = 'delegate', replace(attribute_value, 'uosmo', '')::int / pow(10, 6), 0)) as total_staked_volume,
    sum(iff(msg_type = 'unbond', replace(attribute_value, 'uosmo', '')::int / pow(10, 6), 0)) as total_unstaked_volume,
    total_staked_volume - total_unstaked_volume as netflow_staked_volume,
    587378721 as circulating_supply,
    (netflow_staked_volume / circulating_supply) * 100 as staked_to_circulating_supply_ratio_percent
    from osmosis.core.fact_msg_attributes
    where tx_succeeded = 1
    and attribute_key = 'amount'
    and msg_type in ('delegate', 'unbond')
    group by 1

    union all

    select
    'Cosmos' as chain,
    sum(iff(msg_type = 'delegate', replace(attribute_value, 'uatom', '')::int / pow(10, 6), 0)) as total_staked_volume,
    sum(iff(msg_type = 'unbond', replace(attribute_value, 'uatom', '')::int / pow(10, 6), 0)) as total_unstaked_volume,
    total_staked_volume - total_unstaked_volume as netflow_staked_volume,
    369758591 as circulating_supply,
    (netflow_staked_volume / circulating_supply) * 100 as staked_to_circulating_supply_ratio_percent
    from cosmos.core.fact_msg_attributes
    where tx_succeeded = 1
    Run a query to Download Data