MLDZMNavp7
    Updated 2022-11-09
    with tb1 as (SELECT
    SYMBOL_IN,
    count(distinct tx_hash) as swap_no,
    count(distinct ORIGIN_FROM_ADDRESS) as swappers,
    sum(AMOUNT_IN_USD) as volume,
    volume/swap_no as average_volume
    FROM optimism.velodrome.ez_swaps where SYMBOL_OUT='OP'
    group by 1 having volume is not null
    union all
    SELECT
    SYMBOL_IN,
    count(distinct tx_hash) as swap_no,
    count(distinct ORIGIN_FROM_ADDRESS) as swappers,
    sum(AMOUNT_IN_USD) as volume,
    volume/swap_no as average_volume
    FROM optimism.sushi.ez_swaps where SYMBOL_OUT='OP'
    group by 1 having volume is not null
    order by 4 desc limit 10)

    SELECT
    date_trunc('week',BLOCK_TIMESTAMP) as week,
    SYMBOL_IN,
    count(distinct tx_hash) as swap_no,
    count(distinct ORIGIN_FROM_ADDRESS) as swappers,
    sum(AMOUNT_IN_USD) as volume,
    volume/swap_no as average_volume
    FROM optimism.velodrome.ez_swaps where SYMBOL_OUT='OP'
    and SYMBOL_IN in (select SYMBOL_IN from tb1)
    group by 1,2 having volume is not null
    union all
    SELECT
    date_trunc('week',BLOCK_TIMESTAMP) as week,
    SYMBOL_IN,
    count(distinct tx_hash) as swap_no,
    count(distinct ORIGIN_FROM_ADDRESS) as swappers,
    sum(AMOUNT_IN_USD) as volume,
    Run a query to Download Data