@0xmonaco/types 1.0.47 → 1.0.48
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.
|
@@ -32,6 +32,42 @@ export interface MarginAccountSummary {
|
|
|
32
32
|
unrealizedPnl: string;
|
|
33
33
|
realizedPnl: string;
|
|
34
34
|
updatedAt: string;
|
|
35
|
+
/**
|
|
36
|
+
* The collateral still available to open NEW orders in this risk bucket:
|
|
37
|
+
* the largest increase in the bucket's worst-case order reserve the risk
|
|
38
|
+
* engine's admission gate accepts, automatic top-up from the parent margin
|
|
39
|
+
* account's unallocated capacity included. Zero while the account or bucket
|
|
40
|
+
* is frozen for liquidation, and for an isolated bucket whose market is
|
|
41
|
+
* halted (a cross bucket's market is chosen per order, so a halt cannot be
|
|
42
|
+
* folded into its figure — a halted pair still refuses orders).
|
|
43
|
+
*
|
|
44
|
+
* The trading-side sibling of `withdrawableCollateral`, and deliberately a
|
|
45
|
+
* different figure: this one credits an unrealized gain in full, because a
|
|
46
|
+
* gain is legitimate initial margin for new positions, while a withdrawal
|
|
47
|
+
* never counts one. It already contains the bucket's live free collateral —
|
|
48
|
+
* do not add `freeCollateral` or `unrealizedPnl` on top. It can also
|
|
49
|
+
* legitimately differ from this row's `freeCollateral`, a persisted
|
|
50
|
+
* reconstruction that cannot see the engine's worst-case resting-order
|
|
51
|
+
* reserve.
|
|
52
|
+
*
|
|
53
|
+
* NOT additive across rows: every bucket's figure includes the SAME parent
|
|
54
|
+
* unallocated headroom, so summing rows multiply-counts it, and committing
|
|
55
|
+
* collateral in one bucket shrinks its siblings' figures.
|
|
56
|
+
*
|
|
57
|
+
* This is a requirement budget, not an order size: an order is charged the
|
|
58
|
+
* increase it causes in the bucket's worst-case per-pair reserve, so a
|
|
59
|
+
* reducing, reduce-only, or opposite-side order sheltered by a larger
|
|
60
|
+
* resting ladder needs less or none of it (and can be admitted even when
|
|
61
|
+
* this field is zero), while an order crossing a losing position can need
|
|
62
|
+
* more than its own margin-plus-fee. Divide by a market's initial margin
|
|
63
|
+
* rate for indicative notional capacity; the authoritative per-order answer
|
|
64
|
+
* remains `simulateRiskBucketOrderRisk`.
|
|
65
|
+
*
|
|
66
|
+
* Present only on risk-bucket rows served from a live risk engine snapshot;
|
|
67
|
+
* absent (the key is omitted, never null) on parent rows and on
|
|
68
|
+
* persisted-fallback reads.
|
|
69
|
+
*/
|
|
70
|
+
availableOrderCollateral?: string;
|
|
35
71
|
}
|
|
36
72
|
export interface ListMarginAccountsParams {
|
|
37
73
|
page?: number;
|
|
@@ -203,6 +203,18 @@ export interface PortfolioRiskBucket {
|
|
|
203
203
|
* partial withdrawals below it.
|
|
204
204
|
*/
|
|
205
205
|
withdrawableCollateral: string;
|
|
206
|
+
/**
|
|
207
|
+
* The collateral still available to open NEW orders in this risk bucket —
|
|
208
|
+
* the same engine-served admission bound as
|
|
209
|
+
* `MarginAccountSummary.availableOrderCollateral` (see that field for the
|
|
210
|
+
* full semantics: an envelope delta with parent auto top-up included, NOT
|
|
211
|
+
* additive across rows, zero while frozen), truncated toward zero at quote
|
|
212
|
+
* decimals like `withdrawableCollateral` beside it.
|
|
213
|
+
*
|
|
214
|
+
* Present only when a live risk engine snapshot served the bound; absent
|
|
215
|
+
* (the key is omitted, never null) on persisted-fallback reads.
|
|
216
|
+
*/
|
|
217
|
+
availableOrderCollateral?: string;
|
|
206
218
|
}
|
|
207
219
|
export interface PortfolioMargin {
|
|
208
220
|
asOf: string;
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, OrderSide, OrderType, PositionSide, TimeInForce } from "../../trading";
|
|
2
|
+
/**
|
|
3
|
+
* The canonical `reason` values carried by a **live** conditional-order update.
|
|
4
|
+
*
|
|
5
|
+
* Not the complete set of strings the field can hold: the subscribe-time
|
|
6
|
+
* snapshot reuses this same data shape with the literal `"snapshot"`, and the
|
|
7
|
+
* wire field is a free-form server string rather than a closed enum, so this
|
|
8
|
+
* alias is documentation and a narrowing aid only. Match on it with a default
|
|
9
|
+
* branch; see `ConditionalOrderEventData.reason`.
|
|
10
|
+
*/
|
|
2
11
|
export type ConditionalOrderEventReason = "created" | "activated" | "cancelled" | "parent_cancelled" | "triggered" | "failed" | "oco_cancelled";
|
|
12
|
+
/**
|
|
13
|
+
* A conditional (TP/SL) order's current state.
|
|
14
|
+
*
|
|
15
|
+
* **The value unions below are the values the server can send today, not a
|
|
16
|
+
* runtime guarantee.** `@0xmonaco/core` parses this frame leniently — an
|
|
17
|
+
* unrecognized `orderType`, `state`, `side`, `positionSide`, `conditionType`,
|
|
18
|
+
* `triggerSource`, `associationType` or `timeInForce` is passed through as-is
|
|
19
|
+
* rather than validated, because throwing inside the WebSocket message handler
|
|
20
|
+
* would drop the entire update with nothing surfaced to the consumer
|
|
21
|
+
* (0XM-2627). Most of these unions mirror an exhaustive server-side mapping, so
|
|
22
|
+
* a value outside one means the server gained a variant this SDK version
|
|
23
|
+
* predates. `orderType` is the exception — its mapping ends in a catch-all arm,
|
|
24
|
+
* so its completeness rests on producer validation instead; see that field's
|
|
25
|
+
* own note.
|
|
26
|
+
*
|
|
27
|
+
* Consequently: match on these fields with a `default` branch rather than
|
|
28
|
+
* relying on exhaustiveness, exactly as you would for the free-form `reason`.
|
|
29
|
+
* A dropped frame is a worse failure than an unhandled value, so the parser
|
|
30
|
+
* chooses the latter — the same trade the position, liquidation and
|
|
31
|
+
* market-stats parsers already make.
|
|
32
|
+
*/
|
|
3
33
|
export interface ConditionalOrderEventData {
|
|
4
34
|
conditionalOrderId: string;
|
|
5
35
|
tradingPairId: string;
|
|
@@ -13,12 +43,35 @@ export interface ConditionalOrderEventData {
|
|
|
13
43
|
triggerPrice: string;
|
|
14
44
|
side: OrderSide;
|
|
15
45
|
positionSide: PositionSide;
|
|
46
|
+
/**
|
|
47
|
+
* Order shape the conditional order places when it triggers.
|
|
48
|
+
*
|
|
49
|
+
* `LIMIT` and `MARKET` are the complete set: both creation paths reject
|
|
50
|
+
* anything else — `orderType must be MARKET or LIMIT` from the TP/SL handler
|
|
51
|
+
* and `parent TP/SL order_type must be MARKET or LIMIT` from the matching
|
|
52
|
+
* engine's leg-shape check. The other server-side `OrderType` variants
|
|
53
|
+
* cannot reach this event.
|
|
54
|
+
*
|
|
55
|
+
* Unlike the other fields here, that rests on validation rather than on an
|
|
56
|
+
* exhaustive mapping: the server's `order_type` arm ends in a catch-all that
|
|
57
|
+
* Debug-formats and uppercases the variant, so were validation ever relaxed
|
|
58
|
+
* the value would arrive as e.g. `STOPLOSS` rather than the canonical
|
|
59
|
+
* `STOP_LOSS`. The parser passes such a value through untouched.
|
|
60
|
+
*/
|
|
16
61
|
orderType: OrderType;
|
|
17
62
|
limitPrice?: string;
|
|
18
63
|
quantity?: string;
|
|
19
64
|
slippageToleranceBps?: number;
|
|
20
65
|
reduceOnly: boolean;
|
|
21
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Time in force for a `LIMIT` conditional order; absent for `MARKET`.
|
|
68
|
+
*
|
|
69
|
+
* The full `TimeInForce` enum, not the `GTC`/`IOC` subset the creation paths
|
|
70
|
+
* validate: this field mirrors an unconstrained `time_in_force` column that
|
|
71
|
+
* the server maps exhaustively over every variant, so a value written by any
|
|
72
|
+
* other path reaches the wire as-is. Narrow before relying on the subset.
|
|
73
|
+
*/
|
|
74
|
+
timeInForce?: TimeInForce;
|
|
22
75
|
state: ConditionalOrderState;
|
|
23
76
|
triggeredOrderId?: string;
|
|
24
77
|
triggeredAt?: string;
|
|
@@ -26,7 +79,13 @@ export interface ConditionalOrderEventData {
|
|
|
26
79
|
cancelledAt?: string;
|
|
27
80
|
expiresAt?: string;
|
|
28
81
|
failureReason?: string;
|
|
29
|
-
|
|
82
|
+
/**
|
|
83
|
+
* What produced this update. Free-form on the wire — the server field is a
|
|
84
|
+
* plain string, not an enum — but a live update's canonical values are the
|
|
85
|
+
* ones listed on {@link ConditionalOrderEventReason}. The subscribe-time
|
|
86
|
+
* snapshot builds the same shape with `"snapshot"` instead.
|
|
87
|
+
*/
|
|
88
|
+
reason: string;
|
|
30
89
|
updatedAt: string;
|
|
31
90
|
}
|
|
32
91
|
export interface ConditionalOrderEvent {
|
package/dist/wire/schema.d.ts
CHANGED
|
@@ -4064,6 +4064,14 @@ export interface components {
|
|
|
4064
4064
|
riskBucketId?: string | null;
|
|
4065
4065
|
marginMode?: string | null;
|
|
4066
4066
|
selectedTradingPairIds?: string[] | null;
|
|
4067
|
+
/**
|
|
4068
|
+
* @description See `MarginAccountSummary.available_order_collateral`: the collateral
|
|
4069
|
+
* still available to open NEW orders in this risk bucket, the risk engine
|
|
4070
|
+
* admission gate's own bound with parent auto top-up included. Present only
|
|
4071
|
+
* on risk-bucket rows served from a live engine snapshot; absent on parent
|
|
4072
|
+
* rows and persisted-fallback reads.
|
|
4073
|
+
*/
|
|
4074
|
+
availableOrderCollateral?: string | null;
|
|
4067
4075
|
};
|
|
4068
4076
|
GetMarkPriceResponse: {
|
|
4069
4077
|
/** Format: uuid */
|
|
@@ -5706,6 +5714,42 @@ export interface components {
|
|
|
5706
5714
|
marginMode?: string | null;
|
|
5707
5715
|
/** @description Present for cross risk-bucket summary rows. */
|
|
5708
5716
|
selectedTradingPairIds?: string[] | null;
|
|
5717
|
+
/**
|
|
5718
|
+
* @description The collateral still available to open NEW orders in this risk bucket:
|
|
5719
|
+
* the largest increase in the bucket's worst-case order reserve the risk
|
|
5720
|
+
* engine's admission gate accepts, automatic top-up from the parent margin
|
|
5721
|
+
* account's unallocated capacity included. Zero while the account or bucket
|
|
5722
|
+
* is frozen for liquidation, and for an isolated bucket whose market is
|
|
5723
|
+
* halted. (A cross bucket's market is chosen per order, so a halt cannot be
|
|
5724
|
+
* folded into its figure — a halted pair still refuses orders.)
|
|
5725
|
+
*
|
|
5726
|
+
* The trading-side sibling of `withdrawable_collateral`, and deliberately a
|
|
5727
|
+
* different figure: this one credits an unrealized gain in full, because a
|
|
5728
|
+
* gain is legitimate initial margin for new positions, while a withdrawal
|
|
5729
|
+
* never counts one. It already contains the bucket's live free collateral —
|
|
5730
|
+
* do not add `free_collateral` or `unrealized_pnl` on top. It can also
|
|
5731
|
+
* legitimately differ from this row's `free_collateral`, which is a
|
|
5732
|
+
* persisted reconstruction that cannot see the engine's worst-case
|
|
5733
|
+
* resting-order reserve.
|
|
5734
|
+
*
|
|
5735
|
+
* NOT additive across rows: every bucket's figure includes the SAME parent
|
|
5736
|
+
* unallocated headroom, so summing rows multiply-counts it, and committing
|
|
5737
|
+
* collateral in one bucket shrinks its siblings' figures.
|
|
5738
|
+
*
|
|
5739
|
+
* This is a requirement budget, not an order size: an order is charged the
|
|
5740
|
+
* increase it causes in the bucket's worst-case per-pair reserve, so a
|
|
5741
|
+
* reducing, reduce-only, or opposite-side order sheltered by a larger
|
|
5742
|
+
* resting ladder needs less or none of it (and can be admitted even when
|
|
5743
|
+
* this field is zero), while an order crossing a losing position can need
|
|
5744
|
+
* more than its own margin-plus-fee. Divide by a market's initial margin
|
|
5745
|
+
* rate for indicative notional capacity; the authoritative per-order answer
|
|
5746
|
+
* remains `simulate_risk_bucket_order_risk`.
|
|
5747
|
+
*
|
|
5748
|
+
* Present only on risk-bucket summary rows served from a live risk engine
|
|
5749
|
+
* snapshot; absent on parent rows and on persisted-fallback reads, where
|
|
5750
|
+
* neither of the gate's terms is reconstructable.
|
|
5751
|
+
*/
|
|
5752
|
+
availableOrderCollateral?: string | null;
|
|
5709
5753
|
};
|
|
5710
5754
|
MatchResult: {
|
|
5711
5755
|
/**
|
|
@@ -6081,6 +6125,19 @@ export interface components {
|
|
|
6081
6125
|
* may carry sub-tick tails).
|
|
6082
6126
|
*/
|
|
6083
6127
|
withdrawableCollateral?: string | null;
|
|
6128
|
+
/**
|
|
6129
|
+
* @description The collateral still available to open NEW orders in this risk bucket —
|
|
6130
|
+
* the same engine-served admission bound as
|
|
6131
|
+
* `MarginAccountSummary.available_order_collateral` (see that field for the
|
|
6132
|
+
* full semantics: an envelope delta with parent auto top-up included, NOT
|
|
6133
|
+
* additive across rows, zero while frozen), truncated toward zero at quote
|
|
6134
|
+
* decimals like `withdrawable_collateral` beside it.
|
|
6135
|
+
*
|
|
6136
|
+
* Present only when a live risk engine snapshot served the bound; absent on
|
|
6137
|
+
* persisted-fallback reads, where neither of the gate's terms is
|
|
6138
|
+
* reconstructable.
|
|
6139
|
+
*/
|
|
6140
|
+
availableOrderCollateral?: string | null;
|
|
6084
6141
|
};
|
|
6085
6142
|
PortfolioSeriesWindow: {
|
|
6086
6143
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.48",
|
|
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.
|
|
19
|
+
"@0xmonaco/contracts": "1.0.48",
|
|
20
20
|
"zod": "^4.1.12"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|