Moeusdt top holeders
    Updated 2022-06-17

    WITH ins as (
    SELECT
    distinct swapper,
    sum(swap_to_amount) as volume_in,
    count(distinct tx_id) as n_swaps_in,
    avg(swap_to_amount) as avg_volume
    from solana.fact_swaps x
    where
    swap_to_mint in ('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')
    and swap_to_amount >0 and swap_to_amount is not null
    group by 1
    ),
    outs as (
    SELECT
    distinct swapper,
    sum(swap_from_amount) as volume_out,
    count(distinct tx_id) as n_swaps_out,
    avg(swap_from_amount) as avg_volume
    from solana.fact_swaps x
    where
    swap_from_mint in ('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')
    and swap_from_amount >0 and swap_from_amount is not null
    group by 1
    ),
    fin as (SELECT
    x.swapper as swapper,
    volume_in-volume_out as net_volume,
    n_swaps_in+n_swaps_out as total_swaps,
    (x.avg_volume+y.avg_volume)/2 as avg_volume
    from ins x, outs y where x.swapper=y.swapper
    HAVING net_volume>0.1
    order by 2 desc limit 100
    Run a query to Download Data