purifME top 5k stakers
    Updated 2025-01-09
    with locker as (
    select distinct instruction['accounts'][0] as depositor, instruction['accounts'][3] as lockup
    from solana.core.fact_events
    where program_id='veTbq5fF2HWYpgmkwjGKTYLVpY6miWYYmakML7R7LRf'
    and instruction['accounts'][1]='MEFNBXixkEbait3xn9bkm8WsJzXtVsaJEn4c8Sam21u' --me token*/
    )

    select depositor, sum(amount) as amount_staked from (
    select depositor, lockup, sum(amount) as amount from solana.core.fact_transfers t
    join locker l on l.depositor=t.tx_from and l.lockup=t.tx_to
    where mint='MEFNBXixkEbait3xn9bkm8WsJzXtVsaJEn4c8Sam21u'
    and BLOCK_TIMESTAMP <= timestamp '2025-01-06 16:20'
    group by 1,2
    union all
    select depositor, lockup, -1.0*sum(amount) as amount from solana.core.fact_transfers t
    join locker l on l.depositor=t.tx_to and l.lockup=t.tx_from
    where mint='MEFNBXixkEbait3xn9bkm8WsJzXtVsaJEn4c8Sam21u'
    and BLOCK_TIMESTAMP <= timestamp '2025-01-06 16:20'
    group by 1,2
    )
    group by 1 having sum(amount)>0
    order by 2 desc limit 5000
    QueryRunArchived: QueryRun has been archived