MasiDaily stake
    Updated 2023-02-17
    with price as ( select trunc(RECORDED_HOUR,'day') as day ,
    symbol ,
    avg(price) as avg_price
    from osmosis.core.ez_prices
    where symbol in ('ATOM','OSMO','AXL')
    and RECORDED_HOUR >= CURRENT_DATE - 90
    group by 1,2)
    ,
    axelar as ( select trunc(block_timestamp,'day') as day,
    count(DISTINCT tx_id) as count_txs,
    count(DISTINCT DELEGATOR_ADDRESS) as count_users,
    sum(amount/pow(10,6)*avg_price) as volumes
    from axelar.core.fact_staking a left outer join price b on a.block_timestamp::date = b.day
    where block_timestamp >= CURRENT_DATE - 90
    and symbol = 'AXL'
    group by 1)
    ,
    osmo as ( select trunc(block_timestamp,'day') as day,
    count(DISTINCT tx_id) as count_txs,
    count(DISTINCT DELEGATOR_ADDRESS) as count_users,
    sum(amount/pow(10,decimal)*avg_price) as volumes
    from osmosis.core.fact_staking a left outer join price b on a.block_timestamp::date = b.day
    where block_timestamp >= CURRENT_DATE - 90
    and currency = 'uosmo'
    and action = 'delegate'
    and symbol = 'OSMO'
    group by 1)
    ,

    atom as ( select DISTINCT b.tx_id,
    trunc(a.block_timestamp,'day') as day,
    tx_from ,
    replace(ATTRIBUTE_VALUE,'uatom','' ) as amount
    from cosmos.core.fact_msg_attributes a join cosmos.core.fact_transactions b on a.tx_id = b.tx_id
    where MSG_TYPE ilike '%delegate%' and ATTRIBUTE_KEY = 'amount'
    and day >= CURRENT_DATE - 90)
    Run a query to Download Data