@0xmonaco/types 1.0.50-develop.9c1b239 → 1.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,6 +84,51 @@ export interface Order {
84
84
  positionId?: string;
85
85
  /** Stable cause when status is CANCELLED */
86
86
  terminalReason?: OrderTerminalReason;
87
+ /**
88
+ * Opaque, compare-only revision counter for this order's state: a strictly
89
+ * higher value is strictly newer state for that order, and equal values
90
+ * mean identical state.
91
+ *
92
+ * Compare two REST reads of the same order with it — whether a re-poll
93
+ * advanced, or which of `getOrder` and a list row is fresher.
94
+ *
95
+ * The SAME counter is on every WebSocket order event and on the `orders`
96
+ * snapshot frame, so it is also the snapshot-versus-stream reconciliation
97
+ * key: after a disconnect, keep applying events as they arrive and merge a
98
+ * REST read per order — take the REST row when
99
+ * `snapshot.version >= local.version`, else keep local. No buffering, so no
100
+ * quote blackout on reconnect. The rule is `>=` rather than `>` because one
101
+ * sequencer step emits several events for one order (an `OrderPlaced` and
102
+ * then its fills) and a batch shares one step across every item, so equal
103
+ * means "same step" on the stream — and a REST row is that step's final
104
+ * state, so it wins the tie. Between two REST reads, equal does mean
105
+ * identical state.
106
+ *
107
+ * The snapshot frame alone does not close a reconnect gap: an order that
108
+ * filled or was cancelled while the socket was down is in neither the
109
+ * resting snapshot nor the stream. Recover those explicitly — `listUserTrades`
110
+ * for fills, and a targeted `getOrder` for anything local state believes is
111
+ * resting that the snapshot no longer lists.
112
+ *
113
+ * Read nothing else into it. It is not a count of updates; consecutive
114
+ * values are not expected (it is drawn from a global sequence shared by
115
+ * every order, so per-order values are sparse and gaps are normal); and it
116
+ * is not comparable across different orders.
117
+ *
118
+ * Absent means unknown — an order last written before this field existed.
119
+ * Fall back to a full field comparison for those rather than treating
120
+ * absent as version zero. Note that a comparison against an absent value
121
+ * cannot be true either way, so an order held locally without a version is
122
+ * never refreshed by the merge above: take the REST row unconditionally for
123
+ * those rather than letting them go stale.
124
+ *
125
+ * Prefer this over `updatedAt`: `version` is identical on every endpoint
126
+ * that serves the same order state and never advances without a state
127
+ * change, whereas `updatedAt` carries a different clock per endpoint (order
128
+ * detail reports the matching-engine event time, order lists report the
129
+ * database commit time) and can move without the order changing.
130
+ */
131
+ version?: number;
87
132
  }
88
133
  /** Stable terminal causes for accepted orders that end as CANCELLED. */
89
134
  export type OrderTerminalReason = "USER_REQUESTED" | "REPLACED" | "LIQUIDATION" | "INSUFFICIENT_MARGIN" | "REDUCE_ONLY_EXHAUSTED" | "POSITION_CLOSED" | "OCO_SIBLING_TRIGGERED" | "SYSTEM";
@@ -456,6 +456,28 @@ export interface ConditionalOrder {
456
456
  failureReason?: string;
457
457
  createdAt: string;
458
458
  updatedAt: string;
459
+ /**
460
+ * Opaque, compare-only revision counter for this conditional order's state —
461
+ * the sequencer step that wrote it (0XM-2440). A strictly higher value is
462
+ * strictly newer state for that conditional order.
463
+ *
464
+ * Present on REST reads and on the subscribe-time `conditional_orders`
465
+ * snapshot frame. **Absent on live conditional events**, by design: those are
466
+ * emitted from a model captured before the sequencer acted, so the only value
467
+ * available there is the one the row held *before* the change being
468
+ * announced — a client merging on `>=` would let a snapshot read at that
469
+ * version win the tie and undo the transition.
470
+ *
471
+ * So seed conditional state from the snapshot and REST, comparing with
472
+ * `snapshot.version >= local.version`, and apply live events as state without
473
+ * ranking them. `>=` rather than `>`: one sequencer step can write several
474
+ * conditional rows (a trigger writes the triggered row and cancels its OCO
475
+ * sibling), so equal means "same step", not identical state.
476
+ *
477
+ * Absent means unknown — a row last written before the field existed — never
478
+ * zero. Wire: `version`.
479
+ */
480
+ version?: number;
459
481
  }
