Skip to content

Commit

Permalink
wardenswap (duneanalytics#5012)
Browse files Browse the repository at this point in the history
Co-authored-by: Huang Geyang <[email protected]>
  • Loading branch information
tomfutago and Hosuke authored Dec 19, 2023
1 parent f9c6f31 commit ff92bc5
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 12 deletions.
20 changes: 19 additions & 1 deletion models/_sector/dex/trades/optimism/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,22 @@ models:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('hashflow_optimism_base_trades_seed')
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')
3 changes: 3 additions & 0 deletions models/_sector/dex/trades/optimism/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ sources:
- name: balancer_v2_optimism
tables:
- name: Vault_evt_Swap
- name: wardenswap_optimism
tables:
- name: WardenRouterV2_L2_evt_Trade
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
@@ -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
11 changes: 0 additions & 11 deletions models/wardenswap/optimism/wardenswap_optimism_sources.yml

This file was deleted.

0 comments on commit ff92bc5

Please sign in to comment.