Skip to content

Commit 6244423

Browse files
soispokejeff-dude
andauthored
Labels spell build (#1474)
* create static labels cex on ethereum * Update static_labels_ethereum_cex.sql * add labels in dbt_project yml file * Update static_labels_ethereum_cex.sql * Update static_labels_ethereum_cex.sql * update static labels cex * Build safe, cex and nft traders labels * partition and limit nft traders labels * Update query_labels_nft_traders_volume_usd.sql * add decoded contracts, improve overall quality * add funds labels * add tornado cash labels * fix blockchain type tornado cash * nft users improvement * move to unique "labels" schema * improve tornado cash labels * fix nft traders sign ambiguity * fix tornado cash and = signs * Update dbt_project.yml * add balances labels * Revert "add balances labels" This reverts commit c9a0942. * remove ? * Update dbt_project.yml * add balances * Revert "add balances" This reverts commit 76bc61e. * fix indent on dbt project yaml * add suggested changes * expose labels.all in Dune App * add uniqueness test on labels all table * add labels to optimize macro Co-authored-by: jeff-dude <[email protected]>
1 parent 768fd67 commit 6244423

17 files changed

+476
-74
lines changed

dbt_project.yml

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ models:
115115
ethereum:
116116
+schema: balances_ethereum
117117
+materialized: view
118+
118119
labels:
119120
+schema: labels
120121
+materialized: view

macros/alter_table_properties.sql

+10
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,15 @@ ALTER VIEW nft.fees SET TBLPROPERTIES('dune.public'='true',
298298
'dune.data_explorer.contributors'='["soispoke"]');
299299
{% endset %}
300300

301+
{% set labels_all %}
302+
ALTER VIEW labels.all SET TBLPROPERTIES('dune.public'='true',
303+
'dune.data_explorer.blockchains'='["ethereum","solana"]',
304+
'dune.data_explorer.category'='abstraction',
305+
'dune.data_explorer.abstraction.type'='sector',
306+
'dune.data_explorer.abstraction.name'='labels',
307+
'dune.data_explorer.contributors'='["soispoke","hildobby"]');
308+
{% endset %}
309+
301310
{% set nft_aggregators %}
302311
ALTER VIEW nft.aggregators SET TBLPROPERTIES('dune.public'='true',
303312
'dune.data_explorer.blockchains'='["avalanche_c","bnb","ethereum","polygon"]',
@@ -656,6 +665,7 @@ ALTER VIEW archipelago_ethereum.fees SET TBLPROPERTIES ('dune.public'='true',
656665
{% do run_query(nft_mints) %}
657666
{% do run_query(nft_burns) %}
658667
{% do run_query(nft_fees) %}
668+
{% do run_query(labels_all) %}
659669
{% do run_query(uniswap_v1_ethereum_trades) %}
660670
{% do run_query(uniswap_v2_ethereum_trades) %}
661671
{% do run_query(uniswap_ethereum_trades) %}

macros/optimize_tables.sql

+5
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ OPTIMIZE x2y2_ethereum.events;
9191
OPTIMIZE archipelago_ethereum.events;
9292
{% endset %}
9393

94+
{% set labels_all %}
95+
OPTIMIZE labels.all;
96+
{% endset %}
97+
9498

9599
{% do run_query(looksrare_ethereum_events) %}
96100
{% do run_query(magiceden_solana_events) %}
@@ -113,5 +117,6 @@ OPTIMIZE archipelago_ethereum.events;
113117
{% do run_query(uniswap_v2_ethereum_trades) %}
114118
{% do run_query(x2y2_ethereum_events) %}
115119
{% do run_query(archipelago_ethereum_events) %}
120+
{% do run_query(labels_all) %}
116121
{% do log("Tables Optimized", info=True) %}
117122
{% endmacro %}

models/labels/cex/labels_cex_schema.yml

+25-25
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,30 @@ models:
1111
tags: ['labels', 'ethereum', 'cex']
1212
description: "Known centralised exchange addresses across chains"
1313
columns:
14-
- name: blockchain
14+
- &blockchain
15+
name: blockchain
1516
description: "Blockchain"
16-
- name: address
17+
- &address
18+
name: address
1719
description: "Address of known CEX"
18-
- name: name
20+
- &name
21+
name: name
1922
description: "Label name of centralised exchange"
20-
- name: category
23+
- &category
24+
name: category
2125
description: "Label category"
22-
- name: contributor
26+
- &contributor
27+
name: contributor
2328
description: "Wizard(s) contributing to labels"
24-
- name: source
29+
- &source
30+
name: source
2531
description: "How were labels generated (could be static or query)"
26-
- name: created_at
32+
- &created_at
33+
name: created_at
2734
description: "When were labels created"
28-
- name: updated_at
29-
description: "When were labels updated for the last time ?"
35+
- &updated_at
36+
name: updated_at
37+
description: "When were labels updated for the last time"
3038

3139
- name: labels_cex_ethereum
3240
meta:
@@ -38,19 +46,11 @@ models:
3846
tags: ['labels', 'ethereum', 'cex']
3947
description: "Known centralised exchange addresses on Ethereum"
4048
columns:
41-
- name: blockchain
42-
description: "Blockchain"
43-
- name: address
44-
description: "Address of known CEX"
45-
- name: name
46-
description: "Label name of centralised exchange"
47-
- name: category
48-
description: "Label category"
49-
- name: contributor
50-
description: "Wizard(s) contributing to labels"
51-
- name: source
52-
description: "How were labels generated (could be static or query)"
53-
- name: created_at
54-
description: "When were labels created"
55-
- name: updated_at
56-
description: "When were labels updated for the last time ?"
49+
- *blockchain
50+
- *address
51+
- *name
52+
- *category
53+
- *contributor
54+
- *source
55+
- *created_at
56+
- *updated_at

models/labels/funds/labels_funds.sql

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{config(alias='funds')}}
2+
3+
SELECT * FROM {{ ref('labels_funds_ethereum') }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{config(alias='funds_ethereum')}}
2+
3+
SELECT blockchain, address, name, category, contributor, source, created_at, updated_at
4+
FROM (VALUES
5+
(array('ethereum'),'0x2B1Ad6184a6B0fac06bD225ed37C2AbC04415fF4', 'a16z', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
6+
, (array('ethereum'), '0x05e793ce0c6027323ac150f6d45c2344d28b6019', 'a16z', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
7+
, (array('ethereum'), '0xa294cca691e4c83b1fc0c8d63d9a3eef0a196de1', 'Alameda', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
8+
, (array('ethereum'), '0xc5ed2333f8a2c351fca35e5ebadb2a82f5d254c3', 'Alameda Research', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
9+
, (array('ethereum'), '0x84d34f4f83a87596cd3fb6887cff8f17bf5a7b83', 'Alameda Research', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
10+
, (array('ethereum'), '0x4c8cfe078a5b989cea4b330197246ced82764c63', 'Alameda Research', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
11+
, (array('ethereum'), '0x712d0f306956a6a4b4f9319ad9b9de48c5345996', 'Alameda Research', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
12+
, (array('ethereum'), '0xafa64cca337efee0ad827f6c2684e69275226e90', 'CMS Holdings', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
13+
, (array('ethereum'), '0x9b5ea8c719e29a5bd0959faf79c9e5c8206d0499', 'DeFiance Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
14+
, (array('ethereum'), '0xf584f8728b874a6a5c7a8d4d387c9aae9172d621', 'Jump Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
15+
, (array('ethereum'), '0x112b69178d416cd03222de9e6dd6b3adf36412aa', 'Kirin Fund', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
16+
, (array('ethereum'), '0xc8d328b21f476a4b6e0681f6e4e41693a220347d', 'Multicoin Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
17+
, (array('ethereum'), '0x66b870ddf78c975af5cd8edc6de25eca81791de1', 'Oapital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
18+
, (array('ethereum'), '0xd9b012a168fb6c1b71c24db8cee1a256b3caa2a2', 'ParaFi Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
19+
, (array('ethereum'), '0x4655b7ad0b5f5bacb9cf960bbffceb3f0e51f363', 'Scary Chain Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
20+
, (array('ethereum'), '0x80c2c1ceb335e39b7021c646fd3ec159faf9099d', 'Signum Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
21+
, (array('ethereum'), '0x4862733b5fddfd35f35ea8ccf08f5045e57388b3', 'Three Arrows Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
22+
, (array('ethereum'), '0x085af684acdb1220d111fee971b733c5e5ae6ccd', 'Three Arrows Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
23+
, (array('ethereum'), '0x8e04af7f7c76daa9ab429b1340e0327b5b835748', 'Three Arrows Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
24+
, (array('ethereum'), '0x0000006daea1723962647b7e189d311d757fb793', 'Wintermute Trading', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
25+
) AS x (blockchain, address, name, category, contributor, source, created_at, updated_at)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
version: 2
2+
3+
models:
4+
- name: labels_funds
5+
meta:
6+
blockchain: ethereum
7+
sector: labels
8+
project: funds
9+
contibutors: soispoke
10+
config:
11+
tags: ['labels', 'ethereum', 'funds']
12+
description: "Known funds addresses across chains"
13+
columns:
14+
- &blockchain
15+
name: blockchain
16+
description: "Blockchain"
17+
- &address
18+
name: address
19+
description: "Address of known Funds"
20+
- &name
21+
name: name
22+
description: "Label name for funds"
23+
- &category
24+
name: category
25+
description: "Label category"
26+
- &contributor
27+
name: contributor
28+
description: "Wizard(s) contributing to labels"
29+
- &source
30+
name: source
31+
description: "How were labels generated (could be static or query)"
32+
- &created_at
33+
name: created_at
34+
description: "When were labels created"
35+
- &updated_at
36+
name: updated_at
37+
description: "When were labels updated for the last time"
38+
39+
- name: labels_funds_ethereum
40+
meta:
41+
blockchain: ethereum
42+
sector: labels
43+
project: funds
44+
contibutors: hildobby, soispoke
45+
config:
46+
tags: ['labels', 'ethereum', 'funds']
47+
description: "Known funds addresses on Ethereum"
48+
columns:
49+
- *blockchain
50+
- *address
51+
- *name
52+
- *category
53+
- *contributor
54+
- *source
55+
- *created_at
56+
- *updated_at

models/labels/labels_all.sql

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44
file_format = 'delta')
55
}}
66

7+
-- Static Labels
8+
SELECT * FROM {{ ref('labels_cex') }}
9+
UNION
10+
SELECT * FROM {{ ref('labels_funds') }}
11+
UNION
12+
SELECT * FROM {{ ref('labels_submitted_contracts') }}
13+
UNION
714
-- Query Labels
815
SELECT * FROM {{ ref('labels_nft') }}
916
UNION
10-
-- Static Labels
11-
SELECT * FROM {{ ref('labels_cex') }}
17+
SELECT * FROM {{ ref('labels_safe_ethereum') }}
18+
UNION
19+
SELECT * FROM {{ ref('labels_tornado_cash') }}

models/labels/labels_all_schema.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ version: 2
22

33
models:
44
- name: labels_all
5+
tests:
6+
- unique:
7+
column_name: "(address || '-' || name || '-' || blockchain::string)"
58
meta:
69
blockchain: ethereum, solana
710
sector: labels
8-
category: nft, cex
11+
category: cex, nft
912
contibutors: hildobby, soispoke
1013
config:
11-
tags: ['labels', 'ethereum', 'solana', 'nft', 'cex']
14+
tags: ['labels', 'ethereum', 'solana', 'cex', 'nft']
1215
description: "All labels across chains and categories"
1316
columns:
1417
- name: blockchain

models/labels/nft/labels_nft_schema.yml

+35-45
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,29 @@ models:
1212
tags: ['labels', 'nft', 'ethereum', 'solana', 'opensea', 'looksrare', 'x2y2', 'magiceden']
1313
description: "NFT query labels"
1414
columns:
15-
- name: blockchain
16-
description: "Blockchain on which NFT trades have been made"
17-
- name: address
15+
- &blockchain
16+
name: blockchain
17+
description: "Blockchain"
18+
- &address
19+
name: address
1820
description: "Address of NFT traders"
19-
- name: name
21+
- &name
22+
name: name
2023
description: "Label name NFT trader (Top 1, 5, 10% or simply NFT Trader when an address has traded NFTs but is not in top top 10 or above)"
21-
- name: category
24+
- &category
25+
name: category
2226
description: "Label category (NFT here)"
23-
- name: contributor
27+
- &contributor
28+
name: contributor
2429
description: "Wizard(s) contributing to labels"
25-
- name: source
30+
- &source
31+
name: source
2632
description: "How were labels generated (could be static or query)"
27-
- name: created_at
33+
- &created_at
34+
name: created_at
2835
description: "When were labels created"
29-
- name: updated_at
36+
- &updated_at
37+
name: updated_at
3038
description: "When were labels updated for the last time"
3139

3240
- name: labels_nft_users_platforms
@@ -40,22 +48,16 @@ models:
4048
tags: ['labels', 'nft_traders', 'ethereum', 'solana', 'opensea', 'looksrare', 'x2y2', 'magiceden']
4149
description: "NFT Platforms users across chains"
4250
columns:
43-
- name: blockchain
44-
description: "Blockchain"
51+
- *blockchain
4552
- name: address
4653
description: "Address of NFT platforms users"
4754
- name: name
4855
description: "Label name (NFT Platform User)"
49-
- name: category
50-
description: "Label category (NFT here)"
51-
- name: contributor
52-
description: "Wizard(s) contributing to labels"
53-
- name: source
54-
description: "How were labels generated (could be static or query)"
55-
- name: created_at
56-
description: "When were labels created"
57-
- name: updated_at
58-
description: "When were labels updated for the last time"
56+
- *category
57+
- *contributor
58+
- *source
59+
- *created_at
60+
- *updated_at
5961

6062
- name: labels_nft_traders_transactions
6163
meta:
@@ -68,22 +70,16 @@ models:
6870
tags: ['labels', 'nft_traders', 'ethereum', 'solana', 'opensea', 'looksrare', 'x2y2', 'magiceden']
6971
description: "Top NFT traders based on the number of transactions across chains"
7072
columns:
71-
- name: blockchain
72-
description: "Blockchain on which NFT trades have been made"
73+
- *blockchain
7374
- name: address
7475
description: "Address of NFT traders"
7576
- name: name
7677
description: "Label name NFT trader (Top 1, 5, 10% or simply NFT Trader when an address has traded NFTs but is not in top top 10 or above)"
77-
- name: category
78-
description: "Label category (NFT here)"
79-
- name: contributor
80-
description: "Wizard(s) contributing to labels"
81-
- name: source
82-
description: "How were labels generated (could be static or query)"
83-
- name: created_at
84-
description: "When were labels created"
85-
- name: updated_at
86-
description: "When were labels updated for the last time"
78+
- *category
79+
- *contributor
80+
- *source
81+
- *created_at
82+
- *updated_at
8783

8884
- name: labels_nft_traders_volume_usd
8985
meta:
@@ -95,19 +91,13 @@ models:
9591
tags: ['labels', 'nft_traders', 'ethereum', 'solana', 'opensea', 'looksrare', 'x2y2', 'magiceden']
9692
description: "Top NFT traders based on volume in USD across chains"
9793
columns:
98-
- name: blockchain
99-
description: "Blockchain on which NFT trades have been made"
94+
- *blockchain
10095
- name: address
10196
description: "Address of NFT traders"
10297
- name: name
10398
description: "Label name NFT trader (Top 1, 5, 10% or simply NFT Trader when an address has traded NFTs but is not in top top 10 or above)"
104-
- name: category
105-
description: "Label category (NFT here)"
106-
- name: contributor
107-
description: "Wizard(s) contributing to labels"
108-
- name: source
109-
description: "How were labels generated (could be static or query)"
110-
- name: created_at
111-
description: "When were labels created"
112-
- name: updated_at
113-
description: "When were labels updated for the last time"
99+
- *category
100+
- *contributor
101+
- *source
102+
- *created_at
103+
- *updated_at
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{config(alias='safe_ethereum')}}
2+
3+
SELECT
4+
array('ethereum') as blockchain,
5+
address,
6+
'Safe' || ' version ' || creation_version AS name,
7+
'safe' AS category,
8+
'soispoke' AS contributor,
9+
'query' AS source,
10+
timestamp('2022-09-01') as created_at,
11+
now() as updated_at
12+
FROM {{ ref('safe_ethereum_safes') }}

0 commit comments

Comments
 (0)