Muzeinstructions
    Updated 2023-04-13


    with instructions as (

    select
    date_trunc('day', a.block_timestamp) as day,
    'Token Deposits' as instruction,
    count( * ) as count

    from solana.core.fact_transactions a
    left join solana.core.fact_events b on a.tx_id = b.tx_id
    left join lateral flatten (input => log_messages) as messages
    where b.program_id = '4MangoMjqJ2firMokCjjGgoK8d4MXcrgL7XJaL3w6fVg'
    and b.succeeded
    and messages.value::varchar ilike '%Program log: Instruction: tokenDeposit%'
    and a.block_timestamp >= '2023-01-01'
    group by 1,2
    union all

    select
    date_trunc('day', a.block_timestamp) as day,
    'Token Withdrawal' as instruction,
    count( * ) as count


    from solana.core.fact_transactions a
    left join solana.core.fact_events b on a.tx_id = b.tx_id
    left join lateral flatten (input => log_messages) as messages
    where b.program_id = '4MangoMjqJ2firMokCjjGgoK8d4MXcrgL7XJaL3w6fVg'
    and b.succeeded
    and messages.value::varchar ilike '%Program log: Instruction: tokenWithdraw%'
    and a.block_timestamp >= '2023-01-01'
    group by 1,2
    )
    Run a query to Download Data