@0xmonaco/types 1.0.25 → 1.0.26-develop.aeb6d5b

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.
@@ -60,6 +60,7 @@ export declare const AttachPositionTpSlSchema: z.ZodObject<{
60
60
  }>;
61
61
  limitPrice: z.ZodOptional<z.ZodString>;
62
62
  quantity: z.ZodOptional<z.ZodString>;
63
+ closePosition: z.ZodOptional<z.ZodBoolean>;
63
64
  timeInForce: z.ZodOptional<z.ZodEnum<{
64
65
  GTC: "GTC";
65
66
  IOC: "IOC";
@@ -75,6 +76,7 @@ export declare const AttachPositionTpSlSchema: z.ZodObject<{
75
76
  }>;
76
77
  limitPrice: z.ZodOptional<z.ZodString>;
77
78
  quantity: z.ZodOptional<z.ZodString>;
79
+ closePosition: z.ZodOptional<z.ZodBoolean>;
78
80
  timeInForce: z.ZodOptional<z.ZodEnum<{
79
81
  GTC: "GTC";
80
82
  IOC: "IOC";
@@ -82,6 +84,7 @@ export declare const AttachPositionTpSlSchema: z.ZodObject<{
82
84
  slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
83
85
  expiresAt: z.ZodOptional<z.ZodISODateTime>;
84
86
  }, z.core.$strip>>;
87
+ oco: z.ZodOptional<z.ZodBoolean>;
85
88
  }, z.core.$strip>;
86
89
  }, z.core.$strip>;
87
90
  export declare const ListPositionHistorySchema: z.ZodObject<{
@@ -60,6 +60,7 @@ const TpSlLegSchema = z
60
60
  orderType: OrderTypeSchema,
61
61
  limitPrice: PositiveDecimalStringSchema.optional(),
62
62
  quantity: PositiveDecimalStringSchema.optional(),
63
+ closePosition: z.boolean().optional(),
63
64
  timeInForce: ConditionalTimeInForceSchema.optional(),
64
65
  slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
65
66
  expiresAt: ISO8601DateSchema.optional(),
@@ -79,15 +80,28 @@ const TpSlLegSchema = z
79
80
  .refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
80
81
  message: "slippageToleranceBps is only allowed for MARKET TP/SL legs",
81
82
  path: ["slippageToleranceBps"],
83
+ })
84
+ .refine((data) => data.closePosition !== true || data.quantity === undefined, {
85
+ message: "quantity must be omitted when closePosition is true",
86
+ path: ["quantity"],
87
+ })
88
+ .refine((data) => data.quantity !== undefined || data.closePosition !== false, {
89
+ message: "quantity is required when closePosition is false",
90
+ path: ["closePosition"],
82
91
  });
83
92
  export const AttachPositionTpSlSchema = PositionIdSchema.extend({
84
93
  request: z
85
94
  .object({
86
95
  takeProfit: TpSlLegSchema.optional(),
87
96
  stopLoss: TpSlLegSchema.optional(),
97
+ oco: z.boolean().optional(),
88
98
  })
89
99
  .refine((data) => data.takeProfit !== undefined || data.stopLoss !== undefined, {
90
100
  message: "At least one of takeProfit or stopLoss is required",
101
+ })
102
+ .refine((data) => data.oco !== true || (data.takeProfit !== undefined && data.stopLoss !== undefined), {
103
+ message: "oco=true requires both takeProfit and stopLoss",
104
+ path: ["oco"],
91
105
  }),
92
106
  });
