Skip to content

How does cowswap calculate surplus on a filled order? Verify it

cowswap calculates surplus on a filled order as the difference between what the settlement gave you and the worst trade your signed order allowed: extra buy tokens on a sell order, or sell tokens saved on a buy order.

Your signed amounts set the limit. Solvers then compete to settle orders in batch auctions at a better rate. A Coincidence of Wants, where compatible traders’ orders match, or a better route through available liquidity can create the gap. Surplus measures the part of that gap delivered to your order.

Which amounts go into the surplus calculation?

The surplus calculation compares your order’s signed limit with its executed amounts, using the limit for the quantity actually filled. The CoW Protocol documentation defines the sell and buy order formulas and the uniform directional clearing prices used for orders trading the same pair in a batch.

  • Sell order: Subtract the minimum buy amount from the executed buy amount. Surplus is in the buy token.
  • Buy order: Subtract the actual sell amount from the maximum sell amount. Surplus is in the sell token.
  • Partial fill: Scale the signed limit to the filled quantity before subtracting. Comparing a partial fill with the full order’s limit gives the wrong result.

Say you sign a sell order for 1 ETH with a minimum of 2,970 USDC. The settlement sells 1 ETH and credits 3,005 USDC. Your surplus is 3,005 − 2,970 = 35 USDC. The executed buy amount comes from the settlement, not from an earlier quote. Use the amounts credited to your order when reconciling the figure; gross route output can include amounts used for fees.

CoW Swap is the trading interface for signed intents, including swaps, limit orders and TWAP orders. Traders use cowswap.us to send those intents into solver-run batch auctions; the signed constraint and settled fill are the two sides of this calculation.

Why can a buy order show surplus when the bought amount stays fixed?

A buy order shows surplus in the token you saved while buying the specified amount. Say you sign an order to buy 1 ETH for at most 3,020 USDC. A fill that buys 1 ETH for 2,985 USDC leaves 35 USDC of surplus. The ETH amount remains 1; the improvement appears in the USDC spent.

Compare an otherwise identical fill costing 3,020 USDC. It delivers the same 1 ETH but has zero surplus. Only the actual USDC spend changes, so subtracting received ETH from the order’s ETH amount would miss the gain entirely. For a partial buy fill, first scale the maximum USDC spend to the ETH actually bought.

To reconcile an order, read its signed amounts and executed amounts alongside its surplus in the CoW Explorer order record. Identify whether it is a buy or sell order, apply the corresponding formula, and keep the result in that formula’s token.

Why does cowswap show surplus in USD?

The USD figure expresses the token surplus at a valuation rate so different tokens can be compared. Recalculate the token amount first; a USD difference can reflect the valuation used to display it rather than a different executed fill.

Is cowswap surplus the same as price improvement?

Surplus is price improvement measured against your signed limit. A price-improvement figure measured against a quote or market price uses a different baseline and can differ even for the same fill.

The deciding comparison is always the filled quantity at your signed limit versus what settlement delivered. That tells you which token contains the gain and lets you verify the reported surplus.