HosseinUntitled Query
    Updated 2023-01-06
    with t as (
    select
    block_timestamp,
    tx_hash,
    origin_from_address,
    amount_in_usd,
    amount_out_usd
    from optimism.sushi.ez_swaps
    where 'OP' in (symbol_in, symbol_out)

    union all

    select
    block_timestamp,
    tx_hash,
    origin_from_address,
    amount_in_usd,
    amount_out_usd
    from optimism.velodrome.ez_swaps
    where 'OP' in (symbol_in, symbol_out)
    )

    select block_timestamp::date as day,
    count(distinct tx_hash) as swaps_count,
    count(origin_from_address) as swappers_count,
    sum(amount_in_usd) as inflow_volume_usd,
    sum(amount_out_usd) as outflow_volume_usd,
    inflow_volume_usd - outflow_volume_usd as netflow_volume_usd,
    sum (swaps_count) over (order by day) as cumulative_swaps_count,
    sum(inflow_volume_usd) over (order by day) as cumulative_inflow_volume_usd,
    sum(outflow_volume_usd) over (order by day) as cumulative_outflow_volume_usd,
    sum(netflow_volume_usd) over (order by day) as cumulative_netflow_volume_usd
    from t
    where day >= '2022-01-01'
    group by day
    order by day asc
    Run a query to Download Data