diff --git a/dbt_subprojects/dex/models/dex_info.sql b/dbt_subprojects/dex/models/dex_info.sql index ef08d06f0b5..48f9f6ffef5 100644 --- a/dbt_subprojects/dex/models/dex_info.sql +++ b/dbt_subprojects/dex/models/dex_info.sql @@ -13,6 +13,7 @@ FROM (VALUES ('uniswap', 'Uniswap', 'Direct', 'Uniswap') , ('pancakeswap', 'PancakeSwap', 'Direct', 'PancakeSwap') , ('curve', 'Curve', 'Direct', 'CurveFinance') + , ('curvefi', 'Curve', 'Direct', 'CurveFinance') , ('sushiswap', 'SushiSwap', 'Direct', 'SushiSwap') , ('mdex', 'Mdex', 'Direct', 'Mdextech') , ('dodo', 'DODO', 'Direct & Aggregator', 'BreederDodo') -- To Fix, should be just dodo diff --git a/dbt_subprojects/dex/models/trades/base/_schema.yml b/dbt_subprojects/dex/models/trades/base/_schema.yml index fde1b6d7532..0bf11fc608d 100644 --- a/dbt_subprojects/dex/models/trades/base/_schema.yml +++ b/dbt_subprojects/dex/models/trades/base/_schema.yml @@ -58,6 +58,23 @@ models: - check_dex_base_trades_seed: seed_file: ref('stablebase_base_base_trades_seed') + - name: curvefi_base_base_trades + meta: + blockchain: base + sector: dex + project: curvefi + contributors: principatel + config: + tags: ["base", "dex", "trades", "curvefi"] + description: curvefi 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('curvefi_base_base_trades_seed') + - name: sushiswap_v1_base_base_trades meta: blockchain: base diff --git a/dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql b/dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql index fb04c901264..04120fe29ab 100644 --- a/dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/base/dex_base_base_trades.sql @@ -10,6 +10,7 @@ , ref('sushiswap_v1_base_base_trades') , ref('sushiswap_v2_base_base_trades') , ref('stablebase_base_base_trades') + , ref('curvefi_base_base_trades') , ref('aerodrome_base_base_trades') , ref('pancakeswap_v2_base_base_trades') , ref('pancakeswap_v3_base_base_trades') diff --git a/dbt_subprojects/dex/models/trades/base/platforms/curvefi_base_base_trades.sql b/dbt_subprojects/dex/models/trades/base/platforms/curvefi_base_base_trades.sql new file mode 100644 index 00000000000..8f7fc0945eb --- /dev/null +++ b/dbt_subprojects/dex/models/trades/base/platforms/curvefi_base_base_trades.sql @@ -0,0 +1,45 @@ +{{ + config( + schema = 'curvefi_base', + 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')] + ) +}} + +WITH token_swaps AS ( + SELECT + evt_block_number AS block_number, + TRY_CAST(evt_block_time AS TIMESTAMP(3) WITH TIME ZONE) AS block_time, + evt_tx_from AS maker, + evt_tx_to AS taker, + in_amount AS token_sold_amount_raw, + out_amount AS token_bought_amount_raw, + TRY_CAST(route[1] AS VARBINARY) AS token_sold_address, + TRY_CAST(route[CARDINALITY(route)] AS VARBINARY) AS token_bought_address, + contract_address AS project_contract_address, + evt_tx_hash AS tx_hash, + evt_index AS evt_index + FROM delta_prod.curvefi_base.CurveRouter_evt_Exchange +) +SELECT + 'base' AS blockchain, + 'curve' AS project, + '1' AS version, + TRY_CAST(DATE_TRUNC('month', token_swaps.block_time) AS DATE) AS block_month, + TRY_CAST(DATE_TRUNC('day', token_swaps.block_time) AS DATE) AS block_date, + token_swaps.block_time, + token_swaps.block_number, + token_swaps.token_sold_amount_raw, + token_swaps.token_bought_amount_raw, + token_swaps.token_sold_address, + token_swaps.token_bought_address, + token_swaps.maker, + token_swaps.taker, + token_swaps.project_contract_address, + token_swaps.tx_hash, + token_swaps.evt_index +FROM token_swaps \ 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 da4c398563d..a2e2592fb6b 100644 --- a/dbt_subprojects/dex/seeds/trades/_schema.yml +++ b/dbt_subprojects/dex/seeds/trades/_schema.yml @@ -4500,6 +4500,21 @@ seeds: token_sold_amount_raw: uint256 block_date: timestamp + - name: curvefi_base_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: saddle_finance_optimism_base_trades_seed config: column_types: diff --git a/dbt_subprojects/dex/seeds/trades/curvefi_base_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/curvefi_base_base_trades_seed.csv new file mode 100644 index 00000000000..f88ce7aee64 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/curvefi_base_base_trades_seed.csv @@ -0,0 +1,3 @@ +blockchain,project,version,block_month,block_date,block_time,block_number,token_sold_amount_raw,token_bought_amount_raw,token_sold_address,token_bought_address,maker,taker,project_contract_address,tx_hash,evt_index +base,curve,1,2023-10-01 00:00,2023-10-27 00:00,2023-10-27 11:26,5808307,1000000000000000,1779410,0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,0x0000000000000000000000000000000000000000,0xf4da79f6a6f635b9ebb0e4dcbf0efa781a0c5458,0xd6681e74eea20d196c15038c580f721ef2ab6320,0xd6681e74eea20d196c15038c580f721ef2ab6320,0xae6698965a9a0f0ee7c5491a98c584e9e3fe4f1da554b8248cce4386804b7e8c,49 +base,curve,1,2024-05-01 00:00,2024-05-15 00:00,2024-05-15 17:56,14503217,6400000000000000,6399999999999999,0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,0x0000000000000000000000000000000000000000,0x183fd1e6cbcd1d23850712844eff23aec9f07021,0xd6681e74eea20d196c15038c580f721ef2ab6320,0xd6681e74eea20d196c15038c580f721ef2ab6320,0xc6e98b0bb918f079b901361ed0fe758e6ae2c2e4f02b26f9e8941f16b46dead7,105 diff --git a/sources/_sector/dex/trades/base/_sources.yml b/sources/_sector/dex/trades/base/_sources.yml index 0bb8805bdcc..a6a909abc55 100644 --- a/sources/_sector/dex/trades/base/_sources.yml +++ b/sources/_sector/dex/trades/base/_sources.yml @@ -175,6 +175,9 @@ sources: - name: stablebase_base tables: - name: SwapFlashLoan_evt_TokenSwap + - name: curvefi_base + tables: + - name: StableSwap_evt_TokenExchange - name: basex_base tables: - name: UniswapV3Pool_evt_Swap