@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / CreateOrderParams

Interface: CreateOrderParams

Defined in: packages/sdk/src/unified/exchange.ts:407

The optional trailing params bag of SomniaMarkets.createOrder — time-in-force, market-order slippage, and builder-fee attribution. Everything here has a working default.

Properties

timeInForce?

optional timeInForce?: "GTC" | "IOC" | "FOK" | "PO"

Defined in: packages/sdk/src/unified/exchange.ts:409

"IOC" | "FOK" | "PO" (post-only). Default GTC (rest).


postOnly?

optional postOnly?: boolean

Defined in: packages/sdk/src/unified/exchange.ts:411

Alias for timeInForce: "PO".


slippage?

optional slippage?: number

Defined in: packages/sdk/src/unified/exchange.ts:413

Market-order slippage bound vs the best opposite level (default 0.01 = 1%).


builder?

optional builder?: `0x${string}`

Defined in: packages/sdk/src/unified/exchange.ts:419

Routing/builder frontend to attribute the order to. Requires a prior client.createTrader().approveBuilder(...) opt-in on the pool, else a non-zero builderFeeBpsTimes1k reverts. Works on binary, spot and perp.


builderFeeBpsTimes1k?

optional builderFeeBpsTimes1k?: bigint

Defined in: packages/sdk/src/unified/exchange.ts:424

Per-order builder/routing fee in the pool's native bps×1000 unit (must not exceed the effective approval / the pool's max builder fee).


funding?

optional funding?: "auto" | "explicit" | "skip"

Defined in: packages/sdk/src/unified/exchange.ts:455

What to do when the order's collateral is not on the market's chain.

  • "explicit" (the default on a multi-chain exchange): check the escrow token's balance on the market's chain and throw CollateralOnWrongChainError — with where the funds are and a ready bridge plan — instead of sending anything.
  • "auto": bridge the shortfall from the richest other configured chain through SomniaMarkets.ensureFunds, wait for delivery, then place. The order lands seconds after the call. A native route whose destination router cannot pay out throws BridgeLiquidityError and sends nothing. Auto-funded orders for the same account, chain and escrow token are checked and placed one at a time, so each one sees the balance after the one before it took its escrow.
  • "skip" (the default on a single-chain exchange, where there is nowhere else the collateral could be): no balance check — the single round-trip, for a hot path that funds itself.

Checked on a binary buy's collateral and on every spot order. A perp order draws on the MarginBank and a binary sell escrows outcome tokens, so neither is checked here.

A spot order is sized by the pool: the check reads the pool's getAutoPullRequirement (fees included, net of the account's pool vault balance). When the vault covers the order, that read is the whole check. Otherwise the wallet must hold the remainder (as native coin for a native-base sell). Under manual vault mode the pool never pulls from the wallet, so a vault shortfall throws with no bridge plan, even under "auto": deposit into the pool vault instead.