Skip to content

Commit

Permalink
Labels spell build (#1474)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
soispoke and jeff-dude authored Sep 11, 2022
1 parent 768fd67 commit 6244423
Show file tree
Hide file tree
Showing 17 changed files with 476 additions and 74 deletions.
1 change: 1 addition & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ models:
ethereum:
+schema: balances_ethereum
+materialized: view

labels:
+schema: labels
+materialized: view
Expand Down
10 changes: 10 additions & 0 deletions macros/alter_table_properties.sql
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ ALTER VIEW nft.fees SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.contributors'='["soispoke"]');
{% endset %}

{% set labels_all %}
ALTER VIEW labels.all SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.blockchains'='["ethereum","solana"]',
'dune.data_explorer.category'='abstraction',
'dune.data_explorer.abstraction.type'='sector',
'dune.data_explorer.abstraction.name'='labels',
'dune.data_explorer.contributors'='["soispoke","hildobby"]');
{% endset %}

{% set nft_aggregators %}
ALTER VIEW nft.aggregators SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.blockchains'='["avalanche_c","bnb","ethereum","polygon"]',
Expand Down Expand Up @@ -656,6 +665,7 @@ ALTER VIEW archipelago_ethereum.fees SET TBLPROPERTIES ('dune.public'='true',
{% do run_query(nft_mints) %}
{% do run_query(nft_burns) %}
{% do run_query(nft_fees) %}
{% do run_query(labels_all) %}
{% do run_query(uniswap_v1_ethereum_trades) %}
{% do run_query(uniswap_v2_ethereum_trades) %}
{% do run_query(uniswap_ethereum_trades) %}
Expand Down
5 changes: 5 additions & 0 deletions macros/optimize_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ OPTIMIZE x2y2_ethereum.events;
OPTIMIZE archipelago_ethereum.events;
{% endset %}

{% set labels_all %}
OPTIMIZE labels.all;
{% endset %}


{% do run_query(looksrare_ethereum_events) %}
{% do run_query(magiceden_solana_events) %}
Expand All @@ -113,5 +117,6 @@ OPTIMIZE archipelago_ethereum.events;
{% do run_query(uniswap_v2_ethereum_trades) %}
{% do run_query(x2y2_ethereum_events) %}
{% do run_query(archipelago_ethereum_events) %}
{% do run_query(labels_all) %}
{% do log("Tables Optimized", info=True) %}
{% endmacro %}
50 changes: 25 additions & 25 deletions models/labels/cex/labels_cex_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,30 @@ models:
tags: ['labels', 'ethereum', 'cex']
description: "Known centralised exchange addresses across chains"
columns:
- name: blockchain
- &blockchain
name: blockchain
description: "Blockchain"
- name: address
- &address
name: address
description: "Address of known CEX"
- name: name
- &name
name: name
description: "Label name of centralised exchange"
- name: category
- &category
name: category
description: "Label category"
- name: contributor
- &contributor
name: contributor
description: "Wizard(s) contributing to labels"
- name: source
- &source
name: source
description: "How were labels generated (could be static or query)"
- name: created_at
- &created_at
name: created_at
description: "When were labels created"
- name: updated_at
description: "When were labels updated for the last time ?"
- &updated_at
name: updated_at
description: "When were labels updated for the last time"

- name: labels_cex_ethereum
meta:
Expand All @@ -38,19 +46,11 @@ models:
tags: ['labels', 'ethereum', 'cex']
description: "Known centralised exchange addresses on Ethereum"
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Address of known CEX"
- name: name
description: "Label name of centralised exchange"
- name: category
description: "Label category"
- name: contributor
description: "Wizard(s) contributing to labels"
- name: source
description: "How were labels generated (could be static or query)"
- name: created_at
description: "When were labels created"
- name: updated_at
description: "When were labels updated for the last time ?"
- *blockchain
- *address
- *name
- *category
- *contributor
- *source
- *created_at
- *updated_at
3 changes: 3 additions & 0 deletions models/labels/funds/labels_funds.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{config(alias='funds')}}

SELECT * FROM {{ ref('labels_funds_ethereum') }}
25 changes: 25 additions & 0 deletions models/labels/funds/labels_funds_ethereum.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{config(alias='funds_ethereum')}}