460
482
  export interface ListConditionalOrdersResponse {
461
483
  orders: ConditionalOrder[];
@@ -90,6 +90,28 @@ export interface ConditionalOrderEventData {
90
90
  */
91
91
  reason: string;
92
92
  updatedAt: string;
93
+ /**
94
+ * Opaque, compare-only revision counter for this conditional order's state —
95
+ * the sequencer step that wrote it (0XM-2440). A strictly higher value is
96
+ * strictly newer state for that conditional order.
97
+ *
98
+ * Present on REST reads and on the subscribe-time `conditional_orders`
99
+ * snapshot frame. **Absent on live conditional events**, by design: those are
100
+ * emitted from a model captured before the sequencer acted, so the only value
101
+ * available there is the one the row held *before* the change being
102
+ * announced — a client merging on `>=` would let a snapshot read at that
103
+ * version win the tie and undo the transition.
104
+ *
105
+ * So seed conditional state from the snapshot and REST, comparing with
106
+ * `snapshot.version >= local.version`, and apply live events as state without
107
+ * ranking them. `>=` rather than `>`: one sequencer step can write several
108
+ * conditional rows (a trigger writes the triggered row and cancels its OCO
109
+ * sibling), so equal means "same step", not identical state.
110
+ *
111
+ * Absent means unknown — a row last written before the field existed — never
112
+ * zero. Wire: `version`.
113
+ */
114
+ version?: number;
93
115
  }
94
116
  export interface ConditionalOrderEvent {
95
117
  eventType: "conditional_order_update";
@@ -79,6 +79,26 @@ export interface CommonOrderEventData {
79
79
  * silence. Omitted when the order carried none. Wire: `client_order_id`.
80
80
  */
81
81
  clientOrderId?: string;
82
+ /**
83
+ * Sequencer step that produced this event (0XM-2440) — the SAME counter
84
+ * `getOrder` and `getPaginatedOrders` return, so the two are directly
85
+ * comparable. Higher is strictly newer for that order.
86
+ *
87
+ * This is what makes a reconnect reconcilable without buffering: apply
88
+ * events as they arrive, and when the REST snapshot lands take the snapshot
89
+ * for an order when `snapshot.version >= local.version`, else keep local.
90
+ *
91
+ * **Equal does NOT mean identical state here.** One sequencer step emits
92
+ * several events for one order (an `OrderPlaced` and then its fills), and a
93
+ * batch place/replace shares one step across every item — so equal means
94
+ * "same step". A snapshot row is that step's FINAL state, which is why the
95
+ * rule is `>=` and not `>`: on a tie the snapshot is the authority.
96
+ *
97
+ * Values are sparse per order (it comes from a global sequence) and are not
98
+ * comparable between different orders. Omitted, never zero, when unknown —
99
+ * an order last written before the field existed. Wire: `version`.
100
+ */
101
+ version?: number;
82
102
  /**
83
103
  * `true` when the order was admitted post-only (maker-only), so a subscriber
84
104
  * can confirm the flag was honoured without a round trip to `getOrder`.
@@ -3167,6 +3167,12 @@ export interface components {
3167
3167
  parentOrderId?: string | null;
3168
3168
  associationType?: string | null;
3169
3169
  activatedAt?: string | null;
3170
+ /**
3171
+ * Format: int64
3172
+ * @description Opaque, compare-only revision counter for this conditional order's state: the sequencer step that wrote it. A strictly higher value is strictly newer state for that conditional order. The SAME counter is carried on the `conditional_orders` WebSocket SNAPSHOT frame — but deliberately NOT on the live `conditional_orders` events, which build from the row as it stood before the sequencer acted and so could only report the version the row held BEFORE the change they announce. So seed conditional state from the snapshot frame and REST, reconciling on `(conditionalOrderId, version)` — take the REST row when `snapshot.version >= local.version`, else keep local state — and apply the live events as state without ranking them. Note `>=`, not `>`: equal versions mean the SAME STEP rather than identical state, because one step can write several conditional rows (a trigger writes the triggered row and cancels its OCO sibling under one step). A REST row is that step's FINAL state, so it wins a tie. One consequence to plan for: the snapshot is read from the database, which lags the matching engine, so a transition that fires during the read is in neither the snapshot nor the delivered stream and cannot be ranked — re-read the affected rows if a conditional order's state matters at reconnect. Do not read anything else into the number: it is drawn from the same global sequence plain orders use, so values are sparse, gaps are normal, and it is not comparable across different conditional orders — nor against a plain order's version. Absent means unknown: a row last written before this field existed. Fall back to a full field comparison for those rather than treating absent as version zero.
3173
+ * @example 918342
3174
+ */
3175
+ version?: number | null;
3170
3176
  };
3171
3177
  CreateDelegatedSessionRequest: {
3172
3178
  /**
@@ -4527,6 +4533,12 @@ export interface components {
4527
4533
  * @example false
4528
4534
  */
4529
4535
  postOnly?: boolean | null;
4536
+ /**
4537
+ * Format: int64
4538
+ * @description Opaque, compare-only revision counter for this order's state: the sequencer step that wrote it. A strictly higher value is strictly newer state for that order. The SAME counter is carried on every order WebSocket event and on the `orders` snapshot frame, so a reconnecting client reconciles on `(id, version)` — take the REST row when `snapshot.version >= local.version`, else keep local state. Note `>=`, not `>`: on the stream, equal versions mean the SAME STEP rather than identical state, because one step emits several events for one order (an `OrderPlaced` and then its fills) and a batch shares one step across every item. A REST row is that step's FINAL state, so it wins a tie. Between two REST reads the comparison is simpler — equal there does mean identical state. Do not read anything else into the number: it is not a count of updates, consecutive values are not expected (it is drawn from a global sequence shared by every order, so per-order values are sparse and gaps are normal), and it is not comparable across different orders. Absent means unknown: an order last written before this field existed. Fall back to a full field comparison for those rather than treating absent as version zero — and note that a comparison against an absent value is false in both directions, so an order held locally without one is never refreshed by the merge above; take the REST row unconditionally for those. Reconciling on this counter does NOT on its own close a reconnect gap: an order that filled or was cancelled while the socket was down appears in neither the resting snapshot nor the stream, so recover fills from `listUserTrades` (ordered by execution time) and resolve anything your local state believes is resting that the snapshot no longer lists with a targeted `getOrder`. Unlike `updatedAt`, this value is identical on every REST endpoint that serves the same order state, and never advances without a state change.
4539
+ * @example 918342
4540
+ */
4541
+ version?: number | null;
4530
4542
  };
4531
4543
  /** @description Orderbook snapshot with token metadata and sequence number. */
4532
4544
  GetOrderbookResponse: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/types",
3
- "version": "1.0.50-develop.9c1b239",
3
+ "version": "1.0.51",
4
4
  "type": "module",
5
5
  "homepage": "https://docs.0xmonaco.com/sdk/typescript",
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "lint": "biome lint ."
17
17
  },
18
18
  "dependencies": {
19
- "@0xmonaco/contracts": "1.0.50-develop.9c1b239",
19
+ "@0xmonaco/contracts": "1.0.51",
20
20
  "zod": "^4.1.12"
21
21
  },
22
22
  "peerDependencies": {