CryptoIcicleOptimism-9.Optimistic Bears - Swap Metrics
    Updated 2022-08-09
    -- Payout 150 USDC
    -- Grand Prize 450 USDC
    -- Level Advanced

    -- What's going on with Optimism?
    -- This is an open-ended bounty, what we call a Free Square, and it’s an opportunity for you to show us what you’ve got.
    -- Any topic is fair game; The goal here is to explore the data in creative ways and show off your explorations with visualizations (or even a tool/frontend if you’ve got eyes on the grand prize).

    with
    txns as (
    select
    t.*,
    ((t.gas_price/1e9) * (t.gas_used)) as gas_used_eth
    from optimism.core.fact_transactions t
    join optimism.core.fact_event_logs e on t.tx_hash = e.tx_hash and e.event_name = 'Swap'
    and t.block_timestamp between '2022-07-01' and '2022-07-31'
    )

    select
    block_timestamp::date as date,
    count(distinct from_address) as n_users,
    count(distinct tx_hash) as swap_frequency,
    sum(gas_used_eth) as swap_gas_eth,
    sum(n_users) over (order by date asc rows between unbounded preceding and current row) as cum_n_users,
    sum(swap_gas_eth) over (order by date asc rows between unbounded preceding and current row) as cum_swap_gas_eth,
    sum(swap_frequency) over (order by date asc rows between unbounded preceding and current row) as cum_swap_frequency
    from txns
    group by date
    Run a query to Download Data