Skip to content

Commit

Permalink
added version to unique_trade_id again and distinct to uniswap trades… (
Browse files Browse the repository at this point in the history
#1253)

… to make sure we have no dupes

Some duplicates were actually cause by txs like this one: https://etherscan.io/tx/0x956dd8bded921b16b93fd0a89d5ae1db53c5ed5fc06d1f548a8c438c17492338
where both uniswap v3 and v2 contracts were used in the same tx

Brief comments on the purpose of your changes:


*For Dune Engine V2*
I've checked that:

* [ ] I tested the query on dune.com after compiling the model with dbt compile (compiled queries are written to the target directory)
* [ ] I used "refs" to reference other models in this repo and "sources" to reference raw or decoded tables 
* [ ] if adding a new model, I added a test
* [ ] the filename is unique and ends with .sql
* [ ] each sql file is a select statement and has only one view, table or function defined  
* [ ] column names are `lowercase_snake_cased`

When you are ready for a review, tag duneanalytics/data-experience. We will re-open your forked pull request as an internal pull request. Then your spells will run in dbt and the logs will be avaiable in Github Actions DBT Slim CI. This job will only run the models and tests changed by your PR compared to the production project.
  • Loading branch information
soispoke authored Jul 6, 2022
1 parent a8e9286 commit 82d9870
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
alias='trades')
}}

SELECT blockchain, project, version, block_time, token_a_symbol, token_b_symbol,
SELECT DISTINCT blockchain, project, version, block_time, token_a_symbol, token_b_symbol,
token_a_amount, token_b_amount, trader_a, trader_b, usd_amount, token_a_address,
token_b_address, exchange_contract_address, tx_hash, tx_from, tx_to, unique_trade_id
FROM (SELECT * FROM {{ ref('uniswap_v2_ethereum_trades') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
)
}}

SELECT
SELECT DISTINCT
'ethereum' as blockchain,
'uniswap' as project,
'v2' as version,
Expand All @@ -27,7 +27,7 @@ SELECT
tx_hash,
tx.from as tx_from,
tx.to as tx_to,
tx_hash || '-' || evt_index::string || '-' || token_a_address || '-' || token_a_amount_raw::string as unique_trade_id
'v2' || '-' || tx_hash || '-' || evt_index::string || '-' || token_a_address || '-' || token_a_amount_raw::string as unique_trade_id
FROM (
--Uniswap v2
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
alias='trades')
}}

SELECT DISTINCT
SELECT
'ethereum' as blockchain,
'uniswap' as project,
'v3' as version,
Expand All @@ -24,7 +24,7 @@ SELECT DISTINCT
tx_hash,
tx.from as tx_from,
tx.to as tx_to,
tx_hash || '-' || evt_index::string || '-' || token_a_amount_raw::string as unique_trade_id
'v3' || '-' || tx_hash || '-' || evt_index::string || '-' || token_a_amount_raw::string as unique_trade_id
FROM (--Uniswap v3
SELECT
t.evt_block_time AS block_time,
Expand Down
2 changes: 1 addition & 1 deletion spellbook/models/uniswap/uniswap_trades.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ models:
config:
tags: ['ethereum','uniswap','trades']
description: >
Uniswap V1 trades
Uniswap trades
columns:
- &blockchain
name: blockchain
Expand Down

0 comments on commit 82d9870

Please sign in to comment.