Ali3NDistribution of Swappers By Swaps Count (Avalanche Pharaoh)
    Updated 2025-03-24
    -- forked from Distribution of Swappers By Swaps Count (Avalanche Pangolin) @ https://flipsidecrypto.xyz/studio/queries/0f6c6ea0-5132-41be-b368-81f5a7afec9f

    with timetable as (
    select case when '{{TimeFrame}}' = 'Last 7 Days' then 7
    when '{{TimeFrame}}' = 'Last 30 Days' then 30
    when '{{TimeFrame}}' = 'Last 60 Days' then 60
    when '{{TimeFrame}}' = 'Last 90 Days' then 90
    when '{{TimeFrame}}' = 'Last 180 Days' then 180
    when '{{TimeFrame}}' = 'Last 365 Days' then 365
    when '{{TimeFrame}}' = 'All Time' then 5000
    else 5000 end as timeframe),

    maintable as (
    select origin_from_address,
    count (distinct tx_hash) as Swaps_Count
    from avalanche.defi.ez_dex_swaps t1
    join timetable
    where platform ilike '%pharaoh%'
    and block_timestamp >= CURRENT_DATE - timeframe
    group by 1)

    select case when Swaps_Count = 1 then '1 Swap'
    when Swaps_Count > 1 and Swaps_Count <= 5 then '2 - 5 Swaps'
    when Swaps_Count > 5 and Swaps_Count <= 10 then '6 - 10 Swaps'
    when Swaps_Count > 10 and Swaps_Count <= 50 then '11 - 50 Swaps'
    when Swaps_Count > 50 and Swaps_Count <= 100 then '51 - 100 Swaps'
    else '> 100 Swaps' end as type,
    count (distinct origin_from_address)
    from maintable
    group by 1
    order by 2 desc



    Auto-refreshes every 12 hours
    QueryRunArchived: QueryRun has been archived