Skip to the article
Token Trail

News from across crypto

How to Get an Off-Chain DEX Limit Order Filled Correctly

Learn how off-chain limit orders get filled on a DEX: you sign terms, a filler submits them when your price works, and the contract settles the token swap.

By The Token Trail Desk4 min read

How to Get an Off-Chain DEX Limit Order Filled Correctly

An off-chain limit order gets filled when you sign its terms and a filler submits it to a settlement contract at a price that works; the contract checks the order and swaps the tokens in one transaction. The order stays off-chain while it waits, so signing it costs no gas and you avoid a gas payment just to post or update it.

From signed order to token swap

First, you sign an EIP-712 typed message that sets the token pair, amounts, and expiry. It is a readable format for signing structured data. Signing sends no transaction. To move your tokens when the order fills, the contract also needs an existing token approval.

Next, the signed order goes into an off-chain order book. Fillers—traders or services that submit orders—watch these books for trades they can execute. A signed order can be copied, so taking it out of one book does not make the signature invalid.

A filler submits the order when they can take your price and still cover the transaction’s gas. The 0x Protocol settlement contract checks the signature, expiry, and amounts, then transfers both sides of the trade atomically: either the swap completes together or it does not. Your approved tokens move from your wallet at fill time; the filler submits the transaction and pays its gas.

Say you sign an order to sell 1 ETH for 4,000 USDC. A filler may submit it once market bids are above that price by enough to cover gas and leave the filler a reason to act. The contract checks the order and, if it is valid and fillable, sends your ETH and the USDC to their respective recipients in the same transaction. Matcha swap helps readers exchange one token for another by finding routes across liquidity sources. For background on gas sponsorship, matcha gasless swap adds context about how a transaction’s gas can be covered.

You can cancel in two ways. An off-chain cancel removes the order from the book you cancel it on, but a copied signature can still be filled until it expires, fills, or is invalidated on-chain. An on-chain cancellation invalidates the order itself, so it cannot be filled even if someone kept a copy; sending that cancellation costs gas. This is the trade-off: off-chain orders are cheaper to post and update, while on-chain cancellation gives stronger certainty. For someone placing a first order, knowing whether it is still valid matters more than avoiding the cancellation gas if they need it stopped.

Once the fill transaction is confirmed, the example order has sold 1 ETH and delivered 4,000 USDC, subject to the signed terms. That confirmation tells you the swap settled on-chain, rather than merely disappearing from an order book.

Related questions

Does placing a limit order cost gas?

Signing and posting the order off-chain do not cost gas. A separate approval transaction may be needed before the contract can transfer your tokens, and an on-chain cancellation costs gas.

Can a limit order fill partially?

Yes. 0x limit orders can be filled for less than the full amount. The remaining amount may stay fillable until it expires, fills, or is cancelled on-chain.

Other questions

Can I edit a limit order after signing it?

No. The signed amounts and expiry are part of the message. To change them, cancel the old order and sign a new one. An off-chain cancel alone does not invalidate copies of the old signature.

Are limit orders exposed to MEV?

A filler submits the signed order in an on-chain transaction, so the fill becomes visible when submitted. EIP-712 specifies signing; it does not itself prevent front-running. The contract still checks the order terms when processing the fill.

Do limit orders work across chains?

A signed order is tied to the relevant contract and chain context. A fill on one chain does not itself settle tokens on another; cross-chain trading requires a separate mechanism.