Skip to content

Commit

Permalink
metaplex initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CaoimhConway committed Oct 23, 2024
1 parent 686b595 commit f3ee982
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
10 changes: 10 additions & 0 deletions models/projects/metaplex/core/ez_metaplex_metrics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{
config(
materialized="table",
snowflake_warehouse="metaplex",
database="metaplex",
schema="core",
alias="ez_metrics",
)
}}

30 changes: 30 additions & 0 deletions models/staging/metaplex/fact_metaplex_buybacks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{ config(
materialized= "table",
snowflake_warehouse="METAPLEX"
) }}

WITH daily_balances AS (
SELECT
DATE_TRUNC('day', block_timestamp) AS block_date,
account_address,
mint,
MAX(balance) AS ending_balance
FROM
solana_flipside.core.fact_token_balances
WHERE
owner = 'E7Hzc1cQwx5BgJa8hJGVuDF2G2f2penLrhiKU6nU53gK'
AND mint = 'METAewgxyPbgwsseH8T16a39CQ5VyVxZi9zXiDPY18m'
AND succeeded = TRUE
GROUP BY
DATE_TRUNC('day', block_timestamp),
account_address,
mint
)

SELECT
block_date,
ending_balance
FROM
daily_balances
ORDER BY
block_date ASC
51 changes: 51 additions & 0 deletions models/staging/metaplex/fact_metaplex_revenue.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{ config(
materialized= "table",
snowflake_warehouse="METAPLEX"
) }}

WITH metaplex_revenue AS (
SELECT
DATE(block_timestamp) AS block_date,
COUNT(DISTINCT tx_id) * 0.005 AS protocol_revenue
FROM solana_flipside.core.fact_events
WHERE program_id = 'MPL4o4wMzndgh8T1NVDxELQCj5UQfYTYEkabX3wNKtb'
GROUP BY block_date

UNION ALL

SELECT
DATE(block_timestamp) AS block_date,
COUNT(DISTINCT tx_id) * 0.01 AS protocol_revenue
FROM solana_flipside.core.fact_decoded_instructions
WHERE DATE(block_timestamp) >= '2023-06-01'
AND decoded_instruction:name::STRING IN ('CreateMetadataAccountV3', 'Create')
AND program_id IN (
SELECT 'CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d' -- Core
UNION ALL
SELECT 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s' -- Token Metadata
)
GROUP BY block_date

UNION ALL

SELECT
DATE(block_timestamp) AS block_date,
COUNT(DISTINCT tx_id) * 0.0015 AS protocol_revenue
FROM solana_flipside.core.fact_decoded_instructions
WHERE decoded_instruction:name::STRING IN ('CreateV1', 'CreateV2')
AND program_id IN (
SELECT 'CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d' -- Core
UNION ALL
SELECT 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s' -- Token Metadata
)
GROUP BY block_date
)

SELECT
block_date,
protocol_revenue,
SUM(protocol_revenue) OVER (ORDER BY block_date ASC) AS cumulative_revenue
FROM
metaplex_revenue
ORDER BY
block_date ASC

0 comments on commit f3ee982

Please sign in to comment.