Recent surplus shifting issues involving CoW AMMs

Introduction

We have recently become aware of issues with executions of batched solutions from a specific solver that involved at least one CoW AMM. In many such instances, there was clear so-called surplus shifting from a user order to the CoW AMM.

Surplus shifting. The issue of surplus shifting is a well-known problem that has been discussed in the past, as early as almost 3 years ago, and has nothing to do with the specifics of CoW AMMs. The issue can arise whenever at least 2 orders that generate surplus are executed in the same batch and their executions “intersect”; see the introduction and example of this forum post for more details..

CIP-11 addressed this issue by explicitly stating that intentional surplus shifting is not allowed, and introduced a test in order to detect such cases. It was discovered that there are cases where this test, also described here, is not well-defined, and thus cannot be applied in a fully automated fashion; this means that it is more conveniently used as a test after a transaction has been executed. Nevertheless, CIP-11 did introduce a social-consensus rule that states that systematic and non-trivial surplus shifting is not allowed. This rule is also described in the official documentation of the protocol:

Local Token Conservation, aka illegal surplus shifts (CIP-11). Due to the nature of batching, a solver can intentionally transfer surplus among orders that share a common token. This is not allowed, and non-trivial surplus shifts can be penalized and can lead to solver slashing.

Sidenote: social consensus rules. Since the protocol and its batch auctions are quite involved and there are both offchain and onchain components to them, it is known from its early stages that there are certain issues where a formal, programmatically imposed rule to prevent those still does not exist. Thus, the DAO, in order to protect their users and guarantee that even bad edge cases can always be rectified, uses the notion of social consensus rules as rules that are not imposed at the time of the auction but can be imposed retrospectively, in cases where a user was, intentionally or unintentionally, treated unfairly. For that, there is a very substantial requirement of capital that needs to be associated with every active solver, namely the bonding pool, and this capital can be used by the DAO in order to reimburse users, whenever a serious violation of a social consensus rule takes place (see also CIP-7 for the definition of a bonding pool)

Additional protection for users via EBBO. Although the very robust solver competition of CoW Protocol very consistently provides great executions to users, the DAO has also ensured to introduce a very well-defined so-called EBBO rule (“Ethereum Best Bid and Offer”), as an additional social consensus rule, that states that the user should get at least as much as they could get at the major public AMMs (e.g., Uniswap, Balancer, Sushiswap), when routing via (multiple) 2-hop paths that touch some so-called base tokens. This rule, and the processes around how it can be enforced, was actually recently described in CIP-52.

Goal of CoW DAO. It is clear from the points above that CoW DAO strives to protect its users and provide best possible executions for all user intents. And in cases where this cannot be enforced programmatically, it provides very concrete rules and ways to enforce those so that affected users in certain edge-case transactions can get reimbursed, whenever needed. Moreover, the core team has committed to develop monitoring infrastructure in order to check when social consensus rules are violated, and it has worked diligently with all solver teams to minimize potential issues arising from batching.

Issues with surplus shifting to CoW AMMs

We want to make it clear that the core team has several checkpoints in place in order to monitor the competition and ensure that social consensus rules are not violated. And we want to acknowledge that indeed there were alerts relevant to certain CoW AMM transactions; unfortunately due to the multiple tasks the core team is handling at the moment, these alerts were not investigated in a timely manner.

It is very important to state that in many affected transactions, the solver did respect the EBBO condition, or even if it violated it, the magnitude of the violation was much smaller than the surplus attributed to the CoW AMM. And the reason is that EBBO provides a minimum threshold that needs to be delivered by solver. What this means is that if the affected user used Uniswap, for example, in most cases they would NOT get a better execution (one can see that by using the uniswap router at the relevant block). This does not mean that there was no surplus shift, but it does mean that the user still got a deal that was at least as good as in any other popular DEX.

Specifically, in this widely circulated transaction, one can see the following:

  • Exclusive execution on Uniswap where the goal is to convert WETH to WBTC and then to cbBTC would give:
    • WETH → wBTC: out amount = 29.77 wBTC
    • wBTC → cbBTC: out amount = 29.67 cbBTC

This shows that a good routing on Uniswap would have given roughly 29.67 cbBTC to the user. However, this routing is more complex than the EBBO routing; as a reminder, EBBO routing considers routings where each path is of the form “sell_token → base_token → buy_token” where the intermediate hop is optional. If one only looks at such a combination of paths, the EBBO routing would actually give 25.97 cbBTC, way lower than the amount the user received.

Thus, one needs to invoke the unfair surplus shifting social consensus rule to make the case against the solver. Indeed, there is a very evident surplus shift. Because of that, and because of the fact that the protocol’s goal is to provide users with at least as good executions as they can find in other DEXs, we believe it is reasonable to consider the slightly more involved Uniswap routing that returns 29.67 cbBTC as a reference routing in order to quantify how aggressive the surplus shift was. With this, we claim that at least 29.67 - 29.6442 = 0.026 additional cbBTC should have been forwarded to the user, which with prices at the time of the trade, corresponded to roughly 0.862 ETH. This is a non-trivial amount but it is way lower than the surplus the CoW AMM gained. The additional surplus above the Uniswap execution, that the solver generated, was shifted (unfairly) towards the CoW AMM. According to the rules cited above, these are definitely significant amounts, and the solver is required to reimburse the user with at least the reference amount.

We would also like to mention that there is an ongoing investigation that started on March 24, 2025, several days before the issue was first made public on X/Twitter, where the core team has been inspecting flagged transactions in reverse chronological order. The investigation is ongoing and already resulted in a few user reimbursements that the solver issued right away by matching the full amount of the surplus shift (and not just the EBBO, or reasonable external execution, threshold):

Conclusion

Although the core team and the solvers have taken drastic measures to eliminate the surplus shifting issues, and they have succeeded in reducing the frequency significantly, there are still transactions that happen occasionally that suffer from this. The core team commits to continue the investigation and the protocol already has sufficient rules in place to ensure that all users that have been seriously impacted by this phenomenon are reimbursed by the relevant solvers, as this has consistently been the case until now (and way before the creation of CoW AMMs, as again, the issue has nothing to do with CoW AMMs in particular).

Moreover, and very importantly, the core team has been working for several months for upgrading the mechanism and addressing the current limitations more systematically, and will soon post a CIP that proposes to switch to a fair combinatorial auction mechanism. There has already been extensive research on the topic, and a forum post summarizing the main ideas. We are confident that combinatorial auctions will lead to further price improvements for the vast majority of our users and will almost always eliminate serious instances of surplus shifting and EBBO violations.

5 Likes