CryptoIcicleEVM - 4. The “Flippening” Comparison - Swap Metrics
    Updated 2023-03-02
    -- It finally happened. The great Flip everyone’s been waiting for — Optimism and Arbitrum have officially surpassed Ethereum in combined transaction volume.
    -- (What, you were expecting some other flippening?)
    -- Use this historic event to compare and contrast these two major L2 chains.
    -- Include metrics such as total and average transaction volume, average transaction size, active users, new users added, and anything else you find relevant to this comparison.

    -- USDC Payouts:
    -- Rank USDC amount
    -- First place 400
    -- Second place 150
    -- Third place 150
    -- 4th through 15th place 75
    -- 16th through 21st place 50
    -- Payments are issued on the Ethereum mainnet chain.

    with op as (
    with
    txns as (
    select
    t.*,
    tx_fee as fee_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 >= CURRENT_DATE - {{n_days}} and e.block_timestamp >= CURRENT_DATE - {{n_days}}
    )
    select
    block_timestamp::date as date,
    'optimism' as type,
    count(distinct from_address) as n_users,
    count(distinct tx_hash) as swap_frequency,
    sum(fee_eth) as swap_fee_eth,
    sum(n_users) over (order by date asc rows between unbounded preceding and current row) as cum_n_users,
    sum(swap_fee_eth) over (order by date asc rows between unbounded preceding and current row) as cum_swap_fee_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