Skip to content

Commit db4cd45

Browse files
tomfutagojeff-dude
andauthored
CUR2-642: story dexes (#8993)
* feat: sources * feat: story_hunt dex * feat: piperx dex * fix: remove story from main model to allow ci to complete * fix: temp remove story ref * chore: add 2 new dexes * fix: remove uniqueness check on view --------- Co-authored-by: jeff-dude <[email protected]>
1 parent ed679d6 commit db4cd45

File tree

13 files changed

+257
-10
lines changed

13 files changed

+257
-10
lines changed

dbt_subprojects/dex/models/dex_info.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,7 @@ FROM (VALUES
239239
, ('machinex', 'Machine X', 'Direct', 'machinexdotxyz')
240240
, ('cldex', 'CLDEX', 'Direct', 'KaiaChain')
241241
, ('aborean', 'Aborean', 'Direct', 'AboreanFi')
242+
, ('story_hunt', 'Story Hunt', 'Direct', 'story_hunt')
243+
, ('piperx', 'PiperX', 'Direct', 'piperx')
242244
, ('mezo_swap', 'Mezo Swap', 'Direct', 'mezoswap')
243245
) AS temp_table (project, name, marketplace_type, x_username)

dbt_subprojects/dex/models/trades/_schema.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,6 @@ models:
129129
contributors: 0xRob, hosuke, jeff-dude, tomfutago, viniabussafi
130130
config:
131131
tags: [ 'dex' ]
132-
data_tests:
133-
- check_columns_dex_base_trades
134-
- dbt_utils.unique_combination_of_columns:
135-
combination_of_columns:
136-
- blockchain
137-
- project
138-
- version
139-
- tx_hash
140-
- evt_index
141132
columns:
142133
- *blockchain
143134
- *project
@@ -156,4 +147,4 @@ models:
156147
- *tx_hash
157148
- *evt_index
158149
- *tx_from
159-
- *tx_to
150+
- *tx_to

dbt_subprojects/dex/models/trades/dex_base_trades.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
, ref('dex_somnia_base_trades')
4444
, ref('dex_sonic_base_trades')
4545
, ref('dex_sophon_base_trades')
46+
, ref('dex_story_base_trades')
4647
, ref('dex_superseed_base_trades')
4748
, ref('dex_taiko_base_trades')
4849
, ref('dex_tac_base_trades')
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
version: 2
2+
3+
models:
4+
- name: dex_story_base_trades
5+
data_tests:
6+
- check_columns_dex_base_trades
7+
- check_dex_info_relationship
8+
- test_acceptable_usd_amount:
9+
column_name: amount_usd
10+
max_value: 1000000000
11+
12+
- name: story_hunt_story_base_trades
13+
meta:
14+
blockchain: story
15+
sector: dex
16+
project: story_hunt
17+
contributors: tomfutago
18+
config:
19+
tags: ["story", "dex", "trades", "story_hunt"]
20+
description: "Story Hunt story base trades"
21+
data_tests:
22+
- dbt_utils.unique_combination_of_columns:
23+
combination_of_columns:
24+
- tx_hash
25+
- evt_index
26+
- check_dex_base_trades_seed:
27+
seed_file: ref('story_hunt_story_base_trades_seed')
28+
29+
- name: piperx_v2_story_base_trades
30+
meta:
31+
blockchain: story
32+
sector: dex
33+
project: piperx
34+
version: '2'
35+
contributors: tomfutago
36+
config:
37+
tags: ["story", "dex", "trades", "piperx"]
38+
description: "Piperx v2 story base trades"
39+
data_tests:
40+
- dbt_utils.unique_combination_of_columns:
41+
combination_of_columns:
42+
- tx_hash
43+
- evt_index
44+
- check_dex_base_trades_seed:
45+
seed_file: ref('piperx_v2_story_base_trades_seed')
46+
filter:
47+
version: 2
48+
49+
- name: piperx_v3_story_base_trades
50+
meta:
51+
blockchain: story
52+
sector: dex
53+
project: piperx
54+
version: '3'
55+
contributors: tomfutago
56+
config:
57+
tags: ["story", "dex", "trades", "piperx"]
58+
description: "Piperx v3 story base trades"
59+
data_tests:
60+
- dbt_utils.unique_combination_of_columns:
61+
combination_of_columns:
62+
- tx_hash
63+
- evt_index
64+
- check_dex_base_trades_seed:
65+
seed_file: ref('piperx_v3_story_base_trades_seed')
66+
filter:
67+
version: 3
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{ config(
2+
schema = 'dex_story'
3+
, alias = 'base_trades'
4+
, partition_by = ['block_month']
5+
, materialized = 'incremental'
6+
, file_format = 'delta'
7+
, incremental_strategy = 'merge'
8+
, unique_key = ['blockchain', 'project', 'version', 'tx_hash', 'evt_index']
9+
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
10+
)
11+
}}
12+
13+
{% set base_models = [
14+
ref('story_hunt_story_base_trades')
15+
, ref('piperx_v2_story_base_trades')
16+
, ref('piperx_v3_story_base_trades')
17+
] %}
18+
with base_union as (
19+
SELECT *
20+
FROM
21+
(
22+
{% for base_model in base_models %}
23+
SELECT
24+
blockchain
25+
, project
26+
, version
27+
, block_month
28+
, block_date
29+
, block_time
30+
, block_number
31+
, cast(token_bought_amount_raw as uint256) as token_bought_amount_raw
32+
, cast(token_sold_amount_raw as uint256) as token_sold_amount_raw
33+
, token_bought_address
34+
, token_sold_address
35+
, taker
36+
, maker
37+
, project_contract_address
38+
, tx_hash
39+
, evt_index
40+
, row_number() over (partition by tx_hash, evt_index order by tx_hash) as duplicates_rank
41+
FROM
42+
{{ base_model }}
43+
WHERE
44+
token_sold_amount_raw >= 0 and token_bought_amount_raw >= 0
45+
{% if is_incremental() %}
46+
AND {{ incremental_predicate('block_time') }}
47+
{% endif %}
48+
{% if not loop.last %}
49+
UNION ALL
50+
{% endif %}
51+
{% endfor %}
52+
)
53+
WHERE
54+
duplicates_rank = 1
55+
)
56+
57+
{{
58+
add_tx_columns(
59+
model_cte = 'base_union'
60+
, blockchain = 'story'
61+
, columns = ['from', 'to', 'index']
62+
)
63+
}}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{
2+
config(
3+
schema = 'piperx_v2_story',
4+
alias = 'base_trades',
5+
materialized = 'incremental',
6+
file_format = 'delta',
7+
incremental_strategy = 'merge',
8+
unique_key = ['tx_hash', 'evt_index'],
9+
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
10+
)
11+
}}
12+
13+
{{
14+
uniswap_compatible_v2_trades(
15+
blockchain = 'story',
16+
project = 'piperx',
17+
version = '2',
18+
Pair_evt_Swap = source('piperx_story', 'uniswapv2pool_evt_swap'),
19+
Factory_evt_PairCreated = source('piperx_story', 'piperxswapv2factory_evt_paircreated')
20+
)
21+
}}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{
2+
config(
3+
schema = 'piperx_v3_story',
4+
alias = 'base_trades',
5+
materialized = 'incremental',
6+
file_format = 'delta',
7+
incremental_strategy = 'merge',
8+
unique_key = ['tx_hash', 'evt_index'],
9+
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
10+
)
11+
}}
12+
13+
{{
14+
uniswap_compatible_v3_trades(
15+
blockchain = 'story',
16+
project = 'piperx',
17+
version = '3',
18+
Pair_evt_Swap = source('piperx_story', 'uniswapv3pool_evt_swap'),
19+
Factory_evt_PoolCreated = source('piperx_story', 'piperxswapv3factory_evt_poolcreated')
20+
)
21+
}}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{
2+
config(
3+
schema = 'story_hunt_story',
4+
alias = 'base_trades',
5+
materialized = 'incremental',
6+
file_format = 'delta',
7+
incremental_strategy = 'merge',
8+
unique_key = ['tx_hash', 'evt_index'],
9+
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
10+
)
11+
}}
12+
13+
{{
14+
uniswap_compatible_v3_trades(
15+
blockchain = 'story',
16+
project = 'story_hunt',
17+
version = '1',
18+
Pair_evt_Swap = source('story_hunt_story', 'storyhuntv3pool_evt_swap'),
19+
Factory_evt_PoolCreated = source('story_hunt_story', 'storyhuntv3factory_evt_poolcreated')
20+
)
21+
}}

