Skip to content

Commit

Permalink
Fix metaplex fees + added metaplex mints (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny77D authored Nov 25, 2024
1 parent bb7ea7a commit b672554
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
5 changes: 3 additions & 2 deletions models/projects/metaplex/core/ez_metaplex_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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')}}
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions models/staging/metaplex/fact_metaplex_assets_minted.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -21,15 +21,15 @@ 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,
SUM(daily_bubblegum_mints) OVER (ORDER BY date) AS cumulative_bubblegum_mints,
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
date DESC
6 changes: 4 additions & 2 deletions models/staging/metaplex/fact_metaplex_buybacks.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{{ config(
materialized= "incremental",
unique_key="date",
snowflake_warehouse="METAPLEX"
) }}

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'
Expand All @@ -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') }}
Expand Down
2 changes: 1 addition & 1 deletion models/staging/metaplex/fact_metaplex_mints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ WHERE
)
{% if is_incremental() %}
AND block_timestamp > (SELECT MAX(date) FROM {{ this }})
{% endif %}
{% endif %}
7 changes: 4 additions & 3 deletions models/staging/metaplex/fact_metaplex_sales.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{{
config(
materialized = 'incremental',
snowflake_warehouse = 'METAPLEX'
snowflake_warehouse = 'METAPLEX',
unique_key = 'block_timestamp'
)
}}

Expand All @@ -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 %}
WHERE block_timestamp > (SELECT MAX(block_timestamp) FROM {{ this }})
{% endif %}

0 comments on commit b672554

Please sign in to comment.