diff --git a/models/projects/metaplex/core/ez_metaplex_metrics.sql b/models/projects/metaplex/core/ez_metaplex_metrics.sql index 72594ee1..13ee38ed 100644 --- a/models/projects/metaplex/core/ez_metaplex_metrics.sql +++ b/models/projects/metaplex/core/ez_metaplex_metrics.sql @@ -58,9 +58,9 @@ with date_spine as ( , mints as ( select date - , sum(daily_mints) as daily_mints + , daily_mints + , cumulative_mints from {{ ref("fact_metaplex_assets_minted") }} - group by 1 ) , price as ( {{get_coingecko_metrics('metaplex')}} @@ -73,6 +73,7 @@ SELECT , coalesce(buybacks.buyback, 0) as buyback -- 50% of fees (ie all of revenue) go to buybacks but buybacks are done in batches, at the time of the buyback , coalesce(buybacks.buyback_native, 0) as buyback_native , coalesce(mints.daily_mints, 0) as daily_mints + , coalesce(mints.cumulative_mints, 0) as cumulative_mints , coalesce(active_wallets.dau, 0) as dau , coalesce(transactions.txns, 0) as txns , coalesce(unique_signers.unique_signers, 0) as unique_signers diff --git a/models/staging/metaplex/fact_metaplex_assets_minted.sql b/models/staging/metaplex/fact_metaplex_assets_minted.sql index 86bd5235..05af02a4 100644 --- a/models/staging/metaplex/fact_metaplex_assets_minted.sql +++ b/models/staging/metaplex/fact_metaplex_assets_minted.sql @@ -3,10 +3,10 @@ snowflake_warehouse="METAPLEX" ) }} -WITH daily_mints AS ( +WITH metaplex_mints AS ( SELECT date, - COUNT(DISTINCT mint) AS daily_mints, + COUNT(DISTINCT mint) AS mints, COUNT_IF(program_id = 'BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY') AS daily_bubblegum_mints, COUNT_IF(program_id = 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s') AS daily_token_metadata_mints, COUNT_IF(program_id IN ( @@ -21,8 +21,8 @@ WITH daily_mints AS ( SELECT date, - daily_mints, - SUM(daily_mints) OVER (ORDER BY date) AS cumulative_mints, + mints as daily_mints, + SUM(mints) OVER (ORDER BY date) as cumulative_mints, daily_bubblegum_mints, daily_token_metadata_mints, daily_candymachine_mints, @@ -30,6 +30,6 @@ SELECT SUM(daily_token_metadata_mints) OVER (ORDER BY date) AS cumulative_token_metadata_mints, SUM(daily_candymachine_mints) OVER (ORDER BY date) AS cumulative_candymachine_mints FROM - daily_mints + metaplex_mints ORDER BY - date DESC \ No newline at end of file + date DESC diff --git a/models/staging/metaplex/fact_metaplex_buybacks.sql b/models/staging/metaplex/fact_metaplex_buybacks.sql index 174ab6d9..7ffde553 100644 --- a/models/staging/metaplex/fact_metaplex_buybacks.sql +++ b/models/staging/metaplex/fact_metaplex_buybacks.sql @@ -1,5 +1,6 @@ {{ config( materialized= "incremental", + unique_key="date", snowflake_warehouse="METAPLEX" ) }} @@ -7,8 +8,8 @@ WITH buybacks AS ( select date_trunc('day', block_timestamp) as date - , amount - , mint as token_address + , max(amount) as amount + , max(mint) as token_address from solana_flipside.core.fact_transfers where tx_to = 'E7Hzc1cQwx5BgJa8hJGVuDF2G2f2penLrhiKU6nU53gK' and tx_from = 'BBcPaj5v95nFFbXfgTebYyJDSY5HBCpARuRCLynVWimp' and mint = 'METAewgxyPbgwsseH8T16a39CQ5VyVxZi9zXiDPY18m' @@ -17,6 +18,7 @@ buybacks AS ( {% else %} and block_timestamp >= '2024-06-26' {% endif %} + GROUP BY date ) , prices AS ( {{ get_coingecko_price_with_latest('metaplex') }} diff --git a/models/staging/metaplex/fact_metaplex_mints.sql b/models/staging/metaplex/fact_metaplex_mints.sql index 85477cd2..e398f9d5 100644 --- a/models/staging/metaplex/fact_metaplex_mints.sql +++ b/models/staging/metaplex/fact_metaplex_mints.sql @@ -25,4 +25,4 @@ WHERE ) {% if is_incremental() %} AND block_timestamp > (SELECT MAX(date) FROM {{ this }}) - {% endif %} \ No newline at end of file + {% endif %} diff --git a/models/staging/metaplex/fact_metaplex_sales.sql b/models/staging/metaplex/fact_metaplex_sales.sql index 6e4059f9..b158a069 100644 --- a/models/staging/metaplex/fact_metaplex_sales.sql +++ b/models/staging/metaplex/fact_metaplex_sales.sql @@ -1,7 +1,8 @@ {{ config( materialized = 'incremental', - snowflake_warehouse = 'METAPLEX' + snowflake_warehouse = 'METAPLEX', + unique_key = 'block_timestamp' ) }} @@ -13,5 +14,5 @@ FROM JOIN {{ ref('fact_metaplex_mints') }} AS m ON s.mint = m.mint {% if is_incremental() %} - AND block_timestamp > (SELECT MAX(block_timestamp) FROM {{ this }}) -{% endif %} \ No newline at end of file + WHERE block_timestamp > (SELECT MAX(block_timestamp) FROM {{ this }}) +{% endif %}