93
107
  export const ListPositionHistorySchema = PaginationSchema.extend({
@@ -19,12 +19,12 @@ export declare const LedgerEntryTypeSchema: z.ZodEnum<{
19
19
  * Transaction type validation
20
20
  */
21
21
  export declare const TransactionTypeSchema: z.ZodEnum<{
22
+ LIQUIDATION: "LIQUIDATION";
22
23
  FEE: "FEE";
23
24
  DEPOSIT: "DEPOSIT";
24
25
  WITHDRAWAL: "WITHDRAWAL";
25
26
  TRADE: "TRADE";
26
27
  FUNDING: "FUNDING";
27
- LIQUIDATION: "LIQUIDATION";
28
28
  INTEREST: "INTEREST";
29
29
  REWARD: "REWARD";
30
30
  }>;
@@ -45,12 +45,12 @@ export declare const GetUserMovementsSchema: z.ZodObject<{
45
45
  FEE: "FEE";
46
46
  }>>;
47
47
  transactionType: z.ZodOptional<z.ZodEnum<{
48
+ LIQUIDATION: "LIQUIDATION";
48
49
  FEE: "FEE";
49
50
  DEPOSIT: "DEPOSIT";
50
51
  WITHDRAWAL: "WITHDRAWAL";
51
52
  TRADE: "TRADE";
52
53
  FUNDING: "FUNDING";
53
- LIQUIDATION: "LIQUIDATION";
54
54
  INTEREST: "INTEREST";
55
55
  REWARD: "REWARD";
56
56
  }>>;
@@ -66,6 +66,7 @@ export declare const GetUserTradesSchema: z.ZodObject<{
66
66
  page: z.ZodOptional<z.ZodNumber>;
67
67
  pageSize: z.ZodOptional<z.ZodNumber>;
68
68
  tradingPairId: z.ZodOptional<z.ZodUUID>;
69
+ pageToken: z.ZodOptional<z.ZodString>;
69
70
  }, z.core.$strip>;
70
71
  export declare const ListFundingPaymentsSchema: z.ZodObject<{
71
72
  page: z.ZodOptional<z.ZodNumber>;
@@ -41,6 +41,7 @@ export const GetUserTradesSchema = z.object({
41
41
  page: z.number().int("Page must be an integer").min(1, "Page must be at least 1").optional(),
42
42
  pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
43
43
  tradingPairId: UUIDSchema.optional(),
44
+ pageToken: z.string().optional(),
44
45
  });
45
46
  export const ListFundingPaymentsSchema = z.object({
46
47
  page: z.number().int("Page must be an integer").min(1, "Page must be at least 1").optional(),
@@ -261,6 +261,7 @@ export declare const GetPaginatedOrdersSchema: z.ZodObject<{
261
261
  marginAccountId: z.ZodOptional<z.ZodUUID>;
262
262
  page: z.ZodOptional<z.ZodNumber>;
263
263
  pageSize: z.ZodOptional<z.ZodNumber>;
264
+ pageToken: z.ZodOptional<z.ZodString>;
264
265
  }, z.core.$strip>;
265
266
  export declare const ConditionalOrderConditionTypeSchema: z.ZodEnum<{
266
267
  STOP_LOSS: "STOP_LOSS";
@@ -104,6 +104,7 @@ export const ParentTpSlLegSchema = z
104
104
  path: ["slippageToleranceBps"],
105
105
  });
106
106
  const hasParentTpSl = (options) => options?.takeProfit !== undefined || options?.stopLoss !== undefined;
107
+ const legacyPositionSideMatchesOrderSide = (side, positionSide) => positionSide === undefined || (positionSide !== "NONE" && ((side === "BUY" && positionSide === "LONG") || (side === "SELL" && positionSide === "SHORT")));
107
108
  /**
108
109
  * Place Limit Order validation schema
109
110
  */
@@ -132,25 +133,21 @@ export const PlaceLimitOrderSchema = z
132
133
  })
133
134
  .optional(),
134
135
  })
135
- .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.positionSide !== undefined, {
136
- message: "positionSide is required for MARGIN orders",
136
+ .refine((data) => legacyPositionSideMatchesOrderSide(data.side, data.options?.positionSide), {
137
+ message: "positionSide is deprecated; when supplied BUY requires LONG and SELL requires SHORT",
137
138
  path: ["options", "positionSide"],
138
139
  })
139
- .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.leverage !== undefined, {
140
- message: "leverage is required for MARGIN orders",
140
+ .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.reduceOnly === true || data.options.leverage !== undefined, {
141
+ message: "leverage is required for normal MARGIN orders",
141
142
  path: ["options", "leverage"],
142
143
  })
143
144
  .refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode === "MARGIN", {
144
- message: "Parent TP/SL is only supported for MARGIN orders",
145
- path: ["options", "tradingMode"],
146
- })
147
- .refine((data) => !hasParentTpSl(data.options) || data.options?.positionSide !== "NONE", {
148
- message: "Parent TP/SL requires positionSide to be LONG or SHORT",
149
- path: ["options", "positionSide"],
145
+ message: "takeProfit/stopLoss are only supported for MARGIN orders",
146
+ path: ["options"],
150
147
  })
151
148
  .refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
152
- message: "Parent TP/SL cannot be attached to reduceOnly orders",
153
- path: ["options", "reduceOnly"],
149
+ message: "takeProfit/stopLoss cannot be attached to reduce-only orders",
150
+ path: ["options"],
154
151
  })
155
152
  .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
156
153
  message: "riskBucketCollateral is only supported for MARGIN orders",
@@ -209,25 +206,21 @@ export const PlaceMarketOrderSchema = z
209
206
  })
210
207
  .optional(),
211
208
  })
212
- .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.positionSide !== undefined, {
213
- message: "positionSide is required for MARGIN orders",
209
+ .refine((data) => legacyPositionSideMatchesOrderSide(data.side, data.options?.positionSide), {
210
+ message: "positionSide is deprecated; when supplied BUY requires LONG and SELL requires SHORT",
214
211
  path: ["options", "positionSide"],
215
212
  })
216
- .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.leverage !== undefined, {
217
- message: "leverage is required for MARGIN orders",
213
+ .refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.reduceOnly === true || data.options.leverage !== undefined, {
214
+ message: "leverage is required for normal MARGIN orders",
218
215
  path: ["options", "leverage"],
219
216
  })
220
217
  .refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode === "MARGIN", {
221
- message: "Parent TP/SL is only supported for MARGIN orders",
222
- path: ["options", "tradingMode"],
223
- })
224
- .refine((data) => !hasParentTpSl(data.options) || data.options?.positionSide !== "NONE", {
225
- message: "Parent TP/SL requires positionSide to be LONG or SHORT",
226
- path: ["options", "positionSide"],
218
+ message: "takeProfit/stopLoss are only supported for MARGIN orders",
219
+ path: ["options"],
227
220
  })
