@0xmonaco/types 1.0.70 → 1.0.73-develop.af0f5d0

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;
@@ -107,7 +114,7 @@ export interface PositionEventData {
107
114
  /**
108
115
  * What triggered the update. Free-form, but the server uses a canonical set:
109
116
  * `trade`, `close`, `liquidation`, `adl`, `funding`, `margin_added`,
110
- * `margin_reduced`, `margin_collateral_transfer`.
117
+ * `margin_reduced`.
111
118
  */
112
119
  reason: string;
113
120
  /**
@@ -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, `margin_added`/`margin_reduced`), so the mutation did advance
151
- * the persisted version; or the 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,13 +175,17 @@ 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: in practice the FILLS THAT LEAVE A POSITION
176
- * OPEN. Unranked are (a) frames that re-read live risk state after their
177
- * command was sequenced, since a later command can overtake that read —
178
- * the `funding` and `margin_added`/`margin_reduced` frames — and (b)
179
- * TERMINAL frames, which report `size` 0 and `LIQUIDATED` while the stored
180
- * row keeps its size and records `CLOSED`. Those mutations still advance
181
- * the persisted version, so REST and a fresh snapshot rank them.
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.
183
+ * The copy add refreshes the isolated child and its copy-cross siblings at
184
+ * the same version. Cross-risk-bucket ALLOCATE/RELEASE and copy follow/stop
185
+ * refreshes use `margin_added`/`margin_reduced` but are UNRANKED because
186
+ * those commands write no position rows. Wallet IN/OUT and plain isolated allocation emit no
187
+ * position frame. Transfer frames use captured post-command state and are
188
+ * released only after durable acknowledgement.
182
189
  */
183
190
  version?: number;
184
191
  }
@@ -29,6 +29,13 @@ export type TwapOrderEventReason = "created" | "slice_placed" | "slice_skipped"
29
29
  */
30
30
  export interface TwapOrderEventData {
31
31
  twapOrderId: string;
32
+ /**
33
+ * Opaque same-parent reconciliation revision. Compare only updates for this
34
+ * `twapOrderId`: accept an update when its version is greater than or equal
35
+ * to the stored version, ignore lower versions, and expect gaps. A snapshot
36
+ * wins ties. Absent on legacy updates whose revision is unknown.
37
+ */
38
+ version?: number;
32
39
  tradingPairId: string;
33
40
  side: OrderSide | (string & {});
34
41
  tradingMode: TradingMode | (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 ["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_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_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_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];
@@ -11,6 +11,7 @@
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_follow_position_margin",
14
15
  "attach_position_tp_sl",
15
16
  "batch_cancel_all",
16
17
  "batch_cancel_all_by_pair",
@@ -25,10 +26,14 @@ export const OPERATION_IDS = [
25
26
  "claim_buildercode_rewards",
26
27
  "claim_managed_market_lease",
27
28
  "clear_trader_code",
29
+ "close_all_copy_positions",
30
+ "close_follow_positions",
28
31
  "close_position",
32
+ "close_sub_account",
29
33
  "create_challenge",
30
34
  "create_delegated_session",
31
35
  "create_order",
36
+ "create_sub_account",
32
37
  "create_sub_account_limit",
33
38
  "create_twap_order",
34
39
  "delete_sub_account_limit",
@@ -46,6 +51,7 @@ export const OPERATION_IDS = [
46
51
  "get_index_price",
47
52
  "get_lead_trader",
48
53
  "get_margin_account_movements",
54
+ "get_margin_account_pnl",
49
55
  "get_margin_account_summary",
50
56
  "get_mark_price",
51
57
  "get_market_metadata",
@@ -54,6 +60,7 @@ export const OPERATION_IDS = [
54
60
  "get_my_lead_trader",
55
61
  "get_my_referral_downline",
56
62
  "get_my_referral_position",
63
+ "get_my_referral_tree",
57
64
  "get_my_trader_code",
58
65
  "get_open_interest",
59
66
  "get_order_by_id",
@@ -98,6 +105,7 @@ export const OPERATION_IDS = [
98
105
  "list_application_movements",
99
106
  "list_application_orders",
100
107
  "list_application_users",
108
+ "list_builder_fee_changes",
101
109
  "list_buildercode_payouts",
102
110
  "list_conditional_orders",
103
111
  "list_delegated_agent_owners",
@@ -126,6 +134,7 @@ export const OPERATION_IDS = [
126
134
  "replace_order",
127
135
  "revoke_delegated_agent",
128
136
  "revoke_session",
137
+ "set_builder_fee",
129
138
  "set_self_trade_prevention_default",
130
139
  "set_trader_code",
131
140
  "simulate_fees",
@@ -134,6 +143,7 @@ export const OPERATION_IDS = [
134
143
  "simulate_risk_bucket_order_risk",
135
144
  "stop_follow",
136
145
  "submit_whitelist",
146
+ "transfer_collateral",
137
147
  "transfer_collateral_from_margin_account",
138
148
  "transfer_collateral_from_parent_margin_account",
139
149
  "transfer_collateral_to_margin_account",