SELECT blockchain, address, name, category, contributor, source, created_at, updated_at
FROM (VALUES
(array('ethereum'),'0x2B1Ad6184a6B0fac06bD225ed37C2AbC04415fF4', 'a16z', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x05e793ce0c6027323ac150f6d45c2344d28b6019', 'a16z', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0xa294cca691e4c83b1fc0c8d63d9a3eef0a196de1', 'Alameda', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0xc5ed2333f8a2c351fca35e5ebadb2a82f5d254c3', 'Alameda Research', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x84d34f4f83a87596cd3fb6887cff8f17bf5a7b83', 'Alameda Research', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x4c8cfe078a5b989cea4b330197246ced82764c63', 'Alameda Research', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x712d0f306956a6a4b4f9319ad9b9de48c5345996', 'Alameda Research', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0xafa64cca337efee0ad827f6c2684e69275226e90', 'CMS Holdings', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x9b5ea8c719e29a5bd0959faf79c9e5c8206d0499', 'DeFiance Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0xf584f8728b874a6a5c7a8d4d387c9aae9172d621', 'Jump Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x112b69178d416cd03222de9e6dd6b3adf36412aa', 'Kirin Fund', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0xc8d328b21f476a4b6e0681f6e4e41693a220347d', 'Multicoin Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x66b870ddf78c975af5cd8edc6de25eca81791de1', 'Oapital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0xd9b012a168fb6c1b71c24db8cee1a256b3caa2a2', 'ParaFi Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x4655b7ad0b5f5bacb9cf960bbffceb3f0e51f363', 'Scary Chain Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x80c2c1ceb335e39b7021c646fd3ec159faf9099d', 'Signum Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x4862733b5fddfd35f35ea8ccf08f5045e57388b3', 'Three Arrows Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x085af684acdb1220d111fee971b733c5e5ae6ccd', 'Three Arrows Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x8e04af7f7c76daa9ab429b1340e0327b5b835748', 'Three Arrows Capital', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
, (array('ethereum'), '0x0000006daea1723962647b7e189d311d757fb793', 'Wintermute Trading', 'funds', 'soispoke', 'static', timestamp('2022-09-03'), now())
) AS x (blockchain, address, name, category, contributor, source, created_at, updated_at)
56 changes: 56 additions & 0 deletions models/labels/funds/labels_funds_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: 2

models:
- name: labels_funds
meta:
blockchain: ethereum
sector: labels
project: funds
contibutors: soispoke
config:
tags: ['labels', 'ethereum', 'funds']
description: "Known funds addresses across chains"
columns:
- &blockchain
name: blockchain
description: "Blockchain"
- &address
name: address
description: "Address of known Funds"
- &name
name: name
description: "Label name for funds"
- &category
name: category
description: "Label category"
- &contributor
name: contributor
description: "Wizard(s) contributing to labels"
- &source
name: source
description: "How were labels generated (could be static or query)"
- &created_at
name: created_at
description: "When were labels created"
- &updated_at
name: updated_at
description: "When were labels updated for the last time"

- name: labels_funds_ethereum
meta:
blockchain: ethereum
sector: labels
project: funds
contibutors: hildobby, soispoke
config:
tags: ['labels', 'ethereum', 'funds']
description: "Known funds addresses on Ethereum"
columns:
- *blockchain
- *address
- *name
- *category
- *contributor
- *source
- *created_at
- *updated_at
12 changes: 10 additions & 2 deletions models/labels/labels_all.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
file_format = 'delta')
}}

-- Static Labels
SELECT * FROM {{ ref('labels_cex') }}
UNION
SELECT * FROM {{ ref('labels_funds') }}
UNION
SELECT * FROM {{ ref('labels_submitted_contracts') }}
UNION
-- Query Labels
SELECT * FROM {{ ref('labels_nft') }}
UNION
-- Static Labels
SELECT * FROM {{ ref('labels_cex') }}
SELECT * FROM {{ ref('labels_safe_ethereum') }}
UNION
SELECT * FROM {{ ref('labels_tornado_cash') }}
7 changes: 5 additions & 2 deletions models/labels/labels_all_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ version: 2

