Skip to content

Commit

Permalink
standardize unique_trade_id (#1169)
Browse files Browse the repository at this point in the history
Standardize descriptions and unique_trade_id columns + its associated tests across existing abstractions

I've checked that:

* [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] the directory tree matches the pattern /sector/blockchain/ e.g. /tokens/ethereum
* [x] if adding a new model, I added a test
* [x] the filename is unique and ends with .sql
* [x] each file has only one view, table or function defined  
* [x] column names are `lowercase_snake_cased`
  • Loading branch information
soispoke authored Jun 16, 2022
1 parent 7f06863 commit b0b52c4
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 35 deletions.
4 changes: 2 additions & 2 deletions spellbook/models/magiceden/magiceden_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ models:
description: "Value of the trade at time of execution in the original currency"
- name: amount_usd
description: "USD value of the trade at time of execution"
- name: trade_id
description: "Trade ID (derived from id in solana transactions)"
- name: unique_trade_id
description: "Unique trade ID (derived from signatures[0] and id in solana transactions)"
8 changes: 3 additions & 5 deletions spellbook/models/magiceden/solana/magiceden_solana_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ models:
description: >
MagicEden trades on Solana
columns:
- name: unique_id
description: "Unique id, combination of signatures[0] and id"
- name: unique_trade_id
description: "Unique trade id, combination of signatures[0] and id"
tests:
- unique
- &blockchain
Expand All @@ -31,6 +31,4 @@ models:
- name: amount_usd
description: "USD value of the trade at time of execution"
- name: traders
description: "Traders"
- name: trade_id
description: "Trade ID (derived from id in solana transactions)"
description: "Traders"
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}}

SELECT
signatures[0] || id as unique_trade_id,
signatures[0] || '-' || id as unique_trade_id,
'solana' as blockchain,
signatures[0] as tx_hash,
block_time,
Expand Down
4 changes: 2 additions & 2 deletions spellbook/models/nft/nft_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ models:
description: "Value of the trade at time of execution in the original currency"
- name: amount_usd
description: "USD value of the trade at time of execution"
- name: trade_id
description: "Trade ID"
- name: unique_trade_id
description: "Unique trade ID"
6 changes: 2 additions & 4 deletions spellbook/models/opensea/ethereum/opensea_ethereum_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ models:
description: >
OpenSea trades on Ethereum
columns:
- name: unique_id
description: "Unique id, combination of tx_hash and trade_id"
- name: unique_trade_id
description: "Unique trade id, combination of tx_hash and trade_id"
tests:
- unique
- &blockchain
Expand All @@ -38,8 +38,6 @@ models:
description: "Maker"
- name: taker
description: "Taker"
- name: trade_id
description: "Trade id (derived from evt_index for ethereum nft trades)"

- name: opensea_ethereum_volume_day
meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}}

SELECT
evt_tx_hash || evt_index::string as unique_trade_id,
evt_tx_hash || '-' || evt_index::string as unique_trade_id,
'ethereum' as blockchain,
evt_tx_hash as tx_hash,
evt_block_time as block_time,
Expand Down
4 changes: 2 additions & 2 deletions spellbook/models/opensea/opensea_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ models:
description: "Value of the trade at time of execution in the original currency"
- name: amount_usd
description: "USD value of the trade at time of execution"
- name: trade_id
description: "Trade ID"
- name: unique_trade_id
description: "Unique trade ID"

- name: opensea_volume_day
meta:
Expand Down
6 changes: 2 additions & 4 deletions spellbook/models/opensea/solana/opensea_solana_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ models:
description: >
OpenSea trades on Solana
columns:
- name: unique_id
description: "Unique id, combination of signatures[0] and id"
- name: unique_trade_id
description: "Unique trade id, combination of signatures[0] and id"
tests:
- unique
- &blockchain
Expand All @@ -32,8 +32,6 @@ models:
description: "USD value of the trade at time of execution"
- name: traders
description: "Traders"
- name: trade_id
description: "Trade ID (derived from id in solana transactions)"

- name: opensea_solana_volume_day
meta:
Expand Down
2 changes: 1 addition & 1 deletion spellbook/models/opensea/solana/opensea_solana_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}}

SELECT
signatures[0] || id as unique_trade_id,
signatures[0] || '-' || id as unique_trade_id,
'solana' as blockchain,
signatures[0] as tx_hash,
block_time,
Expand Down
18 changes: 7 additions & 11 deletions spellbook/models/uniswap/ethereum/uniswap_ethereum_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ models:
- &tx_to
name: tx_to
description: "Receive this transaction"
- &trade_id
name: trade_id
description: "Trade ID (derived from evt_index for ethereum dex trades)"
- &unique_trade_id
name: unique_trade_id
description: "Unique trade ID (derived from tx_hash and evt_index for ethereum dex trades)"
tests:
- unique

- name: uniswap_v2_ethereum_trades
meta:
Expand All @@ -76,11 +78,7 @@ models:
description: >
Uniswap V2 trades on Ethereum
columns:
- &unique_id
name: unique_id
description: "Unique id, combination of tx_hash and trade_id"
tests:
- unique
- *unique_trade_id
- *blockchain
- *project
- *version
Expand All @@ -98,7 +96,6 @@ models:
- *tx_hash
- *tx_from
- *tx_to
- *trade_id

- name: uniswap_v3_ethereum_trades
meta:
Expand All @@ -110,7 +107,7 @@ models:
description: >
Uniswap V3 trades on Ethereum
columns:
- *unique_id
- *unique_trade_id
- *blockchain
- *project
- *version
Expand All @@ -128,4 +125,3 @@ models:
- *tx_hash
- *tx_from
- *tx_to
- *trade_id
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}}

SELECT
tx_hash || evt_index::string as unique_trade_id,
tx_hash || '-' || evt_index::string as unique_trade_id,
'ethereum' as blockchain,
'uniswap' as project,
'v2' as version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}}

SELECT
tx_hash || evt_index::string as unique_trade_id,
tx_hash || '-' || evt_index::string as unique_trade_id,
'ethereum' as blockchain,
'uniswap' as project,
'v3' as version,
Expand Down

0 comments on commit b0b52c4

Please sign in to comment.