Skip to content

[BREAKING] Make solver trade fee non-optional - #5100

Open
0x2me wants to merge 5 commits into
cowprotocol:mainfrom
0x2me:remove-optional-solver-fee
Open

0x2me wants to merge 5 commits into
cowprotocol:mainfrom
0x2me:remove-optional-solver-fee

Conversation

@0x2me

@0x2me 0x2me commented Oct 14, 2026

Copy link
Copy Markdown

Description

Finishes #2507. Error::ProtocolFeeOnStaticOrder was already removed in #4832; this is the dependent cleanup the issue asks for: fee on Fulfillment and JitTrade in solvers-dto becomes a plain U256 instead of Option<U256>.

Same approach as #3822 (approved in principle there), but narrower: the driver surplus_fee() refactor is left for a follow-up so this stays a small review.

Breaking change to the solver API (crates/solvers/openapi.yml). fee on Fulfillment was documented as "only gets returned for limit orders" and is now required. A solver response containing a fulfillment without fee is rejected at deserialisation by the driver, including on the quoting path, and the whole response is discarded, not just that trade. JitTrade already listed fee as required, so this only tightens the Fulfillment half. Every in-tree solver always emitted fee, so the exposure is limited to external solver engines that relied on the old wording. If a softer landing is preferred, #[serde(default)] on the two fields delivers the same code cleanup while keeping old payloads working; happy to switch.

Changes

  • solvers-dto: fee: U256 on Fulfillment and JitTrade; serde tests for missing and present fee.
  • solvers: drop the Some(..) wrapping in the solution DTO.
  • driver: read fee directly instead of unwrap_or_default(); the test mock solver always emits fee.
  • e2e: fixtures updated.
  • openapi.yml: fee added to Fulfillment.required, description rewritten and typed as TokenAmount.

How to test

  1. cargo nextest run -p solvers-dto (new: fulfillment_requires_fee, fulfillment_fee_round_trips, jit_trade_requires_fee).
  2. cargo nextest run and cargo clippy --locked --workspace --all-features --all-targets -- -D warnings: green locally.
  3. RUST_MIN_STACK=3145728 cargo nextest run -p driver --test-threads 1 --run-ignored ignored-only: 96/96 locally.
  4. E2E suite was compile-checked only (cargo check -p e2e --tests), not run locally; please watch CI.

Related Issues

Fixes #2507


Supersedes #4964, which the stale bot closed before review and GitHub would not reopen after the rebase. Rebased on current main; one conflict in the driver solution DTO resolved (the haircut_fee argument was removed upstream).

@fleupold @MartinquaXD could one of you take a look and approve the CI run when you get a chance? Happy to switch to #[serde(default)] if you prefer the softer landing described above.

@0x2me
0x2me requested a review from a team as a code owner October 14, 2026 17:25
@0x2me
0x2me force-pushed the remove-optional-solver-fee branch from a50c6f5 to 22b1596 Compare October 19, 2026 22:24
@jmg-duarte jmg-duarte changed the title [EASY] Make solver trade fee non-optional [BREAKING] Make solver trade fee non-optional Oct 20, 2026
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.

chore: Remove Error::ProtocolFeeOnStaticOrder

1 participant