Skip to content

Commit

Permalink
Fixed Contract Deployment Counts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny77D committed Dec 11, 2024
1 parent 53277b0 commit e4e9a77
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 56 deletions.
15 changes: 15 additions & 0 deletions macros/contracts/get_contract_deployments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% macro get_contract_deployments(chain) %}
select
'{{chain}}' as chain,
date_trunc(week, block_timestamp) as date,
count(distinct from_address) as contract_deployers,
count(*) as contracts_deployed
from {{chain}}_flipside.core.fact_traces
where type in ('CREATE', 'CREATE2')
and TRACE_STATUS = 'SUCCESS'
{% if is_incremental() %}
and block_timestamp >= (select max(date) from {{ this }})
{% endif %}
group by date
order by date desc
{% endmacro %}
16 changes: 2 additions & 14 deletions models/metrics/contracts/fact_arbitrum_contracts.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
{{ config(materialized="incremental", unique_key="date") }}
{{ config(materialized="incremental", unique_key="date", snowflake_warehouse='ARBITRUM_MD') }}

select
'arbitrum' as chain,
date_trunc(week, block_timestamp) as date,
count(distinct from_address) as contract_deployers,
count(*) as contracts_deployed
from arbitrum_flipside.core.fact_transactions
where
to_address is null
{% if is_incremental() %}
and block_timestamp >= (select max(date) from {{ this }})
{% endif %}
group by date
order by date desc
{{get_contract_deployments("arbitrum")}}
16 changes: 2 additions & 14 deletions models/metrics/contracts/fact_base_contracts.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
{{ config(materialized="incremental", unique_key="date") }}
{{ config(materialized="incremental", unique_key="date", snowflake_warehouse='BASE_MD') }}

select
'base' as chain,
date_trunc(week, block_timestamp) as date,
count(distinct from_address) as contract_deployers,
count(*) as contracts_deployed
from base_flipside.core.fact_transactions
where
to_address is null
{% if is_incremental() %}
and block_timestamp >= (select max(date) from {{ this }})
{% endif %}
group by date
order by date desc
{{get_contract_deployments("base")}}
16 changes: 2 additions & 14 deletions models/metrics/contracts/fact_ethereum_contracts.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
{{ config(materialized="incremental", unique_key="date") }}
{{ config(materialized="incremental", unique_key="date", snowflake_warehouse='ETHEREUM') }}

select
'ethereum' as chain,
date_trunc(week, block_timestamp) as date,
count(distinct from_address) as contract_deployers,
count(*) as contracts_deployed
from ethereum_flipside.core.fact_transactions
where
to_address is null
{% if is_incremental() %}
and block_timestamp >= (select max(date) from {{ this }})
{% endif %}
group by date
order by date desc
{{get_contract_deployments("ethereum")}}
16 changes: 2 additions & 14 deletions models/metrics/contracts/fact_optimism_contracts.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
{{ config(materialized="incremental", unique_key="date") }}
{{ config(materialized="incremental", unique_key="date", snowflake_warehouse='OPTIMISM_MD') }}

select
'optimism' as chain,
date_trunc(week, block_timestamp) as date,
count(distinct from_address) as contract_deployers,
count(*) as contracts_deployed
from optimism_flipside.core.fact_transactions
where
to_address is null
{% if is_incremental() %}
and block_timestamp >= (select max(date) from {{ this }})
{% endif %}
group by date
order by date desc
{{get_contract_deployments("optimism")}}

0 comments on commit e4e9a77

Please sign in to comment.