Skip to content

Commit d68ff34

Browse files
authored
Revert "temp: revert DEX changes due to dbt cloud bug (duneanalytics#8530)" (duneanalytics#8531)
This reverts commit 4528233.
1 parent 4528233 commit d68ff34

29 files changed

Lines changed: 322 additions & 11 deletions
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{% macro native_compatible_trades(
2+
blockchain = null,
3+
project = null,
4+
sources = []
5+
)
6+
%}
7+
8+
WITH dexs AS (
9+
{% for src in sources %}
10+
SELECT
11+
'{{ src["version"] }}' as version,
12+
t.evt_block_number AS block_number,
13+
t.evt_block_time AS block_time,
14+
t.evt_tx_from as taker,
15+
CAST(NULL AS VARBINARY) AS maker,
16+
t.sellerTokenAmount as token_sold_amount_raw,
17+
t.buyerTokenAmount as token_bought_amount_raw,
18+
t.sellerToken as token_sold_address,
19+
t.buyerToken as token_bought_address,
20+
t.contract_address AS project_contract_address,
21+
t.evt_tx_hash AS tx_hash,
22+
t.evt_index
23+
FROM {{ source('native_' ~ blockchain, src["source"] )}} t
24+
{% if is_incremental() %}
25+
WHERE {{ incremental_predicate('evt_block_time') }}
26+
{% endif %}
27+
{% if not loop.last %}
28+
UNION ALL
29+
{% endif %}
30+
{% endfor %}
31+
)
32+
33+
SELECT
34+
'{{ blockchain }}' AS blockchain,
35+
'{{ project }}' AS project,
36+
dexs.version,
37+
CAST(date_trunc('month', dexs.block_time) AS date) AS block_month,
38+
CAST(date_trunc('day', dexs.block_time) AS date) AS block_date,
39+
dexs.block_time,
40+
dexs.block_number,
41+
dexs.token_bought_amount_raw,
42+
dexs.token_sold_amount_raw,
43+
dexs.token_bought_address,
44+
dexs.token_sold_address,
45+
dexs.taker,
46+
dexs.maker,
47+
dexs.project_contract_address,
48+
dexs.tx_hash,
49+
dexs.evt_index
50+
FROM dexs
51+
52+
{% endmacro %}

dbt_subprojects/dex/models/_projects/cow_protocol/polygon/cow_protocol_polygon_trades.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ valued_trades as (
188188
-- ETH Flow orders have trader = sender of orderCreation.
189189
case when sender is not null then sender else trader end as trader,
190190
sell_token_address,
191-
case when sender is not null then 'AVAX' else sell_token end as sell_token,
191+
case when sender is not null then 'POL' else sell_token end as sell_token,
192192
buy_token_address,
193193
buy_token,
194194
case

dbt_subprojects/dex/models/_projects/paraswap/base/paraswap_base_trades.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
{% set paraswap_models = [
99
ref('paraswap_v5_base_trades')
10-
,ref('paraswap_v6_base_trades')
1110
,ref('paraswap_delta_v2_base_trades')
1211
] %}
13-
12+
--exclude trouble model: ,ref('paraswap_v6_base_trades')
1413

1514
SELECT *
1615
FROM (

dbt_subprojects/dex/models/dex_info.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,5 @@ FROM (VALUES
222222
, ('rooster_protocol', 'Rooster Protocol', 'Direct', 'roosterprotocol')
223223
, ('mindgames', 'Mindgames', 'Direct', 'mindgames_io')
224224
, ('yeiswap', 'YeiSwap', 'Direct', 'YeiFinance')
225+
, ('native', 'Native', 'Direct', 'Native')
225226
) AS temp_table (project, name, marketplace_type, x_username)

dbt_subprojects/dex/models/trades/arbitrum/_schema.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,5 +886,24 @@ models:
886886
- evt_index
887887
- check_dex_base_trades_seed:
888888
seed_file: ref('fluid_arbitrum_base_trades_seed')
889+
filter:
890+
version: 1
891+
892+
- name: native_arbitrum_base_trades
893+
meta:
894+
blockchain: arbitrum
895+
sector: dex
896+
project: native
897+
contributors: j92z
898+
config:
899+
tags: ["arbitrum", "dex", "trades", "native"]
900+
description: "native arbitrum base trades"
901+
data_tests:
902+
- dbt_utils.unique_combination_of_columns:
903+
combination_of_columns:
904+
- tx_hash
905+
- evt_index
906+
- check_dex_base_trades_seed:
907+
seed_file: ref('native_arbitrum_base_trades_seed')
889908
filter:
890909
version: 1

dbt_subprojects/dex/models/trades/arbitrum/dex_arbitrum_base_trades.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
, ref('akronswap_arbitrum_base_trades')
5555
, ref('mindgames_arbitrum_base_trades')
5656
, ref('fluid_v1_arbitrum_base_trades')
57+
, ref('native_arbitrum_base_trades')
5758
] %}
5859

5960
WITH base_union AS (

dbt_subprojects/dex/models/trades/arbitrum/platforms/fluid_v1_arbitrum_base_trades.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111
}}
1212

13-
{% set native_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' %}
13+
{% set native_address = '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1' %}
1414

1515
WITH
1616
decoded_events AS (
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{
2+
config(
3+
schema = 'native_arbitrum',
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+
set config_sources = [
15+
{'version': '1', 'source': 'NativeRFQPool_evt_RFQTrade'},
16+
]
17+
%}
18+
19+
{{
20+
native_compatible_trades(
21+
blockchain = 'arbitrum',
22+
project = 'native',
23+
sources = config_sources
24+
)
25+
}}

dbt_subprojects/dex/models/trades/base/_schema.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,3 +1153,22 @@ models:
11531153
seed_file: ref('fluid_base_base_trades_seed')
11541154
filter:
11551155
version: 1
1156+
1157+
- name: native_base_base_trades
1158+
meta:
1159+
blockchain: base
1160+
sector: dex
1161+
project: native
1162+
contributors: j92z
1163+
config:
1164+
tags: ["base", "dex", "trades", "native"]
1165+
description: "native base base trades"
1166+
data_tests:
1167+
- dbt_utils.unique_combination_of_columns:
1168+
combination_of_columns:
1169+
- tx_hash
1170+
- evt_index
1171+
- check_dex_base_trades_seed:
1172+
seed_file: ref('native_base_base_trades_seed')
1173+
filter:
1174+
version: 1

dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
, ref('otsea_base_base_trades')
6161
, ref('tapio_base_base_trades')
6262
, ref('fluid_v1_base_base_trades')
63+
, ref('native_base_base_trades')
6364
] %}
6465

6566
WITH base_union AS (

0 commit comments

Comments
 (0)