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

Artemis Wrapped: adding wrapped queries #688

Merged
merged 2 commits into from
Dec 19, 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions models/artemis_wrapped/aggregate/agg_base_tokens_held.sql
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions models/artemis_wrapped/aggregate/agg_solana_tokens_held.sql
Original file line number Diff line number Diff line change
@@ -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
58 changes: 58 additions & 0 deletions models/artemis_wrapped/dim_artemis_wrapped.sql
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 13 additions & 0 deletions models/artemis_wrapped/dim_blockbuster.sql
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions models/artemis_wrapped/dim_bob_the_builder.sql
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions models/artemis_wrapped/dim_boomer.sql
Original file line number Diff line number Diff line change
@@ -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')}}
14 changes: 14 additions & 0 deletions models/artemis_wrapped/dim_botimus_prime.sql
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions models/artemis_wrapped/dim_dora_the_explorer.sql
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions models/artemis_wrapped/dim_old_mcdonald.sql
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions models/artemis_wrapped/dim_rugged_rat.sql
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions models/artemis_wrapped/dim_solana_trench_warrior.sql
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions models/artemis_wrapped/dim_terminally_based.sql
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions models/artemis_wrapped/dim_wolf_of_wallstreet.sql
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql
Original file line number Diff line number Diff line change
@@ -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') }}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading