From 6244423c42c65a080dd0a1a97222a4d37648c9c1 Mon Sep 17 00:00:00 2001 From: soispoke <66172107+soispoke@users.noreply.github.com> Date: Sun, 11 Sep 2022 23:09:26 +0700 Subject: [PATCH] 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 c9a0942b6e9ae11925eb7fa951b90ca3477682f0. * remove ? * Update dbt_project.yml * add balances * Revert "add balances" This reverts commit 76bc61e09ec87e967c5e2820d18b57742a533ff3. * 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 --- dbt_project.yml | 1 + macros/alter_table_properties.sql | 10 ++ macros/optimize_tables.sql | 5 + models/labels/cex/labels_cex_schema.yml | 50 ++++---- models/labels/funds/labels_funds.sql | 3 + models/labels/funds/labels_funds_ethereum.sql | 25 ++++ models/labels/funds/labels_funds_schema.yml | 56 +++++++++ models/labels/labels_all.sql | 12 +- models/labels/labels_all_schema.yml | 7 +- models/labels/nft/labels_nft_schema.yml | 80 ++++++------- models/labels/safe/labels_safe_ethereum.sql | 12 ++ models/labels/safe/labels_safe_schema.yml | 30 +++++ .../labels_decoded_contracts_sources.yml | 110 ++++++++++++++++++ .../labels_submitted_contracts.sql | 61 ++++++++++ .../labels_submitted_contracts_schema.yml | 29 +++++ .../tornado_cash/labels_tornado_cash.sql | 29 +++++ .../labels_tornado_cash_schema.yml | 30 +++++ 17 files changed, 476 insertions(+), 74 deletions(-) create mode 100644 models/labels/funds/labels_funds.sql create mode 100644 models/labels/funds/labels_funds_ethereum.sql create mode 100644 models/labels/funds/labels_funds_schema.yml create mode 100644 models/labels/safe/labels_safe_ethereum.sql create mode 100644 models/labels/safe/labels_safe_schema.yml create mode 100644 models/labels/submitted_contracts/labels_decoded_contracts_sources.yml create mode 100644 models/labels/submitted_contracts/labels_submitted_contracts.sql create mode 100644 models/labels/submitted_contracts/labels_submitted_contracts_schema.yml create mode 100644 models/labels/tornado_cash/labels_tornado_cash.sql create mode 100644 models/labels/tornado_cash/labels_tornado_cash_schema.yml diff --git a/dbt_project.yml b/dbt_project.yml index dbda4553974..67ab7fe017d 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -115,6 +115,7 @@ models: ethereum: +schema: balances_ethereum +materialized: view + labels: +schema: labels +materialized: view diff --git a/macros/alter_table_properties.sql b/macros/alter_table_properties.sql index aa5f023c448..1fd015b6d0a 100644 --- a/macros/alter_table_properties.sql +++ b/macros/alter_table_properties.sql @@ -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"]', @@ -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) %} diff --git a/macros/optimize_tables.sql b/macros/optimize_tables.sql index 4803e0dd960..d8d596fe7dd 100644 --- a/macros/optimize_tables.sql +++ b/macros/optimize_tables.sql @@ -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) %} @@ -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 %} diff --git a/models/labels/cex/labels_cex_schema.yml b/models/labels/cex/labels_cex_schema.yml index db27def8ec2..2549afc511f 100644 --- a/models/labels/cex/labels_cex_schema.yml +++ b/models/labels/cex/labels_cex_schema.yml @@ -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: @@ -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 ?" \ No newline at end of file + - *blockchain + - *address + - *name + - *category + - *contributor + - *source + - *created_at + - *updated_at \ No newline at end of file diff --git a/models/labels/funds/labels_funds.sql b/models/labels/funds/labels_funds.sql new file mode 100644 index 00000000000..e8e19bab2ae --- /dev/null +++ b/models/labels/funds/labels_funds.sql @@ -0,0 +1,3 @@ +{{config(alias='funds')}} + +SELECT * FROM {{ ref('labels_funds_ethereum') }} diff --git a/models/labels/funds/labels_funds_ethereum.sql b/models/labels/funds/labels_funds_ethereum.sql new file mode 100644 index 00000000000..06858b2f09f --- /dev/null +++ b/models/labels/funds/labels_funds_ethereum.sql @@ -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) \ No newline at end of file diff --git a/models/labels/funds/labels_funds_schema.yml b/models/labels/funds/labels_funds_schema.yml new file mode 100644 index 00000000000..66872e8347f --- /dev/null +++ b/models/labels/funds/labels_funds_schema.yml @@ -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 \ No newline at end of file diff --git a/models/labels/labels_all.sql b/models/labels/labels_all.sql index 4d82a6212c3..23fbcf579b8 100644 --- a/models/labels/labels_all.sql +++ b/models/labels/labels_all.sql @@ -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') }} \ No newline at end of file +SELECT * FROM {{ ref('labels_safe_ethereum') }} +UNION +SELECT * FROM {{ ref('labels_tornado_cash') }} diff --git a/models/labels/labels_all_schema.yml b/models/labels/labels_all_schema.yml index 1248dd6558a..675e7d060a2 100644 --- a/models/labels/labels_all_schema.yml +++ b/models/labels/labels_all_schema.yml @@ -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 diff --git a/models/labels/nft/labels_nft_schema.yml b/models/labels/nft/labels_nft_schema.yml index 920b5cc4600..ddde696c7e7 100644 --- a/models/labels/nft/labels_nft_schema.yml +++ b/models/labels/nft/labels_nft_schema.yml @@ -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 @@ -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: @@ -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: @@ -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" \ No newline at end of file + - *category + - *contributor + - *source + - *created_at + - *updated_at \ No newline at end of file diff --git a/models/labels/safe/labels_safe_ethereum.sql b/models/labels/safe/labels_safe_ethereum.sql new file mode 100644 index 00000000000..88218118fa6 --- /dev/null +++ b/models/labels/safe/labels_safe_ethereum.sql @@ -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') }} \ No newline at end of file diff --git a/models/labels/safe/labels_safe_schema.yml b/models/labels/safe/labels_safe_schema.yml new file mode 100644 index 00000000000..d9521cc427a --- /dev/null +++ b/models/labels/safe/labels_safe_schema.yml @@ -0,0 +1,30 @@ +version: 2 + +models: + - name: labels_safe_ethereum + meta: + blockchain: ethereum + sector: labels + category: safe + project: ['safe'] + contibutors: soispoke + config: + tags: ['labels', 'safe', 'ethereum'] + description: "Safe query labels" + columns: + - name: blockchain + description: "Blockchain" + - name: address + description: "Safe address" + - name: name + description: "Label name, including the Safe version" + - 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" \ No newline at end of file diff --git a/models/labels/submitted_contracts/labels_decoded_contracts_sources.yml b/models/labels/submitted_contracts/labels_decoded_contracts_sources.yml new file mode 100644 index 00000000000..0d05ed61f8e --- /dev/null +++ b/models/labels/submitted_contracts/labels_decoded_contracts_sources.yml @@ -0,0 +1,110 @@ +version: 2 + +sources: + - name: arbitrum + description: "Arbitrum contracts submitted" + freshness: + warn_after: { count: 12, period: hour } + tables: + - name: contracts_submitted + loaded_at_field: created_at + columns: + - name: abi + - name: address + - name: code + - name: created_at + - name: dynamic + - name: factory + - name: from + - name: name + - name: namespace + + - name: avalanche_c + description: "Avalanche contracts submitted" + freshness: + warn_after: { count: 12, period: hour } + tables: + - name: contracts_submitted + loaded_at_field: created_at + columns: + - name: abi + - name: address + - name: code + - name: created_at + - name: dynamic + - name: factory + - name: from + - name: name + - name: namespace + + - name: ethereum + description: "Ethereum contracts submitted" + freshness: + warn_after: { count: 12, period: hour } + tables: + - name: contracts_submitted + loaded_at_field: created_at + columns: + - name: abi + - name: address + - name: code + - name: created_at + - name: dynamic + - name: factory + - name: from + - name: name + - name: namespace + + - name: bnb + description: "BNB contracts submitted" + freshness: + warn_after: { count: 12, period: hour } + tables: + - name: contracts_submitted + loaded_at_field: created_at + columns: + - name: abi + - name: address + - name: code + - name: created_at + - name: dynamic + - name: factory + - name: from + - name: name + - name: namespace + + - name: optimism + description: "Optimism contracts submitted" + freshness: + warn_after: { count: 12, period: hour } + tables: + - name: contracts_submitted + loaded_at_field: created_at + columns: + - name: abi + - name: address + - name: code + - name: created_at + - name: dynamic + - name: factory + - name: from + - name: name + - name: namespace + + - name: gnosis + description: "Gnosis contracts submitted" + freshness: + warn_after: { count: 12, period: hour } + tables: + - name: contracts_submitted + loaded_at_field: created_at + columns: + - name: abi + - name: address + - name: code + - name: created_at + - name: dynamic + - name: factory + - name: from + - name: name + - name: namespace \ No newline at end of file diff --git a/models/labels/submitted_contracts/labels_submitted_contracts.sql b/models/labels/submitted_contracts/labels_submitted_contracts.sql new file mode 100644 index 00000000000..047158ae124 --- /dev/null +++ b/models/labels/submitted_contracts/labels_submitted_contracts.sql @@ -0,0 +1,61 @@ +{{config(alias='submitted_contracts')}} + +SELECT array('ethereum') as blockchain, + address, + name || '_' || namespace as name, + 'submitted_contracts' as category, + 'soispoke' as contributor, + 'static' AS source, + date('2022-09-23') as created_at, + now() as modified_at +FROM {{ source('ethereum','contracts_submitted') }} +UNION +SELECT array('gnosis') as blockchain, + address, + name || '_' || namespace as name, + 'submitted_contracts' as category, + 'soispoke' as contributor, + 'static' AS source, + date('2022-09-23') as created_at, + now() as modified_at +FROM {{ source('gnosis','contracts_submitted') }} +UNION +SELECT array('avalanche_c') as blockchain, + address, + name || '_' || namespace as name, + 'submitted_contracts' as category, + 'soispoke' as contributor, + 'static' AS source, + date('2022-09-23') as created_at, + now() as modified_at +FROM {{ source('avalanche_c','contracts_submitted') }} +UNION +SELECT array('arbitrum') as blockchain, + address, + name || '_' || namespace as name, + 'submitted_contracts' as category, + 'soispoke' as contributor, + 'static' AS source, + date('2022-09-23') as created_at, + now() as modified_at +FROM {{ source('arbitrum','contracts_submitted') }} +UNION +SELECT array('bnb') as blockchain, + address, + name || '_' || namespace as name, + 'submitted_contracts' as category, + 'soispoke' as contributor, + 'static' AS source, + date('2022-09-23') as created_at, + now() as modified_at +FROM {{ source('bnb','contracts_submitted') }} +UNION +SELECT array('optimism') as blockchain, + address, + name || '_' || namespace as name, + 'submitted_contracts' as category, + 'soispoke' as contributor, + 'static' AS source, + date('2022-09-23') as created_at, + now() as modified_at +FROM {{ source('optimism','contracts_submitted') }} \ No newline at end of file diff --git a/models/labels/submitted_contracts/labels_submitted_contracts_schema.yml b/models/labels/submitted_contracts/labels_submitted_contracts_schema.yml new file mode 100644 index 00000000000..8c6962f88c2 --- /dev/null +++ b/models/labels/submitted_contracts/labels_submitted_contracts_schema.yml @@ -0,0 +1,29 @@ +version: 2 + +models: + - name: labels_submitted_contracts + meta: + blockchain: ethereum, arbitrum, gnosis, optimism, bnb, avalanche_c + sector: labels + category: submitted_contracts + contibutors: soispoke + config: + tags: ['query', 'labels', 'ethereum', 'submitted_contracts'] + description: "Dune submitted contracts query labels across chains" + columns: + - name: blockchain + description: "Blockchain" + - name: address + description: "Label address" + - name: name + description: "Label name (name and namespace) of the submitted contract" + - 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" diff --git a/models/labels/tornado_cash/labels_tornado_cash.sql b/models/labels/tornado_cash/labels_tornado_cash.sql new file mode 100644 index 00000000000..5e9c17794f6 --- /dev/null +++ b/models/labels/tornado_cash/labels_tornado_cash.sql @@ -0,0 +1,29 @@ +{{config(alias='tornado_cash')}} + +WITH tornado_addresses AS ( +SELECT + lower(blockchain) as blockchain, + tx_hash, + depositor AS address, + 'Depositor' as name +FROM {{ ref('tornado_cash_deposits') }} +UNION +SELECT + lower(blockchain) as blockchain, + tx_hash, + recipient AS address, + 'Recipient' as name +FROM {{ ref('tornado_cash_withdrawals') }} +) + +SELECT + collect_set(blockchain) as blockchain, + address, + 'Tornado Cash ' || array_join(collect_set(name),' and ') AS name, + 'tornado_cash' AS category, + 'soispoke' AS contributor, + 'query' AS source, + timestamp('2022-10-01') as created_at, + now() as updated_at +FROM tornado_addresses +GROUP BY address \ No newline at end of file diff --git a/models/labels/tornado_cash/labels_tornado_cash_schema.yml b/models/labels/tornado_cash/labels_tornado_cash_schema.yml new file mode 100644 index 00000000000..78b6f7a820c --- /dev/null +++ b/models/labels/tornado_cash/labels_tornado_cash_schema.yml @@ -0,0 +1,30 @@ +version: 2 + +models: + - name: labels_tornado_cash + meta: + blockchain: ethereum + sector: labels + category: tornado_cash + project: ['tornado_cash'] + contibutors: soispoke + config: + tags: ['labels', 'tornado_cash', 'ethereum', 'arbitrum','bnb','avalanche_c','optimism','gnosis'] + description: "Tornado Cash depositors and recipients query labels across chains" + columns: + - name: blockchain + description: "Blockchain" + - name: address + description: "Tornado cash depositor/recipient address" + - name: name + description: "Label name" + - 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" \ No newline at end of file