cypheroptimism dashboard - daily stats
    Updated 2023-05-29
    with first_tx as (select
    from_address,
    min(block_timestamp) as timestamp
    from optimism.core.fact_transactions
    group by 1),
    daily_new_users as (select
    date(date_trunc('day', timestamp)) as date,
    count(*) as n_new_users,
    sum(n_new_users) over (order by date asc rows between unbounded preceding and current row) as cum_users
    from first_tx
    group by date),
    active_users as (select
    date(date_trunc('day', block_timestamp)) as date,
    count(distinct (from_address)) as active_users,
    count(distinct(tx_hash)) as n_tx,
    sum(tx_fee) as fee_eth,
    fee_eth/n_tx avg_tx_fee,
    n_tx/86400 as avg_tps
    from optimism.core.fact_transactions
    group by 1),


    active_contracts as (select
    date(date_trunc('day', block_timestamp)) as date,
    count(distinct(contract_address)) as active_contracts
    from optimism.core.fact_event_logs
    group by date),

    first_tx_cont as (select
    contract_address,
    min(block_timestamp) as timestamp
    from optimism.core.fact_event_logs
    group by 1
    ),
    Run a query to Download Data