DEV Community

Anna Botsford
Anna Botsford

Posted on

Choosing a CoW Swap Order Cancellation Method

Choose off-chain cancellation when saving gas matters; choose on-chain cancellation when you want the order invalidated on the blockchain. Both can lose a race with a trade that is already being settled, so speed matters either way.

What changes when I cancel off-chain or on-chain?

Off-chain cancellation asks CoW Swap’s order book—the online list of open trades—to stop offering your order. It costs no network transaction fee, often called gas, but relies on the order book processing your request.

On-chain cancellation sends a transaction to the settlement contract, the blockchain program that checks and completes trades. The contract records that your order is invalid, so a later trade cannot use it. You pay the network’s gas fee for that transaction.

Think of the difference as crossing your name off a shop’s list versus changing the official record. The first is quicker and free when the shop acts promptly. The second creates a public record, but you still wait for the network to confirm it.

Which method should I pick?

For a routine change of mind, I’d pick off-chain cancellation. It avoids a fee, and the interface makes the request straightforward. In the cowswap interface, open your pending order and choose “Cancel order”; check that the right order is selected before confirming.

Choose on-chain cancellation if you prefer the order’s invalidation to be recorded by the contract instead of relying on the order book. It may suit a time-sensitive order when you can submit the transaction promptly and accept the gas cost. That cost changes with the network and congestion, so check the wallet’s fee estimate before signing.

Neither choice guarantees the order stops instantly. Solvers—automated traders that compete to complete orders—may already have included it in a batch auction, a process that checks a group of trades together. If a settlement transaction gets confirmed first, cancellation cannot undo the completed trade.

What is the race, and how do I check the result?

Cancellation races the trade through two different paths. With off-chain cancellation, the order book must process your request before a solver’s settlement can use the order. With on-chain cancellation, the invalidation transaction must be confirmed before the settlement transaction.

For example, if you request off-chain cancellation just after a solver has prepared a settlement, the order may still be included. An on-chain request also has a delay: until the network confirms it, the order can remain valid. A higher priority fee may help your transaction get processed sooner, but it cannot promise that cancellation wins.

After requesting cancellation, check the order’s status in the activity panel or CoW Explorer. For on-chain cancellation, also check that the transaction succeeded on the correct network. If the order shows as filled, compare its settlement time with your cancellation request; a later status update alone does not prove which happened first.

Are there cases where one method is unavailable?

Yes. Orders that use CoW Swap’s Eth-flow route for native ETH can only be cancelled on-chain. That route places the order through a contract that holds the ETH, so the cancellation must also reach the blockchain; a free off-chain request is not available for it.

Also, cancelling an order does not revoke your token approval. An approval lets the protocol spend approved tokens for valid orders; cancelling invalidates one specific order. Revoking the approval is a separate action and is not a substitute for cancelling the order.

For most ordinary orders, I’d start with the free off-chain request and check its status. Pick on-chain cancellation when contract-recorded invalidation matters enough to justify gas, and act quickly with either method.

Top comments (0)