@0xmonaco/types 1.0.39 → 1.0.41-develop.ebb62ed

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.
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Market-stats WebSocket Event Types
3
+ *
4
+ * Types for the two real-time market statistics channels:
5
+ * - per-market (`market_stats:<tradingPairId>`): a full stats frame for one
6
+ * market, carried by `MarketStatsEvent`.
7
+ * - all-markets (`market_stats`): one summary row per market in a single frame,
8
+ * carried by `MarketStatsAllEvent`.
9
+ *
10
+ * Both are public channels (no authentication). Lag policy is Conflate: a
11
+ * lagging subscriber is fast-forwarded to the latest frame rather than
12
+ * disconnected. Each frame carries the market's full current stats, so consume
13
+ * it as a terminal-state snapshot, never as an additive delta.
14
+ *
15
+ * Perp-only fields (index/mark price, open interest, funding) are optional and
16
+ * omitted on the wire for spot markets, which have no positions or funding.
17
+ * All numeric quantities are decimal strings except `fundingTimestamp`, which
18
+ * is a millisecond epoch number.
19
+ */
20
+ /**
21
+ * Market tradability label, derived from the oracle market status. Spot markets
22
+ * only emit `TRADABLE` or `HALTED`.
23
+ */
24
+ export type MarketStatus = "TRADABLE" | "POST_ONLY" | "HALTED" | "NOT_READY" | "UNKNOWN";
25
+ /**
26
+ * Full per-market statistics for the `market_stats:<tradingPairId>` channel.
27
+ */
28
+ export interface MarketStatsData {
29
+ /** Market symbol, e.g. "BTC/USDC" */
30
+ symbol: string;
31
+ /** Trading pair identifier (UUID) */
32
+ tradingPairId: string;
33
+ /** Oracle index price (decimal string). Perp-only; omitted for spot. */
34
+ indexPrice?: string;
35
+ /** Mark price (decimal string). Perp-only; omitted for spot. */
36
+ markPrice?: string;
37
+ /** Mid price between best bid and best ask (decimal string) */
38
+ midPrice?: string;
39
+ /** Best bid price (decimal string) */
40
+ bestBidPrice?: string;
41
+ /** Best ask price (decimal string) */
42
+ bestAskPrice?: string;
43
+ /** Open interest (decimal string). Perp-only; omitted for spot. */
44
+ openInterest?: string;
45
+ /** Open interest limit (decimal string). Perp-only; omitted for spot. */
46
+ openInterestLimit?: string;
47
+ /** Last trade price (decimal string) */
48
+ lastTradePrice?: string;
49
+ /** 24h base-token volume (decimal string) */
50
+ dailyBaseTokenVolume?: string;
51
+ /** 24h quote-token volume (decimal string) */
52
+ dailyQuoteTokenVolume?: string;
53
+ /** 24h low price (decimal string) */
54
+ dailyPriceLow?: string;
55
+ /** 24h high price (decimal string) */
56
+ dailyPriceHigh?: string;
57
+ /** 24h absolute price change, `latestClose - open24hAgo` (decimal string) */
58
+ dailyPriceChange?: string;
59
+ /** 24h percentage price change, two decimals (decimal string) */
60
+ dailyPriceChangePercent?: string;
61
+ /** Current (last settled) funding rate (decimal string). Perp-only; omitted for spot. */
62
+ currentFundingRate?: string;
63
+ /** Estimated next-window funding rate (decimal string). Perp-only; omitted for spot. */
64
+ fundingRate?: string;
65
+ /** Next funding time as a millisecond epoch. Perp-only; omitted for spot. */
66
+ fundingTimestamp?: number;
67
+ /** Funding premium (decimal string). Perp-only; omitted for spot. */
68
+ premium?: string;
69
+ /** Base interest rate for the funding formula (decimal string). Perp-only; omitted for spot. */
70
+ baseInterestRate?: string;
71
+ /** Live funding cap, lower bound (decimal string). Perp-only; omitted for spot. */
72
+ fundingClampSmall?: string;
73
+ /** Live funding cap, upper bound (decimal string). Perp-only; omitted for spot. */
74
+ fundingClampBig?: string;
75
+ }
76
+ /**
77
+ * Per-market statistics event on the `market_stats:<tradingPairId>` channel.
78
+ */
79
+ export interface MarketStatsEvent {
80
+ /** Trading pair identifier (UUID) */
81
+ tradingPairId: string;
82
+ /** Market statistics for this pair */
83
+ data: MarketStatsData;
84
+ }
85
+ /**
86
+ * A single market's row in the all-markets summary frame. A lighter shape than
87
+ * {@link MarketStatsData}: enough to render a markets table.
88
+ */
89
+ export interface MarketStatsSummary {
90
+ /** Trading pair identifier (UUID) */
91
+ tradingPairId: string;
92
+ /** Market symbol, e.g. "BTC/USDC" */
93
+ symbol: string;
94
+ /** Last trade price (decimal string) */
95
+ lastTradePrice?: string;
96
+ /** Mark price (decimal string). Perp-only; omitted for spot. */
97
+ markPrice?: string;
98
+ /** 24h absolute price change (decimal string) */
99
+ dailyPriceChange?: string;
100
+ /** 24h percentage price change, two decimals (decimal string) */
101
+ dailyPriceChangePercent?: string;
102
+ /** 24h base-token volume (decimal string) */
103
+ dailyBaseTokenVolume?: string;
104
+ /** 24h quote-token volume (decimal string) */
105
+ dailyQuoteTokenVolume?: string;
106
+ /** 24h high price (decimal string) */
107
+ dailyPriceHigh?: string;
108
+ /** 24h low price (decimal string) */
109
+ dailyPriceLow?: string;
110
+ /** Open interest (decimal string). Perp-only; omitted for spot. */
111
+ openInterest?: string;
112
+ /** Current (last settled) funding rate (decimal string). Perp-only; omitted for spot. */
113
+ currentFundingRate?: string;
114
+ /** Next funding time as a millisecond epoch. Perp-only; omitted for spot. */
115
+ fundingTimestamp?: number;
116
+ /** Tradability label (always present) */
117
+ marketStatus: MarketStatus;
118
+ }
119
+ /**
120
+ * All-markets summary event on the `market_stats` channel: one
121
+ * {@link MarketStatsSummary} per market, in a single frame per push.
122
+ */
123
+ export interface MarketStatsAllEvent {
124
+ /** One summary row per market */
125
+ markets: MarketStatsSummary[];
126
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Market-stats WebSocket Event Types
3
+ *
4
+ * Types for the two real-time market statistics channels:
5
+ * - per-market (`market_stats:<tradingPairId>`): a full stats frame for one
6
+ * market, carried by `MarketStatsEvent`.
7
+ * - all-markets (`market_stats`): one summary row per market in a single frame,
8
+ * carried by `MarketStatsAllEvent`.
9
+ *
10
+ * Both are public channels (no authentication). Lag policy is Conflate: a
11
+ * lagging subscriber is fast-forwarded to the latest frame rather than
12
+ * disconnected. Each frame carries the market's full current stats, so consume
13
+ * it as a terminal-state snapshot, never as an additive delta.
14
+ *
15
+ * Perp-only fields (index/mark price, open interest, funding) are optional and
16
+ * omitted on the wire for spot markets, which have no positions or funding.
17
+ * All numeric quantities are decimal strings except `fundingTimestamp`, which
18
+ * is a millisecond epoch number.
19
+ */
@@ -13,10 +13,25 @@ export interface UserMovementEventData {
13
13
  id: string;
14
14
  /** Entry type (e.g., "credit", "debit") */
15
15
  entryType: string;
16
- /** Transaction type (e.g., "deposit", "withdrawal", "trade") */
16
+ /**
17
+ * Transaction type (e.g., "deposit", "withdrawal", "trade", "funding").
18
+ * A `funding` movement records a funding payment already settled against
19
+ * margin collateral; it reconciles with the matching `balance_update` event
20
+ * whose `reason` is `funding`.
21
+ */
17
22
  transactionType: string;
18
- /** Token contract address */
23
+ /** Movement status (e.g., "completed", "pending", "failed"). Wire: `status`. */
24
+ status?: string;
25
+ /** Token contract address. Wire: `token` (older payloads use the `token_address` alias). */
26
+ token?: Address;
27
+ /**
28
+ * Legacy alias for `token`, always populated from `token` (falling back to the
29
+ * `token_address` wire alias). Stays required for back-compat — every movement
30
+ * carries a token address — so existing consumers reading it don't break.
31
+ */
19
32
  tokenAddress: Address;
33
+ /** Asset registry id (UUID). Wire: `asset_id`. */
34
+ assetId?: string;
20
35
  /** Token symbol */
21
36
  symbol?: string;
22
37
  /** Token decimals */
@@ -49,6 +64,8 @@ export interface UserMovementEventData {
49
64
  description?: string;
50
65
  /** Transaction hash (if applicable) */
51
66
  txHash?: string;
67
+ /** Block number (if applicable). Wire: `block_number`. */
68
+ blockNumber?: number;
52
69
  /** Timestamp when the movement was created (ISO 8601) */
53
70
  createdAt?: string;
54
71
  }
@@ -59,6 +59,15 @@ export interface CommonOrderEventData {
59
59
  quantityRaw?: string;
60
60
  /** Time in force - present in most events */
61
61
  timeInForce?: TimeInForce;
62
+ /**
63
+ * Client-assigned correlation handle, echoed so an event can be matched to
64
+ * the request that placed the order without a round trip to `getOrder`.
65
+ * Carried on every order event that inherits these fields — placed, taker and
66
+ * maker fills, cancelled, rejected and expired — so a submit whose HTTP
67
+ * response was lost can be resolved from the stream alone. Omitted when the
68
+ * order carried none. Wire: `client_order_id`.
69
+ */
70
+ clientOrderId?: string;
62
71
  }
63
72
  /**
64
73
  * OrderPlaced event - emitted when a new order is placed
@@ -140,14 +149,23 @@ export interface OrderPartiallyFilledEvent extends OrderEvent {
140
149
  /** Execution price (maker orders only) */
141
150
  executionPrice?: string;
142
151
  /**
143
- * Quantity filled in this event (maker orders only). The wire field is
144
- * `filled_quantity` (→ `filledQuantity`); for a maker this is the current
145
- * trade's quantity. The previous `executionQuantity` never matched the
146
- * wire. For a taker the same-named field carries the cumulative order fill.
152
+ * Cumulative order fill so far, on EVERY role. The wire field is
153
+ * `filled_quantity` (→ `filledQuantity`); for both taker and maker it is
154
+ * the order's cumulative fill (a maker previously reported only the current
155
+ * trade's quantity here; the older `executionQuantity` never matched the
156
+ * wire at all). The per-event increment is `lastFillQuantity`.
147
157
  */
148
158
  filledQuantity?: string;
149
159
  /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
150
160
  filledQuantityRaw?: string;
161
+ /**
162
+ * Incremental quantity filled by THIS event: for a taker the summed
163
+ * quantity of the trades this event covers, for a maker this single trade's
164
+ * quantity. Omitted when the event carries no fill. Wire: `last_fill_quantity`.
165
+ */
166
+ lastFillQuantity?: string;
167
+ /** `lastFillQuantity` in RAW (integer, base-unit) precision. Wire: `last_fill_quantity_raw`. */
168
+ lastFillQuantityRaw?: string;
151
169
  /** `remainingQuantity` in RAW (integer, base-unit) precision. Wire: `remaining_quantity_raw`. */
152
170
  remainingQuantityRaw?: string;
153
171
  /**
@@ -200,14 +218,23 @@ export interface OrderFilledEvent extends OrderEvent {
200
218
  /** Execution price (maker orders only) */
201
219
  executionPrice?: string;
202
220
  /**
203
- * Quantity filled in this event (maker orders only). The wire field is
204
- * `filled_quantity` (→ `filledQuantity`); for a maker this is the current
205
- * trade's quantity. The previous `executionQuantity` never matched the
206
- * wire. For a taker the same-named field carries the cumulative order fill.
221
+ * Cumulative order fill so far, on EVERY role. The wire field is
222
+ * `filled_quantity` (→ `filledQuantity`); for both taker and maker it is
223
+ * the order's cumulative fill (a maker previously reported only the current
224
+ * trade's quantity here; the older `executionQuantity` never matched the
225
+ * wire at all). The per-event increment is `lastFillQuantity`.
207
226
  */
208
227
  filledQuantity?: string;
209
228
  /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
210
229
  filledQuantityRaw?: string;
230
+ /**
231
+ * Incremental quantity filled by THIS event: for a taker the summed
232
+ * quantity of the trades this event covers, for a maker this single trade's
233
+ * quantity. Omitted when the event carries no fill. Wire: `last_fill_quantity`.
234
+ */
235
+ lastFillQuantity?: string;
236
+ /** `lastFillQuantity` in RAW (integer, base-unit) precision. Wire: `last_fill_quantity_raw`. */
237
+ lastFillQuantityRaw?: string;
211
238
  /** `remainingQuantity` in RAW (integer, base-unit) precision. Wire: `remaining_quantity_raw`. */
212
239
  remainingQuantityRaw?: string;
213
240
  /**
@@ -231,6 +258,14 @@ export interface OrderCancelledEvent extends OrderEvent {
231
258
  reason?: string;
232
259
  /** Stable machine-readable cancellation cause */
233
260
  terminalReason?: OrderTerminalReason;
261
+ /**
262
+ * Cumulative order fill at cancellation, mirroring `filledQuantity` on the
263
+ * taker/maker fill events so consumers read one field across every order
264
+ * event (0XM-2389). `totalFilled` is retained as a legacy alias.
265
+ */
266
+ filledQuantity?: string;
267
+ /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
268
+ filledQuantityRaw?: string;
234
269
  /** Total filled quantity before cancellation */
235
270
  totalFilled?: string;
236
271
  /** `totalFilled` in RAW (integer, base-unit) precision. Wire: `total_filled_raw`. */
@@ -241,6 +276,16 @@ export interface OrderCancelledEvent extends OrderEvent {
241
276
  remainingQuantityRaw?: string;
242
277
  /** Number of trades executed before cancellation */
243
278
  tradesCount?: number;
279
+ /**
280
+ * Volume-weighted average fill price of the cancelled order, on the full
281
+ * (resting-order) cancel payload. Wire: `average_fill_price`.
282
+ */
283
+ averageFillPrice?: string;
284
+ /**
285
+ * Cancellation timestamp on the full (resting-order) cancel payload,
286
+ * RFC3339 with a `Z` suffix. Wire: `cancelled_at`.
287
+ */
288
+ cancelledAt?: string;
244
289
  };
245
290
  }
246
291
  /**
@@ -15,11 +15,12 @@ export type PositionEventSide = "LONG" | "SHORT";
15
15
  /**
16
16
  * Position lifecycle status.
17
17
  *
18
- * NOTE: this is PascalCase on the wire (`Open`, not `OPEN`) - the underlying
19
- * enum has no serde rename, unlike side/trading-mode fields. That asymmetry is
20
- * the live wire format and is preserved verbatim here.
18
+ * Matches the REST position status strings exactly (the server previously
19
+ * emitted PascalCase `Open`, which diverged from REST). Values are
20
+ * SCREAMING_SNAKE_CASE except a closing position, which REST and the wire
21
+ * report as `LIQUIDATING` (not `CLOSING`).
21
22
  */
22
- export type PositionEventStatus = "Open" | "Closing" | "Closed" | "Liquidated" | "Expired";
23
+ export type PositionEventStatus = "OPEN" | "LIQUIDATING" | "CLOSED" | "LIQUIDATED" | "EXPIRED";
23
24
  /**
24
25
  * Position event data containing the current state of a single position.
25
26
  */
@@ -32,7 +33,7 @@ export interface PositionEventData {
32
33
  tradingPairId: string;
33
34
  /** Position side */
34
35
  side: PositionEventSide;
35
- /** Position lifecycle status (PascalCase on the wire) */
36
+ /** Position lifecycle status (SCREAMING_SNAKE_CASE on the wire, e.g. "OPEN") */
36
37
  status: PositionEventStatus;
37
38
  /** Absolute position size (decimal string) */
38
39
  size: string;
@@ -48,7 +49,15 @@ export interface PositionEventData {
48
49
  isolatedMargin: string;
49
50
  /** Effective leverage (decimal string) */
50
51
  leverage: string;
51
- /** What triggered the update (e.g. "trade", free-form) */
52
+ /** Trade that caused the update, when driven by a fill (UUID). Omitted otherwise. */
53
+ tradeId?: string;
54
+ /** Order that caused the update, when driven by an order (UUID). Omitted otherwise. */
55
+ orderId?: string;
56
+ /**
57
+ * What triggered the update. Free-form, but the server uses a canonical set:
58
+ * `trade`, `close`, `liquidation`, `adl`, `funding`, `margin_added`,
59
+ * `margin_reduced`, `margin_collateral_transfer`.
60
+ */
52
61
  reason: string;
53
62
  /** Timestamp when the position state was updated (ISO 8601) */
54
63
  updatedAt: string;
@@ -10,6 +10,6 @@
10
10
  * hand-written SDK surface. CI regenerates it and fails on a diff, identical to
11
11
  * the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
12
12
  */
13
- export declare const OPERATION_IDS: readonly ["add_position_margin", "attach_position_tp_sl", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_conditional_order", "cancel_order", "check_trader_code_availability", "clear_trader_code", "close_position", "create_challenge", "create_delegated_session", "create_order", "create_sub_account_limit", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_candles", "get_conditional_order", "get_faucet_info", "get_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_trader_code", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_assets", "get_portfolio_chart", "get_portfolio_margin", "get_portfolio_performance", "get_portfolio_realized_pnl", "get_portfolio_stats", "get_portfolio_summary", "get_position", "get_position_pnl_history", "get_position_risk", "get_pulse", "get_rewards_balance", "get_screener", "get_sub_account_limits", "get_trade_by_id", "get_trader_code_info", "get_trades", "get_trading_pair_by_id", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_withdrawal", "health_check", "initiate_withdrawal", "list_all_funding_history", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_funding_history", "list_funding_payments", "list_margin_accounts", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "mint_tokens", "reduce_position_margin", "refresh_session", "register_deposit_address", "replace_order", "revoke_delegated_agent", "revoke_session", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "submit_whitelist", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
13
+ export declare const OPERATION_IDS: readonly ["attach_position_tp_sl", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_conditional_order", "cancel_order", "check_trader_code_availability", "clear_trader_code", "close_position", "create_challenge", "create_delegated_session", "create_order", "create_sub_account_limit", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_candles", "get_conditional_order", "get_faucet_info", "get_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_trader_code", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_assets", "get_portfolio_chart", "get_portfolio_margin", "get_portfolio_performance", "get_portfolio_realized_pnl", "get_portfolio_stats", "get_portfolio_summary", "get_position", "get_position_pnl_history", "get_position_risk", "get_pulse", "get_rewards_balance", "get_screener", "get_sub_account_limits", "get_trade_by_id", "get_trader_code_info", "get_trades", "get_trading_pair_by_id", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_withdrawal", "health_check", "initiate_withdrawal", "list_all_funding_history", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_funding_history", "list_funding_payments", "list_margin_accounts", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "mint_tokens", "refresh_session", "register_deposit_address", "replace_order", "revoke_delegated_agent", "revoke_session", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "submit_whitelist", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
14
14
  /** Union of every OpenAPI operationId in the spec. */
15
15
  export type OperationId = (typeof OPERATION_IDS)[number];
@@ -11,7 +11,6 @@
11
11
  * the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
12
12
  */
13
13
  export const OPERATION_IDS = [
14
- "add_position_margin",
15
14
  "attach_position_tp_sl",
16
15
  "batch_cancel_all",
17
16
  "batch_cancel_all_by_pair",
@@ -95,7 +94,6 @@ export const OPERATION_IDS = [
95
94
  "list_sub_accounts_with_balances",
96
95
  "list_trading_pairs",
97
96
  "mint_tokens",
98
- "reduce_position_margin",
99
97
  "refresh_session",
100
98
  "register_deposit_address",
101
99
  "replace_order",