@somnia-chain/markets-sdk


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

Function: decodePerpStopOrderIds()

decodePerpStopOrderIds(logs, registry): bigint[]

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

Registry order ids from a receipt's logs, in the registry's own (GTE, LTE) order.

The ids only surface through PendingOrderCreated — the create functions' return value is unreadable from a receipt — so this is the only way to learn what a placement created. trader.placePerpStopOrder calls it for you; it is exported for the build path, where the caller sends the transaction and so holds the only copy of the receipt.

Filters to registry's own logs: another contract could emit a matching signature, and in a batched UserOp several contracts' logs share one receipt.

Details

  • logs: The receipt's logs.
  • registry: The PerpStopOrderRegistry the placement targeted.
  • Returns: The created ids, oldest first; empty if the receipt created none.

Example (Decoding submitted stop IDs)

ts
const { stopOrder } = await trader.buildPlacePerpStopOrder({
  registry, pool, isBid: false, quantity: 10_000_000n,
  triggerPrice: 90_000_000_000_000_000_000n, triggerOperator: 1, stopOrderType: 1,
  skipOperatorApproval: true,
});
const receipt = await myBatcher.send([stopOrder]);
const [stopOrderId] = decodePerpStopOrderIds(receipt.logs, registry);

Parameters

logs

readonly object[]

registry

`0x${string}`

Returns

bigint[]