hessSwap Volume
    Updated 2023-01-25
    with swap_from as ( select date(block_timestamp) as date, origin_from_address , tx_hash , amount_in_usd
    from ethereum.core.ez_dex_swaps
    where symbol_in = 'DYDX' )
    ,
    swap_to as ( select date(block_timestamp) as date, origin_from_address , tx_hash , amount_out_usd
    from ethereum.core.ez_dex_swaps
    where symbol_out = 'DYDX' )
    ,
    final as ( select 'Swap To DYDX' as type, date, count(DISTINCT(origin_from_address)) as total_user, count(DISTINCT(tx_hash)) as total_tx,
    sum(amount_out_usd) as volume, avg(amount_out_usd) as avg_usd
    from swap_to
    where date >= CURRENT_DATE - 180
    group by 1,2
    UNION
    select 'Swap From DYDX' as type, date, count(DISTINCT(origin_from_address)) as total_user, count(DISTINCT(tx_hash)) as total_tx,
    sum(amount_in_usd) as volume, avg(amount_in_usd) as avg_usd
    from swap_from
    where date >= CURRENT_DATE - 180
    group by 1,2)

    select type, sum(total_user) as total_swapper, sum(total_tx) as total_swap, sum(volume) as total_volume, avg(avg_usd) as averageg_usd
    from final
    group by 1
    Run a query to Download Data