From c6d300ab684eec29ecd437e417c3ff5cceeef2d8 Mon Sep 17 00:00:00 2001 From: alexwes Date: Wed, 18 Dec 2024 15:32:11 -0500 Subject: [PATCH 1/5] Wes/jupiter by pool (#680) --- .../core/ez_jupiter_metrics_by_token.sql | 22 +++++++++++++++++++ models/staging/__staging_sources.yml | 1 + 2 files changed, 23 insertions(+) create mode 100644 models/projects/jupiter/core/ez_jupiter_metrics_by_token.sql diff --git a/models/projects/jupiter/core/ez_jupiter_metrics_by_token.sql b/models/projects/jupiter/core/ez_jupiter_metrics_by_token.sql new file mode 100644 index 00000000..7a36f497 --- /dev/null +++ b/models/projects/jupiter/core/ez_jupiter_metrics_by_token.sql @@ -0,0 +1,22 @@ +{{ + config( + materialized="table", + snowflake_warehouse="JUPITER", + database="jupiter", + schema="core", + alias="ez_metrics_by_token", + ) +}} + +SELECT + block_timestamp::date as date, + chain, + app, + symbol as token, + mint as token_address, + sum(fee_usd) as trading_fees, + sum(size_usd) as trading_volume, + count(distinct owner) as unique_traders +FROM {{ ref('fact_jupiter_perps_txs') }} t +LEFT JOIN {{ source('SOLANA_FLIPSIDE_PRICE', 'ez_asset_metadata') }} m ON m.token_address = t.mint +GROUP BY 1,2,3,4,5 \ No newline at end of file diff --git a/models/staging/__staging_sources.yml b/models/staging/__staging_sources.yml index 391716f3..c2cb9472 100644 --- a/models/staging/__staging_sources.yml +++ b/models/staging/__staging_sources.yml @@ -25,6 +25,7 @@ sources: database: SOLANA_FLIPSIDE tables: - name: ez_prices_hourly + - name: ez_asset_metadata # ETHEREUM From 700227b8510ed88f321acc4fb4229529eac1de37 Mon Sep 17 00:00:00 2001 From: alexwes Date: Wed, 18 Dec 2024 15:46:20 -0500 Subject: [PATCH 2/5] Wes/hivemapper (#687) --- ...get_solana_token_mints_burns_transfers.sql | 82 +++++++++++++++++++ .../hivemapper/core/ez_hivemapper_metrics.sql | 74 +++++++++++++++++ .../core/ez_hivemapper_metrics_by_chain.sql | 20 +++++ .../fact_hivemapper_mints_burns_transfers.sql | 33 ++++++++ .../hivemapper/fact_hivemapper_stats.sql | 45 ++++++++++ 5 files changed, 254 insertions(+) create mode 100644 macros/solana_utils/get_solana_token_mints_burns_transfers.sql create mode 100644 models/projects/hivemapper/core/ez_hivemapper_metrics.sql create mode 100644 models/projects/hivemapper/core/ez_hivemapper_metrics_by_chain.sql create mode 100644 models/staging/hivemapper/fact_hivemapper_mints_burns_transfers.sql create mode 100644 models/staging/hivemapper/fact_hivemapper_stats.sql diff --git a/macros/solana_utils/get_solana_token_mints_burns_transfers.sql b/macros/solana_utils/get_solana_token_mints_burns_transfers.sql new file mode 100644 index 00000000..4a8b9cee --- /dev/null +++ b/macros/solana_utils/get_solana_token_mints_burns_transfers.sql @@ -0,0 +1,82 @@ +{% macro get_solana_token_mints_burns_transfers(token_address) %} + -- mints + SELECT + m.block_timestamp, + m.tx_id, + m.block_id, + index, + inner_index, + 'mint' as action, + m.mint, + m.token_account as tx_to_account, + null as tx_from_account, + m.mint_amount as amount_native, + m.mint_authority as token_authority, + fact_token_mint_actions_id as unique_id + from + solana_flipside.defi.fact_token_mint_actions m + where + 1 = 1 + and mint = '{{ token_address }}' + {% if is_incremental() %} + and block_timestamp >= (select dateadd('day', -3, max(block_timestamp)) from {{ this }}) + {% else %} + and block_timestamp >= '2022-11-01' + {% endif %} + + + union all + + -- transfers + SELECT + tf.block_timestamp, + tf.tx_id, + tf.block_id, + SPLIT_PART(index, '.', 1) as index, + COALESCE(NULLIF(SPLIT_PART(index, '.', 2), ''), 0) as inner_index, + 'transfer' as action, + tf.mint, + tf.tx_to as tx_to_account, + tf.tx_from as tx_from_account, + tf.amount as amount_native, + null as token_authority, + fact_transfers_id as unique_id + from + solana_flipside.core.fact_transfers tf + where + 1 = 1 + and mint = '{{ token_address }}' + {% if is_incremental() %} + and block_timestamp >= (select dateadd('day', -3, max(block_timestamp)) from {{ this }}) + {% else %} + and block_timestamp >= '2022-11-01' + {% endif %} + + union all + + -- burns + SELECT + b.block_timestamp, + b.tx_id, + b.block_id, + index, + inner_index, + 'burn' as action, + b.mint, + null as tx_to_account, + b.token_account as tx_from_account, + b.burn_amount as amount_native, + b.burn_authority as token_authority, + fact_token_burn_actions_id as unique_id + from + solana_flipside.defi.fact_token_burn_actions b + where + 1 = 1 + and mint = '{{ token_address }}' + {% if is_incremental() %} + and block_timestamp >= (select dateadd('day', -3, max(block_timestamp)) from {{ this }}) + {% else %} + and block_timestamp >= '2022-11-01' + {% endif %} + +{% endmacro %} \ No newline at end of file diff --git a/models/projects/hivemapper/core/ez_hivemapper_metrics.sql b/models/projects/hivemapper/core/ez_hivemapper_metrics.sql new file mode 100644 index 00000000..d0ed0622 --- /dev/null +++ b/models/projects/hivemapper/core/ez_hivemapper_metrics.sql @@ -0,0 +1,74 @@ +{{ + config( + materialized="table", + snowflake_warehouse="HIVEMAPPER", + database="hivemapper", + schema="core", + alias="ez_metrics", + ) +}} + +with + date_spine as ( + select * from {{ ref('dim_date_spine') }} + where date between '2022-12-20' and to_date(sysdate()) + ) + +, bme_reward_types_cte as ( + SELECT + distinct reward_type as bme_reward_types + FROM + {{ ref('fact_hivemapper_stats') }} + WHERE reward_type like 'Honey Burst%' or reward_type like 'Map Consumption%' +) +, stats as ( + select + block_timestamp::date as date, + SUM( + CASE + WHEN reward_type in (SELECT bme_reward_types FROM bme_reward_types_cte) AND action = 'mint' THEN amount_usd + END + ) as supply_side_fees, + SUM( + CASE + WHEN action = 'burn' and block_timestamp::date >= '2024-04-17' THEN amount_usd * 0.75 -- MIP 15 was introduced on 2024-04-17 and changed the burn fee structure such that 75% of burns are permanent (prev 0%) + END + ) as revenue, + SUM( + CASE + WHEN action = 'burn' THEN amount_usd -- MIP 15 was introduced on 2024-04-17 and changed the burn fee structure such that 75% of burns are permanent (prev 0%) + END + ) as fees, + SUM( + CASE WHEN action = 'mint' + THEN amount_native + END + ) as mints_native, + SUM( + CASE WHEN action = 'burn' + THEN amount_native + END + ) as burn_native, + COUNT( distinct + CASE WHEN action = 'mint' + THEN tx_to_account + WHEN action = 'transfer' AND reward_type in ('Bounty') + THEN tx_to_account + END + ) AS contributors + from + {{ ref('fact_hivemapper_stats') }} + GROUP BY + 1 +) +SELECT + date_spine.date, + COALESCE(stats.fees, 0) as fees, + COALESCE(stats.supply_side_fees, 0) as primary_supply_side_revenue, + COALESCE(stats.revenue, 0) as revenue, + COALESCE(stats.mints_native, 0) as mints_native, + COALESCE(stats.burn_native, 0) as burn_native, + COALESCE(stats.contributors, 0) as dau +FROM date_spine +LEFT JOIN stats ON date_spine.date = stats.date +WHERE date_spine.date < to_date(sysdate()) \ No newline at end of file diff --git a/models/projects/hivemapper/core/ez_hivemapper_metrics_by_chain.sql b/models/projects/hivemapper/core/ez_hivemapper_metrics_by_chain.sql new file mode 100644 index 00000000..a3e21da8 --- /dev/null +++ b/models/projects/hivemapper/core/ez_hivemapper_metrics_by_chain.sql @@ -0,0 +1,20 @@ +{{ + config( + materialized="table", + snowflake_warehouse="HIVEMAPPER", + database="hivemapper", + schema="core", + alias="ez_metrics_by_chain", + ) +}} + +select + date, + 'solana' as chain, + fees, + primary_supply_side_revenue, + revenue, + mints_native, + burn_native, + dau +from {{ ref('ez_hivemapper_metrics') }} \ No newline at end of file diff --git a/models/staging/hivemapper/fact_hivemapper_mints_burns_transfers.sql b/models/staging/hivemapper/fact_hivemapper_mints_burns_transfers.sql new file mode 100644 index 00000000..9788b73d --- /dev/null +++ b/models/staging/hivemapper/fact_hivemapper_mints_burns_transfers.sql @@ -0,0 +1,33 @@ +{{ + config( + materialized="incremental", + snowflake_warehouse="HIVEMAPPER", + unique_key=["tx_id", "action", "index", "inner_index"] + ) +}} + +with events as ( + {{ get_solana_token_mints_burns_transfers('4vMsoUT2BWatFweudnQM1xedRLfJgJ7hswhcpz4xgBTy') }} +) + +SELECT + e.block_timestamp, + e.tx_id, + e.index, + e.inner_index, + tx.log_messages, + e.action, + e.tx_to_account, + e.tx_from_account, + e.amount_native / 1e9 as amount_native +from + events e + join solana_flipside.core.fact_transactions tx on e.tx_id = tx.tx_id +where + 1 = 1 + {% if is_incremental() %} + and tx.block_timestamp >= (SELECT dateadd('day', -3, max(block_timestamp)) FROM {{ this }}) + {% else %} + and tx.block_timestamp >= '2022-11-01' + {% endif %} + and tx.succeeded \ No newline at end of file diff --git a/models/staging/hivemapper/fact_hivemapper_stats.sql b/models/staging/hivemapper/fact_hivemapper_stats.sql new file mode 100644 index 00000000..4af26360 --- /dev/null +++ b/models/staging/hivemapper/fact_hivemapper_stats.sql @@ -0,0 +1,45 @@ +{{ + config( + materialized="incremental", + snowflake_warehouse="HIVEMAPPER", + unique_key=["tx_id", "action", "index", "inner_index"] + ) +}} + +select + block_timestamp, + tx_id, + index, + inner_index, + log_messages, + action, + case + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 12): "Map Coverage"%' then 'Map Coverage' + when ARRAY_TO_STRING(log_messages, ',') like 'Program log: Memo (len 20): \"Map Coverage (Fleet)\"' then 'Map Coverage (Fleet)' + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 6): "Bounty"%' then 'Bounty' + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 4): "Buzz"%' then 'Buzz' + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 18): "Map Editing and QA"%' then 'Map Editing and QA' + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 15): "Map Consumption"%' then 'Map Consumption' + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 23): "Map Consumption (fleet)"%' then 'Map Consumption (fleet)' + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 17): "Foundation Reward"%' then 'FTM' + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 11): "Honey Burst"%' then 'Honey Burst' + when ARRAY_TO_STRING(log_messages, ',') like '%Program log: Memo (len 19): "Honey Burst (fleet)"%' then 'Honey Burst (fleet)' + else null + end as reward_type, + tx_to_account, + o1.owner as tx_to_owner, + tx_from_account, + o2.owner as tx_from_owner, + amount_native, + amount_native * p.price as amount_usd +from {{ref('fact_hivemapper_mints_burns_transfers')}} +left join solana_flipside.core.fact_token_account_owners o1 on o1.account_address = tx_to_account +left join solana_flipside.core.fact_token_account_owners o2 on o2.account_address = tx_from_account +left join solana_flipside.price.ez_prices_hourly p on p.hour = date_trunc('hour', block_timestamp) and p.token_address = '4vMsoUT2BWatFweudnQM1xedRLfJgJ7hswhcpz4xgBTy' +where 1=1 + and ( + not(action = 'transfer' AND reward_type is null) + ) +{% if is_incremental() %} + and block_timestamp >= (select dateadd('day', -3, max(block_timestamp)) from {{ this }}) +{% endif %} \ No newline at end of file From 051385279be8ea4a9e94808c33ca7662f6737087 Mon Sep 17 00:00:00 2001 From: SebMelendez01 <78228475+SebMelendez01@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:03:16 -0500 Subject: [PATCH 3/5] Artemis Wrapped: adding wrapped queries (#688) --- .../aggregate/agg_base_app_interactions.sql | 9 +++ .../agg_base_contract_deployments.sql | 8 +++ .../aggregate/agg_base_daily_interactions.sql | 7 +++ .../agg_base_stablecoin_classification.sql | 6 ++ .../aggregate/agg_base_tokens_held.sql | 26 +++++++++ .../aggregate/agg_solana_app_interactions.sql | 7 +++ .../agg_solana_contract_deployments.sql | 6 ++ .../agg_solana_daily_interactions.sql | 7 +++ .../agg_solana_stablecoin_classification.sql | 6 ++ .../aggregate/agg_solana_tokens_held.sql | 35 +++++++++++ .../artemis_wrapped/dim_artemis_wrapped.sql | 58 +++++++++++++++++++ models/artemis_wrapped/dim_blockbuster.sql | 13 +++++ .../artemis_wrapped/dim_bob_the_builder.sql | 11 ++++ models/artemis_wrapped/dim_boomer.sql | 9 +++ models/artemis_wrapped/dim_botimus_prime.sql | 14 +++++ .../artemis_wrapped/dim_dora_the_explorer.sql | 11 ++++ models/artemis_wrapped/dim_old_mcdonald.sql | 13 +++++ models/artemis_wrapped/dim_rugged_rat.sql | 8 +++ .../dim_solana_trench_warrior.sql | 7 +++ .../artemis_wrapped/dim_terminally_based.sql | 7 +++ .../dim_wolf_of_wallstreet.sql | 40 +++++++++++++ .../metrics/agg_artemis_wrapped_metrics.sql | 13 +++++ .../agg_base_artemis_wrapped_metrics.sql | 10 ++++ ...e_artemis_wrapped_metrics_with_percent.sql | 21 +++++++ .../agg_solana_artemis_wrapped_metrics.sql | 11 ++++ ...a_artemis_wrapped_metrics_with_percent.sql | 20 +++++++ 26 files changed, 383 insertions(+) create mode 100644 models/artemis_wrapped/aggregate/agg_base_app_interactions.sql create mode 100644 models/artemis_wrapped/aggregate/agg_base_contract_deployments.sql create mode 100644 models/artemis_wrapped/aggregate/agg_base_daily_interactions.sql create mode 100644 models/artemis_wrapped/aggregate/agg_base_stablecoin_classification.sql create mode 100644 models/artemis_wrapped/aggregate/agg_base_tokens_held.sql create mode 100644 models/artemis_wrapped/aggregate/agg_solana_app_interactions.sql create mode 100644 models/artemis_wrapped/aggregate/agg_solana_contract_deployments.sql create mode 100644 models/artemis_wrapped/aggregate/agg_solana_daily_interactions.sql create mode 100644 models/artemis_wrapped/aggregate/agg_solana_stablecoin_classification.sql create mode 100644 models/artemis_wrapped/aggregate/agg_solana_tokens_held.sql create mode 100644 models/artemis_wrapped/dim_artemis_wrapped.sql create mode 100644 models/artemis_wrapped/dim_blockbuster.sql create mode 100644 models/artemis_wrapped/dim_bob_the_builder.sql create mode 100644 models/artemis_wrapped/dim_boomer.sql create mode 100644 models/artemis_wrapped/dim_botimus_prime.sql create mode 100644 models/artemis_wrapped/dim_dora_the_explorer.sql create mode 100644 models/artemis_wrapped/dim_old_mcdonald.sql create mode 100644 models/artemis_wrapped/dim_rugged_rat.sql create mode 100644 models/artemis_wrapped/dim_solana_trench_warrior.sql create mode 100644 models/artemis_wrapped/dim_terminally_based.sql create mode 100644 models/artemis_wrapped/dim_wolf_of_wallstreet.sql create mode 100644 models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql create mode 100644 models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics.sql create mode 100644 models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql create mode 100644 models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics.sql create mode 100644 models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql diff --git a/models/artemis_wrapped/aggregate/agg_base_app_interactions.sql b/models/artemis_wrapped/aggregate/agg_base_app_interactions.sql new file mode 100644 index 00000000..c8cc4835 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_base_app_interactions.sql @@ -0,0 +1,9 @@ +{{config(materialized='table')}} +-- BLOCKBUSTER +-- DORA THE EXPLORER +-- OLD MACDONALD +-- SOLANA TRENCH WARRIOR +select from_address as address, app, count(distinct tx_hash) as interactions +from {{ref('ez_base_transactions')}} +where block_timestamp > '2023-12-31' and app is not null +group by 1, 2 diff --git a/models/artemis_wrapped/aggregate/agg_base_contract_deployments.sql b/models/artemis_wrapped/aggregate/agg_base_contract_deployments.sql new file mode 100644 index 00000000..008ed688 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_base_contract_deployments.sql @@ -0,0 +1,8 @@ +{{config(materialized='table')}} + +-- BOB THE BUILDER +select from_address as address, count(distinct to_address) as contract_deployments +from base_flipside.core.fact_traces +where type in ('CREATE', 'CREATE2') + and block_timestamp > '2023-12-31' +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/aggregate/agg_base_daily_interactions.sql b/models/artemis_wrapped/aggregate/agg_base_daily_interactions.sql new file mode 100644 index 00000000..2b025779 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_base_daily_interactions.sql @@ -0,0 +1,7 @@ +{{config(materialized='table')}} + +-- BOTEMUS PRIME +select block_timestamp::date as date, from_address as address, count(distinct tx_hash) as daily_interactions +from {{ ref('ez_base_transactions') }} +where block_timestamp > '2023-12-31' +group by 1, 2 \ No newline at end of file diff --git a/models/artemis_wrapped/aggregate/agg_base_stablecoin_classification.sql b/models/artemis_wrapped/aggregate/agg_base_stablecoin_classification.sql new file mode 100644 index 00000000..33893c75 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_base_stablecoin_classification.sql @@ -0,0 +1,6 @@ +{{config(materialized='table')}} +-- BOOMER +select from_address as address, array_agg(distinct symbol) as symbols, max(stablecoin_supply) as max_stablecoin_supply +from {{ref('ez_base_stablecoin_metrics_by_address')}} +where date > '2023-12-31' +group by 1 diff --git a/models/artemis_wrapped/aggregate/agg_base_tokens_held.sql b/models/artemis_wrapped/aggregate/agg_base_tokens_held.sql new file mode 100644 index 00000000..cbc24184 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_base_tokens_held.sql @@ -0,0 +1,26 @@ +{{config(materialized='table')}} +--WOLF OF WALLSTREET +--RUGGED RAT +with + tokens as ( + select contract_address, symbol + from ( + values + ('0x4ed4e862860bed51a9570b96d89af5e1b0efefed', 'DEGEN') + , ('0x52b492a33e447cdb854c7fc19f1e57e8bfa1777d', 'PEPE') + , ('0xb1a03eda10342529bbf8eb700a06c60441fef25d', 'MIGGLES') + , ('0xac1bd2486aaf3b5c0fc3fd868558b082a531b2b4', 'TOSHI') + , ('0x9a26f5433671751c3276a065f57e5a02d2817973', 'KEYCAT') + , ('0x2f20cf3466f80a5f7f532fca553c8cbc9727fef6', 'AKUMA') + , ('0xfad8cb754230dbfd249db0e8eccb5142dd675a0d', 'AEROBUD') + , ('0x23a96680ccde03bd4bdd9a3e9a0cb56a5d27f7c9', 'HENLO') + , ('0x6921b130d297cc43754afba22e5eac0fbf8db75b', 'DOGINME') + , ('0x768be13e1680b5ebe0024c42c896e3db59ec0149', 'SKI') + , ('0x532f27101965dd16442e59d40670faf5ebb142e4', 'BRETT') + ) as t(contract_address, symbol) + ) +select lower(address) as address, symbol, min(block_timestamp) as first_seen, coalesce(max(block_timestamp), sysdate()) as last_interaction_timestamp +from {{ ref('fact_base_address_balances_by_token') }} t +inner join tokens on lower(t.contract_address) = lower(tokens.contract_address) +where block_timestamp > '2023-12-31' +group by 1, 2 \ No newline at end of file diff --git a/models/artemis_wrapped/aggregate/agg_solana_app_interactions.sql b/models/artemis_wrapped/aggregate/agg_solana_app_interactions.sql new file mode 100644 index 00000000..0384cc05 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_solana_app_interactions.sql @@ -0,0 +1,7 @@ +{{config(materialized='table', snowflake_warehouse='BALANCES_LG')}} + +select value as address, app, count(distinct tx_hash) as interactions +from {{ref('ez_solana_transactions')}}, + lateral flatten(input => signers) +where block_timestamp > '2023-12-31' and app is not null +group by 1, 2 \ No newline at end of file diff --git a/models/artemis_wrapped/aggregate/agg_solana_contract_deployments.sql b/models/artemis_wrapped/aggregate/agg_solana_contract_deployments.sql new file mode 100644 index 00000000..1c1f78f4 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_solana_contract_deployments.sql @@ -0,0 +1,6 @@ +{{config(materialized='table')}} + +select instruction:parsed:info:account::string as address, count(*) as contract_deployments +from solana_flipside.core.fact_events +where program_id = 'BPFLoaderUpgradeab1e11111111111111111111111' +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/aggregate/agg_solana_daily_interactions.sql b/models/artemis_wrapped/aggregate/agg_solana_daily_interactions.sql new file mode 100644 index 00000000..4a90bb04 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_solana_daily_interactions.sql @@ -0,0 +1,7 @@ +{{config(materialized='table', snowflake_warehouse='BALANCES_LG')}} + +select block_timestamp::date as date, value as address, count(distinct tx_hash) as daily_interactions +from {{ ref('ez_solana_transactions') }}, + lateral flatten(input => signers) +where block_timestamp > '2023-12-31' +group by 1, 2 \ No newline at end of file diff --git a/models/artemis_wrapped/aggregate/agg_solana_stablecoin_classification.sql b/models/artemis_wrapped/aggregate/agg_solana_stablecoin_classification.sql new file mode 100644 index 00000000..63b27673 --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_solana_stablecoin_classification.sql @@ -0,0 +1,6 @@ +{{config(materialized='table')}} + +select from_address as address, array_agg(distinct symbol) as symbols, max(stablecoin_supply) as max_stablecoin_supply +from {{ref('ez_solana_stablecoin_metrics_by_address')}} +where date > '2023-12-31' +group by 1 diff --git a/models/artemis_wrapped/aggregate/agg_solana_tokens_held.sql b/models/artemis_wrapped/aggregate/agg_solana_tokens_held.sql new file mode 100644 index 00000000..f578ea9f --- /dev/null +++ b/models/artemis_wrapped/aggregate/agg_solana_tokens_held.sql @@ -0,0 +1,35 @@ +{{config(materialized='table')}} +--WOLF OF WALLSTREET +--RUGGED RAT +with + tokens as ( + select contract_address, symbol + from ( + values + ('DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263', 'BONK') + , ('EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm', 'WIF') + , ('2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump', 'PNUT') + , ('7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr', 'POPCAT') + , ('9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump', 'FARTCOIN') + , ('HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC', 'AI16Z') + , ('CzLSujWBLFsSjncfkh59rUFqvafWcY5tzedWJSuypump', 'GOAT') + , ('MEW1gQWJ3nEXg2qgERiKu7FAFj79PHvQVREQUzScPP5', 'MEW') + , ('63LfDmNb3MQ8mw9MtZ2To9bEA2M71kZUUGq5tiJxcqj9', 'GIGA') + , ('ukHH6c7mMyiWCf1b9pnWe25TSpkDDt3H5pQZgZ74J82', 'BOME') + , ('GJAFwWjJ3vnTsrQVabjBVK2TYB1YtRCQXRDfDgUnpump', 'ACT') + , ('8x5VqbHA8D7NkD52uNuS5nnt3PwA8pLD34ymskeSo2Wn', 'ZEREBRO') + , ('ED5nyyWEzpPPiWimP8vYm7sD7TD3LAt3Q3gRTWHzPJBY', 'MOODENG') + , ('Df6yfrKC8kZE3KNkrHERKzAetSxbrWeniQfyJY4Jpump', 'CHILLGUY') + , ('A8C3xuqscfmyLrte3VmTqrAq8kgMASius9AFNANwpump', 'FWOG') + + + , ('4GFe6MBDorSy5bLbiUMrgETr6pZcjyfxMDm5ehSgpump', 'HAWKTUAH') + , ('3an8rhdepsLCya22af7qDBKPbdomw8K4iCHXaA2Gpump', 'QUANT') + + ) as t(contract_address, symbol) + ) +select lower(address) as address, symbol, min(block_timestamp) as first_seen, coalesce(max(block_timestamp), sysdate()) as last_interaction_timestamp +from {{ ref('fact_solana_address_balances_by_token') }} t +inner join tokens on lower(t.contract_address) = lower(tokens.contract_address) +where block_timestamp > '2023-12-31' +group by 1, 2 \ No newline at end of file diff --git a/models/artemis_wrapped/dim_artemis_wrapped.sql b/models/artemis_wrapped/dim_artemis_wrapped.sql new file mode 100644 index 00000000..d962c75c --- /dev/null +++ b/models/artemis_wrapped/dim_artemis_wrapped.sql @@ -0,0 +1,58 @@ +{{config(materialized='table')}} +with +categories as ( + select + coalesce( + block_buster.address + , bob_the_builder.address + , botimus_prime.address + , terminally_based.address + , wolf_of_wallstreet.address + , dora_the_explorer.address + , old_mcdonald.address + , boomer.address + ) as address + , coalesce( + block_buster.category + , bob_the_builder.category + , botimus_prime.category + , terminally_based.category + , wolf_of_wallstreet.category + , dora_the_explorer.category + , old_mcdonald.category + , boomer.category + ) as category + , coalesce( + block_buster.reason::string + , bob_the_builder.reason::string + , botimus_prime.reason::string + , terminally_based.reason::string + , ARRAY_TO_STRING(wolf_of_wallstreet.reason, ', ') + , dora_the_explorer.reason::string + , ARRAY_TO_STRING(old_mcdonald.reason, ', ') + , ARRAY_TO_STRING(boomer.reason, ', ') + ) as reason + from {{ref('dim_blockbuster')}} block_buster + full outer join {{ref('dim_bob_the_builder')}} bob_the_builder using (address) + full outer join {{ref('dim_botimus_prime')}} botimus_prime using (address) + full outer join {{ref('dim_terminally_based')}} terminally_based using (address) + full outer join {{ref('dim_wolf_of_wallstreet')}} wolf_of_wallstreet using (address) + full outer join {{ref('dim_dora_the_explorer')}} dora_the_explorer using (address) + full outer join {{ref('dim_old_mcdonald')}} old_mcdonald using (address) + full outer join {{ref('dim_boomer')}} boomer using (address) +) + +select + address + , coalesce(category, 'NORMIE') as category + , reason + , total_txns + , total_txns_percent_rank as total_txns_percent_rank + , total_gas_paid + , total_gas_paid_percent_rank as total_gas_paid_percent_rank + , days_onchain + , days_onchain_percent_rank as days_onchain_percent_rank + , apps_used + , apps_used_percent_rank as apps_used_percent_rank +from {{ref('agg_artemis_wrapped_metrics')}} +left join categories using (address) \ No newline at end of file diff --git a/models/artemis_wrapped/dim_blockbuster.sql b/models/artemis_wrapped/dim_blockbuster.sql new file mode 100644 index 00000000..97cf1dcd --- /dev/null +++ b/models/artemis_wrapped/dim_blockbuster.sql @@ -0,0 +1,13 @@ +{{config(materialized='table')}} + +select lower(address) as address, 'THE_BLOCKBUSTER' as category, count(distinct app) as reason +from {{ ref('agg_base_app_interactions') }} +group by 1 +having reason > 20 + +union all + +select lower(address) as address, 'THE_BLOCKBUSTER' as category, count(distinct app) as reason +from {{ ref('agg_solana_app_interactions') }} +group by 1 +having reason > 20 diff --git a/models/artemis_wrapped/dim_bob_the_builder.sql b/models/artemis_wrapped/dim_bob_the_builder.sql new file mode 100644 index 00000000..b4c81fb9 --- /dev/null +++ b/models/artemis_wrapped/dim_bob_the_builder.sql @@ -0,0 +1,11 @@ +{{config(materialized='table')}} + +select lower(address) as address, 'BOB_THE_BUIDLER' as category, contract_deployments as reason +from {{ ref('agg_base_contract_deployments') }} +where contract_deployments > 5 + +union all + +select lower(address) as address, 'BOB_THE_BUIDLER' as category, contract_deployments as reason +from {{ ref('agg_solana_contract_deployments') }} +where contract_deployments > 5 \ No newline at end of file diff --git a/models/artemis_wrapped/dim_boomer.sql b/models/artemis_wrapped/dim_boomer.sql new file mode 100644 index 00000000..9e0f66c8 --- /dev/null +++ b/models/artemis_wrapped/dim_boomer.sql @@ -0,0 +1,9 @@ +{{config(materialized='table')}} + +select lower(address) as address, 'BOOMER' as category, symbols as reason +from {{ ref('agg_base_stablecoin_classification')}} + +union all + +select lower(address) as address, 'BOOMER' as category, symbols as reason +from {{ ref('agg_solana_stablecoin_classification')}} \ No newline at end of file diff --git a/models/artemis_wrapped/dim_botimus_prime.sql b/models/artemis_wrapped/dim_botimus_prime.sql new file mode 100644 index 00000000..4400afc1 --- /dev/null +++ b/models/artemis_wrapped/dim_botimus_prime.sql @@ -0,0 +1,14 @@ +{{config(materialized='table')}} + +select lower(address) as address, 'BOTIMUS_PRIME' as category, count(distinct date) as reason +from {{ref('agg_base_daily_interactions')}} +where daily_interactions > 1000 +group by 1 + +union all + + +select lower(address) as address, 'BOTIMUS_PRIME' as category, count(distinct date) as reason +from {{ref('agg_solana_daily_interactions')}} +where daily_interactions > 1000 +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/dim_dora_the_explorer.sql b/models/artemis_wrapped/dim_dora_the_explorer.sql new file mode 100644 index 00000000..f2aa1e31 --- /dev/null +++ b/models/artemis_wrapped/dim_dora_the_explorer.sql @@ -0,0 +1,11 @@ +{{config(materialized='table')}} + +select lower(address) as address, 'DORA_THE_EXPLORER' as category, count(distinct app) as reason +from {{ ref('agg_base_app_interactions')}} +group by 1 +having reason >= 3 and reason <= 20 +union all +select lower(address) as address, 'DORA_THE_EXPLORER' as category, count(distinct app) as reason +from {{ ref('agg_solana_app_interactions')}} +group by 1 +having reason >= 3 and reason <= 20 diff --git a/models/artemis_wrapped/dim_old_mcdonald.sql b/models/artemis_wrapped/dim_old_mcdonald.sql new file mode 100644 index 00000000..7b801d61 --- /dev/null +++ b/models/artemis_wrapped/dim_old_mcdonald.sql @@ -0,0 +1,13 @@ +{{config(materialized='table')}} + +select lower(address) as address, 'OLD_MCDONALD' as category, array_agg(distinct app) as reason +from {{ ref('agg_base_app_interactions') }} +where app in ('aave', 'uniswap', 'aerodrome', 'sushiswap') and interactions > 5 +group by 1 + +union all + +select lower(address) as address, 'OLD_MCDONALD' as category, array_agg(distinct app) as reason +from {{ ref('agg_solana_app_interactions') }} +where app in ('jupiter', 'drift', 'magic_eden', 'kamino', 'selenium') and interactions > 5 +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/dim_rugged_rat.sql b/models/artemis_wrapped/dim_rugged_rat.sql new file mode 100644 index 00000000..44407472 --- /dev/null +++ b/models/artemis_wrapped/dim_rugged_rat.sql @@ -0,0 +1,8 @@ +{{config(materialized='table')}} + +select lower(address) as address, 'WOLF_OF_WALL_STREET' as category, array_agg(distinct symbol) as reason +from {{ ref('agg_solana_tokens_held') }} +where + (symbol = 'HAWKTUAH' and first_seen <= '2024-11-26') + or (symbol = 'QUANT' and first_seen < '2024-11-21') +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/dim_solana_trench_warrior.sql b/models/artemis_wrapped/dim_solana_trench_warrior.sql new file mode 100644 index 00000000..61a0c708 --- /dev/null +++ b/models/artemis_wrapped/dim_solana_trench_warrior.sql @@ -0,0 +1,7 @@ +{{config(materialized='table')}} + + +select lower(address) as address, 'SOLANA_TRENCH_WARRIOR' as category, array_agg(app) as reason +from {{ ref('agg_solana_app_interactions') }} +where interactions > 300 and app in ('pumpdotfun', 'raydium') +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/dim_terminally_based.sql b/models/artemis_wrapped/dim_terminally_based.sql new file mode 100644 index 00000000..416eb85d --- /dev/null +++ b/models/artemis_wrapped/dim_terminally_based.sql @@ -0,0 +1,7 @@ +{{config(materialized='table')}} + + +select lower(address) as address, 'TERMINALLY_ONBASE' as category, count(distinct date) as reason +from {{ ref('agg_base_daily_interactions')}} +group by 1 +having reason > 100 \ No newline at end of file diff --git a/models/artemis_wrapped/dim_wolf_of_wallstreet.sql b/models/artemis_wrapped/dim_wolf_of_wallstreet.sql new file mode 100644 index 00000000..5ff88cee --- /dev/null +++ b/models/artemis_wrapped/dim_wolf_of_wallstreet.sql @@ -0,0 +1,40 @@ +{{config(materialized='table')}} + +select lower(address) as address, 'WOLF_OF_WALL_STREET' as category, array_agg(distinct symbol) as reason +from {{ ref('agg_base_tokens_held') }} +where + (symbol = 'DEGEN' and first_seen < '2024-03-24') + or (symbol = 'PEPE' and first_seen < '2024-11-23') + or (symbol = 'MIGGLES' and first_seen < '2024-11-12') + or (symbol = 'TOSHI' and first_seen < '2024-11-06') + or (symbol = 'KEYCAT' and first_seen < '2024-11-04') + or (symbol = 'AKUMA' and first_seen < '2024-12-12') + or (symbol = 'AEROBUD' and first_seen < '2024-11-29') + or (symbol = 'HENLO' and first_seen < '2024-12-02') + or (symbol = 'DOGINME' and first_seen < '2024-09-30') + or (symbol = 'SKI' and first_seen < '2024-11-25') + or (symbol = 'BRETT' and first_seen < '2024-11-07') +group by 1 + +union all + +select lower(address) as address, 'WOLF_OF_WALL_STREET' as category, array_agg(distinct symbol) as reason +from {{ ref('agg_solana_tokens_held') }} +where + (symbol = 'BONK' and first_seen < '2024-10-26') + or (symbol = 'WIF' and first_seen < '2024-02-22') + or (symbol = 'PNUT' and first_seen < '2024-09-10') + or (symbol = 'POPCAT' and first_seen < '2024-06-22') + or (symbol = 'FARTCOIN' and first_seen < '2024-12-07') + or (symbol = 'AI16Z' and first_seen < '2024-12-12') + or (symbol = 'GOAT' and first_seen < '2024-11-25') + or (symbol = 'MEW' and first_seen < '2024-09-01') + or (symbol = 'GIGA' and first_seen < '2024-09-30') + or (symbol = 'BOME' and first_seen < '2024-03-14') + or (symbol = 'ACT' and first_seen < '2024-11-07') + or (symbol = 'ZEREBRO' and first_seen < '2024-11-10') + or (symbol = 'MOODENG' and first_seen < '2024-11-04') + or (symbol = 'CHILLGUY' and first_seen < '2024-11-18') + or (symbol = 'FWOG' and first_seen < '2024-10-26') + +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql b/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql new file mode 100644 index 00000000..55d64aa2 --- /dev/null +++ b/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql @@ -0,0 +1,13 @@ +{{config(materialized='view')}} + +select + address + , total_txns + , total_txns_percent_rank + , total_gas_paid + , total_gas_paid_percent_rank + , days_onchain + , days_onchain_percent_rank + , apps_used + , apps_used_percent_rank +from {{ ref('agg_base_artemis_wrapped_metrics') }} \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics.sql b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics.sql new file mode 100644 index 00000000..41ffe0db --- /dev/null +++ b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics.sql @@ -0,0 +1,10 @@ +{{config(materialized='table', snowflake_warehouse='BALANCES_LG')}} +select + lower(from_address) as address + , count(distinct tx_hash) as total_txns + , sum(gas_usd) as total_gas_paid + , count(distinct raw_date) as days_onchain + , count(distinct app) as apps_used +from {{ ref('ez_base_transactions') }} +where block_timestamp > '2023-12-31' +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql new file mode 100644 index 00000000..3c23b6fd --- /dev/null +++ b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql @@ -0,0 +1,21 @@ +{{config(materialized='table', snowflake_warehouse='BALANCES_LG')}} + +SELECT + address, + total_txns, + (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) + FROM agg_data AS inner_data + WHERE inner_data.total_txns > outer_data.total_txns) AS total_txns_percent_rank, + total_gas_paid, + (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) + FROM agg_data AS inner_data + WHERE inner_data.total_gas_paid > outer_data.total_gas_paid) AS total_gas_paid_percent_rank, + days_onchain, + (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) + FROM agg_data AS inner_data + WHERE inner_data.days_onchain > outer_data.days_onchain) AS days_onchain_percent_rank, + apps_used, + (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) + FROM agg_data AS inner_data + WHERE inner_data.apps_used > outer_data.apps_used) AS apps_used_percent_rank +FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS outer_data \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics.sql b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics.sql new file mode 100644 index 00000000..ee76779d --- /dev/null +++ b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics.sql @@ -0,0 +1,11 @@ +{{config(materialized='table', snowflake_warehouse='BALANCES_LG')}} +select + value as address + , count(distinct tx_hash) as total_txns + , sum(gas_usd) as total_gas_paid + , count(distinct raw_date) as days_onchain + , count(distinct app) as apps_used +from {{ ref('ez_solana_transactions') }}, +lateral flatten(input => signers) +where block_timestamp > '2023-12-31' +group by 1 \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql new file mode 100644 index 00000000..cb1b10bf --- /dev/null +++ b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql @@ -0,0 +1,20 @@ +{{config(materialized='table', snowflake_warehouse='BALANCES_LG')}} +SELECT + address, + total_txns, + (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) + FROM agg_data AS inner_data + WHERE inner_data.total_txns > outer_data.total_txns) AS total_txns_percent_rank, + total_gas_paid, + (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) + FROM agg_data AS inner_data + WHERE inner_data.total_gas_paid > outer_data.total_gas_paid) AS total_gas_paid_percent_rank, + days_onchain, + (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) + FROM agg_data AS inner_data + WHERE inner_data.days_onchain > outer_data.days_onchain) AS days_onchain_percent_rank, + apps_used, + (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) + FROM agg_data AS inner_data + WHERE inner_data.apps_used > outer_data.apps_used) AS apps_used_percent_rank +FROM {{ref("agg_solana_artemis_wrapped_metrics")}} AS outer_data From c69336aae3090da9ad8b3ae86c3d61c16e3f22af Mon Sep 17 00:00:00 2001 From: SebMelendez01 <78228475+SebMelendez01@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:57:46 -0500 Subject: [PATCH 4/5] Updating wrapped models (#689) --- .../artemis_wrapped/dim_artemis_wrapped.sql | 18 +++++------ .../metrics/agg_artemis_wrapped_metrics.sql | 14 +++++++- ...e_artemis_wrapped_metrics_with_percent.sql | 32 ++++++++++++------- ...a_artemis_wrapped_metrics_with_percent.sql | 32 ++++++++++++------- 4 files changed, 62 insertions(+), 34 deletions(-) diff --git a/models/artemis_wrapped/dim_artemis_wrapped.sql b/models/artemis_wrapped/dim_artemis_wrapped.sql index d962c75c..50c8380b 100644 --- a/models/artemis_wrapped/dim_artemis_wrapped.sql +++ b/models/artemis_wrapped/dim_artemis_wrapped.sql @@ -33,13 +33,13 @@ categories as ( , ARRAY_TO_STRING(boomer.reason, ', ') ) as reason from {{ref('dim_blockbuster')}} block_buster - full outer join {{ref('dim_bob_the_builder')}} bob_the_builder using (address) - full outer join {{ref('dim_botimus_prime')}} botimus_prime using (address) - full outer join {{ref('dim_terminally_based')}} terminally_based using (address) - full outer join {{ref('dim_wolf_of_wallstreet')}} wolf_of_wallstreet using (address) - full outer join {{ref('dim_dora_the_explorer')}} dora_the_explorer using (address) - full outer join {{ref('dim_old_mcdonald')}} old_mcdonald using (address) - full outer join {{ref('dim_boomer')}} boomer using (address) + full outer join {{ref('dim_bob_the_builder')}} bob_the_builder on lower(block_buster.address) = lower(bob_the_builder.address) + full outer join {{ref('dim_botimus_prime')}} botimus_prime on lower(block_buster.address) = lower(botimus_prime.address) + full outer join {{ref('dim_terminally_based')}} terminally_based on lower(block_buster.address) = lower(terminally_based.address) + full outer join {{ref('dim_wolf_of_wallstreet')}} wolf_of_wallstreet on lower(block_buster.address) = lower(wolf_of_wallstreet.address) + full outer join {{ref('dim_dora_the_explorer')}} dora_the_explorer on lower(block_buster.address) = lower(dora_the_explorer.address) + full outer join {{ref('dim_old_mcdonald')}} old_mcdonald on lower(block_buster.address) = lower(old_mcdonald.address) + full outer join {{ref('dim_boomer')}} boomer on lower(block_buster.address) = lower(boomer.address) ) select @@ -54,5 +54,5 @@ select , days_onchain_percent_rank as days_onchain_percent_rank , apps_used , apps_used_percent_rank as apps_used_percent_rank -from {{ref('agg_artemis_wrapped_metrics')}} -left join categories using (address) \ No newline at end of file +from {{ref('agg_artemis_wrapped_metrics')}} wrapped +left join categories on lower(wrapped.address) = lower(categories.address) \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql b/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql index 55d64aa2..d3fe0382 100644 --- a/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql +++ b/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql @@ -10,4 +10,16 @@ select , days_onchain_percent_rank , apps_used , apps_used_percent_rank -from {{ ref('agg_base_artemis_wrapped_metrics') }} \ No newline at end of file +from {{ ref('agg_base_artemis_wrapped_metrics_with_percent') }} +union all +select + address + , total_txns + , total_txns_percent_rank + , total_gas_paid + , total_gas_paid_percent_rank + , days_onchain + , days_onchain_percent_rank + , apps_used + , apps_used_percent_rank +from {{ ref('agg_solana_artemis_wrapped_metrics_with_percent') }} \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql index 3c23b6fd..e8435c2d 100644 --- a/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql +++ b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql @@ -3,19 +3,27 @@ SELECT address, total_txns, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.total_txns > outer_data.total_txns) AS total_txns_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 97059729.0 + FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.total_txns > outer_data.total_txns + ) AS total_txns_percent_rank, total_gas_paid, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.total_gas_paid > outer_data.total_gas_paid) AS total_gas_paid_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 97059729.0 + FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.total_gas_paid > outer_data.total_gas_paid + ) AS total_gas_paid_percent_rank, days_onchain, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.days_onchain > outer_data.days_onchain) AS days_onchain_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 97059729.0 + FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.days_onchain > outer_data.days_onchain + ) AS days_onchain_percent_rank, apps_used, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.apps_used > outer_data.apps_used) AS apps_used_percent_rank + ( + SELECT COUNT(*) * 1.0 / 97059729.0 + FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.apps_used > outer_data.apps_used + ) AS apps_used_percent_rank FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS outer_data \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql index cb1b10bf..4d2079f5 100644 --- a/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql +++ b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql @@ -2,19 +2,27 @@ SELECT address, total_txns, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.total_txns > outer_data.total_txns) AS total_txns_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 660782282.0 + FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.total_txns > outer_data.total_txns + ) AS total_txns_percent_rank, total_gas_paid, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.total_gas_paid > outer_data.total_gas_paid) AS total_gas_paid_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 660782282.0 + FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.total_gas_paid > outer_data.total_gas_paid + ) AS total_gas_paid_percent_rank, days_onchain, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.days_onchain > outer_data.days_onchain) AS days_onchain_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 660782282.0 + FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.days_onchain > outer_data.days_onchain + ) AS days_onchain_percent_rank, apps_used, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.apps_used > outer_data.apps_used) AS apps_used_percent_rank + ( + SELECT COUNT(*) * 1.0 / 660782282.0 + FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.apps_used > outer_data.apps_used + ) AS apps_used_percent_rank FROM {{ref("agg_solana_artemis_wrapped_metrics")}} AS outer_data From 60c45eb7a861ab8297cfbfb25d9fa7fda01dae40 Mon Sep 17 00:00:00 2001 From: SebMelendez01 <78228475+SebMelendez01@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:53:57 -0500 Subject: [PATCH 5/5] Updating Art Wrapped Models (#690) --- .../artemis_wrapped/dim_artemis_wrapped.sql | 20 +++++-------- models/artemis_wrapped/dim_rugged_rat.sql | 2 +- .../dim_solana_trench_warrior.sql | 7 +++-- .../metrics/agg_artemis_wrapped_metrics.sql | 16 ++++------ ...e_artemis_wrapped_metrics_with_percent.sql | 29 ------------------- ...a_artemis_wrapped_metrics_with_percent.sql | 28 ------------------ 6 files changed, 18 insertions(+), 84 deletions(-) delete mode 100644 models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql delete mode 100644 models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql diff --git a/models/artemis_wrapped/dim_artemis_wrapped.sql b/models/artemis_wrapped/dim_artemis_wrapped.sql index 50c8380b..2e06468a 100644 --- a/models/artemis_wrapped/dim_artemis_wrapped.sql +++ b/models/artemis_wrapped/dim_artemis_wrapped.sql @@ -33,26 +33,22 @@ categories as ( , ARRAY_TO_STRING(boomer.reason, ', ') ) as reason from {{ref('dim_blockbuster')}} block_buster - full outer join {{ref('dim_bob_the_builder')}} bob_the_builder on lower(block_buster.address) = lower(bob_the_builder.address) - full outer join {{ref('dim_botimus_prime')}} botimus_prime on lower(block_buster.address) = lower(botimus_prime.address) - full outer join {{ref('dim_terminally_based')}} terminally_based on lower(block_buster.address) = lower(terminally_based.address) - full outer join {{ref('dim_wolf_of_wallstreet')}} wolf_of_wallstreet on lower(block_buster.address) = lower(wolf_of_wallstreet.address) - full outer join {{ref('dim_dora_the_explorer')}} dora_the_explorer on lower(block_buster.address) = lower(dora_the_explorer.address) - full outer join {{ref('dim_old_mcdonald')}} old_mcdonald on lower(block_buster.address) = lower(old_mcdonald.address) - full outer join {{ref('dim_boomer')}} boomer on lower(block_buster.address) = lower(boomer.address) + full outer join {{ref('dim_bob_the_builder')}} bob_the_builder using(address) + full outer join {{ref('dim_botimus_prime')}} botimus_prime using(address) + full outer join {{ref('dim_terminally_based')}} terminally_based using(address) + full outer join {{ref('dim_wolf_of_wallstreet')}} wolf_of_wallstreet using(address) + full outer join {{ref('dim_dora_the_explorer')}} dora_the_explorer using(address) + full outer join {{ref('dim_old_mcdonald')}} old_mcdonald using(address) + full outer join {{ref('dim_boomer')}} boomer using(address) ) select - address + wrapped.address , coalesce(category, 'NORMIE') as category , reason , total_txns - , total_txns_percent_rank as total_txns_percent_rank , total_gas_paid - , total_gas_paid_percent_rank as total_gas_paid_percent_rank , days_onchain - , days_onchain_percent_rank as days_onchain_percent_rank , apps_used - , apps_used_percent_rank as apps_used_percent_rank from {{ref('agg_artemis_wrapped_metrics')}} wrapped left join categories on lower(wrapped.address) = lower(categories.address) \ No newline at end of file diff --git a/models/artemis_wrapped/dim_rugged_rat.sql b/models/artemis_wrapped/dim_rugged_rat.sql index 44407472..d1fd7d66 100644 --- a/models/artemis_wrapped/dim_rugged_rat.sql +++ b/models/artemis_wrapped/dim_rugged_rat.sql @@ -1,6 +1,6 @@ {{config(materialized='table')}} -select lower(address) as address, 'WOLF_OF_WALL_STREET' as category, array_agg(distinct symbol) as reason +select lower(address) as address, 'RUGGED_RAT' as category, array_agg(distinct symbol) as reason from {{ ref('agg_solana_tokens_held') }} where (symbol = 'HAWKTUAH' and first_seen <= '2024-11-26') diff --git a/models/artemis_wrapped/dim_solana_trench_warrior.sql b/models/artemis_wrapped/dim_solana_trench_warrior.sql index 61a0c708..19924061 100644 --- a/models/artemis_wrapped/dim_solana_trench_warrior.sql +++ b/models/artemis_wrapped/dim_solana_trench_warrior.sql @@ -1,7 +1,8 @@ {{config(materialized='table')}} -select lower(address) as address, 'SOLANA_TRENCH_WARRIOR' as category, array_agg(app) as reason +select lower(address) as address, 'SOLANA_TRENCH_WARRIOR' as category, sum(interactions) as reason from {{ ref('agg_solana_app_interactions') }} -where interactions > 300 and app in ('pumpdotfun', 'raydium') -group by 1 \ No newline at end of file +where app in ('pumpdotfun', 'raydium') +group by 1 +having reason > 300 \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql b/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql index d3fe0382..2693b13b 100644 --- a/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql +++ b/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql @@ -3,23 +3,17 @@ select address , total_txns - , total_txns_percent_rank , total_gas_paid - , total_gas_paid_percent_rank , days_onchain - , days_onchain_percent_rank , apps_used - , apps_used_percent_rank -from {{ ref('agg_base_artemis_wrapped_metrics_with_percent') }} +from {{ ref('agg_base_artemis_wrapped_metrics') }} + union all + select - address + address::string as address , total_txns - , total_txns_percent_rank , total_gas_paid - , total_gas_paid_percent_rank , days_onchain - , days_onchain_percent_rank , apps_used - , apps_used_percent_rank -from {{ ref('agg_solana_artemis_wrapped_metrics_with_percent') }} \ No newline at end of file +from {{ ref('agg_solana_artemis_wrapped_metrics') }} \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql deleted file mode 100644 index e8435c2d..00000000 --- a/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql +++ /dev/null @@ -1,29 +0,0 @@ -{{config(materialized='table', snowflake_warehouse='BALANCES_LG')}} - -SELECT - address, - total_txns, - ( - SELECT COUNT(*) * 1.0 / 97059729.0 - FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data - WHERE inner_data.total_txns > outer_data.total_txns - ) AS total_txns_percent_rank, - total_gas_paid, - ( - SELECT COUNT(*) * 1.0 / 97059729.0 - FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data - WHERE inner_data.total_gas_paid > outer_data.total_gas_paid - ) AS total_gas_paid_percent_rank, - days_onchain, - ( - SELECT COUNT(*) * 1.0 / 97059729.0 - FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data - WHERE inner_data.days_onchain > outer_data.days_onchain - ) AS days_onchain_percent_rank, - apps_used, - ( - SELECT COUNT(*) * 1.0 / 97059729.0 - FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data - WHERE inner_data.apps_used > outer_data.apps_used - ) AS apps_used_percent_rank -FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS outer_data \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql deleted file mode 100644 index 4d2079f5..00000000 --- a/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql +++ /dev/null @@ -1,28 +0,0 @@ -{{config(materialized='table', snowflake_warehouse='BALANCES_LG')}} -SELECT - address, - total_txns, - ( - SELECT COUNT(*) * 1.0 / 660782282.0 - FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data - WHERE inner_data.total_txns > outer_data.total_txns - ) AS total_txns_percent_rank, - total_gas_paid, - ( - SELECT COUNT(*) * 1.0 / 660782282.0 - FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data - WHERE inner_data.total_gas_paid > outer_data.total_gas_paid - ) AS total_gas_paid_percent_rank, - days_onchain, - ( - SELECT COUNT(*) * 1.0 / 660782282.0 - FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data - WHERE inner_data.days_onchain > outer_data.days_onchain - ) AS days_onchain_percent_rank, - apps_used, - ( - SELECT COUNT(*) * 1.0 / 660782282.0 - FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data - WHERE inner_data.apps_used > outer_data.apps_used - ) AS apps_used_percent_rank -FROM {{ref("agg_solana_artemis_wrapped_metrics")}} AS outer_data