Ali3NDistribution of Swappers By Swaps Volume (Avalanche Pharaoh)
    Updated 2025-03-24
    -- forked from Distribution of Swappers By Swaps Volume (Avalanche Pangolin) @ https://flipsidecrypto.xyz/studio/queries/5e59d03f-e363-4676-a258-7e4568ba9090

    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),

    swaptx as (
    select distinct tx_hash
    from avalanche.defi.ez_dex_swaps t1
    join timetable
    where platform ilike '%pharaoh%'
    and block_timestamp >= CURRENT_DATE - timeframe),

    maintable as (
    select origin_from_address,
    sum (coalesce(amount_in_usd,amount_out_usd,0)) as Volume
    from avalanche.defi.ez_dex_swaps t1
    join timetable
    where platform ilike '%pharaoh%'
    and amount_out_usd is not null
    and amount_in_usd is not null
    and block_timestamp >= CURRENT_DATE - timeframe
    group by 1)

    select case when volume < 10 then '< $10'
    when volume >= 10 and volume < 100 then '$10 - $100'
    when volume >= 100 and volume < 1000 then '$100 - $1,000'
    when volume >= 1000 and volume < 10000 then '$1,000 - $10,000'
    else '> $10,000' end as volume_type,
    count (distinct origin_from_address)
    Auto-refreshes every 12 hours
    QueryRunArchived: QueryRun has been archived