Eman-RazVolume of Actions
    Updated 2023-04-13
    with tab1 as (select date_trunc('day',block_timestamp) as date, sum(amount)/pow(10,9) as sol_amount, case
    when (action='deposit' or action='deposit_dao' or action='deposit_dao_stake' or
    action='deposit_dao_with_referrer' or action='deposit_stake') then 'Stake'
    when (action='order_unstake' or action='withdraw' or action='withdraw_dao' or
    action='withdraw_dao_stake' or action='withdraw_stake' or action='claim') then 'Unstake'
    end as action_, count(distinct tx_id) as event_count
    from solana.core.fact_stake_pool_actions
    where block_timestamp::date>='2022-10-01' and amount is not null and succeeded='TRUE'
    group by 1,3
    order by 1),
    tab2 as (select date_trunc('day',recorded_hour) as date, avg(close) as avg_price
    from solana.core.fact_token_prices_hourly
    where symbol='SOL'
    group by 1
    order by 1)

    select tab1.date as date, sol_amount*avg_price as "Volume (USD)", action_, event_count
    from tab1 left join tab2 on tab1.date=tab2.DATE
    order by 1
    Run a query to Download Data