hess11. Top pairs
    Updated 2023-03-11
    with sushi as ( select 'ARB-Sushi' as chain,concat(symbol_in,'/',symbol_out) as pairs, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(origin_from_address)) as total_user,
    sum(amount_in_usd) as volume, avg(amount_in_usd) as avg_usd
    from arbitrum.sushi.ez_swaps
    where block_timestamp >= CURRENT_DATE - 90
    and (AMOUNT_IN_USD between AMOUNT_OUT_USD - 1000 and AMOUNT_OUT_USD + 1000)
    group by 1,2
    UNION
    select 'AVA-Sushi' as chain,concat(symbol_in,'/',symbol_out) as pairs, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(origin_from_address)) as total_user,
    sum(amount_in_usd) as volume, avg(amount_in_usd) as avg_usd
    from Avalanche.sushi.ez_swaps
    where block_timestamp >= CURRENT_DATE - 90
    group by 1,2
    UNION
    select 'OP-Sushi' as chain,concat(symbol_in,'/',symbol_out) as pairs, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(origin_from_address)) as total_user,
    sum(amount_in_usd) as volume, avg(amount_in_usd) as avg_usd
    from optimism.sushi.ez_swaps
    where block_timestamp >= CURRENT_DATE - 90
    group by 1,2
    )
    ,
    velodrome as ( select 'OP-Velodrome' as chain, concat(symbol_in,'/',symbol_out) as pairs,count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(origin_from_address)) as total_user,
    sum(amount_in_usd) as volume, avg(amount_in_usd) as avg_usd
    from optimism.velodrome.ez_swaps
    where block_timestamp >= CURRENT_DATE - 90
    and (AMOUNT_IN_USD between AMOUNT_OUT_USD - 1000 and AMOUNT_OUT_USD + 1000)
    group by 1,2)
    ,
    from_token as ( select date(block_timestamp) as date, tx_hash, contract_address as from_token, raw_amount as from_amount
    from avalanche.core.fact_token_transfers
    where origin_to_address = '0xe3ffc583dc176575eea7fd9df2a7c65f7e23f4c3' and origin_from_address = from_address
    and date >= current_date - 90)
    ,
    to_token as ( select date, a.tx_hash, origin_from_address, from_token, from_amount, contract_address as to_token, raw_amount as to_amount
    from avalanche.core.fact_token_transfers a join from_token b on a.tx_hash = b.tx_hash
    where to_address = '0xe3ffc583dc176575eea7fd9df2a7c65f7e23f4c3'
    and origin_to_address = '0xe3ffc583dc176575eea7fd9df2a7c65f7e23f4c3'
    Run a query to Download Data