SalehSolana Protocol Feature-pools weekly
    Updated 2022-07-13
    with lst_top_pools as (
    select top 10
    SWAP_FROM_MINT || '=>' || SWAP_TO_MINT as pool_address
    ,(select min( LABEL) from solana.core.dim_labels where ADDRESS=SWAP_FROM_MINT) ||'=>'
    ||(select min( LABEL) from solana.core.dim_labels where ADDRESS=SWAP_TO_MINT) as pool_name
    ,count(tx_id) as tx_count
    ,count(DISTINCT swapper) as wallets
    from solana.core.fact_swaps
    where block_timestamp::date>='2022-01-01'
    and SWAP_PROGRAM='raydium v4'
    and SUCCEEDED=true
    group by 1,2
    order by tx_count DESC
    )
    select
    date_trunc(week,block_timestamp)::date as weekly
    ,(select min( LABEL) from solana.core.dim_labels where ADDRESS=SWAP_FROM_MINT) ||'=>'
    ||(select min( LABEL) from solana.core.dim_labels where ADDRESS=SWAP_TO_MINT) as pool_name
    ,count(tx_id) as tx_count
    ,count(DISTINCT swapper) as wallets
    ,sum(SWAP_FROM_AMOUNT) as from_amount
    ,sum(SWAP_TO_AMOUNT) as to_amount
    ,sum(tx_count) over (partition by pool_name order by weekly) as growth_tx
    ,sum(wallets) over (partition by pool_name order by weekly) as growth_wallets
    from solana.core.fact_swaps
    where block_timestamp::date>='2022-01-01'
    and SWAP_PROGRAM='raydium v4'
    and SUCCEEDED=true
    and SWAP_FROM_MINT || '=>' || SWAP_TO_MINT in (select pool_address from lst_top_pools )
    group by 1,2
    order by 1


    Run a query to Download Data