build_order
Construct a signed CoW order with slippage enforcement and partner fee on Ophis. The order limits are validated against a live quote and include EIP-712 signing data.
Instructions
Build a bounded, ready-to-sign CoW order on Ophis. Returns { order, signing:{domain,types,primaryType}, fullAppData, appDataHash, partnerFee, next }. The receiver is ALWAYS PINNED to the owner (proceeds cannot leave the account); this public endpoint exposes no custom-receiver option. Uses the correct per-chain settlement contract (Optimism/MegaETH/HyperEVM are non-canonical) and embeds the CIP-75 partner fee. Apply slippage to the LIMIT side by kind: for kind 'sell' lower buyAmount (your minimum out); for kind 'buy' raise sellAmount (your maximum in). slippageBips is capped at 5000 (50%, default = the cap) and ENFORCED: build_order fetches a live quote and REJECTS the call if the limit is worse than slippageBips vs that quote (or if a quote cannot be fetched — retry). Sign order as EIP-712 with signing, then call submit_order.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | Yes | EVM chain id (use a chainId from list_chains `tradeable`). | |
| owner | Yes | The signer/owner address (receiver defaults to this). | |
| sellToken | Yes | Sell token address (0x...). | |
| buyToken | Yes | Buy token address (0x...). | |
| sellAmount | Yes | In atoms. kind 'sell': the EXACT amount you sell. kind 'buy': the MAXIMUM you'll spend (slippage-adjusted UP from the quote). | |
| buyAmount | Yes | In atoms. kind 'sell': the MINIMUM you accept (slippage-adjusted DOWN from the quote). kind 'buy': the EXACT amount you want to receive. | |
| kind | Yes | 'sell' = sellAmount is exact and buyAmount is your minimum out; 'buy' = buyAmount is exact and sellAmount is your maximum in. | |
| validForSeconds | No | Order lifetime in seconds (default 1200 = 20 min; minimum 60). The enforced live-quote fetch can consume several seconds, so very short lifetimes would return a near-expired order the orderbook rejects. | |
| feeAmount | No | Signed feeAmount in atoms. Must be omitted or "0" on this tool (the fee is taken from surplus + the appData partner fee). | |
| partiallyFillable | No | Allow partial fills (default false = fill-or-kill). | |
| slippageBips | No | Max accepted slippage in bips; capped at 5000 (50%, the default bound); recorded in appData. ENFORCED: build_order fetches a live quote and rejects a limit worse than this vs the quote. Fund safety: the receiver is always pinned to the owner. | |
| referenceBuyAmount | No | ||
| referenceSellAmount | No | ||
| referrerCode | No | Affiliate referral code to embed in appData (credits that code's owner for this trade). Defaults to the server's OPHIS_DEFAULT_REFERRER_CODE if set. Grammar: 3-64 chars [a-z0-9_-]; an invalid code errors. |