hessDaily Swap
    Updated 2023-09-04
    with swap_out as ( select *
    from avalanche.defi.ez_dex_swaps
    where symbol_in = 'JOE'
    and block_timestamp::date >= current_date - 90
    UNION
    select *
    from arbitrum.defi.ez_dex_swaps
    where symbol_in = 'JOE'
    and block_timestamp::date >= current_date - 90)
    ,
    swap_in as ( select *
    from avalanche.defi.ez_dex_swaps
    where symbol_out = 'JOE'
    and block_timestamp::date >= current_date - 90
    UNION
    select *
    from arbitrum.defi.ez_dex_swaps
    where symbol_out = 'JOE'
    and block_timestamp::date >= current_date - 90)


    select date(block_timestamp) as date, 'Sell' as type, count(DISTINCT(origin_from_address)) as users, count(DISTINCT(tx_hash)) as total_tx, sum(amount_in_usd) as volume
    from swap_out
    where symbol_in = 'JOE'
    and block_timestamp::date >= current_date - 90
    group by 1,2
    UNION
    select date(block_timestamp) as date, 'Buy' as type, count(DISTINCT(origin_from_address)) as users, count(DISTINCT(tx_hash)) as total_tx, sum(amount_out_usd) as volume
    from swap_in
    where symbol_out = 'JOE'
    and block_timestamp::date >= current_date - 90
    group by 1,2