-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
686b595
commit f3ee982
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) | ||
}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |