From 09d95f961da62992380c6d889e88775407655bd3 Mon Sep 17 00:00:00 2001 From: Jam516 Date: Fri, 7 Jun 2024 10:28:42 +0100 Subject: [PATCH] commit --- models/_sector/dex/trades/scroll/_schema.yml | 19 +++++++++- .../platforms/iziswap_scroll_base_trades.sql | 38 +++++++++++++++++++ .../_sector/dex/trades/scroll/_sources.yml | 3 ++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 models/_sector/dex/trades/scroll/platforms/iziswap_scroll_base_trades.sql diff --git a/models/_sector/dex/trades/scroll/_schema.yml b/models/_sector/dex/trades/scroll/_schema.yml index 171f0f923e3..5cafaa4a492 100644 --- a/models/_sector/dex/trades/scroll/_schema.yml +++ b/models/_sector/dex/trades/scroll/_schema.yml @@ -105,4 +105,21 @@ models: - tx_hash - evt_index - check_dex_base_trades_seed: - seed_file: ref('nuri_scroll_base_trades_seed') \ No newline at end of file + seed_file: ref('nuri_scroll_base_trades_seed') + + - name: iziswap_scroll_base_trades + meta: + blockchain: scroll + sector: dex + project: iziswap + contributors: niftytable + config: + tags: [ 'scroll', 'dex', 'trades', 'iziswap' ] + description: "Iziswap scroll base trades" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + # - check_dex_base_trades_seed: + # seed_file: ref('iziswap_scroll_base_trades_seed') \ No newline at end of file diff --git a/models/_sector/dex/trades/scroll/platforms/iziswap_scroll_base_trades.sql b/models/_sector/dex/trades/scroll/platforms/iziswap_scroll_base_trades.sql new file mode 100644 index 00000000000..d426ade2b1c --- /dev/null +++ b/models/_sector/dex/trades/scroll/platforms/iziswap_scroll_base_trades.sql @@ -0,0 +1,38 @@ +{{ + config( + schema = 'iziswap_scroll', + 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')] + ) +}} + +{% set iziswap_start_date = "2023-10-13" %} + +SELECT + 'scroll' AS blockchain + , 'iziswap' AS project + , contract_address AS project_contract_address + , '1' AS version + , evt_tx_hash AS tx_hash + , evt_index + , evt_block_time AS block_time + , evt_block_number AS block_number + , CAST(DATE_TRUNC('month', evt_block_time) AS DATE) AS block_month + , CAST(DATE_TRUNC('day', evt_block_time) AS DATE) AS block_date + , CASE WHEN sellXEarnY THEN tokenY ELSE tokenX END AS token_bought_address + , CASE WHEN sellXEarnY THEN tokenX ELSE tokenY END AS token_sold_address + , CASE WHEN sellXEarnY THEN amountY ELSE amountX END AS token_bought_amount_raw + , CASE WHEN sellXEarnY THEN amountX ELSE amountY END AS token_sold_amount_raw + , CAST(evt_tx_from AS VARBINARY) AS taker + , CAST(evt_tx_to AS VARBINARY) AS maker +FROM {{ source('iziswap_scroll', 'iZiSwapPool_evt_Swap') }} +{% if is_incremental() %} +WHERE {{incremental_predicate('evt_block_time')}} +{% else %} +WHERE evt_block_time >= TIMESTAMP '{{iziswap_start_date}}' +{% endif %} + diff --git a/sources/_sector/dex/trades/scroll/_sources.yml b/sources/_sector/dex/trades/scroll/_sources.yml index dce53b7b0ff..39db7d131ae 100644 --- a/sources/_sector/dex/trades/scroll/_sources.yml +++ b/sources/_sector/dex/trades/scroll/_sources.yml @@ -27,3 +27,6 @@ sources: tables: - name: ClPoolFactory_evt_PoolCreated - name: ClPool_evt_Swap + - name: iziswap_scroll + tables: + - name: iZiSwapPool_evt_Swap