From 4bfa9172dc7362ab422783d96eef1c64ca7156a5 Mon Sep 17 00:00:00 2001 From: Haris Angelidakis <64154020+harisang@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:18:17 +0300 Subject: [PATCH] Merge weth and native eth imbalances (#367) Some unexpected results showed up from time to time in txs where native ETH was traded. This PR modifies the slippage Dune query and proposes that we convert every perceived ETH imbalance to a WETH imbalance (so that only the price feed of WETH is used in a consistent way). The proposed change has been applied to the following queries (sharing ids here): - 3427730 - 2332678 - 2510345/4131517 --- queries/dune_v2/period_slippage.sql | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/queries/dune_v2/period_slippage.sql b/queries/dune_v2/period_slippage.sql index ae00685b..39400a39 100644 --- a/queries/dune_v2/period_slippage.sql +++ b/queries/dune_v2/period_slippage.sql @@ -305,7 +305,7 @@ block_range as ( on from_hex(r.order_uid) = t.order_uid and from_hex(r.tx_hash) = t.tx_hash where t.order_type='SELL' ) -,incoming_and_outgoing_with_internalized_imbalances as ( +,incoming_and_outgoing_with_internalized_imbalances_unmerged as ( select * from ( select * from incoming_and_outgoing_with_internalized_imbalances_temp union all @@ -315,6 +315,21 @@ block_range as ( ) as _ order by block_time ) +,incoming_and_outgoing_with_internalized_imbalances as ( + select + block_time, + tx_hash, + solver_address, + symbol, + CASE + WHEN token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee then 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 + ELSE token + END as token, + amount, + transfer_type + from incoming_and_outgoing_with_internalized_imbalances_unmerged +) + -- These batches involve a token who do not emit standard transfer events. -- These batches are excluded due to inaccurate prices. ,excluded_batches as (