-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
28 changed files
with
303 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{% macro swaap_v2_compatible_trades( | ||
blockchain = null, | ||
project = null, | ||
version = null | ||
) | ||
%} | ||
|
||
WITH dexs AS | ||
( | ||
SELECT | ||
t.evt_block_number AS block_number | ||
, t.evt_block_time AS block_time | ||
, CAST(null AS VARBINARY) AS taker | ||
, t.contract_address AS maker | ||
, CASE WHEN amountIn < INT256 '0' THEN abs(amountIn) ELSE abs(amountOut) END AS token_bought_amount_raw -- when amountIn is negative it means trader_a is buying tokenIn from the pool | ||
, CASE WHEN amountIn < INT256 '0' THEN abs(amountOut) ELSE abs(amountIn) END AS token_sold_amount_raw | ||
, CASE WHEN amountIn < INT256 '0' THEN t.tokenIn ELSE t.tokenOut END AS token_bought_address | ||
, CASE WHEN amountIn < INT256 '0' THEN t.tokenOut ELSE t.tokenIn 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(project ~ '_v' ~ version ~ '_' ~ blockchain, 'Vault_evt_Swap' )}} t | ||
{% if is_incremental() %} | ||
WHERE | ||
{{ incremental_predicate('t.evt_block_time') }} | ||
{% endif %} | ||
) | ||
|
||
SELECT | ||
'{{ blockchain }}' AS blockchain | ||
, '{{ project }}' AS project | ||
, '{{ version }}' 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 | ||
|
||
{% endmacro %} |
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
19 changes: 19 additions & 0 deletions
19
dex/models/trades/base/platforms/swaap_v2_base_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,19 @@ | ||
{{ | ||
config( | ||
schema = 'swaap_v2_base', | ||
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')] | ||
) | ||
}} | ||
|
||
{{ | ||
swaap_v2_compatible_trades( | ||
blockchain = 'base', | ||
project = 'swaap', | ||
version = '2' | ||
) | ||
}} |
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
19 changes: 19 additions & 0 deletions
19
dex/models/trades/ethereum/platforms/swaap_v2_ethereum_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,19 @@ | ||
{{ | ||
config( | ||
schema = 'swaap_v2_ethereum', | ||
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')] | ||
) | ||
}} | ||
|
||
{{ | ||
swaap_v2_compatible_trades( | ||
blockchain = 'ethereum', | ||
project = 'swaap', | ||
version = '2' | ||
) | ||
}} |
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
19 changes: 19 additions & 0 deletions
19
dex/models/trades/optimism/platforms/swaap_v2_optimism_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,19 @@ | ||
{{ | ||
config( | ||
schema = 'swaap_v2_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')] | ||
) | ||
}} | ||
|
||
{{ | ||
swaap_v2_compatible_trades( | ||
blockchain = 'optimism', | ||
project = 'swaap', | ||
version = '2' | ||
) | ||
}} |
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
19 changes: 19 additions & 0 deletions
19
dex/models/trades/polygon/platforms/swaap_v2_polygon_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,19 @@ | ||
{{ | ||
config( | ||
schema = 'swaap_v2_polygon', | ||
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')] | ||
) | ||
}} | ||
|
||
{{ | ||
swaap_v2_compatible_trades( | ||
blockchain = 'polygon', | ||
project = 'swaap', | ||
version = '2' | ||
) | ||
}} |
Oops, something went wrong.