-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
, "nova" | ||
, "optimism" | ||
, "polygon" | ||
, "ronin" | ||
, "scroll" | ||
, "sei" | ||
, "zkevm" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: dex_ronin_base_trades | ||
data_tests: | ||
- check_dex_info_relationship | ||
|
||
- name: katana_ronin_base_trades | ||
meta: | ||
blockchain: ronin | ||
sector: dex | ||
project: katana | ||
contributors: jeff-dude | ||
config: | ||
tags: [ 'ronin', 'dex', 'trades', 'katana' ] | ||
description: "Katana ronin 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('katana_ronin_base_trades_seed') |
48 changes: 48 additions & 0 deletions
48
dbt_subprojects/dex/models/trades/ronin/dex_ronin_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{{ config( | ||
schema = 'dex_ronin' | ||
, alias = 'base_trades' | ||
, materialized = 'view' | ||
) | ||
}} | ||
|
||
{% set base_models = [ | ||
ref('katana_ronin_base_trades') | ||
] %} | ||
|
||
WITH base_union AS ( | ||
SELECT * | ||
FROM ( | ||
{% for base_model in base_models %} | ||
SELECT | ||
blockchain | ||
, project | ||
, version | ||
, block_month | ||
, block_date | ||
, block_time | ||
, block_number | ||
, token_bought_amount_raw | ||
, token_sold_amount_raw | ||
, token_bought_address | ||
, token_sold_address | ||
, taker | ||
, maker | ||
, project_contract_address | ||
, tx_hash | ||
, evt_index | ||
FROM | ||
{{ base_model }} | ||
{% if not loop.last %} | ||
UNION ALL | ||
{% endif %} | ||
{% endfor %} | ||
) | ||
) | ||
|
||
{{ | ||
add_tx_columns( | ||
model_cte = 'base_union' | ||
, blockchain = 'ronin' | ||
, columns = ['from', 'to', 'index'] | ||
) | ||
}} |
56 changes: 56 additions & 0 deletions
56
dbt_subprojects/dex/models/trades/ronin/platforms/katana_ronin_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{{ config( | ||
schema = 'katana_ronin' | ||
, 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 | ||
t.evt_block_number AS block_number | ||
, t.evt_block_time AS block_time | ||
, t._to AS taker | ||
, t.contract_address AS maker | ||
, CASE WHEN _amount0Out = UINT256 '0' THEN _amount1Out ELSE _amount0Out END AS token_bought_amount_raw | ||
, CASE WHEN _amount0In = UINT256 '0' OR _amount1Out = UINT256 '0' THEN _amount1In ELSE _amount0In END AS token_sold_amount_raw | ||
, CASE WHEN _amount0Out = UINT256 '0' THEN f._token1 ELSE f._token0 END AS token_bought_address | ||
, CASE WHEN _amount0In = UINT256 '0' OR _amount1Out = UINT256 '0' THEN f._token1 ELSE f._token0 END AS token_sold_address | ||
, t.contract_address AS project_contract_address | ||
, t.evt_tx_hash AS tx_hash | ||
, t.evt_index AS evt_index | ||
FROM | ||
{{ source('katana_dex_ronin', 'KatanaPair_evt_Swap') }} t | ||
INNER JOIN | ||
{{ source('katana_dex_ronin', 'KatanaFactory_evt_PairCreated') }} f | ||
ON f._pair = t.contract_address | ||
{% if is_incremental() %} | ||
WHERE | ||
{{ incremental_predicate('t.evt_block_time') }} | ||
{% endif %} | ||
|
||
) | ||
|
||
SELECT | ||
'ronin' AS blockchain | ||
, 'katana' 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
dbt_subprojects/dex/seeds/trades/katana_ronin_base_trades_seed.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw | ||
ronin,katana,2,2024-01-17,0xca2c3b5d6aec890d5bfe1fb8616036a01b702948107fdb4a243453cfe5a6d86a,10,0x1b918543b518e34902e1e8dd76052bee43c762ff,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,31230074,12492104858888467232497,5109345881300390132 | ||
ronin,katana,2,2023-03-01,0xcab674e07e3c5b0b6dd53b52971edabc929a2fd907b85d781f70bac74767c6e3,10,0xc99a6a985ed2cac1ef41640596c5a5f9f4e19ef5,0xe514d9deb7966c8be0ca922de8a064264ea6bcd4,22465731,1700000000000000,3070678253641756888 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: katana_dex_ronin | ||
tables: | ||
- name: KatanaPair_evt_Swap | ||
- name: KatanaFactory_evt_PairCreated |