0xsloaneDex swap volume median by swap program
    Updated 2024-10-31
    WITH dest_swap AS (
    SELECT
    CASE WHEN swap_program ilike '%raydium%' then 'raydium'
    WHEN swap_program ilike '%orca%' then 'orca'
    WHEN swap_program ilike '%whirlpool%' then 'orca'
    WHEN swap_program ilike '%jupiter%' then 'jupiter'
    WHEN swap_program ilike '%meteora%' then 'meteora'
    WHEN swap_program ilike '%saber%' then 'saber'
    ELSE LOWER(swap_program)
    END AS swap_program_grouped
    , COALESCE(swap_to_amount_usd,0) AS swap_amount_usd
    FROM solana.defi.ez_dex_swaps fs
    WHERE TRUE
    AND block_timestamp::DATE BETWEEN DATEADD(day, -{{days_to_look_back}}, current_date()) AND current_date() - 1
    AND swap_to_amount_usd > 0
    )
    SELECT
    swap_program_grouped
    , PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY swap_amount_usd) AS percentile_25_swap_volume_usd
    , PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY swap_amount_usd) AS percentile_50_swap_volume_usd
    , PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY swap_amount_usd) AS percentile_75_swap_volume_usd
    FROM
    dest_swap
    GROUP BY
    1
    ORDER BY
    3 DESC


    QueryRunArchived: QueryRun has been archived