From d10e509ef4f4dd1a4862591ce09da51fcc9055e8 Mon Sep 17 00:00:00 2001 From: hinus <64959125+cxheng315@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:32:26 +0800 Subject: [PATCH 1/5] feat: add katana v3 dex ronin --- .../dex/models/trades/ronin/_schema.yml | 27 +++++++++++++---- .../trades/ronin/dex_ronin_base_trades.sql | 3 +- ...es.sql => katana_v2_ronin_base_trades.sql} | 2 +- .../platforms/katana_v3_ronin_base_trades.sql | 21 ++++++++++++++ dbt_subprojects/dex/seeds/trades/_schema.yml | 29 ++++++++++++++----- ...v => katana_v2_ronin_base_trades_seed.csv} | 2 +- .../katana_v3_ronin_base_trades_seed.csv | 3 ++ sources/_sector/dex/trades/ronin/_sources.yml | 8 +++-- 8 files changed, 78 insertions(+), 17 deletions(-) rename dbt_subprojects/dex/models/trades/ronin/platforms/{katana_ronin_base_trades.sql => katana_v2_ronin_base_trades.sql} (98%) create mode 100644 dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql rename dbt_subprojects/dex/seeds/trades/{katana_ronin_base_trades_seed.csv => katana_v2_ronin_base_trades_seed.csv} (94%) create mode 100644 dbt_subprojects/dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv diff --git a/dbt_subprojects/dex/models/trades/ronin/_schema.yml b/dbt_subprojects/dex/models/trades/ronin/_schema.yml index 9d9035dda64..7f3d5f1d310 100644 --- a/dbt_subprojects/dex/models/trades/ronin/_schema.yml +++ b/dbt_subprojects/dex/models/trades/ronin/_schema.yml @@ -5,19 +5,36 @@ models: data_tests: - check_dex_info_relationship - - name: katana_ronin_base_trades + - name: katana_v2_ronin_base_trades meta: blockchain: ronin sector: dex project: katana - contributors: jeff-dude + contributors: jeff-dude, cxheng315 config: - tags: [ 'ronin', 'dex', 'trades', 'katana' ] - description: "Katana ronin base trades" + tags: ["ronin", "dex", "trades", "katana"] + description: "Katana v2 ronin 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('katana_ronin_base_trades_seed') \ No newline at end of file + seed_file: ref('katana_v2_ronin_base_trades_seed') + + - name: katana_v3_ronin_base_trades + meta: + blockchain: ronin + sector: dex + project: katana + contributors: cxheng315 + config: + tags: ["ronin", "dex", "trades", "katana"] + description: "Katana v3 ronin 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('katana_v3_ronin_base_trades_seed') diff --git a/dbt_subprojects/dex/models/trades/ronin/dex_ronin_base_trades.sql b/dbt_subprojects/dex/models/trades/ronin/dex_ronin_base_trades.sql index 1cd7eaa3262..108ff7cd73d 100644 --- a/dbt_subprojects/dex/models/trades/ronin/dex_ronin_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/ronin/dex_ronin_base_trades.sql @@ -6,7 +6,8 @@ }} {% set base_models = [ - ref('katana_ronin_base_trades') + ref('katana_v2_ronin_base_trades') + , ref('katana_v3_ronin_base_trades') ] %} WITH base_union AS ( diff --git a/dbt_subprojects/dex/models/trades/ronin/platforms/katana_ronin_base_trades.sql b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v2_ronin_base_trades.sql similarity index 98% rename from dbt_subprojects/dex/models/trades/ronin/platforms/katana_ronin_base_trades.sql rename to dbt_subprojects/dex/models/trades/ronin/platforms/katana_v2_ronin_base_trades.sql index c2f1d62f8a6..e6a6eeb4997 100644 --- a/dbt_subprojects/dex/models/trades/ronin/platforms/katana_ronin_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v2_ronin_base_trades.sql @@ -1,5 +1,5 @@ {{ config( - schema = 'katana_ronin' + schema = 'katana_v2_ronin' , alias = 'base_trades' , materialized = 'incremental' , file_format = 'delta' diff --git a/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql new file mode 100644 index 00000000000..658c142dddf --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'katana_v3_ronin' + , 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 = 'ronin' + , project = 'katana' + , version = '3' + , Pair_evt_Swap = source('katana_dex_ronin', 'KatanaV3Pool_evt_Swap') + , Factory_evt_PoolCreated = source('katana_dex_ronin', 'KatanaV3Factory_evt_PoolCreated') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/trades/_schema.yml b/dbt_subprojects/dex/seeds/trades/_schema.yml index 1bc3dd58d97..742c9e2f5d4 100644 --- a/dbt_subprojects/dex/seeds/trades/_schema.yml +++ b/dbt_subprojects/dex/seeds/trades/_schema.yml @@ -4454,7 +4454,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: infusion_base_base_trades_seed config: column_types: @@ -4499,7 +4499,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: akronswap_base_base_trades_seed config: column_types: @@ -4514,8 +4514,23 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - - - name: katana_ronin_base_trades_seed + + - name: katana_v2_ronin_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp + + - name: katana_v3_ronin_base_trades_seed config: column_types: blockchain: varchar @@ -4544,7 +4559,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: elk_finance_gnosis_base_trades_seed config: column_types: @@ -4559,7 +4574,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: levinswap_gnosis_base_trades_seed config: column_types: @@ -4574,7 +4589,7 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp - + - name: fluid_ethereum_base_trades_seed config: column_types: diff --git a/dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/katana_v2_ronin_base_trades_seed.csv similarity index 94% rename from dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv rename to dbt_subprojects/dex/seeds/trades/katana_v2_ronin_base_trades_seed.csv index d8a0d2f8ea0..e65244bf053 100644 --- a/dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv +++ b/dbt_subprojects/dex/seeds/trades/katana_v2_ronin_base_trades_seed.csv @@ -1,3 +1,3 @@ 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 ronin,katana,2,2024-01-17,0xca2c3b5d6aec890d5bfe1fb8616036a01b702948107fdb4a243453cfe5a6d86a,10,0x1b918543b518e34902e1e8dd76052bee43c762ff,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,31230074,12492104858888467232497,5109345881300390132 -ronin,katana,2,2023-03-01,0xcab674e07e3c5b0b6dd53b52971edabc929a2fd907b85d781f70bac74767c6e3,10,0xc99a6a985ed2cac1ef41640596c5a5f9f4e19ef5,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,22465731,1700000000000000,3070678253641756888 \ No newline at end of file +ronin,katana,2,2023-03-01,0xcab674e07e3c5b0b6dd53b52971edabc929a2fd907b85d781f70bac74767c6e3,10,0xc99a6a985ed2cac1ef41640596c5a5f9f4e19ef5,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,22465731,1700000000000000,3070678253641756888 diff --git a/dbt_subprojects/dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv new file mode 100644 index 00000000000..2266c165446 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv @@ -0,0 +1,3 @@ +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 +ronin,katana,3,2024-12-19,0x92f922acbb1a4a80b2ad56d8b6ce2cc587f2851fac7b3e37582f7578db55ee4d,160,0xc6046fa4b8961b0e9d823bb3f2dde8fe161d547d,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,40907478,234401580938417717096,26553212520000000000 +ronin,katana,3,2024-12-19,0x340763e80131db74ce992733518944ad35d1290aaae53f5eeacaeb994057f49e,39,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,0x0b7007c13325c48911f73a2dad5fa5dcbf808adc,40908371,141505036347788395809,300000000 diff --git a/sources/_sector/dex/trades/ronin/_sources.yml b/sources/_sector/dex/trades/ronin/_sources.yml index 8c61432710f..e7d9b4b1f0f 100644 --- a/sources/_sector/dex/trades/ronin/_sources.yml +++ b/sources/_sector/dex/trades/ronin/_sources.yml @@ -1,7 +1,11 @@ version: 2 sources: - - name: katana_dex_ronin + - name: katana_v2_dex_ronin tables: - name: KatanaPair_evt_Swap - - name: KatanaFactory_evt_PairCreated \ No newline at end of file + - name: KatanaFactory_evt_PairCreated + - name: katana_v3_dex_ronin + tables: + - name: KatanaV3Pool_evt_Swap + - name: KatanaV3Factory_evt_PoolCreated From 325835a473cc0a50e77858ba6bd4035d232bd07a Mon Sep 17 00:00:00 2001 From: hinus <64959125+cxheng315@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:49:49 +0800 Subject: [PATCH 2/5] Update _sources.yml fix source not found --- sources/_sector/dex/trades/ronin/_sources.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/_sector/dex/trades/ronin/_sources.yml b/sources/_sector/dex/trades/ronin/_sources.yml index e7d9b4b1f0f..4e40c27221e 100644 --- a/sources/_sector/dex/trades/ronin/_sources.yml +++ b/sources/_sector/dex/trades/ronin/_sources.yml @@ -1,11 +1,11 @@ version: 2 sources: - - name: katana_v2_dex_ronin + - name: katana_dex_ronin tables: - name: KatanaPair_evt_Swap - name: KatanaFactory_evt_PairCreated - - name: katana_v3_dex_ronin + - name: katana_dex_ronin tables: - name: KatanaV3Pool_evt_Swap - name: KatanaV3Factory_evt_PoolCreated From 2eaff956aa0e1367099f3a661546644aa2c963b2 Mon Sep 17 00:00:00 2001 From: hinus <64959125+cxheng315@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:55:08 +0800 Subject: [PATCH 3/5] Update katana_v3_ronin_base_trades.sql add line break --- .../trades/ronin/platforms/katana_v3_ronin_base_trades.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql index 658c142dddf..ad3b9dd5e27 100644 --- a/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/ronin/platforms/katana_v3_ronin_base_trades.sql @@ -18,4 +18,4 @@ , Pair_evt_Swap = source('katana_dex_ronin', 'KatanaV3Pool_evt_Swap') , Factory_evt_PoolCreated = source('katana_dex_ronin', 'KatanaV3Factory_evt_PoolCreated') ) -}} \ No newline at end of file +}} From 905bae592fe2f5e7996492e584d1636628edf619 Mon Sep 17 00:00:00 2001 From: hinus <64959125+cxheng315@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:39:48 +0800 Subject: [PATCH 4/5] merge katana seed file --- dbt_subprojects/dex/models/trades/ronin/_schema.yml | 8 ++++++-- ..._trades_seed.csv => katana_ronin_base_trades_seed.csv} | 2 ++ .../dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv | 3 --- 3 files changed, 8 insertions(+), 5 deletions(-) rename dbt_subprojects/dex/seeds/trades/{katana_v2_ronin_base_trades_seed.csv => katana_ronin_base_trades_seed.csv} (57%) delete mode 100644 dbt_subprojects/dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv diff --git a/dbt_subprojects/dex/models/trades/ronin/_schema.yml b/dbt_subprojects/dex/models/trades/ronin/_schema.yml index 7f3d5f1d310..9402dc644cc 100644 --- a/dbt_subprojects/dex/models/trades/ronin/_schema.yml +++ b/dbt_subprojects/dex/models/trades/ronin/_schema.yml @@ -20,7 +20,9 @@ models: - tx_hash - evt_index - check_dex_base_trades_seed: - seed_file: ref('katana_v2_ronin_base_trades_seed') + seed_file: ref('katana_ronin_base_trades_seed') + filter: + version: 2 - name: katana_v3_ronin_base_trades meta: @@ -37,4 +39,6 @@ models: - tx_hash - evt_index - check_dex_base_trades_seed: - seed_file: ref('katana_v3_ronin_base_trades_seed') + seed_file: ref('katana_ronin_base_trades_seed') + filter: + version: 3 diff --git a/dbt_subprojects/dex/seeds/trades/katana_v2_ronin_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv similarity index 57% rename from dbt_subprojects/dex/seeds/trades/katana_v2_ronin_base_trades_seed.csv rename to dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv index e65244bf053..a34825a4783 100644 --- a/dbt_subprojects/dex/seeds/trades/katana_v2_ronin_base_trades_seed.csv +++ b/dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv @@ -1,3 +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 ronin,katana,2,2024-01-17,0xca2c3b5d6aec890d5bfe1fb8616036a01b702948107fdb4a243453cfe5a6d86a,10,0x1b918543b518e34902e1e8dd76052bee43c762ff,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,31230074,12492104858888467232497,5109345881300390132 ronin,katana,2,2023-03-01,0xcab674e07e3c5b0b6dd53b52971edabc929a2fd907b85d781f70bac74767c6e3,10,0xc99a6a985ed2cac1ef41640596c5a5f9f4e19ef5,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,22465731,1700000000000000,3070678253641756888 +ronin,katana,3,2024-12-19,0x92f922acbb1a4a80b2ad56d8b6ce2cc587f2851fac7b3e37582f7578db55ee4d,160,0xc6046fa4b8961b0e9d823bb3f2dde8fe161d547d,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,40907478,234401580938417717096,26553212520000000000 +ronin,katana,3,2024-12-19,0x340763e80131db74ce992733518944ad35d1290aaae53f5eeacaeb994057f49e,39,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,0x0b7007c13325c48911f73a2dad5fa5dcbf808adc,40908371,141505036347788395809,300000000 diff --git a/dbt_subprojects/dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv deleted file mode 100644 index 2266c165446..00000000000 --- a/dbt_subprojects/dex/seeds/trades/katana_v3_ronin_base_trades_seed.csv +++ /dev/null @@ -1,3 +0,0 @@ -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 -ronin,katana,3,2024-12-19,0x92f922acbb1a4a80b2ad56d8b6ce2cc587f2851fac7b3e37582f7578db55ee4d,160,0xc6046fa4b8961b0e9d823bb3f2dde8fe161d547d,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,40907478,234401580938417717096,26553212520000000000 -ronin,katana,3,2024-12-19,0x340763e80131db74ce992733518944ad35d1290aaae53f5eeacaeb994057f49e,39,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,0x0b7007c13325c48911f73a2dad5fa5dcbf808adc,40908371,141505036347788395809,300000000 From 1f9e26394578b2f6311f96b37e04bab94843b266 Mon Sep 17 00:00:00 2001 From: hinus <64959125+cxheng315@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:45:34 +0800 Subject: [PATCH 5/5] fix file not found in schema --- dbt_subprojects/dex/seeds/trades/_schema.yml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/dbt_subprojects/dex/seeds/trades/_schema.yml b/dbt_subprojects/dex/seeds/trades/_schema.yml index 742c9e2f5d4..d8ddcc7e148 100644 --- a/dbt_subprojects/dex/seeds/trades/_schema.yml +++ b/dbt_subprojects/dex/seeds/trades/_schema.yml @@ -4515,22 +4515,7 @@ seeds: token_sold_amount_raw: uint256 block_date: timestamp - - name: katana_v2_ronin_base_trades_seed - config: - column_types: - blockchain: varchar - project: varchar - version: varchar - tx_hash: varbinary - evt_index: uint256 - block_number: uint256 - token_bought_address: varbinary - token_sold_address: varbinary - token_bought_amount_raw: uint256 - token_sold_amount_raw: uint256 - block_date: timestamp - - - name: katana_v3_ronin_base_trades_seed + - name: katana_ronin_base_trades_seed config: column_types: blockchain: varchar