afonsoOP stats daily
    Updated 2023-04-06
    with t as (
    select
    block_timestamp,
    tx_hash,
    origin_from_address,
    iff(symbol_in = 'OP', amount_in_usd, 0) as outflow_usd,
    iff(symbol_in = 'OP', amount_out_usd, 0) as inflow_usd,
    inflow_usd - outflow_usd as netflow
    from optimism.sushi.ez_swaps
    where 'OP' in (symbol_in, symbol_out)

    union all

    select
    block_timestamp,
    tx_hash,
    origin_from_address,
    iff(symbol_in = 'OP', amount_in_usd, 0) as outflow_usd,
    iff(symbol_in = 'OP', amount_out_usd, 0) as inflow_usd,
    inflow_usd - outflow_usd as netflow
    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(inflow_usd) as inflow_volume_usd,
    sum(outflow_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'
    Run a query to Download Data