superflyArbitrum New Users Weekly
    Updated 2023-01-13
    with users_transaction as (
    select from_address as account, block_timestamp
    from arbitrum.core.fact_transactions
    union
    select to_address as account, block_timestamp
    from arbitrum.core.fact_transactions
    ),

    new_users_date as (
    select account,
    min(block_timestamp) as min_block_time
    from users_transaction
    group by account
    order by 2
    ),

    new_users_weekly as (
    select date_trunc('week', min_block_time) as block_date,
    count(distinct account) as new_users_count
    from new_users_date
    group by 1
    order by 1
    ),

    new_users_weekly_change as (
    select block_date,
    new_users_count,
    (new_users_count - lag(new_users_count, 1) over (order by block_date)) / (lag(new_users_count, 1) over (order by block_date)) as change_rate
    from new_users_weekly
    order by block_date
    )

    select block_date,
    new_users_count,
    (case when change_rate > 50 then 50 else change_rate end) as change_rate -- Do some normalize
    from new_users_weekly_change
    Run a query to Download Data