Skip to content

Support quotes without reference prices, drop market order class - #224

Merged
tilacog merged 3 commits into
mainfrom
quote-limit-orders-without-reference-price
Sep 16, 2026
Merged

tilacog merged 3 commits into
mainfrom
quote-limit-orders-without-reference-price

Conversation

@fleupold

Copy link
Copy Markdown
Collaborator

Description

Since cowprotocol/services#4874 the driver sends every quote as a limit order, leading to solvers from this crate failing to create quotes for two reasons"

  1. Swap::into_solution simulated gas for every limit order. The synthetic quote order is owned by the zero address, and simulation reverts with ERC20: transfer to the zero address, so the swap was dropped.
  • Single::into_solution converted the gas cost into a sell-token fee with sell_token?, so a missing reference price dropped the solution as well.

While porting the upstream fix, this PR also removes the market/limit order distinction. Every order has been a limit order for a long time and since cowprotocol/services#4874 the protocol-fee code path is dead.

Changes

Note, that most changes are trying to fix/improve the tests for this crate.

  • Only simulate gas when the auction has a sell token price (i.e. in real auctions). Quotes use the gas reported by the DEX, mirroring Always quote with limit orders rebased cowprotocol/services#4874.

  • Fall back to a zero fee when there is no sell token price. The orderbook API estimates the fee for quotes itself.

  • Drop Fee::Protocol / Fee::Surplus, Order::solver_determines_fee() and the order::Class domain enum.

  • Tests: all orders are limit orders now (market_order.rs -> limit_order.rs). Some expected amounts change by the fee which is now taken from surplus.

  • Every test declares the JSON-RPC calls it expects through a mock node (tests::mock::node).

  • Claude repaired three fixtures that only passed because the DEX response failed to parse: Balancer out_of_price (missing paths, misspelled returnAmountRaw), 0x out_of_price (empty response) and dex::wrong_execution (missing data wrapper, buy-side amounts swapped). They now exercise the checks they describe.

How to test

CI

@@ -1,5 +1,5 @@
//! This test ensures that the Balancer SOR solver properly handles sell and buy
//! market orders, turning Balancer SOR responses into CoW Protocol solutions.
//! orders, turning Balancer SOR responses into CoW Protocol solutions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything below is adjusting tests

@MartinquaXD MartinquaXD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me.
Given that the zeroex solver is no longer in use we can probably delete the code so that changes like this one don't have to adjust a bunch of dead tests.

Comment on lines +125 to +126
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2": "226932091840732390283",
"0xba100000625a3754423978a60c9317c58a424e3d": "997070755000000000"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values, executedAmount and fee are now tied to the gas estimate call. Meaning if the mock returns a different gas estimate all these values would change again?

@tilacog
tilacog merged commit b8f867f into main Sep 16, 2026
3 checks passed
@tilacog
tilacog deleted the quote-limit-orders-without-reference-price branch September 16, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants