From 5aae18b9f08b5c6b19af30944c89e024c22e9a49 Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Tue, 13 Feb 2024 10:05:23 +0100 Subject: [PATCH] Ignore slippage for settlements with ERC404 tokens (#341) This PR addresses #340 by explicitly excluding settlements from slippage which trade the ERC404 tokens 404, Pandora, Monarch, and Rug. No other ERC404 tokens seem to have been traded on CoW Protocol until all of them were blocked in the backend. --- queries/dune_v2/period_slippage.sql | 32 +++++++++++++++++------------ src/queries.py | 2 +- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/queries/dune_v2/period_slippage.sql b/queries/dune_v2/period_slippage.sql index 6aedce19..2610559f 100644 --- a/queries/dune_v2/period_slippage.sql +++ b/queries/dune_v2/period_slippage.sql @@ -1,5 +1,5 @@ --- https://github.com/cowprotocol/solver-rewards/pull/330 --- Query Here: https://dune.com/queries/3333368 +-- https://github.com/cowprotocol/solver-rewards/pull/340 +-- Query Here: https://dune.com/queries/3427668 with block_range as ( select @@ -7,7 +7,7 @@ block_range as ( max("number") as end_block from ethereum.blocks where time >= cast('{{StartTime}}' as timestamp) and time < cast('{{EndTime}}' as timestamp) - ) +) ,batch_meta as ( select b.block_time, b.block_number, @@ -192,13 +192,7 @@ block_range as ( join pre_batch_transfers pbt on bm.tx_hash = pbt.tx_hash ) --- These batches involve a token AXS (Old) --- whose transfer function doesn't align with the emitted transfer event. -,excluded_batches as ( - select tx_hash from filtered_trades - where 0xf5d669627376ebd411e34b98f19c868c8aba5ada in (buy_token, sell_token) -), -incoming_and_outgoing as ( +,incoming_and_outgoing as ( SELECT block_time, tx_hash, @@ -225,7 +219,6 @@ incoming_and_outgoing as ( left outer join tokens.erc20 t on i.token = t.contract_address and blockchain = 'ethereum' - where tx_hash not in (select tx_hash from excluded_batches) ) -- -- V3 PoC Query For Token List: https://dune.com/queries/2259926 ,token_list as ( @@ -266,6 +259,18 @@ incoming_and_outgoing as ( ) as _ order by block_time ) +-- These batches involve a token who do not emit standard transfer events. +,excluded_batches as ( + select tx_hash from filtered_trades + where 0xf5d669627376ebd411e34b98f19c868c8aba5ada in (buy_token, sell_token) -- exclude AXS (Old) + -- mixed ERC20/ERC721 tokens: + or 0xf66434c34f3644473d91f065bF35225aec9e0Cfd in (buy_token, sell_token) -- exclude 404 + or 0x9E9FbDE7C7a83c43913BddC8779158F1368F0413 in (buy_token, sell_token) -- exclude PANDORA + or 0x6C061D18D2b5bbfBe8a8D1EEB9ee27eFD544cC5D in (buy_token, sell_token) -- exclude MNRCH + or 0xbE33F57f41a20b2f00DEc91DcC1169597f36221F in (buy_token, sell_token) -- exclude Rug + or 0x938403C5427113C67b1604d3B407D995223C2B78 in (buy_token, sell_token) -- exclude OOZ + or 0x54832d8724f8581e7Cc0914b3A4e70aDC0D94872 in (buy_token, sell_token) -- exclude DN404 +) ,final_token_balance_sheet as ( select solver_address, @@ -276,6 +281,7 @@ incoming_and_outgoing as ( date_trunc('hour', block_time) as hour from incoming_and_outgoing_with_internalized_imbalances + where tx_hash not in (select tx_hash from excluded_batches) group by symbol, token, solver_address, tx_hash, block_time having @@ -393,7 +399,7 @@ incoming_and_outgoing as ( sum(usd_value) as usd_value, sum(eth_slippage_wei) as eth_slippage_wei, concat( - ' Query: "PERIOD_SLIPPAGE": QueryData( name="Solver Slippage for Period", filepath="period_slippage.sql", - q_id=3333368, + q_id=3427668, ), "DASHBOARD_SLIPPAGE": QueryData( name="Period Solver Rewards",