Updated 2023-12-03
    -- forked from part1 copy @ https://flipsidecrypto.xyz/edit/queries/ef30669e-4c26-46f3-8414-cafe6bcdb1d4

    with t as (
    select
    tx_id,
    block_timestamp,
    nvl(signers[1], signers[0]) as user,
    iff(pre.value:owner = 'FK1VcVh5PqEUm8U3aEz69DRSNSCjD6cMjzGx3KKbiE8', 'Fee', 'Subscribe') as type,
    (post.value:uiTokenAmount:amount - pre.value:uiTokenAmount:amount)/1e6 as amount_acs
    from solana.core.fact_transactions
    join lateral flatten (input => pre_token_balances) pre
    join lateral flatten (input => post_token_balances) post
    where log_messages::string ilike '%6HW8dXjtiTGkD4jzXs7igdFmZExPpmwUrRN5195xGup%'
    and log_messages::string ilike '%Program log: Instruction: Stake%'
    and succeeded = 1
    and pre.value:owner != user
    and pre.value:owner = post.value:owner
    )

    select * from t
    where block_timestamp::date >= '2023-04-01' and block_timestamp::date < '2023-06-01'


    Run a query to Download Data