NavidCopy of Copy of Copy of Untitled Query
    Updated 2022-11-13
    with pool_actions as (
    SELECT
    case
    when action ilike '%deposit%' then 'Deposit'
    when action ilike '%withdraw%' then 'Withdraw'
    end as action_type,
    *
    from
    solana.core.fact_stake_pool_actions
    where
    succeeded
    ), daily_pool_actions as (
    select
    action_type,
    date_trunc('day', block_timestamp) as day,
    -- count(distinct tx_id) as transactions_count,
    -- count(distinct stake_pool_name) as pools_count,
    sum(ifnull(amount, 0)/1e9) as volume
    from
    pool_actions
    group BY
    action_type, day
    ), daily_flow as (
    select
    day,
    volume
    from
    daily_pool_actions
    where
    action_type='Deposit'
    union all
    select
    day,
    volume*-1
    from
    daily_pool_actions
    Run a query to Download Data