Ali3NTop 10 Velodrome Swappers By Their Swaps Count Uni vs Velo vs Zipswap Optimism
    Updated 2022-11-28
    with maintable as (
    select 'Sushiswap' as dex,
    origin_from_address,
    count (distinct t1.tx_hash) as Swaps_Count,
    sum (amount_in_usd) as Total_USD_Volume,
    sum (tx_fee) as Total_Fee
    from optimism.sushi.ez_swaps t1 join optimism.core.fact_transactions t2 on t1.tx_hash = t2.tx_hash
    and t1.block_timestamp >= CURRENT_DATE - {{since_days_ago}}
    group by 1,2

    union ALL

    select 'Velodrome' as dex,
    origin_from_address,
    count (distinct t1.tx_hash) as Swaps_Count,
    sum (amount_in_usd) as Total_USD_Volume,
    sum (tx_fee) as Total_Fee
    from optimism.velodrome.ez_swaps t1 join optimism.core.fact_transactions t2 on t1.tx_hash = t2.tx_hash
    and t1.block_timestamp >= CURRENT_DATE - {{since_days_ago}}
    group by 1,2

    union ALL

    select 'Uniswap' as dex,
    origin_from_address,
    count (distinct t1.tx_hash) as Swaps_Count,
    '0' as Total_USD_Volume,
    sum (tx_fee) as Total_Fee
    from optimism.core.fact_event_logs t1 join optimism.core.fact_transactions t2 on t1.tx_hash = t2.tx_hash
    where origin_to_address in ('0xe592427a0aece92de3edee1f18e0157c05861564','0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45')
    and event_name = 'Swap'
    and tx_status = 'SUCCESS'
    and t1.block_timestamp >= CURRENT_DATE - {{since_days_ago}}
    group by 1,2

    union ALL
    Run a query to Download Data