Afonso_Diaz2023-11-27 10:50 PM
    Updated 2023-11-27
    with

    t as (
    select
    recorded_hour::date as date,
    avg(close) as price_usd
    from solana.price.fact_token_prices_hourly
    where symbol = 'SOL'
    group by 1
    ),

    t1 as (
    select
    tx_id,
    block_timestamp,
    signers[0] as user,
    b.value:parsed:info:lamports / 1e9 as amount_sol,
    amount_sol * price_usd as amount_usd
    from solana.core.fact_events a
    join table(flatten (inner_instruction:instructions)) b
    join t on t.date = block_timestamp::date
    where program_id = 'SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy'
    and b.value:programId = '11111111111111111111111111111111'
    and b.value:parsed:type = 'transfer'
    and a.instruction:accounts[7] = 'J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn'
    and succeeded = 1
    and b.value:parsed:info:lamports > 0
    and block_timestamp::date <= '2023-11-25'
    )

    select
    user,
    count(distinct tx_id)
    from t1
    group by 1
    order by 2 DESC
    Run a query to Download Data