0-MIDTotal dex stats copy copy
    Updated 2024-01-15
    with tab1 as (
    select 'ARB'as token
    ,date_trunc('week',BLOCK_TIMESTAMP) as week
    ,sum(AMOUNT_OUT_USD) as buy_volume
    ,count(distinct ORIGIN_FROM_ADDRESS) as buyers
    ,count(distinct TX_HASH) as buy_swaps
    from arbitrum.defi.ez_dex_swaps
    where BLOCK_TIMESTAMP::date>='2023-10-01'
    and PLATFORM='uniswap-v3'
    and SYMBOL_OUT='ARB'
    group by 1,2),
    tab2 as (
    select 'OP'as token
    ,date_trunc('week',BLOCK_TIMESTAMP) as week
    ,sum(AMOUNT_OUT_USD) as buy_volume
    ,count(distinct ORIGIN_FROM_ADDRESS) as buyers
    ,count(distinct TX_HASH) as buy_swaps
    from optimism.defi.ez_dex_swaps
    where BLOCK_TIMESTAMP::date>='2023-10-01'
    and PLATFORM='uniswap-v3'
    and SYMBOL_OUT='OP'
    group by 1,2)
    select token
    ,round(avg(buyers)) as avg_buyers
    ,round(avg(buy_swaps)) as avg_buy_swaps
    from tab1
    group by 1
    union all
    select token
    ,avg(buyers) as avg_buyers
    ,avg(buy_swaps) as avg_buy_swaps
    from tab2
    group by 1

    QueryRunArchived: QueryRun has been archived