From 6146c4e7def2ea5f0dc99173089c116aff849fe4 Mon Sep 17 00:00:00 2001 From: Sebastian Melendez Date: Tue, 14 May 2024 10:38:29 -0400 Subject: [PATCH 1/5] adding rolling mau and wau --- macros/metrics/get_mau_metrics.sql | 24 ------- .../get_rolling_active_address_metrics.sql | 7 +++ macros/rolling_active_addresses.sql | 63 +++++++++++++++++++ .../arbitrum/core/ez_arbitrum_metrics.sql | 5 +- .../avalanche/core/ez_avalanche_metrics.sql | 5 +- models/projects/base/core/ez_base_metrics.sql | 5 +- .../projects/blast/core/ez_blast_metrics.sql | 5 +- models/projects/bsc/core/ez_bsc_metrics.sql | 5 +- .../ethereum/core/ez_ethereum_metrics.sql | 5 +- models/projects/near/core/ez_near_metrics.sql | 7 ++- .../optimism/core/ez_optimism_metrics.sql | 5 +- .../polygon/core/ez_polygon_metrics.sql | 5 +- .../solana/core/ez_solana_metrics.sql | 4 ++ models/projects/tron/core/ez_tron_metrics.sql | 5 +- ...fact_arbitrum_rolling_active_addresses.yml | 45 +++++++++++++ ...fact_arbitrum_rolling_active_addresses.sql | 9 +++ ...act_avalanche_rolling_active_addresses.yml | 45 +++++++++++++ ...act_avalanche_rolling_active_addresses.sql | 9 +++ ...est_fact_base_rolling_active_addresses.yml | 45 +++++++++++++ .../fact_base_rolling_active_addresses.sql | 9 +++ ...st_fact_blast_rolling_active_addresses.yml | 45 +++++++++++++ .../fact_blast_rolling_active_addresses.sql | 9 +++ ...test_fact_bsc_rolling_active_addresses.yml | 45 +++++++++++++ .../bsc/fact_bsc_rolling_active_addresses.sql | 9 +++ ...fact_ethereum_rolling_active_addresses.yml | 45 +++++++++++++ ...fact_ethereum_rolling_active_addresses.sql | 9 +++ ...est_fact_near_rolling_active_addresses.yml | 45 +++++++++++++ .../fact_near_rolling_active_addresses.sql | 9 +++ ...fact_optimism_rolling_active_addresses.yml | 45 +++++++++++++ ...fact_optimism_rolling_active_addresses.sql | 9 +++ ..._fact_polygon_rolling_active_addresses.yml | 45 +++++++++++++ .../fact_polygon_rolling_active_addresses.sql | 9 +++ ...t_fact_solana_rolling_active_addresses.yml | 45 +++++++++++++ .../fact_solana_rolling_active_addresses.sql | 9 +++ ...est_fact_tron_rolling_active_addresses.yml | 45 +++++++++++++ .../fact_tron_rolling_active_addresses.sql | 9 +++ 36 files changed, 701 insertions(+), 43 deletions(-) delete mode 100644 macros/metrics/get_mau_metrics.sql create mode 100644 macros/metrics/get_rolling_active_address_metrics.sql create mode 100644 macros/rolling_active_addresses.sql create mode 100644 models/staging/arbitrum/_test_fact_arbitrum_rolling_active_addresses.yml create mode 100644 models/staging/arbitrum/fact_arbitrum_rolling_active_addresses.sql create mode 100644 models/staging/avalanche/_test_fact_avalanche_rolling_active_addresses.yml create mode 100644 models/staging/avalanche/fact_avalanche_rolling_active_addresses.sql create mode 100644 models/staging/base/_test_fact_base_rolling_active_addresses.yml create mode 100644 models/staging/base/fact_base_rolling_active_addresses.sql create mode 100644 models/staging/blast/_test_fact_blast_rolling_active_addresses.yml create mode 100644 models/staging/blast/fact_blast_rolling_active_addresses.sql create mode 100644 models/staging/bsc/_test_fact_bsc_rolling_active_addresses.yml create mode 100644 models/staging/bsc/fact_bsc_rolling_active_addresses.sql create mode 100644 models/staging/ethereum/_test_fact_ethereum_rolling_active_addresses.yml create mode 100644 models/staging/ethereum/fact_ethereum_rolling_active_addresses.sql create mode 100644 models/staging/near/_test_fact_near_rolling_active_addresses.yml create mode 100644 models/staging/near/fact_near_rolling_active_addresses.sql create mode 100644 models/staging/optimism/_test_fact_optimism_rolling_active_addresses.yml create mode 100644 models/staging/optimism/fact_optimism_rolling_active_addresses.sql create mode 100644 models/staging/polygon/_test_fact_polygon_rolling_active_addresses.yml create mode 100644 models/staging/polygon/fact_polygon_rolling_active_addresses.sql create mode 100644 models/staging/solana/_test_fact_solana_rolling_active_addresses.yml create mode 100644 models/staging/solana/fact_solana_rolling_active_addresses.sql create mode 100644 models/staging/tron/_test_fact_tron_rolling_active_addresses.yml create mode 100644 models/staging/tron/fact_tron_rolling_active_addresses.sql diff --git a/macros/metrics/get_mau_metrics.sql b/macros/metrics/get_mau_metrics.sql deleted file mode 100644 index 87f2099b..00000000 --- a/macros/metrics/get_mau_metrics.sql +++ /dev/null @@ -1,24 +0,0 @@ -{% macro get_mau_metrics(chain) %} - {% if chain == "tron" %} - select - date_trunc('month', block_timestamp) as date, - count(distinct from_address) as mau - from tron_allium.raw.transactions - where receipt_status = 1 - group by date - {% elif chain == "celo" %} - select - date_trunc('month', block_timestamp) as date, - count(distinct from_address) as mau - from {{ ref("fact_celo_transactions") }} - where status = 1 - group by date - {% else %} - select - date_trunc('month', block_timestamp) as date, - count(distinct from_address) as mau - from {{ chain }}_flipside.core.fact_transactions - where status = 'SUCCESS' - group by date - {% endif %} -{% endmacro %} \ No newline at end of file diff --git a/macros/metrics/get_rolling_active_address_metrics.sql b/macros/metrics/get_rolling_active_address_metrics.sql new file mode 100644 index 00000000..f20e3367 --- /dev/null +++ b/macros/metrics/get_rolling_active_address_metrics.sql @@ -0,0 +1,7 @@ +{% macro get_rolling_active_address_metrics(chain) %} + select + date, + mau, + wau + from {{ref("fact_" ~ chain ~ "_rolling_active_addresses")}} +{% endmacro %} \ No newline at end of file diff --git a/macros/rolling_active_addresses.sql b/macros/rolling_active_addresses.sql new file mode 100644 index 00000000..20ca71d6 --- /dev/null +++ b/macros/rolling_active_addresses.sql @@ -0,0 +1,63 @@ +{% macro rolling_active_addresses(chain) %} + with + {% if chain == 'solana' %} + distinct_dates as ( + select distinct + raw_date + from {{ chain }}.prod_raw.ez_transactions + where succeeded = 'TRUE' + {% if is_incremental() %} + and raw_date > (select dateadd('day', -1, max(date)) from {{ this }}) + {% endif %} + ), + distinct_dates_for_rolling_active_address as ( + select distinct + raw_date, + value as from_address + from {{ chain }}.prod_raw.ez_transactions, lateral flatten(input => signers) + where succeeded = 'TRUE' + ), + {% else %} + distinct_dates as ( + select distinct + raw_date + from {{ chain }}.prod_raw.ez_transactions + {% if is_incremental() %} + where raw_date > (select dateadd('day', -1, max(date)) from {{ this }}) + {% endif %} + ), + distinct_dates_for_rolling_active_address as ( + select distinct + raw_date, + from_address + from {{ chain }}.prod_raw.ez_transactions + ), + {% endif %} + + + rolling_mau as ( + select + t1.raw_date, + count(distinct t2.from_address) as mau + from distinct_dates t1 + join distinct_dates_for_rolling_active_address t2 on t2.raw_date between dateadd(DAY, -29, t1.raw_date) and t1.raw_date + group by t1.raw_date + ), + rolling_wau as ( + select + t1.raw_date, + count(distinct t2.from_address) as wau + from distinct_dates t1 + join distinct_dates_for_rolling_active_address t2 on t2.raw_date between dateadd(DAY, -6, t1.raw_date) and t1.raw_date + group by t1.raw_date + ) +select + rolling_mau.raw_date as date, + '{{ chain }}' as chain, + mau, + wau +from rolling_mau +left join rolling_wau using(raw_date) +where rolling_mau.raw_date < to_date(sysdate()) +order by date +{% endmacro %} \ No newline at end of file diff --git a/models/projects/arbitrum/core/ez_arbitrum_metrics.sql b/models/projects/arbitrum/core/ez_arbitrum_metrics.sql index 867ddd5e..1959666c 100644 --- a/models/projects/arbitrum/core/ez_arbitrum_metrics.sql +++ b/models/projects/arbitrum/core/ez_arbitrum_metrics.sql @@ -22,12 +22,13 @@ with contract_data as ({{ get_contract_metrics("arbitrum") }}), nft_metrics as ({{ get_nft_metrics("arbitrum") }}), p2p_metrics as ({{ get_p2p_metrics("arbitrum") }}), - mau_metrics as ({{ get_mau_metrics("arbitrum") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("arbitrum") }}) select fundamental_data.date, fundamental_data.chain, txns, dau, + wau, mau, fees_native, -- total gas fees paid on l2 by users(L2 Fees) fees, @@ -73,5 +74,5 @@ left join github_data on fundamental_data.date = github_data.date left join contract_data on fundamental_data.date = contract_data.date left join nft_metrics on fundamental_data.date = nft_metrics.date left join p2p_metrics on fundamental_data.date = p2p_metrics.date -left join mau_metrics on fundamental_data.date = mau_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/projects/avalanche/core/ez_avalanche_metrics.sql b/models/projects/avalanche/core/ez_avalanche_metrics.sql index 1c907594..5cb518cf 100644 --- a/models/projects/avalanche/core/ez_avalanche_metrics.sql +++ b/models/projects/avalanche/core/ez_avalanche_metrics.sql @@ -24,13 +24,14 @@ with ), nft_metrics as ({{ get_nft_metrics("avalanche") }}), p2p_metrics as ({{ get_p2p_metrics("avalanche") }}), - mau_metrics as ({{ get_mau_metrics("avalanche") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("avalanche") }}) select coalesce(fundamental_data.date, staking_data.date) as date, coalesce(fundamental_data.chain, 'avalanche') as chain, txns, dau, + wau, mau, fees_native, case when fees is null then fees_native * price else fees end as fees, @@ -78,5 +79,5 @@ left join contract_data on staking_data.date = contract_data.date left join issuance_data on staking_data.date = issuance_data.date left join nft_metrics on staking_data.date = nft_metrics.date left join p2p_metrics on staking_data.date = p2p_metrics.date -left join mau_metrics on staking_data.date = mau_metrics.date +left join rolling_metrics on staking_data.date = rolling_metrics.date where coalesce(fundamental_data.date, staking_data.date) < to_date(sysdate()) diff --git a/models/projects/base/core/ez_base_metrics.sql b/models/projects/base/core/ez_base_metrics.sql index 74d15073..93b05e43 100644 --- a/models/projects/base/core/ez_base_metrics.sql +++ b/models/projects/base/core/ez_base_metrics.sql @@ -20,13 +20,14 @@ with ), -- supply side revenue and fees nft_metrics as ({{ get_nft_metrics("base") }}), p2p_metrics as ({{ get_p2p_metrics("base") }}), - mau_metrics as ({{ get_mau_metrics("base") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("base") }}) select fundamental_data.date, fundamental_data.chain, txns, dau, + wau, mau, fees_native, -- total gas fees paid on l2 by users(L2 Fees) fees, @@ -62,5 +63,5 @@ left join expenses_data on fundamental_data.date = expenses_data.date left join contract_data on fundamental_data.date = contract_data.date left join nft_metrics on fundamental_data.date = nft_metrics.date left join p2p_metrics on fundamental_data.date = p2p_metrics.date -left join mau_metrics on fundamental_data.date = mau_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/projects/blast/core/ez_blast_metrics.sql b/models/projects/blast/core/ez_blast_metrics.sql index ab1c940b..32e692d8 100644 --- a/models/projects/blast/core/ez_blast_metrics.sql +++ b/models/projects/blast/core/ez_blast_metrics.sql @@ -21,7 +21,7 @@ with select date, chain, l1_data_cost_native, l1_data_cost, revenue_native, revenue from {{ ref("agg_daily_blast_revenue") }} ), - mau_metrics as ({{ get_mau_metrics("blast") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("blast") }}) select coalesce( fundamental_data.date, @@ -33,6 +33,7 @@ select 'blast' as chain, txns, dau, + wau, mau, fees_native, fees, @@ -59,5 +60,5 @@ left join defillama_data on fundamental_data.date = defillama_data.date left join stablecoin_data on fundamental_data.date = stablecoin_data.date left join contract_data on fundamental_data.date = contract_data.date left join expenses_data on fundamental_data.date = expenses_data.date -left join mau_metrics on fundamental_data.date = mau_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/projects/bsc/core/ez_bsc_metrics.sql b/models/projects/bsc/core/ez_bsc_metrics.sql index d5d09afc..233b88d1 100644 --- a/models/projects/bsc/core/ez_bsc_metrics.sql +++ b/models/projects/bsc/core/ez_bsc_metrics.sql @@ -17,12 +17,13 @@ with github_data as ({{ get_github_metrics("Binance Smart Chain") }}), contract_data as ({{ get_contract_metrics("bsc") }}), nft_metrics as ({{ get_nft_metrics("bsc") }}), - mau_metrics as ({{ get_mau_metrics("bsc") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("bsc") }}) select fundamental_data.date, fundamental_data.chain, txns, dau, + wau, mau, fees_native, fees, @@ -58,5 +59,5 @@ left join stablecoin_data on fundamental_data.date = stablecoin_data.date left join github_data on fundamental_data.date = github_data.date left join contract_data on fundamental_data.date = contract_data.date left join nft_metrics on fundamental_data.date = nft_metrics.date -left join mau_metrics on fundamental_data.date = mau_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/projects/ethereum/core/ez_ethereum_metrics.sql b/models/projects/ethereum/core/ez_ethereum_metrics.sql index c25f1951..459f7871 100644 --- a/models/projects/ethereum/core/ez_ethereum_metrics.sql +++ b/models/projects/ethereum/core/ez_ethereum_metrics.sql @@ -30,13 +30,14 @@ with ), nft_metrics as ({{ get_nft_metrics("ethereum") }}), p2p_metrics as ({{ get_p2p_metrics("ethereum") }}), - mau_metrics as ({{ get_mau_metrics("ethereum") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("ethereum") }}) select fundamental_data.date, fundamental_data.chain, txns, dau, + wau, mau, fees_native, case when fees is null then fees_native * price else fees end as fees, @@ -99,5 +100,5 @@ left join github_data on fundamental_data.date = github_data.date left join contract_data on fundamental_data.date = contract_data.date left join nft_metrics on fundamental_data.date = nft_metrics.date left join p2p_metrics on fundamental_data.date = p2p_metrics.date -left join mau_metrics on fundamental_data.date = mau_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/projects/near/core/ez_near_metrics.sql b/models/projects/near/core/ez_near_metrics.sql index 0cac25f8..fe54d6ce 100644 --- a/models/projects/near/core/ez_near_metrics.sql +++ b/models/projects/near/core/ez_near_metrics.sql @@ -18,13 +18,17 @@ with ), github_data as ({{ get_github_metrics("near") }}), contract_data as ({{ get_contract_metrics("near") }}), - p2p_metrics as ({{ get_p2p_metrics("near") }}) + p2p_metrics as ({{ get_p2p_metrics("near") }}), + rolling_metrics as ({{ get_rolling_active_address_metrics("near") }}) + select fundamental_data.date, fundamental_data.chain, txns, dau, + wau, + mau, fees_native, case when fees is null then fees_native * price else fees end as fees, avg_txn_fee, @@ -56,4 +60,5 @@ left join revenue_data on fundamental_data.date = revenue_data.date left join github_data on fundamental_data.date = github_data.date left join contract_data on fundamental_data.date = contract_data.date left join p2p_metrics on fundamental_data.date = p2p_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/projects/optimism/core/ez_optimism_metrics.sql b/models/projects/optimism/core/ez_optimism_metrics.sql index 7b6f49d2..f546a2e5 100644 --- a/models/projects/optimism/core/ez_optimism_metrics.sql +++ b/models/projects/optimism/core/ez_optimism_metrics.sql @@ -22,7 +22,7 @@ with ), -- supply side revenue and fees nft_metrics as ({{ get_nft_metrics("optimism") }}), p2p_metrics as ({{ get_p2p_metrics("optimism") }}), - mau_metrics as ({{ get_mau_metrics("optimism") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("optimism") }}) select coalesce( @@ -37,6 +37,7 @@ select 'optimism' as chain, txns, dau, + wau, mau, fees_native, -- total gas fees paid on l2 by users(L2 Fees) fees, @@ -82,5 +83,5 @@ left join github_data on fundamental_data.date = github_data.date left join contract_data on fundamental_data.date = contract_data.date left join nft_metrics on fundamental_data.date = nft_metrics.date left join p2p_metrics on fundamental_data.date = p2p_metrics.date -left join mau_metrics on fundamental_data.date = mau_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/projects/polygon/core/ez_polygon_metrics.sql b/models/projects/polygon/core/ez_polygon_metrics.sql index 4700ba22..e2808f9f 100644 --- a/models/projects/polygon/core/ez_polygon_metrics.sql +++ b/models/projects/polygon/core/ez_polygon_metrics.sql @@ -22,13 +22,14 @@ with ), nft_metrics as ({{ get_nft_metrics("polygon") }}), p2p_metrics as ({{ get_p2p_metrics("polygon") }}), - mau_metrics as ({{ get_mau_metrics("polygon") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("polygon") }}) select fundamental_data.date, fundamental_data.chain, txns, dau, + wau, mau, fees_native, fees, @@ -72,5 +73,5 @@ left join contract_data on fundamental_data.date = contract_data.date left join revenue_data on fundamental_data.date = revenue_data.date left join nft_metrics on fundamental_data.date = nft_metrics.date left join p2p_metrics on fundamental_data.date = p2p_metrics.date -left join mau_metrics on fundamental_data.date = mau_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/projects/solana/core/ez_solana_metrics.sql b/models/projects/solana/core/ez_solana_metrics.sql index fe7b4350..b4c2cbf6 100644 --- a/models/projects/solana/core/ez_solana_metrics.sql +++ b/models/projects/solana/core/ez_solana_metrics.sql @@ -21,6 +21,7 @@ with ), nft_metrics as ({{ get_nft_metrics("solana") }}), p2p_metrics as ({{ get_p2p_metrics("solana") }}), + rolling_metrics as ({{ get_rolling_active_address_metrics("solana") }}), {% if not is_incremental() %} unrefreshed_data as ( select @@ -152,6 +153,8 @@ select -- fact_votes_agg_block txns, dau, + wau, + mau, returning_users, new_users, weekly_commits_core_ecosystem, @@ -185,4 +188,5 @@ left join staking_data on fundamental_usage.date = staking_data.date left join issuance_data on fundamental_usage.date = issuance_data.date left join nft_metrics on fundamental_usage.date = nft_metrics.date left join p2p_metrics on fundamental_usage.date = p2p_metrics.date +left join rolling_metrics on fundamental_usage.date = rolling_metrics.date where fundamental_usage.date < to_date(sysdate()) diff --git a/models/projects/tron/core/ez_tron_metrics.sql b/models/projects/tron/core/ez_tron_metrics.sql index d3adc79e..0530192b 100644 --- a/models/projects/tron/core/ez_tron_metrics.sql +++ b/models/projects/tron/core/ez_tron_metrics.sql @@ -15,7 +15,7 @@ with stablecoin_data as ({{ get_stablecoin_metrics("tron") }}), github_data as ({{ get_github_metrics("tron") }}), p2p_metrics as ({{ get_p2p_metrics("tron") }}), - mau_metrics as ({{ get_mau_metrics("tron") }}) + rolling_metrics as ({{ get_rolling_active_address_metrics("tron") }}) select coalesce( fundamental_data.date, @@ -27,6 +27,7 @@ select 'tron' as chain, txns, dau, + wau, mau, fees_native, fees_native as revenue_native, @@ -61,5 +62,5 @@ left join defillama_data on fundamental_data.date = defillama_data.date left join stablecoin_data on fundamental_data.date = stablecoin_data.date left join github_data on fundamental_data.date = github_data.date left join p2p_metrics on fundamental_data.date = p2p_metrics.date -left join mau_metrics on fundamental_data.date = mau_metrics.date +left join rolling_metrics on fundamental_data.date = rolling_metrics.date where fundamental_data.date < to_date(sysdate()) diff --git a/models/staging/arbitrum/_test_fact_arbitrum_rolling_active_addresses.yml b/models/staging/arbitrum/_test_fact_arbitrum_rolling_active_addresses.yml new file mode 100644 index 00000000..fe393674 --- /dev/null +++ b/models/staging/arbitrum/_test_fact_arbitrum_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_arbitrum_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/arbitrum/fact_arbitrum_rolling_active_addresses.sql b/models/staging/arbitrum/fact_arbitrum_rolling_active_addresses.sql new file mode 100644 index 00000000..4d75602f --- /dev/null +++ b/models/staging/arbitrum/fact_arbitrum_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="ARBITRUM", + ) +}} + +{{ rolling_active_addresses("arbitrum") }} \ No newline at end of file diff --git a/models/staging/avalanche/_test_fact_avalanche_rolling_active_addresses.yml b/models/staging/avalanche/_test_fact_avalanche_rolling_active_addresses.yml new file mode 100644 index 00000000..bf76df8d --- /dev/null +++ b/models/staging/avalanche/_test_fact_avalanche_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_avalanche_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/avalanche/fact_avalanche_rolling_active_addresses.sql b/models/staging/avalanche/fact_avalanche_rolling_active_addresses.sql new file mode 100644 index 00000000..6a2cc7ec --- /dev/null +++ b/models/staging/avalanche/fact_avalanche_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="AVALANCHE", + ) +}} + +{{ rolling_active_addresses("avalanche") }} \ No newline at end of file diff --git a/models/staging/base/_test_fact_base_rolling_active_addresses.yml b/models/staging/base/_test_fact_base_rolling_active_addresses.yml new file mode 100644 index 00000000..94e5e145 --- /dev/null +++ b/models/staging/base/_test_fact_base_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_base_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/base/fact_base_rolling_active_addresses.sql b/models/staging/base/fact_base_rolling_active_addresses.sql new file mode 100644 index 00000000..410a5d0c --- /dev/null +++ b/models/staging/base/fact_base_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="BASE", + ) +}} + +{{ rolling_active_addresses("base") }} \ No newline at end of file diff --git a/models/staging/blast/_test_fact_blast_rolling_active_addresses.yml b/models/staging/blast/_test_fact_blast_rolling_active_addresses.yml new file mode 100644 index 00000000..a5dd321b --- /dev/null +++ b/models/staging/blast/_test_fact_blast_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_blast_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/blast/fact_blast_rolling_active_addresses.sql b/models/staging/blast/fact_blast_rolling_active_addresses.sql new file mode 100644 index 00000000..1c1204ca --- /dev/null +++ b/models/staging/blast/fact_blast_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="BLAST", + ) +}} + +{{ rolling_active_addresses("blast") }} \ No newline at end of file diff --git a/models/staging/bsc/_test_fact_bsc_rolling_active_addresses.yml b/models/staging/bsc/_test_fact_bsc_rolling_active_addresses.yml new file mode 100644 index 00000000..96b4bcff --- /dev/null +++ b/models/staging/bsc/_test_fact_bsc_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_bsc_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/bsc/fact_bsc_rolling_active_addresses.sql b/models/staging/bsc/fact_bsc_rolling_active_addresses.sql new file mode 100644 index 00000000..8898ca43 --- /dev/null +++ b/models/staging/bsc/fact_bsc_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="BSC_MD", + ) +}} + +{{ rolling_active_addresses("bsc") }} \ No newline at end of file diff --git a/models/staging/ethereum/_test_fact_ethereum_rolling_active_addresses.yml b/models/staging/ethereum/_test_fact_ethereum_rolling_active_addresses.yml new file mode 100644 index 00000000..fc17cf83 --- /dev/null +++ b/models/staging/ethereum/_test_fact_ethereum_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_ethereum_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/ethereum/fact_ethereum_rolling_active_addresses.sql b/models/staging/ethereum/fact_ethereum_rolling_active_addresses.sql new file mode 100644 index 00000000..d50177fc --- /dev/null +++ b/models/staging/ethereum/fact_ethereum_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="ETHEREUM", + ) +}} + +{{ rolling_active_addresses("ethereum") }} \ No newline at end of file diff --git a/models/staging/near/_test_fact_near_rolling_active_addresses.yml b/models/staging/near/_test_fact_near_rolling_active_addresses.yml new file mode 100644 index 00000000..fdd83410 --- /dev/null +++ b/models/staging/near/_test_fact_near_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_near_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/near/fact_near_rolling_active_addresses.sql b/models/staging/near/fact_near_rolling_active_addresses.sql new file mode 100644 index 00000000..e7d13998 --- /dev/null +++ b/models/staging/near/fact_near_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="NEAR", + ) +}} + +{{ rolling_active_addresses("near") }} \ No newline at end of file diff --git a/models/staging/optimism/_test_fact_optimism_rolling_active_addresses.yml b/models/staging/optimism/_test_fact_optimism_rolling_active_addresses.yml new file mode 100644 index 00000000..caf38983 --- /dev/null +++ b/models/staging/optimism/_test_fact_optimism_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_optimism_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/optimism/fact_optimism_rolling_active_addresses.sql b/models/staging/optimism/fact_optimism_rolling_active_addresses.sql new file mode 100644 index 00000000..aec5be11 --- /dev/null +++ b/models/staging/optimism/fact_optimism_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key="date", + snowflake_warehouse="OPTIMISM", + ) +}} + +{{ rolling_active_addresses("optimism") }} \ No newline at end of file diff --git a/models/staging/polygon/_test_fact_polygon_rolling_active_addresses.yml b/models/staging/polygon/_test_fact_polygon_rolling_active_addresses.yml new file mode 100644 index 00000000..9874cd86 --- /dev/null +++ b/models/staging/polygon/_test_fact_polygon_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_polygon_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/polygon/fact_polygon_rolling_active_addresses.sql b/models/staging/polygon/fact_polygon_rolling_active_addresses.sql new file mode 100644 index 00000000..007752a0 --- /dev/null +++ b/models/staging/polygon/fact_polygon_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="POLYGON", + ) +}} + +{{ rolling_active_addresses("polygon") }} \ No newline at end of file diff --git a/models/staging/solana/_test_fact_solana_rolling_active_addresses.yml b/models/staging/solana/_test_fact_solana_rolling_active_addresses.yml new file mode 100644 index 00000000..c7498327 --- /dev/null +++ b/models/staging/solana/_test_fact_solana_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_solana_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/solana/fact_solana_rolling_active_addresses.sql b/models/staging/solana/fact_solana_rolling_active_addresses.sql new file mode 100644 index 00000000..7d94db88 --- /dev/null +++ b/models/staging/solana/fact_solana_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="SOLANA", + ) +}} + +{{ rolling_active_addresses("solana") }} \ No newline at end of file diff --git a/models/staging/tron/_test_fact_tron_rolling_active_addresses.yml b/models/staging/tron/_test_fact_tron_rolling_active_addresses.yml new file mode 100644 index 00000000..b75889f7 --- /dev/null +++ b/models/staging/tron/_test_fact_tron_rolling_active_addresses.yml @@ -0,0 +1,45 @@ +models: + - name: fact_tron_rolling_active_addresses + tests: + - "dbt_expectations.expect_table_row_count_to_be_between:": + min_value: 1 + max_value: 1000000 + columns: + - name: CHAIN + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - name: mau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: wau + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_column_values_to_be_within_n_moving_stdevs: + date_column_name: DATE + period: day + lookback_periods: 1 + trend_periods: 14 + test_periods: 28 + sigma_threshold: 3 + take_logs: true + severity: warn + - name: DATE + tests: + - not_null + - dbt_expectations.expect_column_to_exist + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 3 + severity: warn diff --git a/models/staging/tron/fact_tron_rolling_active_addresses.sql b/models/staging/tron/fact_tron_rolling_active_addresses.sql new file mode 100644 index 00000000..a2a59dcb --- /dev/null +++ b/models/staging/tron/fact_tron_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="TRON", + ) +}} + +{{ rolling_active_addresses("tron") }} \ No newline at end of file From d98b3957390b9674f273f31b185a6340bdd5fef1 Mon Sep 17 00:00:00 2001 From: Sebastian Melendez Date: Tue, 14 May 2024 10:46:31 -0400 Subject: [PATCH 2/5] removing mau for celo --- macros/bridge/cctp_evm_transfers.sql | 40 +++++++++++++++++ models/projects/celo/core/ez_celo_metrics.sql | 4 +- models/staging/cctp/fact_cctp_transfers.sql | 43 +++++++++++++++++++ 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 macros/bridge/cctp_evm_transfers.sql create mode 100644 models/staging/cctp/fact_cctp_transfers.sql diff --git a/macros/bridge/cctp_evm_transfers.sql b/macros/bridge/cctp_evm_transfers.sql new file mode 100644 index 00000000..345ca7dd --- /dev/null +++ b/macros/bridge/cctp_evm_transfers.sql @@ -0,0 +1,40 @@ +{% macro cctp_transfers(chain, contract_address, source_domain_id) %} + {% if chain == 'solana'} + select + block_timestamp, + block_id as block_number, + tx_id as tx_hash, + program_id as contract_address, + PC_DBT_DB.PROD.BASE58_TO_HEX(f.value:data) as hex_data, + PC_DBT_DB.PROD.hex_to_base58(SUBSTRING(hex_data,129,64)) as sender, -- Need to figure out which one is the sender + PC_DBT_DB.PROD.BIG_ENDIAN_HEX_TO_DECIMAL(SUBSTRING(hex_data,33,16)) as nonce, + '0x' || SUBSTRING(hex_data,193,64) as reciepient, + PC_DBT_DB.PROD.BIG_ENDIAN_HEX_TO_DECIMAL(SUBSTRING(hex_data,113,16)) as amount, + PC_DBT_DB.PROD.hex_to_base58(SUBSTRING(hex_data,49,64)) as burn_token, + 5 as source_domain_id, + PC_DBT_DB.PROD.BIG_ENDIAN_HEX_TO_DECIMAL(SUBSTRING(hex_data,257,8)) as destination_domain_id + succeeded as status + FROM solana_flipside.core.fact_events, + lateral flatten(input => get_path(inner_instruction, 'instructions')) AS f + where program_id = 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' + and SUBSTRING(hex_data,17,16) = '90fc9192064aa7eb' + {% elif chain == 'noble' %} + + {% else %} + select + block_timestamp, + block_number, + tx_hash, + contract_address, + decoded_log:depositor::string as sender, + decoded_log:amount::number as nonce, + decoded_log:mintRecipient::string as reciepient, + decoded_log:amount::number as amount, + decoded_log:burnToken::string as burn_token, + {{ source_domain_id }} as source_domain_id, + decoded_log:destinationDomain::number as destination_domain_id , + tx_status as status + from {{ chain }}_flipside.core.ez_decoded_event_logs + where lower(contract_address) = lower('{{ contract_address }}') and event_name in ('DepositForBurn') + {% endif %} +{% endmacro %} \ No newline at end of file diff --git a/models/projects/celo/core/ez_celo_metrics.sql b/models/projects/celo/core/ez_celo_metrics.sql index fa785b1f..a6ef8216 100644 --- a/models/projects/celo/core/ez_celo_metrics.sql +++ b/models/projects/celo/core/ez_celo_metrics.sql @@ -17,8 +17,7 @@ with price_data as ({{ get_coingecko_metrics("celo") }}), defillama_data as ({{ get_defillama_metrics("celo") }}), github_data as ({{ get_github_metrics("celo") }}), - stablecoin_data as ({{ get_stablecoin_metrics("celo") }}), - mau_metrics as ({{ get_mau_metrics("celo") }}) + stablecoin_data as ({{ get_stablecoin_metrics("celo") }}) select fundamental_data.date, fundamental_data.chain, @@ -47,5 +46,4 @@ left join price_data on fundamental_data.date = price_data.date left join defillama_data on fundamental_data.date = defillama_data.date left join github_data on fundamental_data.date = github_data.date left join stablecoin_data on fundamental_data.date = stablecoin_data.date -left join mau_metrics on fundamental_data.date = mau_metrics.date where fundamental_data.date < to_date(sysdate()) \ No newline at end of file diff --git a/models/staging/cctp/fact_cctp_transfers.sql b/models/staging/cctp/fact_cctp_transfers.sql new file mode 100644 index 00000000..a111e61a --- /dev/null +++ b/models/staging/cctp/fact_cctp_transfers.sql @@ -0,0 +1,43 @@ +with +ethereum_source_transfers as ( + {{ cctp_evm_transfers("ethereum", "0xbd3fa81b58ba92a82136038b25adec7066af3155", 0) }} +), +avalanche_source_transfers as ( + {{ cctp_evm_transfers("avalanche", "0x6b25532e1060ce10cc3b0a99e5683b91bfde6982", 1) }} +), +optimism_source_transfers as ( + {{ cctp_evm_transfers("optimism", "0x2B4069517957735bE00ceE0fadAE88a26365528f", 2) }} +), +arbitrum_source_transfers as ( + {{ cctp_evm_transfers("arbitrum", "0x19330d10D9Cc8751218eaf51E8885D058642E08A", 3) }} +), +base_source_transfers as ( + {{ cctp_evm_transfers("base", " 0x1682Ae6375C4E4A97e4B583BC394c861A46D8962", 6) }} +), +polygon_source_transfers as ( + {{ cctp_evm_transfers("polygon", "0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE", 7) }} +), +solana_source_transfers as ( + {{ cctp_solana_transfers("solana", "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", 4) }} +), +noble_source_transfers as ( + {{ cctp_noble_transfers("noble", "noble1afmt2kk6n9fr7pwkjhe25hz86dlmkp2v4phl98", 5) }} +) + + + +-- select +-- block_timestamp, +-- block_height as block_number, +-- tx_id as tx_hash, +-- 'noble1afmt2kk6n9fr7pwkjhe25hz86dlmkp2v4phl98' as contract_address, +-- JSON_EXTRACT(message, '$.from') as sender, +-- null as nonce, +-- JSON_EXTRACT(message, '$.mint_recipient') as reciepient, +-- JSON_EXTRACT(message, '$.amount') as amount, +-- JSON_EXTRACT(message, '$.burn_token') as burn_token, +-- 4 as source_domain_id, +-- JSON_EXTRACT(message, '$.destination_domain') as destination_domain_id +-- from `numia-data.noble.noble_tx_messages` +-- where SUBSTR(message_type, -17) = 'MsgDepositForBurn' +-- limit 100 From 28cb05ff25eca3b9e2a7335db57e57cf2ebc04f2 Mon Sep 17 00:00:00 2001 From: Sebastian Melendez Date: Tue, 14 May 2024 10:50:12 -0400 Subject: [PATCH 3/5] cleaning up v1 of cctp --- macros/bridge/cctp_evm_transfers.sql | 4 +- models/staging/cctp/fact_cctp_transfers.sql | 54 ++++++--------------- 2 files changed, 15 insertions(+), 43 deletions(-) diff --git a/macros/bridge/cctp_evm_transfers.sql b/macros/bridge/cctp_evm_transfers.sql index 345ca7dd..9b0cc8d0 100644 --- a/macros/bridge/cctp_evm_transfers.sql +++ b/macros/bridge/cctp_evm_transfers.sql @@ -1,5 +1,5 @@ {% macro cctp_transfers(chain, contract_address, source_domain_id) %} - {% if chain == 'solana'} + {% if chain == 'solana' %} select block_timestamp, block_id as block_number, @@ -18,8 +18,6 @@ lateral flatten(input => get_path(inner_instruction, 'instructions')) AS f where program_id = 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' and SUBSTRING(hex_data,17,16) = '90fc9192064aa7eb' - {% elif chain == 'noble' %} - {% else %} select block_timestamp, diff --git a/models/staging/cctp/fact_cctp_transfers.sql b/models/staging/cctp/fact_cctp_transfers.sql index a111e61a..dbf12d5c 100644 --- a/models/staging/cctp/fact_cctp_transfers.sql +++ b/models/staging/cctp/fact_cctp_transfers.sql @@ -1,43 +1,17 @@ -with -ethereum_source_transfers as ( - {{ cctp_evm_transfers("ethereum", "0xbd3fa81b58ba92a82136038b25adec7066af3155", 0) }} -), -avalanche_source_transfers as ( - {{ cctp_evm_transfers("avalanche", "0x6b25532e1060ce10cc3b0a99e5683b91bfde6982", 1) }} -), -optimism_source_transfers as ( - {{ cctp_evm_transfers("optimism", "0x2B4069517957735bE00ceE0fadAE88a26365528f", 2) }} -), -arbitrum_source_transfers as ( - {{ cctp_evm_transfers("arbitrum", "0x19330d10D9Cc8751218eaf51E8885D058642E08A", 3) }} -), -base_source_transfers as ( - {{ cctp_evm_transfers("base", " 0x1682Ae6375C4E4A97e4B583BC394c861A46D8962", 6) }} -), -polygon_source_transfers as ( - {{ cctp_evm_transfers("polygon", "0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE", 7) }} -), -solana_source_transfers as ( - {{ cctp_solana_transfers("solana", "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", 4) }} -), -noble_source_transfers as ( - {{ cctp_noble_transfers("noble", "noble1afmt2kk6n9fr7pwkjhe25hz86dlmkp2v4phl98", 5) }} -) +{{ cctp_evm_transfers("ethereum", "0xbd3fa81b58ba92a82136038b25adec7066af3155", 0) }} +union all +{{ cctp_evm_transfers("avalanche", "0x6b25532e1060ce10cc3b0a99e5683b91bfde6982", 1) }} +union all +{{ cctp_evm_transfers("optimism", "0x2B4069517957735bE00ceE0fadAE88a26365528f", 2) }} +union all +{{ cctp_evm_transfers("arbitrum", "0x19330d10D9Cc8751218eaf51E8885D058642E08A", 3) }} +union all +{{ cctp_evm_transfers("base", " 0x1682Ae6375C4E4A97e4B583BC394c861A46D8962", 6) }} +union all +{{ cctp_evm_transfers("polygon", "0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE", 7) }} +union all +{{ cctp_solana_transfers("solana", "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", 4) }} + --- select --- block_timestamp, --- block_height as block_number, --- tx_id as tx_hash, --- 'noble1afmt2kk6n9fr7pwkjhe25hz86dlmkp2v4phl98' as contract_address, --- JSON_EXTRACT(message, '$.from') as sender, --- null as nonce, --- JSON_EXTRACT(message, '$.mint_recipient') as reciepient, --- JSON_EXTRACT(message, '$.amount') as amount, --- JSON_EXTRACT(message, '$.burn_token') as burn_token, --- 4 as source_domain_id, --- JSON_EXTRACT(message, '$.destination_domain') as destination_domain_id --- from `numia-data.noble.noble_tx_messages` --- where SUBSTR(message_type, -17) = 'MsgDepositForBurn' --- limit 100 From 55c11bcc951e2a3293404b9b9c497544a11908fa Mon Sep 17 00:00:00 2001 From: Sebastian Melendez Date: Tue, 14 May 2024 10:59:11 -0400 Subject: [PATCH 4/5] updating cctp --- .../{cctp_evm_transfers.sql => cctp_transfers.sql} | 0 models/staging/cctp/fact_cctp_transfers.sql | 14 +++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) rename macros/bridge/{cctp_evm_transfers.sql => cctp_transfers.sql} (100%) diff --git a/macros/bridge/cctp_evm_transfers.sql b/macros/bridge/cctp_transfers.sql similarity index 100% rename from macros/bridge/cctp_evm_transfers.sql rename to macros/bridge/cctp_transfers.sql diff --git a/models/staging/cctp/fact_cctp_transfers.sql b/models/staging/cctp/fact_cctp_transfers.sql index dbf12d5c..ea7b4b83 100644 --- a/models/staging/cctp/fact_cctp_transfers.sql +++ b/models/staging/cctp/fact_cctp_transfers.sql @@ -1,16 +1,16 @@ -{{ cctp_evm_transfers("ethereum", "0xbd3fa81b58ba92a82136038b25adec7066af3155", 0) }} +{{ cctp_transfers("ethereum", "0xbd3fa81b58ba92a82136038b25adec7066af3155", 0) }} union all -{{ cctp_evm_transfers("avalanche", "0x6b25532e1060ce10cc3b0a99e5683b91bfde6982", 1) }} +{{ cctp_transfers("avalanche", "0x6b25532e1060ce10cc3b0a99e5683b91bfde6982", 1) }} union all -{{ cctp_evm_transfers("optimism", "0x2B4069517957735bE00ceE0fadAE88a26365528f", 2) }} +{{ cctp_transfers("optimism", "0x2B4069517957735bE00ceE0fadAE88a26365528f", 2) }} union all -{{ cctp_evm_transfers("arbitrum", "0x19330d10D9Cc8751218eaf51E8885D058642E08A", 3) }} +{{ cctp_transfers("arbitrum", "0x19330d10D9Cc8751218eaf51E8885D058642E08A", 3) }} union all -{{ cctp_evm_transfers("base", " 0x1682Ae6375C4E4A97e4B583BC394c861A46D8962", 6) }} +{{ cct_transfers("base", "0x1682Ae6375C4E4A97e4B583BC394c861A46D8962", 6) }} union all -{{ cctp_evm_transfers("polygon", "0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE", 7) }} +{{ cctp_transfers("polygon", "0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE", 7) }} union all -{{ cctp_solana_transfers("solana", "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", 4) }} +{{ cctp_transfers("solana", "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", 4) }} From be293c140f04088b8b7bd46164a8f6c7f2d1667a Mon Sep 17 00:00:00 2001 From: Sebastian Melendez Date: Tue, 14 May 2024 11:02:38 -0400 Subject: [PATCH 5/5] fixing build bug --- models/staging/cctp/fact_cctp_transfers.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/staging/cctp/fact_cctp_transfers.sql b/models/staging/cctp/fact_cctp_transfers.sql index ea7b4b83..77fcd0fe 100644 --- a/models/staging/cctp/fact_cctp_transfers.sql +++ b/models/staging/cctp/fact_cctp_transfers.sql @@ -6,7 +6,7 @@ union all union all {{ cctp_transfers("arbitrum", "0x19330d10D9Cc8751218eaf51E8885D058642E08A", 3) }} union all -{{ cct_transfers("base", "0x1682Ae6375C4E4A97e4B583BC394c861A46D8962", 6) }} +{{ cctp_transfers("base", "0x1682Ae6375C4E4A97e4B583BC394c861A46D8962", 6) }} union all {{ cctp_transfers("polygon", "0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE", 7) }} union all