From ff92bc5765aa077cf274891b93ff4da0dd0350fe Mon Sep 17 00:00:00 2001 From: tomfutago <35136350+tomfutago@users.noreply.github.com> Date: Tue, 19 Dec 2023 13:51:26 +0000 Subject: [PATCH] wardenswap (#5012) Co-authored-by: Huang Geyang --- .../_sector/dex/trades/optimism/_schema.yml | 20 +++++++- .../_sector/dex/trades/optimism/_sources.yml | 3 ++ .../optimism/dex_optimism_base_trades.sql | 1 + .../wardenswap_optimism_base_trades.sql | 49 +++++++++++++++++++ .../optimism/wardenswap_optimism_sources.yml | 11 ----- 5 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 models/_sector/dex/trades/optimism/platforms/wardenswap_optimism_base_trades.sql delete mode 100644 models/wardenswap/optimism/wardenswap_optimism_sources.yml diff --git a/models/_sector/dex/trades/optimism/_schema.yml b/models/_sector/dex/trades/optimism/_schema.yml index e1aa95ad1f8..688b58ddc4b 100644 --- a/models/_sector/dex/trades/optimism/_schema.yml +++ b/models/_sector/dex/trades/optimism/_schema.yml @@ -158,4 +158,22 @@ models: - tx_hash - evt_index - check_dex_base_trades_seed: - seed_file: ref('hashflow_optimism_base_trades_seed') \ No newline at end of file + seed_file: ref('hashflow_optimism_base_trades_seed') + + + - name: wardenswap_optimism_base_trades + meta: + blockchain: optimism + sector: dex + project: wardenswap + contributors: Chain_L, tomfutago + config: + tags: [ 'optimism', 'dex', 'trades', 'wardenswap' ] + description: "Wardenswap optimism base trades" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('wardenswap_optimism_base_trades_seed') \ No newline at end of file diff --git a/models/_sector/dex/trades/optimism/_sources.yml b/models/_sector/dex/trades/optimism/_sources.yml index 1730b6b58f4..77dc5db143a 100644 --- a/models/_sector/dex/trades/optimism/_sources.yml +++ b/models/_sector/dex/trades/optimism/_sources.yml @@ -15,3 +15,6 @@ sources: - name: balancer_v2_optimism tables: - name: Vault_evt_Swap + - name: wardenswap_optimism + tables: + - name: WardenRouterV2_L2_evt_Trade diff --git a/models/_sector/dex/trades/optimism/dex_optimism_base_trades.sql b/models/_sector/dex/trades/optimism/dex_optimism_base_trades.sql index cb49344d69c..61823e05935 100644 --- a/models/_sector/dex/trades/optimism/dex_optimism_base_trades.sql +++ b/models/_sector/dex/trades/optimism/dex_optimism_base_trades.sql @@ -14,6 +14,7 @@ , ref('hashflow_optimism_base_trades') , ref('zipswap_optimism_base_trades') , ref('balancer_v2_optimism_base_trades') + , ref('wardenswap_optimism_base_trades') ] %} WITH base_union AS ( diff --git a/models/_sector/dex/trades/optimism/platforms/wardenswap_optimism_base_trades.sql b/models/_sector/dex/trades/optimism/platforms/wardenswap_optimism_base_trades.sql new file mode 100644 index 00000000000..553df3ccff0 --- /dev/null +++ b/models/_sector/dex/trades/optimism/platforms/wardenswap_optimism_base_trades.sql @@ -0,0 +1,49 @@ +{{ + config( + schema = 'wardenswap_optimism', + 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 dexs AS ( + SELECT + evt_block_number AS block_number, + evt_block_time AS block_time, + trader AS taker, + receiver AS maker, + destAmount AS token_bought_amount_raw, + srcAmount AS token_sold_amount_raw, + destAsset AS token_bought_address, + srcAsset AS token_sold_address, + contract_address AS project_contract_address, + evt_tx_hash AS tx_hash, + evt_index + FROM {{ source('wardenswap_optimism', 'WardenRouterV2_L2_evt_Trade') }} t + {% if is_incremental() %} + WHERE {{ incremental_predicate('t.evt_block_time') }} + {% endif %} +) + +SELECT + 'optimism' AS blockchain, + 'wardenswap' AS project, + '2' AS version, + CAST(date_trunc('month', dexs.block_time) AS date) AS block_month, + CAST(date_trunc('day', dexs.block_time) AS date) AS block_date, + dexs.block_time, + dexs.block_number, + dexs.token_bought_amount_raw, + dexs.token_sold_amount_raw, + dexs.token_bought_address, + dexs.token_sold_address, + dexs.taker, + dexs.maker, + dexs.project_contract_address, + dexs.tx_hash, + dexs.evt_index +FROM dexs diff --git a/models/wardenswap/optimism/wardenswap_optimism_sources.yml b/models/wardenswap/optimism/wardenswap_optimism_sources.yml deleted file mode 100644 index da0742cbe4f..00000000000 --- a/models/wardenswap/optimism/wardenswap_optimism_sources.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: 2 - -sources: - - name: wardenswap_optimism - freshness: - warn_after: { count: 12, period: hour } - description: > - Decoded event table for swaps on wardenswap - tables: - - name: WardenRouterV2_L2_evt_Trade - loaded_at_field: evt_block_time \ No newline at end of file