@0xmonaco/types 1.0.73 → 1.0.74

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.
@@ -50,12 +50,14 @@ export declare const TransferCollateralToRiskBucketSchema: z.ZodObject<{
50
50
  tradingPairId: z.ZodUUID;
51
51
  strategyKey: z.ZodOptional<z.ZodString>;
52
52
  marginMode: z.ZodOptional<z.ZodLiteral<"ISOLATED">>;
53
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
53
54
  selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
54
55
  applyToPositionMargin: z.ZodOptional<z.ZodBoolean>;
55
56
  }, z.core.$strict>, z.ZodObject<{
56
57
  asset: z.ZodString;
57
58
  amount: z.ZodString;
58
59
  marginMode: z.ZodLiteral<"CROSS">;
60
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
59
61
  selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
60
62
  strategyKey: z.ZodOptional<z.ZodNever>;
61
63
  tradingPairId: z.ZodOptional<z.ZodNever>;
@@ -154,6 +156,7 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
154
156
  tradingPairId: z.ZodUUID;
155
157
  strategyKey: z.ZodOptional<z.ZodString>;
156
158
  marginMode: z.ZodOptional<z.ZodLiteral<"ISOLATED">>;
159
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
157
160
  selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
158
161
  applyToPositionMargin: z.ZodOptional<z.ZodBoolean>;
159
162
  }, z.core.$strict>, z.ZodObject<{
@@ -177,7 +180,38 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
177
180
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
178
181
  slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
179
182
  marginMode: z.ZodLiteral<"CROSS">;
183
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
180
184
  selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
181
185
  strategyKey: z.ZodOptional<z.ZodNever>;
182
186
  }, z.core.$strict>]>>;
183
187
  }, z.core.$strip>;
188
+ export declare const CreateMarginSubAccountSchema: z.ZodObject<{
189
+ request: z.ZodObject<{
190
+ subaccountKey: z.ZodString;
191
+ label: z.ZodOptional<z.ZodString>;
192
+ }, z.core.$strict>;
193
+ }, z.core.$strip>;
194
+ export declare const CloseMarginSubAccountSchema: z.ZodObject<{
195
+ marginAccountId: z.ZodUUID;
196
+ }, z.core.$strip>;
197
+ export declare const GetMarginAccountPnlSchema: z.ZodObject<{
198
+ marginAccountId: z.ZodUUID;
199
+ }, z.core.$strip>;
200
+ export declare const TransferMarginCollateralSchema: z.ZodObject<{
201
+ request: z.ZodObject<{
202
+ asset: z.ZodString;
203
+ amount: z.ZodString;
204
+ from: z.ZodUnion<readonly [z.ZodObject<{
205
+ wallet: z.ZodLiteral<true>;
206
+ }, z.core.$strict>, z.ZodObject<{
207
+ marginAccountId: z.ZodUUID;
208
+ riskBucketId: z.ZodOptional<z.ZodUUID>;
209
+ }, z.core.$strict>]>;
210
+ to: z.ZodUnion<readonly [z.ZodObject<{
211
+ wallet: z.ZodLiteral<true>;
212
+ }, z.core.$strict>, z.ZodObject<{
213
+ marginAccountId: z.ZodUUID;
214
+ riskBucketId: z.ZodOptional<z.ZodUUID>;
215
+ }, z.core.$strict>]>;
216
+ }, z.core.$strict>;
217
+ }, z.core.$strip>;
@@ -49,6 +49,9 @@ const RiskBucketRequestSchema = z.object({
49
49
  });
