Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jam516 committed Jun 7, 2024
1 parent b8b5725 commit 09d95f9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
19 changes: 18 additions & 1 deletion models/_sector/dex/trades/scroll/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,21 @@ models:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('nuri_scroll_base_trades_seed')
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')
Original file line number Diff line number Diff line change
@@ -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 %}

3 changes: 3 additions & 0 deletions sources/_sector/dex/trades/scroll/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ sources:
tables:
- name: ClPoolFactory_evt_PoolCreated
- name: ClPool_evt_Swap
- name: iziswap_scroll
tables:
- name: iZiSwapPool_evt_Swap

0 comments on commit 09d95f9

Please sign in to comment.