Skip to content

Commit

Permalink
Merge weth and native eth imbalances (#367)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
harisang authored Jun 18, 2024
1 parent 9577798 commit 4bfa917
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion queries/dune_v2/period_slippage.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand 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 (
Expand Down

0 comments on commit 4bfa917

Please sign in to comment.