models:
- name: labels_all
tests:
- unique:
column_name: "(address || '-' || name || '-' || blockchain::string)"
meta:
blockchain: ethereum, solana
sector: labels
category: nft, cex
category: cex, nft
contibutors: hildobby, soispoke
config:
tags: ['labels', 'ethereum', 'solana', 'nft', 'cex']
tags: ['labels', 'ethereum', 'solana', 'cex', 'nft']
description: "All labels across chains and categories"
columns:
- name: blockchain
Expand Down
80 changes: 35 additions & 45 deletions models/labels/nft/labels_nft_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,29 @@ models:
tags: ['labels', 'nft', 'ethereum', 'solana', 'opensea', 'looksrare', 'x2y2', 'magiceden']
description: "NFT query labels"
columns:
- name: blockchain
description: "Blockchain on which NFT trades have been made"
- name: address
- &blockchain
name: blockchain
description: "Blockchain"
- &address
name: address
description: "Address of NFT traders"
- name: name
- &name
name: name
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)"
- name: category
- &category
name: category
description: "Label category (NFT here)"
- name: contributor
- &contributor
name: contributor
description: "Wizard(s) contributing to labels"
- name: source
- &source
name: source
description: "How were labels generated (could be static or query)"
- name: created_at
- &created_at
name: created_at
description: "When were labels created"
- name: updated_at
- &updated_at
name: updated_at
description: "When were labels updated for the last time"

- name: labels_nft_users_platforms
Expand All @@ -40,22 +48,16 @@ models:
tags: ['labels', 'nft_traders', 'ethereum', 'solana', 'opensea', 'looksrare', 'x2y2', 'magiceden']
description: "NFT Platforms users across chains"
columns:
- name: blockchain
description: "Blockchain"
- *blockchain
- name: address
description: "Address of NFT platforms users"
- name: name
description: "Label name (NFT Platform User)"
- name: category
description: "Label category (NFT here)"
- name: contributor
description: "Wizard(s) contributing to labels"
- name: source
description: "How were labels generated (could be static or query)"
- name: created_at
description: "When were labels created"
- name: updated_at
description: "When were labels updated for the last time"
- *category
- *contributor
- *source
- *created_at
- *updated_at

- name: labels_nft_traders_transactions
meta:
Expand All @@ -68,22 +70,16 @@ models:
tags: ['labels', 'nft_traders', 'ethereum', 'solana', 'opensea', 'looksrare', 'x2y2', 'magiceden']
description: "Top NFT traders based on the number of transactions across chains"
columns:
- name: blockchain
description: "Blockchain on which NFT trades have been made"
- *blockchain
- name: address
description: "Address of NFT traders"
- name: name
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)"
- name: category
description: "Label category (NFT here)"
- name: contributor
description: "Wizard(s) contributing to labels"
- name: source
description: "How were labels generated (could be static or query)"
- name: created_at
description: "When were labels created"
- name: updated_at
description: "When were labels updated for the last time"
- *category
- *contributor
- *source
- *created_at
- *updated_at

- name: labels_nft_traders_volume_usd
meta:
Expand All @@ -95,19 +91,13 @@ models:
tags: ['labels', 'nft_traders', 'ethereum', 'solana', 'opensea', 'looksrare', 'x2y2', 'magiceden']
description: "Top NFT traders based on volume in USD across chains"
columns:
- name: blockchain
description: "Blockchain on which NFT trades have been made"
- *blockchain
- name: address
description: "Address of NFT traders"
- name: name
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)"
- name: category
description: "Label category (NFT here)"
- name: contributor
description: "Wizard(s) contributing to labels"
- name: source
description: "How were labels generated (could be static or query)"
- name: created_at
description: "When were labels created"
- name: updated_at
description: "When were labels updated for the last time"
- *category
- *contributor
- *source
- *created_at
- *updated_at
12 changes: 12 additions & 0 deletions models/labels/safe/labels_safe_ethereum.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{config(alias='safe_ethereum')}}

SELECT
array('ethereum') as blockchain,
address,
'Safe' || ' version ' || creation_version AS name,
'safe' AS category,
'soispoke' AS contributor,
'query' AS source,
timestamp('2022-09-01') as created_at,
now() as updated_at
FROM {{ ref('safe_ethereum_safes') }}
Loading

0 comments on commit 6244423

Please sign in to comment.