@0xmonaco/types 1.0.58-develop.f12e78b → 1.0.59

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.
@@ -125,9 +125,13 @@ export interface Position {
125
125
  * independent live matching-engine read rather than from the versioned row,
126
126
  * so it can reflect a later command than the version names and must be
127
127
  * taken from the newer payload. Also still take
128
- * `markPrice`, `unrealizedPnl`, `liquidationPrice` and `leverage` from the
129
- * newer payload: those four are re-derived from the oracle mark on every
130
- * read, carry no version, and the version does not advance for them.
128
+ * `markPrice`, `unrealizedPnl`, `liquidationPrice`, `leverage`,
129
+ * `maintenanceMarginRequired` and `initialMarginRequired` from the newer
130
+ * payload: those six are re-derived on every read rather than served from
131
+ * the versioned row, carry no version, and the version does not advance for
132
+ * them. Five move with the oracle mark; `leverage` does not, but the live
133
+ * surfaces derive it while the persisted row serves its stored column, so it
134
+ * can still disagree at an unchanged version.
131
135
  * Discarding a whole payload on an equal version freezes displayed PnL
132
136
  * until the position's next real mutation.
133
137
  *
@@ -8,6 +8,7 @@
8
8
  * Detected broadcast lag closes the connection with 1013 and requires resync.
9
9
  * A lost terminal position update need not have a later replacement.
10
10
  */
11
+ import type { MarginMode } from "../../margin-accounts";
11
12
  /**
12
13
  * Position side. The server emits `LONG` or `SHORT` for an open position.
13
14
  */
@@ -55,6 +56,50 @@ export interface PositionEventData {
55
56
  isolatedMargin: string;
56
57
  /** Effective leverage (decimal string) */
57
58
  leverage: string;
59
+ /**
60
+ * Risk bucket that scopes this position's margin (UUID) — the same
61
+ * `riskBucketId` REST returns (0XM-2668). Omitted only for a legacy
62
+ * unbucketed position, and on a terminal frame whose close came back through
63
+ * the durable log rather than in-band.
64
+ */
65
+ riskBucketId?: string;
66
+ /**
67
+ * Margin mode of `riskBucketId`: `CROSS` or `ISOLATED`, the same `marginMode`
68
+ * REST returns (0XM-2668). Omitted for a position with no risk bucket, since
69
+ * there is then no mode to report.
70
+ *
71
+ * Do NOT infer it from `riskBucketId` in either direction. The two are
72
+ * resolved from different sources — the bucket id from the position, the mode
73
+ * from the risk engine when it holds the position and from the bucket row
74
+ * otherwise — so an id can arrive with no mode: a terminal row whose bucket
75
+ * record is unavailable, a read taken while the engine is unreachable, or a
76
+ * producer older than this field. Treat a missing mode as unknown and leave
77
+ * the position's mode unchanged; defaulting it to `CROSS` mis-renders an
78
+ * isolated position's backing.
79
+ *
80
+ * VERSIONED: a position's mode changes only on a real mutation, never on an
81
+ * oracle tick. See `version`.
82
+ */
83
+ marginMode?: MarginMode | (string & {});
84
+ /**
85
+ * Maintenance margin this position requires at `markPrice` (decimal string),
86
+ * the same `maintenanceMarginRequired` REST returns (0XM-2668). `"0"` when
87
+ * the position has no open exposure, so a terminal frame reports zero rather
88
+ * than omitting it.
89
+ *
90
+ * UNVERSIONED: re-derived from the oracle mark on every frame. See `version`
91
+ * for the whole unversioned group.
92
+ */
93
+ maintenanceMarginRequired?: string;
94
+ /**
95
+ * Initial margin this position requires at `markPrice` (decimal string),
96
+ * honoring both its effective leverage and the market initial-margin floor —
97
+ * the same `initialMarginRequired` REST returns (0XM-2668). `"0"` when the
98
+ * position has no open exposure.
99
+ *
100
+ * UNVERSIONED, for the same reason as `maintenanceMarginRequired`.
101
+ */
102
+ initialMarginRequired?: string;
58
103
  /** Trade that caused the update, when driven by a fill (UUID). Omitted otherwise. */
59
104
  tradeId?: string;
60
105
  /** Order that caused the update, when driven by an order (UUID). Omitted otherwise. */
@@ -65,7 +110,29 @@ export interface PositionEventData {
65
110
  * `margin_reduced`, `margin_collateral_transfer`.
66
111
  */
67
112
  reason: string;
68
- /** Timestamp when the position state was updated (ISO 8601) */
113
+ /**
114
+ * When the position was last MUTATED (ISO 8601) — a fill, collateral
115
+ * transfer, funding settlement or close.
116
+ *
117
+ * Read from the producer's own record of the mutation, never stamped while
118
+ * the frame is serialized (0XM-2668), so two frames for a position nothing
119
+ * has changed repeat one timestamp and a valuation-only oracle reprice does
120
+ * not move it. Do not use it as a reconciliation key — that is `version`'s
121
+ * job; this is display metadata.
122
+ *
123
+ * It matches a REST read of the same OPEN position exactly. Two cases come
124
+ * from the server's persistence clock instead and differ by the persistence
125
+ * lag: a TERMINAL row (this frame carries the engine's close instant, a
126
+ * terminal REST read carries the stored one), and any position read after a
127
+ * matching-engine restart. Accurate to that lag, not to the microsecond.
128
+ *
129
+ * A third case is not lag-bounded: while the server's matching engine is
130
+ * unreachable, a REST read of an OPEN position falls back to that row's
131
+ * lifecycle timestamps and can report the position's opening instant until
132
+ * funding settles. This frame is unaffected — it is built from engine state
133
+ * — so a REST value OLDER than a frame you already hold is expected during
134
+ * that window, and the frame is the fresher one.
135
+ */
69
136
  updatedAt: string;
70
137
  /**
71
138
  * Opaque, non-negative producer-owned row version for this position
@@ -94,10 +161,14 @@ export interface PositionEventData {
94
161
  * than from the versioned row, so it can reflect a later command than the
95
162
  * version names and must be taken from the newer payload or you retain
96
163
  * stale backing. Also still take `markPrice`, `unrealizedPnl`,
97
- * `liquidationPrice` and `leverage` from the newer frame: those four are
98
- * re-derived from the oracle mark on every frame, carry no version, and the
99
- * version does not advance for them. Discarding an equal-version frame
100
- * wholesale freezes displayed unrealized PnL until the position's next real
164
+ * `liquidationPrice`, `leverage`, `maintenanceMarginRequired` and
165
+ * `initialMarginRequired` from the newer frame: those six are re-derived
166
+ * per frame rather than served from the versioned row, carry no version,
167
+ * and the version does not advance for them. Five move with the oracle
168
+ * mark; `leverage` does not — it is opening notional over posted margin —
169
+ * but the live surfaces derive it while a persisted read serves the row's
170
+ * stored column, so it can still disagree at an unchanged version. Discarding an equal-version frame wholesale
171
+ * freezes displayed unrealized PnL until the position's next real
101
172
  * mutation — up to the one-hour funding interval.
102
173
  *
103
174
  * A frame is ranked only when it is a faithful projection of the row
@@ -5321,6 +5321,30 @@ export interface components {
5321
5321
  */
5322
5322
  liquidationPrice?: string | null;
5323
5323
  status?: string | null;
5324
+ /**
5325
+ * @description RFC 3339 instant at which this position was last MUTATED — a fill,
5326
+ * collateral transfer, funding settlement or close — as the producer that
5327
+ * owns the position recorded it. It is NOT the instant the response was
5328
+ * built: polling an unchanged position returns the same value, and an oracle
5329
+ * reprice does not move it. For an OPEN position every surface reports the
5330
+ * same instant — the list, the detail read, the risk read, the WebSocket
5331
+ * positions snapshot, and the live position_update frames.
5332
+ *
5333
+ * Two cases come from the persistence clock instead and differ from the
5334
+ * matching engine's by the persistence lag: a TERMINAL row (the live
5335
+ * position_update frame carries the engine's close instant, this field
5336
+ * carries the stored one), and any position read after a matching-engine
5337
+ * restart. Accurate to that lag, not to the microsecond.
5338
+ *
5339
+ * A third case is not lag-bounded: an OPEN row read while the matching
5340
+ * engine is unreachable falls back to the row's own lifecycle columns
5341
+ * (close, then last funding, then open), so a position filled repeatedly
5342
+ * since it opened reports its opening instant until funding settles. The
5343
+ * live position_update frame is unaffected.
5344
+ *
5345
+ * Display metadata. `version` is the reconciliation key; ordering position
5346
+ * state by this field is never correct.
5347
+ */
5324
5348
  updatedAt?: string | null;
5325
5349
  riskBucketId?: string | null;
5326
5350
  marginMode?: string | null;
@@ -5374,7 +5398,7 @@ export interface components {
5374
5398
  cumFees?: string | null;
5375
5399
  /**
5376
5400
  * Format: int64
5377
- * @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price and leverage are UNVERSIONED valuation fields re-derived from the oracle mark on every frame: the version does not advance for them (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, does restamp the account's open positions), so the merge rule is per field group — on an equal version skip the versioned fields but still take those four from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
5401
+ * @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, does restamp the account's open positions), so the merge rule is per field group — on an equal version skip the versioned fields but still take all six from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL and can leave a stale margin requirement on screen. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
5378
5402
  * @example 918342
5379
5403
  */
5380
5404
  version?: number | null;
@@ -5414,6 +5438,30 @@ export interface components {
5414
5438
  * position has no open exposure.
5415
5439
  */
5416
5440
  initialMarginRequired?: string | null;
5441
+ /**
5442
+ * @description RFC 3339 instant at which this position was last MUTATED — a fill,
5443
+ * collateral transfer, funding settlement or close — as the producer that
5444
+ * owns the position recorded it. It is NOT the instant the response was
5445
+ * built: polling an unchanged position returns the same value, and an oracle
5446
+ * reprice does not move it. For an OPEN position every surface reports the
5447
+ * same instant — the list, the detail read, the risk read, the WebSocket
5448
+ * positions snapshot, and the live position_update frames.
5449
+ *
5450
+ * Two cases come from the persistence clock instead and differ from the
5451
+ * matching engine's by the persistence lag: a TERMINAL row (the live
5452
+ * position_update frame carries the engine's close instant, this field
5453
+ * carries the stored one), and any position read after a matching-engine
5454
+ * restart. Accurate to that lag, not to the microsecond.
5455
+ *
5456
+ * A third case is not lag-bounded: an OPEN row read while the matching
5457
+ * engine is unreachable falls back to the row's own lifecycle columns
5458
+ * (close, then last funding, then open), so a position filled repeatedly
5459
+ * since it opened reports its opening instant until funding settles. The
5460
+ * live position_update frame is unaffected.
5461
+ *
5462
+ * Display metadata. `version` is the reconciliation key; ordering position
5463
+ * state by this field is never correct.
5464
+ */
5417
5465
  updatedAt?: string | null;
5418
5466
  };
5419
5467
  GetProfileResponse: {
@@ -6829,6 +6877,30 @@ export interface components {
6829
6877
  */
6830
6878
  liquidationPrice?: string | null;
6831
6879
  status?: string | null;
6880
+ /**
6881
+ * @description RFC 3339 instant at which this position was last MUTATED — a fill,
6882
+ * collateral transfer, funding settlement or close — as the producer that
6883
+ * owns the position recorded it. It is NOT the instant the response was
6884
+ * built: polling an unchanged position returns the same value, and an oracle
6885
+ * reprice does not move it. For an OPEN position every surface reports the
6886
+ * same instant — the list, the detail read, the risk read, the WebSocket
6887
+ * positions snapshot, and the live position_update frames.
6888
+ *
6889
+ * Two cases come from the persistence clock instead and differ from the
6890
+ * matching engine's by the persistence lag: a TERMINAL row (the live
6891
+ * position_update frame carries the engine's close instant, this field
6892
+ * carries the stored one), and any position read after a matching-engine
6893
+ * restart. Accurate to that lag, not to the microsecond.
6894
+ *
6895
+ * A third case is not lag-bounded: an OPEN row read while the matching
6896
+ * engine is unreachable falls back to the row's own lifecycle columns
6897
+ * (close, then last funding, then open), so a position filled repeatedly
6898
+ * since it opened reports its opening instant until funding settles. The
6899
+ * live position_update frame is unaffected.
6900
+ *
6901
+ * Display metadata. `version` is the reconciliation key; ordering position
6902
+ * state by this field is never correct.
6903
+ */
6832
6904
  updatedAt?: string | null;
6833
6905
  riskBucketId?: string | null;
6834
6906
  marginMode?: string | null;
@@ -6882,7 +6954,7 @@ export interface components {
6882
6954
  cumFees?: string | null;
6883
6955
  /**
6884
6956
  * Format: int64
6885
- * @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: it means the row predates this field or came from a producer that does not stamp it, so treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price and leverage are UNVERSIONED valuation fields re-derived from the oracle mark on every frame: the version does not advance for them (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, does restamp the account's open positions), so the merge rule is per field group — on an equal version skip the versioned fields but still take those four from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
6957
+ * @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: it means the row predates this field or came from a producer that does not stamp it, so treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, does restamp the account's open positions), so the merge rule is per field group — on an equal version skip the versioned fields but still take all six from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL and can leave a stale margin requirement on screen. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
6886
6958
  * @example 918342
6887
6959
  */
6888
6960
  version?: number | null;
@@ -9996,6 +10068,13 @@ export interface operations {
9996
10068
  };
9997
10069
  content?: never;
9998
10070
  };
10071
+ /** @description Authentication rate limit exceeded — challenge and verify share one per-client-address budget (60 requests/min sustained, burst 120); retry after the interval in details.retryAfter */
10072
+ 429: {
10073
+ headers: {
10074
+ [name: string]: unknown;
10075
+ };
10076
+ content?: never;
10077
+ };
9999
10078
  /** @description Internal server error */
10000
10079
  500: {
10001
10080
  headers: {
@@ -10152,6 +10231,13 @@ export interface operations {
10152
10231
  };
10153
10232
  content?: never;
10154
10233
  };
10234
+ /** @description Authentication rate limit exceeded — challenge and verify share one per-client-address budget (60 requests/min sustained, burst 120), checked before the signature; retry after the interval in details.retryAfter */
10235
+ 429: {
10236
+ headers: {
10237
+ [name: string]: unknown;
10238
+ };
10239
+ content?: never;
10240
+ };
10155
10241
  /** @description Internal server error */
10156
10242
  500: {
10157
10243
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/types",
3
- "version": "1.0.58-develop.f12e78b",
3
+ "version": "1.0.59",
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.58-develop.f12e78b",
19
+ "@0xmonaco/contracts": "1.0.59",
20
20
  "zod": "^4.1.12"
21
21
  },
22
22
  "peerDependencies": {