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