Skip to content

Commit

Permalink
Ignore slippage for settlements with ERC404 tokens (#341)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fhenneke authored Feb 13, 2024
1 parent 1a00c85 commit 5aae18b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
32 changes: 19 additions & 13 deletions queries/dune_v2/period_slippage.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-- 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
min("number") as start_block,
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,
Expand Down Expand Up @@ -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,
Expand All @@ -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 (
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -393,7 +399,7 @@ incoming_and_outgoing as (
sum(usd_value) as usd_value,
sum(eth_slippage_wei) as eth_slippage_wei,
concat(
'<a href="https://dune.com/queries/2421375?SolverAddress=',
'<a href="https://dune.com/queries/3427668?SolverAddress=',
cast(solver_address as varchar),
'&CTE_NAME=results_per_tx',
'&StartTime={{StartTime}}',
Expand All @@ -408,4 +414,4 @@ incoming_and_outgoing as (
solver_address,
concat(environment, '-', name)
)
select * from {{CTE_NAME}}
select * from {{CTE_NAME}}
2 changes: 1 addition & 1 deletion src/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def with_params(self, params: list[QueryParameter]) -> 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",
Expand Down

0 comments on commit 5aae18b

Please sign in to comment.