50
50
  const IsolatedRiskBucketRequestSchema = RiskBucketRequestSchema.extend({
51
51
  marginMode: z.literal("ISOLATED").optional(),
52
+ // A sub-account funds and previews its own risk buckets; omitted means the
53
+ // default margin account.
54
+ marginAccountId: UUIDSchema.optional(),
52
55
  selectedTradingPairIds: z.never().optional(),
53
56
  // Omitted defaults server-side to true (the Adjust Margin gesture); false
54
57
  // is the plain allocation programmatic funding loops need. The CROSS form
@@ -64,6 +67,7 @@ const IsolatedRiskBucketRequestSchema = RiskBucketRequestSchema.extend({
64
67
  // the pair being previewed, not a scope declaration.
65
68
  const CrossRiskBucketSimulateRequestSchema = z.object({
66
69
  marginMode: z.literal("CROSS"),
70
+ marginAccountId: UUIDSchema.optional(),
67
71
  selectedTradingPairIds: z.never().optional(),
68
72
  strategyKey: z.never().optional(),
69
73
  });
@@ -74,6 +78,7 @@ const CrossRiskBucketSimulateRequestSchema = z.object({
74
78
  // it does nothing rather than believing it took effect.
75
79
  const CrossRiskBucketRequestSchema = z.object({
76
80
  marginMode: z.literal("CROSS"),
81
+ marginAccountId: UUIDSchema.optional(),
77
82
  selectedTradingPairIds: z.never().optional(),
78
83
  strategyKey: z.never().optional(),
79
84
  tradingPairId: z.never().optional(),
@@ -223,3 +228,38 @@ export const SimulateRiskBucketOrderRiskSchema = z
223
228
  message: "price is required for LIMIT risk simulations",
224
229
  path: ["request", "price"],
225
230
  });
231
+ export const CreateMarginSubAccountSchema = z.object({
232
+ request: z
233
+ .object({
234
+ subaccountKey: z
235
+ .string()
236
+ .trim()
237
+ .min(1, "subaccountKey is required")
238
+ .max(64, "subaccountKey must be at most 64 characters")
239
+ .regex(/^[A-Za-z0-9_.:-]+$/, "subaccountKey may contain only letters, digits, '_', '-', '.' and ':'")
240
+ .refine((key) => !key.toLowerCase().startsWith("copy:"), "sub-account keys starting with copy: are reserved")
241
+ .refine((key) => key !== "default", "default names the default margin account"),
242
+ label: z.string().optional(),
243
+ })
244
+ .strict(),
245
+ });
246
+ export const CloseMarginSubAccountSchema = z.object({
247
+ marginAccountId: UUIDSchema,
248
+ });
249
+ export const GetMarginAccountPnlSchema = z.object({
250
+ marginAccountId: UUIDSchema,
251
+ });
252
+ const CollateralTransferEndpointSchema = z.union([
253
+ z.object({ wallet: z.literal(true) }).strict(),
254
+ z.object({ marginAccountId: UUIDSchema, riskBucketId: UUIDSchema.optional() }).strict(),
255
+ ]);
256
+ export const TransferMarginCollateralSchema = z.object({
257
+ request: z
258
+ .object({
259
+ asset: z.string().trim().min(1, "Asset is required"),
260
+ amount: PositiveDecimalStringSchema,
261
+ from: CollateralTransferEndpointSchema,
262
+ to: CollateralTransferEndpointSchema,
263
+ })
264
+ .strict(),
265
+ });
@@ -12,7 +12,7 @@
12
12
  /**
13
13
  * Liquidation alert event data.
14
14
  *
15
- * `status` and `accountState` are free-form strings on the wire (they mirror
15
+ * `status` and `riskBucketState` are free-form strings on the wire (they mirror
16
16
  * server-side enums that carry no wire-level rename), so they are typed as
17
17
  * `string` rather than a closed union to avoid dropping a risk-critical alert
18
18
  * on an unexpected value.
@@ -28,8 +28,8 @@ export interface LiquidationEventData {
28
28
  tradingPairId?: string;
29
29
  /** Liquidation record status (e.g. "UNRESOLVED", free-form) */
30
30
  status: string;
31
- /** Margin-account risk state at alert time (e.g. "PENDING", free-form) */
32
- accountState: string;
31
+ /** The liquidated risk bucket's state at alert time (e.g. "PENDING_LIQUIDATION", free-form) */
32
+ riskBucketState: string;
33
33
  /** Position liquidation price, when known (decimal string) */
34
34
  liquidationPrice?: string;
35
35
  /** Mark price at alert time, when known (decimal string) */
@@ -179,6 +179,12 @@ export interface CommonOrderEventData {
179
179
  * Wire: `parent_order_id`.
180
180
  */
181
181
  parentOrderId?: string;
182
+ /**
183
+ * The margin account the order trades on: the default margin account or one
184
+ * of your sub-accounts, so an owner can route events per account. Omitted for
185
+ * a spot order and by servers predating the field. Wire: `margin_account_id`.
186
+ */
187
+ marginAccountId?: string;
182
188
  /**
183
189
  * The margin position this order is bound to: the same id REST `getOrder`
184
190
  * returns as `positionId`. A margin order placed while its margin account
@@ -42,7 +42,14 @@ export interface PositionEventData {
42
42
  side: PositionEventSide | (string & {});
43
43
  /** Position lifecycle status (SCREAMING_SNAKE_CASE on the wire, e.g. "OPEN") */
44
44
  status: PositionEventStatus | (string & {});
45
- /** Absolute position size (decimal string) */
45
+ /**
46
+ * Absolute position size (decimal string). Open frames carry current size;
47
+ * terminal frames normally carry lifetime reduced quantity — the sum of
48
+ * every reducing execution, not only the exposure before the final close.
49
+ * After restart, incomplete legacy size history carries the known partial
50
+ * quantity and leaves the frame unranked. Detect closure from `status`,
51
+ * never from `size === "0"`.
52
+ */
46
53
  size: string;
47
54
  /** Average entry price (decimal string) */
48
55
  entryPrice: string;
@@ -144,14 +151,10 @@ export interface PositionEventData {
144
151
  * an unranked frame is not comparable with a snapshot row even when their
145
152
  * state matches.
146
153
  * Absent means UNRANKED, never "oldest", and it does NOT tell you whether
147
- * anything was persisted. Four cases reach it: the frame came from a
148
- * producer that predates this field; the emit path wrote no row;
149
- * the path DID write the row but re-reads live risk state after sequencing
150
- * (`funding`), so the mutation did advance the persisted version; or the
151
- * frame is a different projection of the row
152
- * than persistence stores (terminal frames report `size` 0 and
153
- * `LIQUIDATED`, while the stored row keeps its size and records `CLOSED`).
154
- * In the last two, a REST read or a fresh snapshot ranks the mutation.
154
+ * anything was persisted. Current cases are a producer predating this field,
155
+ * an emit path whose command wrote no position row, or a terminal frame
156
+ * rebuilt after restart from legacy reduction history that lacks the size or
157
+ * margin fields needed to reconstruct complete lifetime values.
155
158
  * Fall back to a full field comparison rather than ranking it lowest.
156
159
  *
157
160
  * The merge rule is PER FIELD GROUP, never per frame. On a higher version
@@ -172,15 +175,15 @@ export interface PositionEventData {
172
175
  * mutation — up to the one-hour funding interval.
173
176
  *
174
177
  * A frame is ranked only when it is a faithful projection of the row
175
- * persisted at that sequence: fills that leave a position OPEN, direct
176
- * isolated-position margin adds/reductions, and copy-position margin adds.
178
+ * persisted at that sequence: fills, non-zero funding settlements, terminal
179
+ * closes/liquidations/ADL, direct isolated-position margin adds/reductions,
180
+ * and copy-position margin adds. Funding carries state captured inside its
181
+ * sequencer command; terminal frames retain lifetime reduced quantity and
182
+ * exact CLOSED/LIQUIDATED classification.
177
183
  * The copy add refreshes the isolated child and its copy-cross siblings at
178
184
  * the same version. Cross-risk-bucket ALLOCATE/RELEASE and copy follow/stop
179
185
  * refreshes use `margin_added`/`margin_reduced` but are UNRANKED because
180
- * those commands write no position rows. Funding re-reads live state after
181
- * sequencing and is also unranked. TERMINAL frames are unranked because
182
- * they report `size` 0 and `LIQUIDATED` while the stored row keeps its size
183
- * and records `CLOSED`. Wallet IN/OUT and plain isolated allocation emit no
186
+ * those commands write no position rows. Wallet IN/OUT and plain isolated allocation emit no
184
187
  * position frame. Transfer frames use captured post-command state and are
185
188
  * released only after durable acknowledgement.
186
189
  */
@@ -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_follow_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", "cancel_twap_order", "check_trader_code_availability", "claim_buildercode_rewards", "claim_managed_market_lease", "clear_trader_code", "close_all_copy_positions", "close_follow_positions", "close_position", "create_challenge", "create_delegated_session", "create_order", "create_sub_account_limit", "create_twap_order", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_buildercode_payout_summary", "get_buildercode_rewards_balance", "get_buildercodes_config", "get_candles", "get_conditional_order", "get_faucet_info", "get_follow", "get_funding_state", "get_index_price", "get_lead_trader", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_lead_trader", "get_my_referral_downline", "get_my_referral_position", "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_self_trade_prevention_default", "get_sub_account_limits", "get_sweeper_chains", "get_trade_by_id", "get_trader_code_info", "get_trades", "get_trading_pair_by_id", "get_twap_order", "get_twap_order_tca", "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_builder_fee_changes", "list_buildercode_payouts", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_follow_leader_positions", "list_funding_history", "list_funding_payments", "list_lead_trader_closed_trades", "list_lead_trader_open_positions", "list_lead_traders", "list_managed_market_assignments", "list_margin_accounts", "list_my_followers", "list_my_follows", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "list_twap_orders", "mint_tokens", "preview_follow", "refresh_managed_market_quotes", "refresh_session", "register_deposit_address", "replace_order", "revoke_delegated_agent", "revoke_session", "set_builder_fee", "set_self_trade_prevention_default", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "stop_follow", "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", "upsert_follow", "upsert_lead_trader", "verify_signature"];
13
+ export declare const OPERATION_IDS: readonly ["add_follow_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", "cancel_twap_order", "check_trader_code_availability", "claim_buildercode_rewards", "claim_managed_market_lease", "clear_trader_code", "close_all_copy_positions", "close_follow_positions", "close_position", "close_sub_account", "create_challenge", "create_delegated_session", "create_order", "create_sub_account", "create_sub_account_limit", "create_twap_order", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_buildercode_payout_summary", "get_buildercode_rewards_balance", "get_buildercodes_config", "get_candles", "get_conditional_order", "get_faucet_info", "get_follow", "get_funding_state", "get_index_price", "get_lead_trader", "get_margin_account_movements", "get_margin_account_pnl", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_lead_trader", "get_my_referral_downline", "get_my_referral_position", "get_my_referral_tree", "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_self_trade_prevention_default", "get_sub_account_limits", "get_sweeper_chains", "get_trade_by_id", "get_trader_code_info", "get_trades", "get_trading_pair_by_id", "get_twap_order", "get_twap_order_tca", "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_builder_fee_changes", "list_buildercode_payouts", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_follow_leader_positions", "list_funding_history", "list_funding_payments", "list_lead_trader_closed_trades", "list_lead_trader_open_positions", "list_lead_traders", "list_managed_market_assignments", "list_margin_accounts", "list_my_followers", "list_my_follows", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "list_twap_orders", "mint_tokens", "preview_follow", "refresh_managed_market_quotes", "refresh_session", "register_deposit_address", "replace_order", "revoke_delegated_agent", "revoke_session", "set_builder_fee", "set_self_trade_prevention_default", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "stop_follow", "submit_whitelist", "transfer_collateral", "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", "upsert_follow", "upsert_lead_trader", "verify_signature"];
14
14
  /** Union of every OpenAPI operationId in the spec. */
15
15
  export type OperationId = (typeof OPERATION_IDS)[number];
@@ -29,9 +29,11 @@ export const OPERATION_IDS = [
29
29
  "close_all_copy_positions",
30
30
  "close_follow_positions",
31
31
  "close_position",
32
+ "close_sub_account",
32
33
  "create_challenge",
33
34
  "create_delegated_session",
34
35
  "create_order",
36
+ "create_sub_account",
35
37
  "create_sub_account_limit",
36
38
  "create_twap_order",
37
39
  "delete_sub_account_limit",
@@ -49,6 +51,7 @@ export const OPERATION_IDS = [
49
51
  "get_index_price",
50
52
  "get_lead_trader",
51
53
  "get_margin_account_movements",
54
+ "get_margin_account_pnl",
52
55
  "get_margin_account_summary",
53
56
  "get_mark_price",
54
57
  "get_market_metadata",
@@ -57,6 +60,7 @@ export const OPERATION_IDS = [
57
60
  "get_my_lead_trader",
58
61
  "get_my_referral_downline",
59
62
  "get_my_referral_position",
63
+ "get_my_referral_tree",
60
64
  "get_my_trader_code",
61
65
  "get_open_interest",
62
66
  "get_order_by_id",
@@ -139,6 +143,7 @@ export const OPERATION_IDS = [
139
143
  "simulate_risk_bucket_order_risk",
140
144
  "stop_follow",
141
145
  "submit_whitelist",
146
+ "transfer_collateral",
142
147
  "transfer_collateral_from_margin_account",
143
148
  "transfer_collateral_from_parent_margin_account",
144
149
  "transfer_collateral_to_margin_account",