dbt_subprojects/dex/seeds/trades/_schema.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,6 +6014,49 @@ seeds:
60146014
token_bought_amount_raw: uint256
60156015
token_sold_amount_raw: uint256
60166016
block_date: timestamp
6017+
6018+
- name: story_hunt_story_base_trades_seed
6019+
config:
6020+
column_types:
6021+
blockchain: varchar
6022+
project: varchar
6023+
version: varchar
6024+
tx_hash: varbinary
6025+
evt_index: uint256
6026+
block_number: uint256
6027+
token_bought_address: varbinary
6028+
token_sold_address: varbinary
6029+
token_bought_amount_raw: uint256
6030+
token_sold_amount_raw: uint256
6031+
block_date: timestamp
6032+
- name: piperx_v2_story_base_trades_seed
6033+
config:
6034+
column_types:
6035+
blockchain: varchar
6036+
project: varchar
6037+
version: varchar
6038+
tx_hash: varbinary
6039+
evt_index: uint256
6040+
block_number: uint256
6041+
token_bought_address: varbinary
6042+
token_sold_address: varbinary
6043+
token_bought_amount_raw: uint256
6044+
token_sold_amount_raw: uint256
6045+
block_date: timestamp
6046+
- name: piperx_v3_story_base_trades_seed
6047+
config:
6048+
column_types:
6049+
blockchain: varchar
6050+
project: varchar
6051+
version: varchar
6052+
tx_hash: varbinary
6053+
evt_index: uint256
6054+
block_number: uint256
6055+
token_bought_address: varbinary
6056+
token_sold_address: varbinary
6057+
token_bought_amount_raw: uint256
6058+
token_sold_amount_raw: uint256
6059+
block_date: timestamp
60176060
- name: mezo_swap_mezo_base_trades_seed
60186061
config:
60196062
column_types:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
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

0 commit comments

Comments
 (0)