From 4fbef40777fadd5eea0b1c968d775210263566d6 Mon Sep 17 00:00:00 2001 From: Carl Cervone <42869436+ccerv1@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:06:35 -0400 Subject: [PATCH] adds: models for metal chain (#1576) * add: metal models * add: metal to contracts directory --- .../dbt/models/base_playground_sources.yml | 9 +++++++++ .../int_metal_contract_invocation_events.sql | 19 +++++++++++++++++++ .../blockchain/int_metal_traces.sql | 14 ++++++++++++++ .../blockchain/int_metal_transactions.sql | 14 ++++++++++++++ .../intermediate/directory/int_contracts.sql | 10 ++++++++++ .../models/intermediate/events/int_events.sql | 2 ++ warehouse/dbt/models/metal_sources.yml | 13 +++++++++++++ warehouse/dbt/models/playground_sources.yml | 9 +++++++++ .../staging/metal/stg_metal__deployers.sql | 14 ++++++++++++++ .../staging/metal/stg_metal__factories.sql | 14 ++++++++++++++ 10 files changed, 118 insertions(+) create mode 100644 warehouse/dbt/models/intermediate/blockchain/int_metal_contract_invocation_events.sql create mode 100644 warehouse/dbt/models/intermediate/blockchain/int_metal_traces.sql create mode 100644 warehouse/dbt/models/intermediate/blockchain/int_metal_transactions.sql create mode 100644 warehouse/dbt/models/metal_sources.yml create mode 100644 warehouse/dbt/models/staging/metal/stg_metal__deployers.sql create mode 100644 warehouse/dbt/models/staging/metal/stg_metal__factories.sql diff --git a/warehouse/dbt/models/base_playground_sources.yml b/warehouse/dbt/models/base_playground_sources.yml index 8edf79c90..5de816675 100644 --- a/warehouse/dbt/models/base_playground_sources.yml +++ b/warehouse/dbt/models/base_playground_sources.yml @@ -29,6 +29,15 @@ sources: - name: frax_deployers identifier: stg_frax__deployers + - name: metal_traces + identifier: int_metal_traces + + - name: metal_transactions + identifier: int_metal_transactions + + - name: metal_deployers + identifier: stg_metal__deployers + - name: mode_traces identifier: int_mode_traces diff --git a/warehouse/dbt/models/intermediate/blockchain/int_metal_contract_invocation_events.sql b/warehouse/dbt/models/intermediate/blockchain/int_metal_contract_invocation_events.sql new file mode 100644 index 000000000..aec345303 --- /dev/null +++ b/warehouse/dbt/models/intermediate/blockchain/int_metal_contract_invocation_events.sql @@ -0,0 +1,19 @@ +{{ + config( + materialized='incremental', + partition_by={ + "field": "time", + "data_type": "timestamp", + "granularity": "day", + }, + unique_id="id", + on_schema_change="append_new_columns", + incremental_strategy="insert_overwrite" + ) +}} +{% if is_incremental() %} + {% set start = "TIMESTAMP_SUB(_dbt_max_partition, INTERVAL 1 DAY)" %} +{% else %} + {% set start = "'1970-01-01'" %} +{% endif %} +{{ contract_invocation_events_with_l1("metal", start) }} diff --git a/warehouse/dbt/models/intermediate/blockchain/int_metal_traces.sql b/warehouse/dbt/models/intermediate/blockchain/int_metal_traces.sql new file mode 100644 index 000000000..c772be61a --- /dev/null +++ b/warehouse/dbt/models/intermediate/blockchain/int_metal_traces.sql @@ -0,0 +1,14 @@ +{{ + config( + materialized='incremental', + partition_by={ + "field": "block_timestamp", + "data_type": "timestamp", + "granularity": "day", + }, + unique_id="id", + on_schema_change="append_new_columns", + incremental_strategy="insert_overwrite" + ) +}} +{{ filtered_blockchain_events("METAL", "metal", "traces") }} diff --git a/warehouse/dbt/models/intermediate/blockchain/int_metal_transactions.sql b/warehouse/dbt/models/intermediate/blockchain/int_metal_transactions.sql new file mode 100644 index 000000000..41d33e470 --- /dev/null +++ b/warehouse/dbt/models/intermediate/blockchain/int_metal_transactions.sql @@ -0,0 +1,14 @@ +{{ + config( + materialized='incremental', + partition_by={ + "field": "block_timestamp", + "data_type": "timestamp", + "granularity": "day", + }, + unique_id="id", + on_schema_change="append_new_columns", + incremental_strategy="insert_overwrite" + ) +}} +{{ filtered_blockchain_events("METAL", "metal", "transactions") }} diff --git a/warehouse/dbt/models/intermediate/directory/int_contracts.sql b/warehouse/dbt/models/intermediate/directory/int_contracts.sql index 5fa83bf1a..f61c82dc6 100644 --- a/warehouse/dbt/models/intermediate/directory/int_contracts.sql +++ b/warehouse/dbt/models/intermediate/directory/int_contracts.sql @@ -14,6 +14,11 @@ with deployers as ( 'FRAX' as artifact_source from {{ ref('stg_frax__deployers') }} union all + select + *, + 'METAL' as artifact_source + from {{ ref('stg_metal__deployers') }} + union all select *, 'MODE' as artifact_source @@ -41,6 +46,11 @@ factories as ( 'FRAX' as artifact_source from {{ ref('stg_frax__factories') }} union all + select + *, + 'METAL' as artifact_source + from {{ ref('stg_metal__factories') }} + union all select *, 'MODE' as artifact_source diff --git a/warehouse/dbt/models/intermediate/events/int_events.sql b/warehouse/dbt/models/intermediate/events/int_events.sql index 1c0836b84..f71cc3b2a 100644 --- a/warehouse/dbt/models/intermediate/events/int_events.sql +++ b/warehouse/dbt/models/intermediate/events/int_events.sql @@ -162,6 +162,8 @@ all_events as ( union all select * from {{ ref('int_frax_contract_invocation_events') }} union all + select * from {{ ref('int_metal_contract_invocation_events') }} + union all select * from {{ ref('int_mode_contract_invocation_events') }} union all select * from {{ ref('int_pgn_contract_invocation_events') }} diff --git a/warehouse/dbt/models/metal_sources.yml b/warehouse/dbt/models/metal_sources.yml new file mode 100644 index 000000000..6fd3ac942 --- /dev/null +++ b/warehouse/dbt/models/metal_sources.yml @@ -0,0 +1,13 @@ +sources: + - name: metal + database: opensource-observer + schema: superchain + tables: + - name: blocks + identifier: metal_blocks + + - name: transactions + identifier: metal_transactions + + - name: traces + identifier: metal_traces diff --git a/warehouse/dbt/models/playground_sources.yml b/warehouse/dbt/models/playground_sources.yml index d0a6f38cf..211a83a0a 100644 --- a/warehouse/dbt/models/playground_sources.yml +++ b/warehouse/dbt/models/playground_sources.yml @@ -32,6 +32,15 @@ sources: - name: frax_deployers identifier: stg_frax__deployers + + - name: metal_traces + identifier: int_metal_traces + + - name: metal_transactions + identifier: int_metal_transactions + + - name: metal_deployers + identifier: stg_metal__deployers - name: mode_traces identifier: int_mode_traces diff --git a/warehouse/dbt/models/staging/metal/stg_metal__deployers.sql b/warehouse/dbt/models/staging/metal/stg_metal__deployers.sql new file mode 100644 index 000000000..fc870fe25 --- /dev/null +++ b/warehouse/dbt/models/staging/metal/stg_metal__deployers.sql @@ -0,0 +1,14 @@ +{{ + config( + materialized='incremental', + partition_by={ + "field": "block_timestamp", + "data_type": "timestamp", + "granularity": "day", + }, + unique_id="transaction_hash", + on_schema_change="append_new_columns", + incremental_strategy="insert_overwrite" + ) +}} +{{ transactions_with_receipts_deployers("metal") }} diff --git a/warehouse/dbt/models/staging/metal/stg_metal__factories.sql b/warehouse/dbt/models/staging/metal/stg_metal__factories.sql new file mode 100644 index 000000000..2bea14160 --- /dev/null +++ b/warehouse/dbt/models/staging/metal/stg_metal__factories.sql @@ -0,0 +1,14 @@ +{{ + config( + materialized='incremental', + partition_by={ + "field": "block_timestamp", + "data_type": "timestamp", + "granularity": "day", + }, + unique_id="transaction_hash", + on_schema_change="append_new_columns", + incremental_strategy="insert_overwrite" + ) +}} +{{ factory_deployments("metal") }}