@0xmonaco/types 1.0.38 → 1.0.39-develop.71e039b

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.
@@ -80,6 +80,12 @@ export interface TransferCollateralRequest {
80
80
  amount: string;
81
81
  tradingPairId?: string;
82
82
  strategyKey?: string;
83
+ /**
84
+ * Risk bucket mode. Defaults to ISOLATED, which is selected by
85
+ * `tradingPairId`. Pass `"CROSS"` to release from the account's cross risk
86
+ * bucket, which has no trading pair and so cannot be named any other way.
87
+ */
88
+ marginMode?: MarginMode;
83
89
  }
84
90
  export interface TransferCollateralToParentMarginAccountRequest {
85
91
  asset: string;
@@ -164,20 +164,6 @@ export interface PositionRisk {
164
164
  initialMarginRequired?: string;
165
165
  updatedAt: string;
166
166
  }
167
- export interface AddPositionMarginRequest {
168
- amount: string;
169
- asset: string;
170
- }
171
- export interface ReducePositionMarginRequest {
172
- amount: string;
173
- }
174
- export interface PositionMarginResponse {
175
- positionId: string;
176
- marginAccountId: string;
177
- newIsolatedMargin: string;
178
- status: string;
179
- message: string;
180
- }
181
167
  export interface TpSlLeg {
182
168
  triggerPrice: string;
183
169
  orderType: OrderType;
@@ -311,8 +297,6 @@ export interface PositionsAPI extends BaseAPI {
311
297
  closePosition(positionId: string, request: ClosePositionRequest): Promise<ClosePositionResponse>;
312
298
  batchCloseAllPositions(request?: BatchCloseAllRequest): Promise<BatchCloseAllResponse>;
313
299
  getPositionRisk(positionId: string): Promise<PositionRisk>;
314
- addPositionMargin(positionId: string, request: AddPositionMarginRequest): Promise<PositionMarginResponse>;
315
- reducePositionMargin(positionId: string, request: ReducePositionMarginRequest): Promise<PositionMarginResponse>;
316
300
  attachPositionTpSl(positionId: string, request: AttachPositionTpSlRequest): Promise<AttachPositionTpSlResponse>;
317
301
  listPositionHistory(params?: ListPositionHistoryParams): Promise<ListPositionHistoryResponse>;
318
302
  getPositionPnlHistory(positionId: string, params: GetPositionPnlHistoryParams): Promise<GetPositionPnlHistoryResponse>;
@@ -122,12 +122,6 @@ export interface GetUserBalancesParams {
122
122
  * Response from getting user movements
123
123
  */
124
124
  export interface GetPaginatedUserMovementsResponse {
125
- /**
126
- * Latest movements from the live engine cache (real-time, instant updates).
127
- * These are the most recent movements that may not yet be in PostgreSQL.
128
- * Only populated on page 1; empty for subsequent pages.
129
- */
130
- latest_movements?: LedgerMovement[];
131
125
  /** All movements from PostgreSQL (historical, paginated) */
132
126
  movements: LedgerMovement[];
133
127
  /** Current page number */
@@ -167,11 +167,6 @@ export interface GetPaginatedOrdersParams {
167
167
  * Response from getting paginated orders
168
168
  */
169
169
  export interface GetPaginatedOrdersResponse {
170
- /** Latest orders from the live engine cache (real-time, instant updates).
171
- * These are the most recently created/updated orders that may not yet be in PostgreSQL.
172
- * Only populated on page 1.
173
- */
174
- latest_orders?: Order[];
175
170
  /** Array of historical orders from PostgreSQL (paginated) */
176
171
  orders: Order[];
177
172
  /**
@@ -25,6 +25,10 @@ export declare const TransferCollateralSchema: z.ZodObject<{
25
25
  amount: z.ZodString;
26
26
  tradingPairId: z.ZodOptional<z.ZodUUID>;
27
27
  strategyKey: z.ZodOptional<z.ZodString>;
28
+ marginMode: z.ZodOptional<z.ZodEnum<{
29
+ ISOLATED: "ISOLATED";
30
+ CROSS: "CROSS";
31
+ }>>;
28
32
  }, z.core.$strip>;
29
33
  }, z.core.$strip>;
30
34
  export declare const TransferCollateralToParentMarginAccountSchema: z.ZodObject<{
@@ -25,11 +25,19 @@ export const GetAvailableCollateralSchema = z
25
25
  asset: z.string().trim().min(1, "Asset cannot be empty").optional(),
26
26
  })
27
27
  .optional();
28
- const TransferCollateralRequestSchema = z.object({
28
+ const TransferCollateralRequestSchema = z
29
+ .object({
29
30
  asset: z.string().trim().min(1, "Asset cannot be empty"),
30
31
  amount: PositiveDecimalStringSchema,
31
32
  tradingPairId: UUIDSchema.optional(),
32
33
  strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
34
+ // A cross risk bucket has no trading pair, so CROSS is the only way to name
35
+ // one on the way out (0XM-2420). The two never combine.
36
+ marginMode: z.enum(["ISOLATED", "CROSS"]).optional(),
37
+ })
38
+ .refine((request) => !(request.marginMode === "CROSS" && request.tradingPairId !== undefined), {
39
+ message: "tradingPairId is not supported for CROSS risk buckets",
40
+ path: ["tradingPairId"],
33
41
  });
34
42
  const ParentMarginAccountCollateralRequestSchema = z.object({
35
43
  asset: z.string().trim().min(1, "Asset cannot be empty"),
@@ -37,19 +37,6 @@ export declare const BatchCloseAllSchema: z.ZodObject<{
37
37
  export declare const GetPositionRiskSchema: z.ZodObject<{
38
38
  positionId: z.ZodUUID;
39
39
  }, z.core.$strip>;
40
- export declare const AddPositionMarginSchema: z.ZodObject<{
41
- positionId: z.ZodUUID;
42
- request: z.ZodObject<{
43
- amount: z.ZodString;
44
- asset: z.ZodString;
45
- }, z.core.$strip>;
46
- }, z.core.$strip>;
47
- export declare const ReducePositionMarginSchema: z.ZodObject<{
48
- positionId: z.ZodUUID;
49
- request: z.ZodObject<{
50
- amount: z.ZodString;
51
- }, z.core.$strip>;
52
- }, z.core.$strip>;
53
40
  export declare const AttachPositionTpSlSchema: z.ZodObject<{
54
41
  positionId: z.ZodUUID;
55
42
  request: z.ZodObject<{
@@ -46,17 +46,6 @@ export const BatchCloseAllSchema = z.object({
46
46
  slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
47
47
  });
48
48
  export const GetPositionRiskSchema = PositionIdSchema;
49
- export const AddPositionMarginSchema = PositionIdSchema.extend({
50
- request: z.object({
51
- amount: PositiveDecimalStringSchema,
52
- asset: z.string().trim().min(1, "Asset cannot be empty"),
53
- }),
54
- });
55
- export const ReducePositionMarginSchema = PositionIdSchema.extend({
56
- request: z.object({
57
- amount: PositiveDecimalStringSchema,
58
- }),
59
- });
60
49
  const TpSlLegSchema = z
61
50
  .object({
62
51
  triggerPrice: PositiveDecimalStringSchema,
@@ -360,6 +360,12 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
360
360
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
361
361
  postOnly: z.ZodOptional<z.ZodBoolean>;
362
362
  }, z.core.$strip>;
363
+ /**
364
+ * Maximum items per batch create/replace/cancel request. Mirrors the server's
365
+ * cap (Zenith #11): a batch is one matching-engine sequencer command, so its
366
+ * item count is bounded independent of the transport message-size limit.
367
+ */
368
+ export declare const MAX_BATCH_ORDER_ITEMS = 100;
363
369
  /**
364
370
  * Batch Create Orders validation schema
365
371
  *
@@ -429,13 +429,22 @@ export const BatchCreateOrderItemSchema = z
429
429
  message: "leverage is required for normal MARGIN orders",
430
430
  path: ["leverage"],
431
431
  });
432
+ /**
433
+ * Maximum items per batch create/replace/cancel request. Mirrors the server's
434
+ * cap (Zenith #11): a batch is one matching-engine sequencer command, so its
435
+ * item count is bounded independent of the transport message-size limit.
436
+ */
437
+ export const MAX_BATCH_ORDER_ITEMS = 100;
432
438
  /**
433
439
  * Batch Create Orders validation schema
434
440
  *
435
441
  * Validates the full array of orders for a batch create request.
436
442
  */
437
443
  export const BatchCreateOrdersSchema = z.object({
438
- orders: z.array(BatchCreateOrderItemSchema).min(1, "At least one order is required"),
444
+ orders: z
445
+ .array(BatchCreateOrderItemSchema)
446
+ .min(1, "At least one order is required")
447
+ .max(MAX_BATCH_ORDER_ITEMS, `At most ${MAX_BATCH_ORDER_ITEMS} orders per batch request`),
439
448
  });
440
449
  /**
441
450
  * Single batch replace order item validation schema
@@ -463,5 +472,8 @@ export const BatchReplaceOrderItemSchema = z
463
472
  * Validates the full array of orders for a batch replace request.
464
473
  */
465
474
  export const BatchReplaceOrdersSchema = z.object({
466
- orders: z.array(BatchReplaceOrderItemSchema).min(1, "At least one order is required"),
475
+ orders: z
476
+ .array(BatchReplaceOrderItemSchema)
477
+ .min(1, "At least one order is required")
478
+ .max(MAX_BATCH_ORDER_ITEMS, `At most ${MAX_BATCH_ORDER_ITEMS} orders per batch request`),
467
479
  });
@@ -51,4 +51,15 @@ export type WireCovered<Ergo, Wire> = [MissingWireFields<Ergo, Wire>] extends [n
51
51
  * `tsc` reports the missing wire fields at this line.
52
52
  */
53
53
  export type Expect<T extends true> = T;
54
+ /**
55
+ * Resolves to `true` when `K` is NOT a key of `T`, otherwise `false`. Pair with
56
+ * {@link Expect} to guard that a field stays absent from a public type, so a
57
+ * removed field cannot silently reappear:
58
+ *
59
+ * type _NoLatestOrders = Expect<KeyAbsent<GetPaginatedOrdersResponse, "latest_orders">>;
60
+ *
61
+ * If the key is present, `KeyAbsent` resolves to `false`, `T extends true`
62
+ * fails, and `tsc` reports the reintroduced field at this line.
63
+ */
64
+ export type KeyAbsent<T, K extends PropertyKey> = K extends keyof T ? false : true;
54
65
  export {};
@@ -13,7 +13,7 @@
13
13
  * It also exports the generated runtime `OPERATION_IDS` list and the
14
14
  * `auditSurface` helper that power the MON-1489 endpoint-coverage gate.
15
15
  */
16
- export type { Expect, MissingWireFields, WireCovered, WireSchema, WireSchemas } from "./assert";
16
+ export type { Expect, KeyAbsent, MissingWireFields, WireCovered, WireSchema, WireSchemas } from "./assert";
17
17
  export type { CoverageAudit, SurfaceClassification } from "./audit";
18
18
  export { auditSurface } from "./audit";
19
19
  export type { OperationId } from "./operations";
@@ -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",
@@ -1856,38 +1856,6 @@ export interface paths {
1856
1856
  patch?: never;
1857
1857
  trace?: never;
1858
1858
  };
1859
- "/api/v1/positions/{positionId}/margin/add": {
1860
- parameters: {
1861
- query?: never;
1862
- header?: never;
1863
- path?: never;
1864
- cookie?: never;
1865
- };
1866
- get?: never;
1867
- put?: never;
1868
- post: operations["add_position_margin"];
1869
- delete?: never;
1870
- options?: never;
1871
- head?: never;
1872
- patch?: never;
1873
- trace?: never;
1874
- };
1875
- "/api/v1/positions/{positionId}/margin/reduce": {
1876
- parameters: {
1877
- query?: never;
1878
- header?: never;
1879
- path?: never;
1880
- cookie?: never;
1881
- };
1882
- get?: never;
1883
- put?: never;
1884
- post: operations["reduce_position_margin"];
1885
- delete?: never;
1886
- options?: never;
1887
- head?: never;
1888
- patch?: never;
1889
- trace?: never;
1890
- };
1891
1859
  "/api/v1/positions/{positionId}/pnl/history": {
1892
1860
  parameters: {
1893
1861
  query?: never;
@@ -2224,19 +2192,6 @@ export interface components {
2224
2192
  */
2225
2193
  totalBalanceRaw?: string | null;
2226
2194
  };
2227
- AddPositionMarginRequest: {
2228
- /** @description Collateral asset to move into the isolated bucket. USDC is the current v1 path. */
2229
- asset?: string | null;
2230
- amount?: string | null;
2231
- };
2232
- AddPositionMarginResponse: {
2233
- positionId?: string | null;
2234
- /** @description Margin account UUID for the isolated bucket that was adjusted. */
2235
- marginAccountId?: string | null;
2236
- newIsolatedMargin?: string | null;
2237
- status?: string | null;
2238
- message?: string | null;
2239
- };
2240
2195
  AppUser: {
2241
2196
  /**
2242
2197
  * Format: uuid
@@ -5925,17 +5880,6 @@ export interface components {
5925
5880
  */
5926
5881
  relevance?: number | null;
5927
5882
  };
5928
- ReducePositionMarginRequest: {
5929
- amount?: string | null;
5930
- };
5931
- ReducePositionMarginResponse: {
5932
- positionId?: string | null;
5933
- /** @description Margin account UUID for the isolated bucket that was adjusted. */
5934
- marginAccountId?: string | null;
5935
- newIsolatedMargin?: string | null;
5936
- status?: string | null;
5937
- message?: string | null;
5938
- };
5939
5883
  RefreshRequest: Record<string, never>;
5940
5884
  RefreshResponse: {
5941
5885
  /**
@@ -6703,6 +6647,12 @@ export interface components {
6703
6647
  tradingPairId?: string | null;
6704
6648
  /** @description Optional strategy key echoed in responses when callers scope a risk bucket. */
6705
6649
  strategyKey?: string | null;
6650
+ /**
6651
+ * @description Risk bucket mode. Defaults to ISOLATED, which is selected by tradingPairId.
6652
+ * Pass CROSS to release from the account's cross risk bucket, which has no
6653
+ * trading pair and so cannot be named any other way. Values: ISOLATED, CROSS.
6654
+ */
6655
+ marginMode?: string | null;
6706
6656
  };
6707
6657
  TransferCollateralFromMarginAccountResponse: {
6708
6658
  movementId?: string | null;
@@ -10834,66 +10784,6 @@ export interface operations {
10834
10784
  };
10835
10785
  };
10836
10786
  };
10837
- add_position_margin: {
10838
- parameters: {
10839
- query?: never;
10840
- header?: never;
10841
- path: {
10842
- /**
10843
- * @description Position UUID for the isolated bucket being adjusted.
10844
- * @example 2b1a5f9c-0000-4000-8000-000000000002
10845
- */
10846
- positionId: string;
10847
- };
10848
- cookie?: never;
10849
- };
10850
- requestBody: {
10851
- content: {
10852
- "application/json": components["schemas"]["AddPositionMarginRequest"];
10853
- };
10854
- };
10855
- responses: {
10856
- /** @description OK */
10857
- 200: {
10858
- headers: {
10859
- [name: string]: unknown;
10860
- };
10861
- content: {
10862
- "application/json": components["schemas"]["AddPositionMarginResponse"];
10863
- };
10864
- };
10865
- };
10866
- };
10867
- reduce_position_margin: {
10868
- parameters: {
10869
- query?: never;
10870
- header?: never;
10871
- path: {
10872
- /**
10873
- * @description Position UUID for the isolated bucket being adjusted.
10874
- * @example 2b1a5f9c-0000-4000-8000-000000000002
10875
- */
10876
- positionId: string;
10877
- };
10878
- cookie?: never;
10879
- };
10880
- requestBody: {
10881
- content: {
10882
- "application/json": components["schemas"]["ReducePositionMarginRequest"];
10883
- };
10884
- };
10885
- responses: {
10886
- /** @description OK */
10887
- 200: {
10888
- headers: {
10889
- [name: string]: unknown;
10890
- };
10891
- content: {
10892
- "application/json": components["schemas"]["ReducePositionMarginResponse"];
10893
- };
10894
- };
10895
- };
10896
- };
10897
10787
  get_position_pnl_history: {
10898
10788
  parameters: {
10899
10789
  query: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/types",
3
- "version": "1.0.38",
3
+ "version": "1.0.39-develop.71e039b",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "lint": "biome lint ."
21
21
  },
22
22
  "dependencies": {
23
- "@0xmonaco/contracts": "1.0.38",
23
+ "@0xmonaco/contracts": "1.0.39-develop.71e039b",
24
24
  "zod": "^4.1.12"
25
25
  },
26
26
  "peerDependencies": {