Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metaplex fees + added metaplex mints #644

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 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 @@ -69,10 +69,11 @@ with date_spine as (
SELECT
ds.date
, coalesce(revenue.revenue_usd, 0) as fees
, coalesce(revenue.revenue_usd, 0) / 2 as revenue -- Fees are paid continuously, but revenue is only recognized at the time of the buyback
, coalesce(revenue.revenue_usd, 0) as revenue -- Fees + Revenue are same - 50% fees go to buybacks | the other 50% goes to dao treasury.
akan72 marked this conversation as resolved.
Show resolved Hide resolved
, 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 %}