-
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.
dex.trades
: add HOT-AMM support (#6726)
* dex.trades: add hot-amm support * arbitrum * arbitrum sources * arbitrum sources * fix: no duplicates * remove erc20 dependency * add dex info for valantis * style: naming convention
- Loading branch information
1 parent
d009f88
commit ff5622a
Showing
12 changed files
with
213 additions
and
103 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
dbt_subprojects/dex/macros/models/_project/valantis_compatible_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,52 @@ | ||
{% macro valantis_compatible_hot_trades( | ||
blockchain = null | ||
, project = null | ||
, version = null | ||
, HOT_evt_Swap = null | ||
, Pair_evt_Swap = null | ||
, Factory_evt_PoolCreated = null | ||
) | ||
%} | ||
WITH dexs AS | ||
( | ||
SELECT distinct t.evt_block_number AS block_number | ||
, t.evt_block_time AS block_time | ||
, t.amountOut AS token_bought_amount_raw | ||
, t.amountIn AS token_sold_amount_raw | ||
, CASE WHEN t.isZeroToOne THEN f.token1 ELSE f.token0 END AS token_bought_address | ||
, CASE WHEN t.isZeroToOne THEN f.token0 ELSE f.token1 END AS token_sold_address | ||
, t.sender AS taker | ||
, coalesce(h.contract_address, t.contract_address) AS maker -- HOT for HOTSwaps (solver orders), SovereignPool for AMM swaps (permissionless) | ||
, t.contract_address AS project_contract_address | ||
, t.evt_tx_hash AS tx_hash | ||
, t.evt_index AS evt_index | ||
FROM {{ Pair_evt_Swap }} AS t | ||
INNER JOIN {{ Factory_evt_PoolCreated }} AS f | ||
ON t.contract_address = f.pool | ||
LEFT JOIN {{ HOT_evt_Swap }} AS h | ||
ON t.evt_block_number = h.evt_block_number AND t.evt_tx_hash = h.evt_tx_hash AND t.evt_index = h.evt_index + 3 | ||
{% 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
Oops, something went wrong.