-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add uni v2, v3, v4 to ink * add seeds to uni v4 ink dex trades * update to evt_index (seed was wrong)
- Loading branch information
Showing
9 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: dex_ink_base_trades | ||
data_tests: | ||
- check_dex_info_relationship | ||
- test_acceptable_usd_amount: | ||
column_name: amount_usd | ||
max_value: 1000000000 | ||
|
||
- name: uniswap_v4_ink_base_trades | ||
meta: | ||
blockchain: ink | ||
sector: dex | ||
project: uniswap | ||
contributors: agaperste | ||
config: | ||
tags: [ 'ink', 'dex', 'trades', 'uniswap', 'v4' ] | ||
description: "uniswap ink v4 base trades" | ||
data_tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- tx_hash | ||
- evt_index | ||
- check_dex_base_trades_seed: | ||
seed_file: ref('uniswap_ink_base_trades_seed') | ||
filter: | ||
version: 4 | ||
|
||
- name: uniswap_v3_ink_base_trades | ||
meta: | ||
blockchain: ink | ||
sector: dex | ||
project: uniswap | ||
contributors: hosuke | ||
config: | ||
tags: [ 'ink', 'dex', 'trades', 'uniswap', 'v3' ] | ||
description: "uniswap ink v3 base trades" | ||
data_tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- tx_hash | ||
- evt_index | ||
- check_dex_base_trades_seed: | ||
seed_file: ref('uniswap_ink_base_trades_seed') | ||
filter: | ||
version: 3 | ||
|
||
- name: uniswap_v2_ink_base_trades | ||
meta: | ||
blockchain: ink | ||
sector: dex | ||
project: uniswap | ||
contributors: Henrystats | ||
config: | ||
tags: ["ink", "dex", "trades", "uniswap", "v2"] | ||
description: "uniswap ink v2 base trades" | ||
data_tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- tx_hash | ||
- evt_index | ||
- check_dex_base_trades_seed: | ||
seed_file: ref('uniswap_ink_base_trades_seed') | ||
filter: | ||
version: 2 |
50 changes: 50 additions & 0 deletions
50
dbt_subprojects/dex/models/trades/ink/dex_ink_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{{ config( | ||
schema = 'dex_ink' | ||
, alias = 'base_trades' | ||
, materialized = 'view' | ||
) | ||
}} | ||
|
||
{% set base_models = [ | ||
ref('uniswap_v2_ink_base_trades') | ||
, ref('uniswap_v3_ink_base_trades') | ||
, ref('uniswap_v4_ink_base_trades') | ||
] %} | ||
|
||
WITH base_union AS ( | ||
SELECT * | ||
FROM ( | ||
{% for base_model in base_models %} | ||
SELECT | ||
blockchain | ||
, project | ||
, version | ||
, block_month | ||
, block_date | ||
, block_time | ||
, block_number | ||
, token_bought_amount_raw | ||
, token_sold_amount_raw | ||
, token_bought_address | ||
, token_sold_address | ||
, taker | ||
, maker | ||
, project_contract_address | ||
, tx_hash | ||
, evt_index | ||
FROM | ||
{{ base_model }} | ||
{% if not loop.last %} | ||
UNION ALL | ||
{% endif %} | ||
{% endfor %} | ||
) | ||
) | ||
|
||
{{ | ||
add_tx_columns( | ||
model_cte = 'base_union' | ||
, blockchain = 'ink' | ||
, columns = ['from', 'to', 'index'] | ||
) | ||
}} |
21 changes: 21 additions & 0 deletions
21
dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v2_ink_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{ | ||
config( | ||
schema = 'uniswap_v2_ink', | ||
alias = 'base_trades', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{ | ||
uniswap_compatible_v2_trades( | ||
blockchain = 'ink', | ||
project = 'uniswap', | ||
version = '2', | ||
Pair_evt_Swap = source('uniswap_v2_ink', 'UniswapV2Pair_evt_Swap'), | ||
Factory_evt_PairCreated = source('uniswap_v2_ink', 'UniswapV2Factory_evt_PairCreated') | ||
) | ||
}} |
21 changes: 21 additions & 0 deletions
21
dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v3_ink_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{ config( | ||
schema = 'uniswap_v3_ink' | ||
, alias = 'base_trades' | ||
, materialized = 'incremental' | ||
, file_format = 'delta' | ||
, incremental_strategy = 'merge' | ||
, unique_key = ['tx_hash', 'evt_index'] | ||
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{ | ||
uniswap_compatible_v3_trades( | ||
blockchain = 'ink' | ||
, project = 'uniswap' | ||
, version = '3' | ||
, Pair_evt_Swap = source('uniswap_v3_ink', 'UniswapV3Pool_evt_Swap') | ||
, Factory_evt_PoolCreated = source('uniswap_v3_ink', 'UniswapV3Factory_evt_PoolCreated') | ||
) | ||
}} | ||
|
21 changes: 21 additions & 0 deletions
21
dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v4_ink_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{ config( | ||
schema = 'uniswap_v4_ink' | ||
, alias = 'base_trades' | ||
, materialized = 'incremental' | ||
, file_format = 'delta' | ||
, incremental_strategy = 'merge' | ||
, unique_key = ['tx_hash', 'evt_index'] | ||
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{ | ||
uniswap_compatible_v4_trades( | ||
blockchain = 'ink' | ||
, project = 'uniswap' | ||
, version = '4' | ||
, PoolManager_evt_Swap = source('uniswap_v4_ink', 'PoolManager_evt_Swap') | ||
, PoolManager_evt_Initialize = source('uniswap_v4_ink', 'PoolManager_evt_Initialize') | ||
, taker_column_name = 'evt_tx_from' | ||
) | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
dbt_subprojects/dex/seeds/trades/uniswap_ink_base_trades_seed.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw | ||
ink,uniswap,3,2025-01-29,0x43b1aca915c82c6ed1ccef7eeccfe0653c5661a3a42b07f905a66cc808a998b2,11,0xf1815bd50389c46847f0bda824ec8da914045d14,0x4200000000000000000000000000000000000006,4661269,2798702,900000000000000 | ||
ink,uniswap,3,2025-01-29,0x9fa0e9bd8f3080b0c23e546c1e432159d21c7f9e373dc4e019c986d8e10ca13a,4,0xf1815bd50389c46847f0bda824ec8da914045d14,0x4200000000000000000000000000000000000006,4668859,308979,100000000000000 | ||
ink,uniswap,2,2025-01-29,0xad6ff67b6b3bfde5c5f960e87258dead339888551e06270b327c3ca04dbf050b,8,0x4200000000000000000000000000000000000006,0x11476323d8dfcbafac942588e2f38823d2dd308e,4663507,51408327835755,65110653663860 | ||
ink,uniswap,2,2025-01-29,0x2668ee57490b06f8ab29d2e9a7a474d8ad359634c541b18424441c70c138c751,18,0x11476323d8dfcbafac942588e2f38823d2dd308e,0x4200000000000000000000000000000000000006,4677067,144612215120721,139216911618398 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: uniswap_v4_ink | ||
tables: | ||
- name: PoolManager_evt_Swap | ||
- name: PoolManager_evt_Initialize | ||
- name: uniswap_v3_ink | ||
tables: | ||
- name: UniswapV3Pool_evt_Swap | ||
- name: UniswapV3Factory_evt_PoolCreated | ||
- name: uniswap_v2_ink | ||
tables: | ||
- name: UniswapV2Pair_evt_Swap | ||
- name: UniswapV2Factory_evt_PairCreated |