with users_transaction as (
select FROM_ADDRESS as account, BLOCK_TIMESTAMP
from avalanche.core.fact_transactions
union
select TO_ADDRESS as account, BLOCK_TIMESTAMP
from avalanche.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
)
select block_date,
new_users_count,
sum(new_users_count) over (order by block_date) as accumulate_new_users_count
from new_users_weekly
order by block_date