Skip to content

Commit

Permalink
Add static cex labels (#1512)
Browse files Browse the repository at this point in the history
This PR is meant to give an example of static labels added to the spellbook repo for CEX on ethereum.

Brief comments on the purpose of your changes:


*For Dune Engine V2*
I've checked that:
General checks:
* [x] I tested the query on dune.com after compiling the model with dbt compile (compiled queries are written to the target directory)
* [x] I used "refs" to reference other models in this repo and "sources" to reference raw or decoded tables 
* [x] if adding a new model, I added a test
* [x] the filename is unique and ends with .sql
* [x] each sql file is a select statement and has only one view, table or function defined  
* [x] column names are `lowercase_snake_cased`
* [x] if adding a new model, I edited the dbt project YAML file with new directory path for both models and seeds (if applicable)
* [x] if adding a new model, I edited the alter table macro to display new database object (table or view) in UI explorer
* [x] if adding a new materialized table, I edited the optimize table macro

Join logic:
* [ ] if joining to base table (i.e. ethereum transactions or traces), I looked to make it an inner join if possible

Incremental logic:
* [ ] I used is_incremental & not is_incremental jinja block filters on both base tables and decoded tables
  * [ ] where block_time >= date_trunc("day", now() - interval '1 week')
* [ ] if joining to base table (i.e. ethereum transactions or traces), I applied join condition where block_time >= date_trunc("day", now() - interval '1 week')
* [ ] if joining to prices view, I applied join condition where minute >= date_trunc("day", now() - interval '1 week')
  • Loading branch information
soispoke authored Sep 8, 2022
1 parent 0f4de8e commit 25b44cd
Show file tree
Hide file tree
Showing 6 changed files with 596 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ models:
ethereum:
+schema: balances_ethereum
+materialized: view

labels:
+schema: labels
+materialized: view

tokens:
+schema: tokens
Expand Down
3 changes: 3 additions & 0 deletions models/labels/cex/labels_cex.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{config(alias='cex')}}

SELECT * FROM {{ ref('labels_cex_ethereum') }}
496 changes: 496 additions & 0 deletions models/labels/cex/labels_cex_ethereum.sql

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions models/labels/cex/labels_cex_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: 2

models:
- name: labels_cex
meta:
blockchain: ethereum
sector: labels
project: cex
contibutors: hildobby, soispoke
config:
tags: ['labels', 'ethereum', 'cex']
description: "Known centralised exchange addresses across chains"
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 ?"

- name: labels_cex_ethereum
meta:
blockchain: ethereum
sector: labels
project: cex
contibutors: hildobby, soispoke
config:
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 ?"
8 changes: 8 additions & 0 deletions models/labels/labels_all.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ config(
alias = 'all',
materialized = 'table',
file_format = 'delta')
}}

-- Static Labels
SELECT * FROM {{ ref('labels_cex') }}
29 changes: 29 additions & 0 deletions models/labels/labels_all_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2

models:
- name: labels_all
meta:
blockchain: ethereum, solana
sector: labels
category: cex
contibutors: hildobby, soispoke
config:
tags: ['labels', 'ethereum', 'cex']
description: "All labels across chains and categories"
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Label 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 ?"

0 comments on commit 25b44cd

Please sign in to comment.