diff --git a/models/projects/sei/core/ez_sei_metrics.sql b/models/projects/sei/core/ez_sei_metrics.sql index 30fc3a35..13186b7c 100644 --- a/models/projects/sei/core/ez_sei_metrics.sql +++ b/models/projects/sei/core/ez_sei_metrics.sql @@ -8,36 +8,34 @@ ) }} with - sei_fundamental_metrics as (select * from {{ ref("fact_sei_daa_txns_gas_gas_usd_revenue") }}) - , rolling_metrics as ({{ get_rolling_active_address_metrics("sei_wasm") }}) + sei_combined_fundamental_metrics as ( {{ get_fundamental_data_for_chain("sei") }} ) + , sei_fundamental_metrics as (select * from {{ ref("fact_sei_daa_txns_gas_gas_usd_revenue") }}) + , rolling_metrics as ({{ get_rolling_active_address_metrics("sei") }}) , sei_avg_block_time as (select * from {{ ref("fact_sei_avg_block_time_silver") }}) , price_data as ({{ get_coingecko_metrics("sei-network") }}) , defillama_data as ({{ get_defillama_metrics("sei") }}) , sei_evm_fundamental_metrics as (select * from {{ref("fact_sei_evm_fundamental_metrics_silver")}}) , sei_evm_avg_block_time as (select * from {{ ref("fact_sei_evm_avg_block_time_silver") }}) - , rolling_evm_metrics as ({{ get_rolling_active_address_metrics("sei_evm") }}) select - coalesce(wasm.date, evm.date, sei_avg_block_time.date, price.date, defillama.date) as date + coalesce(combined.date, wasm.date, evm.date, sei_avg_block_time.date, price.date, defillama.date) as date , (wasm_avg_block_time + evm_avg_block_time) / 2 as avg_block_time , (wasm_txns + evm_txns) / 86400 as avg_tps , 'sei' as chain - , wasm_txns + coalesce(evm_txns, 0) as txns - , wasm_daa + coalesce(evm_daa, 0) as dau - , wasm_new_users + coalesce(evm_new_users, 0) as new_users - , wasm_returning_users + coalesce(evm_returning_users, 0) as returning_users - , wasm_rolling_metrics.mau + evm_rolling_metrics.mau as mau - , wasm_rolling_metrics.wau + evm_rolling_metrics.wau as wau - , wasm_gas + coalesce(evm_gas, 0) as fees_native - , wasm_gas_usd + coalesce(evm_gas_usd, 0) as fees - , fees / txns as avg_txn_fee + , combined.txns as txns + , combined.dau as dau + , combined.new_users as new_users + , combined.returning_users as returning_users + , rolling_metrics.mau as mau + , rolling_metrics.wau as wau + , combined.fees_native as fees_native + , combined.fees as fees + , combined.avg_txn_fee as avg_txn_fee , 0 as revenue_native , 0 as revenue , wasm_txns , wasm_daa as wasm_dau , wasm_returning_users , wasm_new_users - , wasm_rolling_metrics.mau as wasm_mau - , wasm_rolling_metrics.wau as wasm_wau , wasm_gas as wasm_fees_native , wasm_gas_usd as wasm_fees , wasm_avg_block_time as wasm_avg_block_time @@ -51,20 +49,18 @@ select , evm_returning_users , evm_txns , evm_daa as evm_dau - , evm_rolling_metrics.mau as evm_mau - , evm_rolling_metrics.wau as evm_wau , evm_avg_tps , evm_gas as evm_fees_native , evm_gas_usd as evm_fees , 0 as evm_revenue , evm_avg_block_time -from sei_fundamental_metrics as wasm -full join rolling_metrics as wasm_rolling_metrics using (date) +from sei_combined_fundamental_metrics as combined +full join sei_fundamental_metrics as wasm using (date) +full join sei_evm_fundamental_metrics as evm using (date) +full join rolling_metrics using (date) full join sei_avg_block_time as sei_avg_block_time using (date) full join sei_evm_avg_block_time using (date) full join price_data as price using (date) full join defillama_data as defillama using (date) -full join sei_evm_fundamental_metrics as evm using (date) -full join rolling_evm_metrics as evm_rolling_metrics using (date) where -coalesce(wasm.date, evm.date, sei_avg_block_time.date, price.date, defillama.date) < date(sysdate()) +coalesce(combined.date, wasm.date, evm.date, sei_avg_block_time.date, price.date, defillama.date) < date(sysdate()) diff --git a/models/staging/sei/fact_sei_rolling_active_addresses.sql b/models/staging/sei/fact_sei_rolling_active_addresses.sql new file mode 100644 index 00000000..6a05d90c --- /dev/null +++ b/models/staging/sei/fact_sei_rolling_active_addresses.sql @@ -0,0 +1,9 @@ +{{ + config( + materialized="incremental", + unique_key=["date"], + snowflake_warehouse="SEI", + ) +}} + +{{ rolling_active_addresses("sei") }} diff --git a/models/staging/sei/fact_sei_wasm_transactions.sql b/models/staging/sei/fact_sei_wasm_transactions.sql index 58d362d1..1f2780ac 100644 --- a/models/staging/sei/fact_sei_wasm_transactions.sql +++ b/models/staging/sei/fact_sei_wasm_transactions.sql @@ -6,6 +6,15 @@ ) }} with + evm_txs AS ( + select + distinct tx_id from sei_flipside.core.fact_msg_attributes + where + msg_type ='message' and attribute_key = 'action' and ATTRIBUTE_VALUE = '/seiprotocol.seichain.evm.MsgEVMTransaction' + {% if is_incremental() %} + AND inserted_timestamp >= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }}) + {% endif %} + ), new_contracts as ( select distinct address, @@ -105,6 +114,10 @@ with AND t2.inserted_timestamp >= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }}) {% endif %} + AND tx_id NOT IN ( + SELECT tx_id + FROM evm_txs e + ) ) SELECT tx_hash