@somnia-chain/markets-sdk


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

Type Alias: PerpStopOrder

PerpStopOrder = object

Defined in: packages/sdk/src/perp/stops.ts:117

One take-profit / stop-loss order on a perp market.

Properties

id

id: string

Defined in: packages/sdk/src/perp/stops.ts:119

Row id (${registry}_${orderId}).


registry

registry: string

Defined in: packages/sdk/src/perp/stops.ts:121

The PerpStopOrderRegistry holding it (lowercased).


orderIdRaw

orderIdRaw: string

Defined in: packages/sdk/src/perp/stops.ts:123

uint128 registry OrderId as a decimal string — pass to trader.cancelStopOrder.


owner

owner: string

Defined in: packages/sdk/src/perp/stops.ts:125

The order's owner (lowercased).


isBid

isBid: boolean

Defined in: packages/sdk/src/perp/stops.ts:127

True = the triggered order buys, false = sells.


quantity

quantity: string

Defined in: packages/sdk/src/perp/stops.ts:129

Quantity in raw base units.


triggerPrice

triggerPrice: string

Defined in: packages/sdk/src/perp/stops.ts:131

The MARK price at which it fires, raw quote units per whole base.


triggerOperator

triggerOperator: number

Defined in: packages/sdk/src/perp/stops.ts:137

Which way the mark must cross triggerPrice to fire: 0 = GTE (fires at or above), 1 = LTE (fires at or below). This, not the side, is what makes a stop a take-profit or a stop-loss.


orderType

orderType: number

Defined in: packages/sdk/src/perp/stops.ts:139

0 = LIMIT, 1 = MARKET — the type of order placed when it fires.


builder

builder: string

Defined in: packages/sdk/src/perp/stops.ts:141

Builder tagged on the resulting order (lowercased); zero address for none.


builderFeeBpsTimes1k

builderFeeBpsTimes1k: string

Defined in: packages/sdk/src/perp/stops.ts:149

The builder fee the triggered order will charge, in bps x 1000 — so 1500 is 1.5bps, not 1500bps. "0" when no builder is tagged.

Only knowable from the creation event: the registry deletes a pending order on every fire, so after a trigger nothing on chain can say what fee was agreed.


status

status: StopOrderStatus

Defined in: packages/sdk/src/perp/stops.ts:151

Lifecycle state — see StopOrderStatus.


placedOrderId

placedOrderId: string | null

Defined in: packages/sdk/src/perp/stops.ts:153

The PerpPool order id created on a successful trigger; null otherwise.


dropReason

dropReason: PerpStopDropReason | null

Defined in: packages/sdk/src/perp/stops.ts:162

Why a trigger placed nothing, decoded — null on a pending or successful order.

Read it before calling a TRIGGER_FAILED order a failure: a reduce-only drop means the stop was overtaken by events (position already closed, flipped, or below minimum), which is ordinary. Only PlacementFailed is a rejection. SOMI is consumed on every fire regardless of outcome.


siblingOrderId

siblingOrderId: string | null

Defined in: packages/sdk/src/perp/stops.ts:180

The LIVE OCO sibling's registry id, as a decimal string — null when this stop is unlinked, and null on every terminal row.

Live is the whole contract, which is why every terminal write clears it. A pair's two rows leave at different times, so a pointer surviving on a departed row names an order whose own state has moved on: a client acting on "cancel the pair" would tear down a stop the trader deliberately kept armed.

A leg that fires WITHOUT filling leaves its partner live and unlinked (back to null) — that is what lets the survivor be re-paired.

Provenance is deliberately not here. Which leg retired this one is PerpStopOrder.cancelReason's job; overloading one column with "my live partner" and "the leg that retired me" is what would make a client act on the wrong one.


intent

intent: PerpStopIntent | null

Defined in: packages/sdk/src/perp/stops.ts:191

Whether the triggered order may only REDUCE the owner's position ("reduceOnly" — a take-profit / stop-loss) or may open and increase one ("opening" — a stop-entry / breakout, gated on initial margin at creation).

null means the registry reported a member this SDK version does not know, and it is deliberately not folded into "reduceOnly": calling an unknown member reduce-only would promise a caller that an order cannot increase their position when a newer member might let it. Treat null as "upgrade the SDK before acting on this".


cancelReason

cancelReason: string | null

Defined in: packages/sdk/src/perp/stops.ts:213

WHY this stop reached CANCELLED"Owner", "LinkedFill" or "Inert". Null on every row that is not cancelled.

All three end the same way for the trader — the order is no longer working — but they are three different stories and two different refunds, so a UI that renders CANCELLED as "you cancelled this, SOMI refunded to your wallet" is wrong for two of them:

  • "Owner" — the owner cancelled it, and the SOMI is pushed back to them in that same transaction.
  • "LinkedFill" — the protocol retired it because its OCO sibling FILLED.
  • "Inert" — a keeper swept it after the registry's Schedule chain wound down.

The last two only CREDIT unclaimedSomi; the trader recovers it via claimSomi().

A raw string rather than a decoded union, matching Order.cancelReason. The vocabulary is the indexer's own — three distinct events, not a contract enum arriving as a uint8 — so there is nothing to decode, and a value this SDK version has not heard of should reach a consumer intact rather than become null.


createdAt

createdAt: string

Defined in: packages/sdk/src/perp/stops.ts:215

Timestamp (unix seconds) the stop was created.


updatedAt

updatedAt: string

Defined in: packages/sdk/src/perp/stops.ts:217

Timestamp (unix seconds) of the last state change.


txHash

txHash: string

Defined in: packages/sdk/src/perp/stops.ts:219

Tx hash the stop was created in.


market

market: PerpStopOrderMarket

Defined in: packages/sdk/src/perp/stops.ts:221

The perp market it targets.