with deploy_contract as (select tx_hash
from near.core.fact_actions_events
where action_name = 'DeployContract'),
new_smart_contracts as (select min(block_timestamp)::date as min_date, tx_receiver
from near.core.fact_transactions
where tx_hash in (select tx_hash from deploy_contract)
group by 2
having min_date <= current_date - 1 and min_date >= current_date - 90)
select min_date, count(distinct tx_receiver) as new_smart_contracts,
sum(new_smart_contracts) over (order by min_date asc rows between unbounded preceding and current row) as cumulative_new_smart_contracts
from new_smart_contracts
group by min_date
order by min_date asc