diff --git a/dbt_subprojects/dex/models/trades/dex_base_trades.sql b/dbt_subprojects/dex/models/trades/dex_base_trades.sql index 0f192a95714..15acc9e96d7 100644 --- a/dbt_subprojects/dex/models/trades/dex_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/dex_base_trades.sql @@ -23,6 +23,7 @@ , ref('dex_fantom_base_trades') , ref('dex_flare_base_trades') , ref('dex_gnosis_base_trades') + , ref('dex_ink_base_trades') , ref('dex_linea_base_trades') , ref('dex_kaia_base_trades') , ref('dex_mantle_base_trades') diff --git a/dbt_subprojects/dex/models/trades/ink/_schema.yml b/dbt_subprojects/dex/models/trades/ink/_schema.yml new file mode 100644 index 00000000000..c9ffdba4c5c --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ink/_schema.yml @@ -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 \ No newline at end of file diff --git a/dbt_subprojects/dex/models/trades/ink/dex_ink_base_trades.sql b/dbt_subprojects/dex/models/trades/ink/dex_ink_base_trades.sql new file mode 100644 index 00000000000..35a1cc132c5 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ink/dex_ink_base_trades.sql @@ -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'] + ) +}} diff --git a/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v2_ink_base_trades.sql b/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v2_ink_base_trades.sql new file mode 100644 index 00000000000..79b02c42a75 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v2_ink_base_trades.sql @@ -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') + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v3_ink_base_trades.sql b/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v3_ink_base_trades.sql new file mode 100644 index 00000000000..af5698f13ca --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v3_ink_base_trades.sql @@ -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') + ) +}} + diff --git a/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v4_ink_base_trades.sql b/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v4_ink_base_trades.sql new file mode 100644 index 00000000000..2729559ff02 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ink/platforms/uniswap_v4_ink_base_trades.sql @@ -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' + ) +}} \ 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 83450755817..26060654406 100644 --- a/dbt_subprojects/dex/seeds/trades/_schema.yml +++ b/dbt_subprojects/dex/seeds/trades/_schema.yml @@ -2055,6 +2055,21 @@ seeds: token_sold_amount_raw: uint256 block_date: timestamp + - name: uniswap_ink_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: uniswap_optimism_base_trades_seed config: column_types: diff --git a/dbt_subprojects/dex/seeds/trades/uniswap_ink_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/uniswap_ink_base_trades_seed.csv new file mode 100644 index 00000000000..edf79c1aff6 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/uniswap_ink_base_trades_seed.csv @@ -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 diff --git a/sources/_sector/dex/trades/ink/_sources.yml b/sources/_sector/dex/trades/ink/_sources.yml new file mode 100644 index 00000000000..166230a8412 --- /dev/null +++ b/sources/_sector/dex/trades/ink/_sources.yml @@ -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 \ No newline at end of file