228
221
  .refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
229
- message: "Parent TP/SL cannot be attached to reduceOnly orders",
230
- path: ["options", "reduceOnly"],
222
+ message: "takeProfit/stopLoss cannot be attached to reduce-only orders",
223
+ path: ["options"],
231
224
  })
232
225
  .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
233
226
  message: "riskBucketCollateral is only supported for MARGIN orders",
@@ -300,6 +293,7 @@ export const GetPaginatedOrdersSchema = z.object({
300
293
  marginAccountId: UUIDSchema.optional(),
301
294
  page: z.number().int().min(1, "Page must be at least 1").optional(),
302
295
  pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
296
+ pageToken: z.string().optional(),
303
297
  });
304
298
  export const ConditionalOrderConditionTypeSchema = z.enum(["STOP_LOSS", "TAKE_PROFIT"], {
305
299
  message: 'conditionType must be "STOP_LOSS" or "TAKE_PROFIT"',
@@ -358,6 +352,10 @@ export const BatchCreateOrderItemSchema = z
358
352
  .refine((data) => data.orderType !== "MARKET" || data.price === undefined, {
359
353
  message: "Price must not be provided for MARKET orders",
360
354
  path: ["price"],
355
+ })
356
+ .refine((data) => data.orderType !== "MARKET" || data.timeInForce === undefined, {
357
+ message: "timeInForce must not be provided for MARKET orders",
358
+ path: ["timeInForce"],
361
359
  })
362
360
  .refine((data) => data.riskBucketCollateral === undefined || data.tradingMode === "MARGIN", {
363
361
  message: "riskBucketCollateral is only supported for MARGIN orders",
@@ -391,12 +389,12 @@ export const BatchCreateOrderItemSchema = z
391
389
  message: "reduceOnly orders cannot create a new risk bucket",
392
390
  path: ["reduceOnly"],
393
391
  })
394
- .refine((data) => data.tradingMode !== "MARGIN" || data.positionSide !== undefined, {
395
- message: "positionSide is required for MARGIN orders",
392
+ .refine((data) => legacyPositionSideMatchesOrderSide(data.side, data.positionSide), {
393
+ message: "positionSide is deprecated; when supplied BUY requires LONG and SELL requires SHORT",
396
394
  path: ["positionSide"],
397
395
  })
398
- .refine((data) => data.tradingMode !== "MARGIN" || data.leverage !== undefined, {
399
- message: "leverage is required for MARGIN orders",
396
+ .refine((data) => data.tradingMode !== "MARGIN" || data.reduceOnly === true || data.leverage !== undefined, {
397
+ message: "leverage is required for normal MARGIN orders",
400
398
  path: ["leverage"],
401
399
  });
402
400
  /**
@@ -4,7 +4,7 @@
4
4
  * TypeScript types for order websocket events matching the Rust backend definitions.
5
5
  * Each event type has specific data fields based on the event context.
6
6
  */
7
- import type { OrderRole, OrderSide, OrderStatus, OrderType, TimeInForce, TradingMode } from "../../trading";
7
+ import type { OrderRole, OrderSide, OrderStatus, OrderTerminalReason, OrderType, TimeInForce, TradingMode } from "../../trading";
8
8
  import type { RawEventMessage } from "../base";
9
9
  /**
10
10
  * Order event types
@@ -197,6 +197,8 @@ export interface OrderCancelledEvent extends OrderEvent {
197
197
  data: CommonOrderEventData & {
198
198
  /** Reason for cancellation */
199
199
  reason?: string;
200
+ /** Stable machine-readable cancellation cause */
201
+ terminalReason?: OrderTerminalReason;
200
202
  /** Total filled quantity before cancellation */
201
203
  totalFilled?: string;
202
204
  /** Remaining quantity when canceled */
@@ -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", "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_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_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_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", "replace_order", "revoke_delegated_agent", "revoke_session", "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 ["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", "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", "replace_order", "revoke_delegated_agent", "revoke_session", "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];
@@ -32,6 +32,7 @@ export const OPERATION_IDS = [
32
32
  "get_available_collateral",
33
33
  "get_candles",
34
34
  "get_conditional_order",
35
+ "get_faucet_info",
35
36
  "get_funding_state",
36
37
  "get_index_price",
37
38
  "get_margin_account_movements",
@@ -59,6 +60,7 @@ export const OPERATION_IDS = [
59
60
  "get_position",
60
61
  "get_position_pnl_history",
61
62
  "get_position_risk",
63
+ "get_pulse",
62
64
  "get_rewards_balance",
63
65
  "get_screener",
64
66
  "get_sub_account_limits",
@@ -74,6 +76,7 @@ export const OPERATION_IDS = [
74
76
  "get_withdrawal",
75
77
  "health_check",
76
78
  "initiate_withdrawal",
79
+ "list_all_funding_history",
77
80
  "list_application_balances",
78
81
  "list_application_movements",
79
82
  "list_application_orders",