@0xmonaco/types 1.0.70 → 1.0.72

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.
@@ -77,8 +77,10 @@ export interface AuthAPI extends BaseAPI {
77
77
  */
78
78
  verifySignature(address: string, signature: string, nonce: string, clientId: string, session: SessionCredentials, referralCode?: string): Promise<AuthState>;
79
79
  /**
80
- * Extends the current session's expiry. The request is signed with the
81
- * active session key (set via {@link setSessionKeypair}).
80
+ * Refreshes the current session's expiry. The request is signed with the
81
+ * active session key (set via {@link setSessionKeypair}). For a delegated
82
+ * session, the returned expiry is capped by the active delegation and may
83
+ * move earlier if the owner shortened that delegation.
82
84
  * @returns Promise resolving to the new expiry
83
85
  */
84
86
  refreshSession(): Promise<SessionRefreshResponse>;
@@ -78,7 +78,9 @@ export interface SessionCredentials {
78
78
  privateKey: string;
79
79
  }
80
80
  /**
81
- * Response to a session refresh request — extends the session's expiry.
81
+ * Response to a session refresh request with the resulting expiry. For a
82
+ * delegated session, this remains capped by the active delegation and may move earlier
83
+ * if the owner shortened that delegation.
82
84
  */
83
85
  export interface SessionRefreshResponse {
84
86
  /** Unix timestamp when the session expires after refresh */
@@ -6,8 +6,8 @@
6
6
  * into it. Leaders are addressed by their custom TraderCode handle.
7
7
  */
8
8
  import type { BaseAPI } from "../api";
9
- import type { ListLeadTraderClosedTradesParams, ListLeadTradersParams, ListMyFollowersParams, ListMyFollowsParams, PreviewFollowParams, UpsertFollowParams, UpsertLeadTraderParams } from "../validation/copy-trading";
10
- import type { GetFollowResponse, GetLeadTraderResponse, ListFollowLeaderPositionsResponse, ListLeadTraderClosedTradesResponse, ListLeadTraderOpenPositionsResponse, ListLeadTradersResponse, ListMyFollowersResponse, ListMyFollowsResponse, PreviewFollowResponse, StopFollowResponse, UpsertFollowResponse, UpsertLeadTraderResponse } from "./responses";
9
+ import type { AddFollowPositionMarginParams, ListLeadTraderClosedTradesParams, ListLeadTradersParams, ListMyFollowersParams, ListMyFollowsParams, PreviewFollowParams, UpsertFollowParams, UpsertLeadTraderParams } from "../validation/copy-trading";
10
+ import type { AddFollowPositionMarginResponse, CloseAllCopyPositionsResponse, CloseFollowPositionsResponse, GetFollowResponse, GetLeadTraderResponse, ListFollowLeaderPositionsResponse, ListLeadTraderClosedTradesResponse, ListLeadTraderOpenPositionsResponse, ListLeadTradersResponse, ListMyFollowersResponse, ListMyFollowsResponse, PreviewFollowResponse, StopFollowResponse, UpsertFollowResponse, UpsertLeadTraderResponse } from "./responses";
11
11
  /**
12
12
  * Copy trading API.
13
13
  *
@@ -69,6 +69,54 @@ export interface CopyTradingAPI extends BaseAPI {
69
69
  * cannot stop a follow (403).
70
70
  */
71
71
  stopFollow(followId: string): Promise<StopFollowResponse>;
72
+ /**
73
+ * Close every position in one of your follows' copy accounts at market
74
+ * (reduce-only, immediate-or-cancel) and cancel the resting orders and
75
+ * conditional orders (TP/SL) on its copy risk buckets, keeping the follow:
76
+ * the leader's next trades keep mirroring. `stopFollow` is the
77
+ * close-and-stop path. Proceeds stay in the copy account. Not a flatten
78
+ * guarantee: a thin or halted market can leave part of a position open
79
+ * (`positionsNotClosed`), and a leader trade after the close opens copies
80
+ * again. Never gated by copy trading being off or an operations block; only
81
+ * a delegated agent session is refused (403). Both close methods share a
82
+ * small per-account rate limit (about one per second, burst 5; 429 with
83
+ * Retry-After). 404 for a follow that is not yours; 409 for a stopped
84
+ * follow or one whose stop is in progress; 400 when the close was refused;
85
+ * 503 when it cannot run right now. The response is sent once the batch is
86
+ * durably logged; fills arrive on the order, position and copy channels.
87
+ */
88
+ closeFollowPositions(followId: string): Promise<CloseFollowPositionsResponse>;
89
+ /**
90
+ * Close the copy positions of every live follow of yours, as
91
+ * `closeFollowPositions` does for one, keeping the follows. Follows whose
92
+ * stop is in progress are listed in `stoppingFollowIds`; a follow whose
93
+ * close could not run is listed in `failedFollows` with a fixed reason
94
+ * while the others still close.
95
+ */
96
+ closeAllCopyPositions(): Promise<CloseAllCopyPositionsResponse>;
97
+ /**
98
+ * Add margin to one of your copy positions: moves `amount` (quote units)
99
+ * from the follow's copy account into the margin of its isolated copy
100
+ * position on `tradingPairId`. The position's margin rises by exactly
101
+ * `amount` and the copy account's remaining collateral falls by the same;
102
+ * your margin account is never touched. It lowers the position's leverage
103
+ * and moves its liquidation price away, and opens no exposure, so it works
104
+ * while copy trading is switched off and on a `CLOSE_ONLY` follow. There
105
+ * is no margin reduction: a follow exits by being stopped.
106
+ *
107
+ * Master account sessions only (a delegated agent or a sub-account gets
108
+ * 403); 404 for a follow that is not yours; 409 while the follow is
109
+ * stopping or once it is stopped, or `COPY_TRADING_UNAVAILABLE` when copy
110
+ * trading is not available on the platform; 400 `COPY_TRADING_REJECTED`
111
+ * when the engine refuses (no isolated copy position on the pair, the
112
+ * position or the margin account is being liquidated, the position has
113
+ * lost more than its margin, more than the copy account can put in); 429
114
+ * over the movement budget withdrawals and collateral transfers share.
115
+ *
116
+ * Not idempotent: a retry after a timeout whose first attempt landed adds
117
+ * the amount twice, so read the follow before retrying.
118
+ */
119
+ addFollowPositionMargin(params: AddFollowPositionMarginParams): Promise<AddFollowPositionMarginResponse>;
72
120
  /** List your follows, newest first. Cursor paged, up to 1000 per page. */
73
121
  listMyFollows(params?: ListMyFollowsParams): Promise<ListMyFollowsResponse>;
74
122
  /**
@@ -91,5 +139,5 @@ export interface CopyTradingAPI extends BaseAPI {
91
139
  */
92
140
  previewFollow(params: PreviewFollowParams): Promise<PreviewFollowResponse>;
93
141
  }
94
- export type { ClosedTrade, ClosedTradeAction, CopySkip, Follow, Follower, GetFollowResponse, GetLeadTraderResponse, LeadTraderFollowSummary, LeadTraderListing, LeadTraderOpenPosition, LeadTraderProfile, LeadTraderRef, LeadTraderSort, LeadTraderStats, LeadTraderStatsWindow, LeadTraderStatus, ListFollowLeaderPositionsResponse, ListLeadTraderClosedTradesResponse, ListLeadTraderOpenPositionsResponse, ListLeadTradersResponse, ListMyFollowersResponse, ListMyFollowsResponse, PreviewFollowResponse, StopFollowResponse, UpsertFollowResponse, UpsertLeadTraderResponse, } from "./responses";
95
- export { ClosedTradeSchema, CopySkipSchema, FollowerSchema, FollowSchema, GetFollowResponseSchema, GetLeadTraderResponseSchema, LeadTraderFollowSummarySchema, LeadTraderListingSchema, LeadTraderOpenPositionSchema, LeadTraderProfileSchema, LeadTraderRefSchema, LeadTraderStatsSchema, ListFollowLeaderPositionsResponseSchema, ListLeadTraderClosedTradesResponseSchema, ListLeadTraderOpenPositionsResponseSchema, ListLeadTradersResponseSchema, ListMyFollowersResponseSchema, ListMyFollowsResponseSchema, PreviewFollowResponseSchema, StopFollowResponseSchema, UpsertFollowResponseSchema, UpsertLeadTraderResponseSchema, } from "./responses";
142
+ export type { AddFollowPositionMarginResponse, CloseAllCopyPositionsResponse, ClosedTrade, ClosedTradeAction, CloseFollowPositionsResponse, CopySkip, Follow, FollowCloseFailure, Follower, GetFollowResponse, GetLeadTraderResponse, LeadTraderFollowSummary, LeadTraderListing, LeadTraderOpenPosition, LeadTraderProfile, LeadTraderRef, LeadTraderSort, LeadTraderStats, LeadTraderStatsWindow, LeadTraderStatus, ListFollowLeaderPositionsResponse, ListLeadTraderClosedTradesResponse, ListLeadTraderOpenPositionsResponse, ListLeadTradersResponse, ListMyFollowersResponse, ListMyFollowsResponse, PreviewFollowResponse, StopFollowResponse, UpsertFollowResponse, UpsertLeadTraderResponse, } from "./responses";
143
+ export { AddFollowPositionMarginResponseSchema, CloseAllCopyPositionsResponseSchema, ClosedTradeSchema, CloseFollowPositionsResponseSchema, CopySkipSchema, FollowCloseFailureSchema, FollowerSchema, FollowSchema, GetFollowResponseSchema, GetLeadTraderResponseSchema, LeadTraderFollowSummarySchema, LeadTraderListingSchema, LeadTraderOpenPositionSchema, LeadTraderProfileSchema, LeadTraderRefSchema, LeadTraderStatsSchema, ListFollowLeaderPositionsResponseSchema, ListLeadTraderClosedTradesResponseSchema, ListLeadTraderOpenPositionsResponseSchema, ListLeadTradersResponseSchema, ListMyFollowersResponseSchema, ListMyFollowsResponseSchema, PreviewFollowResponseSchema, StopFollowResponseSchema, UpsertFollowResponseSchema, UpsertLeadTraderResponseSchema, } from "./responses";
@@ -5,4 +5,4 @@
5
5
  * bucket in their margin account) and every fill the leader makes is mirrored
6
6
  * into it. Leaders are addressed by their custom TraderCode handle.
7
7
  */
8
- export { ClosedTradeSchema, CopySkipSchema, FollowerSchema, FollowSchema, GetFollowResponseSchema, GetLeadTraderResponseSchema, LeadTraderFollowSummarySchema, LeadTraderListingSchema, LeadTraderOpenPositionSchema, LeadTraderProfileSchema, LeadTraderRefSchema, LeadTraderStatsSchema, ListFollowLeaderPositionsResponseSchema, ListLeadTraderClosedTradesResponseSchema, ListLeadTraderOpenPositionsResponseSchema, ListLeadTradersResponseSchema, ListMyFollowersResponseSchema, ListMyFollowsResponseSchema, PreviewFollowResponseSchema, StopFollowResponseSchema, UpsertFollowResponseSchema, UpsertLeadTraderResponseSchema, } from "./responses";
8
+ export { AddFollowPositionMarginResponseSchema, CloseAllCopyPositionsResponseSchema, ClosedTradeSchema, CloseFollowPositionsResponseSchema, CopySkipSchema, FollowCloseFailureSchema, FollowerSchema, FollowSchema, GetFollowResponseSchema, GetLeadTraderResponseSchema, LeadTraderFollowSummarySchema, LeadTraderListingSchema, LeadTraderOpenPositionSchema, LeadTraderProfileSchema, LeadTraderRefSchema, LeadTraderStatsSchema, ListFollowLeaderPositionsResponseSchema, ListLeadTraderClosedTradesResponseSchema, ListLeadTraderOpenPositionsResponseSchema, ListLeadTradersResponseSchema, ListMyFollowersResponseSchema, ListMyFollowsResponseSchema, PreviewFollowResponseSchema, StopFollowResponseSchema, UpsertFollowResponseSchema, UpsertLeadTraderResponseSchema, } from "./responses";
@@ -349,6 +349,45 @@ export declare const PreviewFollowResponseSchema: z.ZodObject<{
349
349
  export declare const StopFollowResponseSchema: z.ZodObject<{
350
350
  followId: z.ZodString;
351
351
  }, z.core.$strip>;
352
+ /**
353
+ * One follow's copy positions closing: a batch acknowledgement, sent once the
354
+ * batch is durably logged. The closes are reduce-only and immediate-or-cancel;
355
+ * each one's fills arrive on the order, position and copy channels. Not a
356
+ * flatten guarantee: `positionsNotClosed` counts what a thin or halted market
357
+ * left open.
358
+ */
359
+ export declare const CloseFollowPositionsResponseSchema: z.ZodObject<{
360
+ followId: z.ZodString;
361
+ closeOrdersPlaced: z.ZodNumber;
362
+ positionsNotClosed: z.ZodNumber;
363
+ }, z.core.$strip>;
364
+ /** A follow whose close could not run. */
365
+ export declare const FollowCloseFailureSchema: z.ZodObject<{
366
+ followId: z.ZodString;
367
+ reason: z.ZodString;
368
+ }, z.core.$strip>;
369
+ /** Result of closing all your copy positions. */
370
+ export declare const CloseAllCopyPositionsResponseSchema: z.ZodObject<{
371
+ follows: z.ZodArray<z.ZodObject<{
372
+ followId: z.ZodString;
373
+ closeOrdersPlaced: z.ZodNumber;
374
+ positionsNotClosed: z.ZodNumber;
375
+ }, z.core.$strip>>;
376
+ stoppingFollowIds: z.ZodArray<z.ZodString>;
377
+ failedFollows: z.ZodArray<z.ZodObject<{
378
+ followId: z.ZodString;
379
+ reason: z.ZodString;
380
+ }, z.core.$strip>>;
381
+ }, z.core.$strip>;
382
+ /** Result of adding margin to one of your copy positions. */
383
+ export declare const AddFollowPositionMarginResponseSchema: z.ZodObject<{
384
+ followId: z.ZodString;
385
+ tradingPairId: z.ZodString;
386
+ riskBucketId: z.ZodString;
387
+ positionId: z.ZodString;
388
+ positionMargin: z.ZodString;
389
+ copyAccountAvailable: z.ZodString;
390
+ }, z.core.$strip>;
352
391
  export type LeadTraderRef = z.infer<typeof LeadTraderRefSchema>;
353
392
  export type LeadTraderProfile = z.infer<typeof LeadTraderProfileSchema>;
354
393
  export type LeadTraderFollowSummary = z.infer<typeof LeadTraderFollowSummarySchema>;
@@ -370,4 +409,8 @@ export type GetFollowResponse = z.infer<typeof GetFollowResponseSchema>;
370
409
  export type ListFollowLeaderPositionsResponse = z.infer<typeof ListFollowLeaderPositionsResponseSchema>;
371
410
  export type UpsertFollowResponse = z.infer<typeof UpsertFollowResponseSchema>;
372
411
  export type StopFollowResponse = z.infer<typeof StopFollowResponseSchema>;
412
+ export type CloseFollowPositionsResponse = z.infer<typeof CloseFollowPositionsResponseSchema>;
413
+ export type FollowCloseFailure = z.infer<typeof FollowCloseFailureSchema>;
414
+ export type CloseAllCopyPositionsResponse = z.infer<typeof CloseAllCopyPositionsResponseSchema>;
373
415
  export type PreviewFollowResponse = z.infer<typeof PreviewFollowResponseSchema>;
416
+ export type AddFollowPositionMarginResponse = z.infer<typeof AddFollowPositionMarginResponseSchema>;
@@ -266,3 +266,52 @@ export const StopFollowResponseSchema = z.object({
266
266
  /** The stopped follow's id. */
267
267
  followId: z.string(),
268
268
  });
269
+ /**
270
+ * One follow's copy positions closing: a batch acknowledgement, sent once the
271
+ * batch is durably logged. The closes are reduce-only and immediate-or-cancel;
272
+ * each one's fills arrive on the order, position and copy channels. Not a
273
+ * flatten guarantee: `positionsNotClosed` counts what a thin or halted market
274
+ * left open.
275
+ */
276
+ export const CloseFollowPositionsResponseSchema = z.object({
277
+ /** The follow's id. */
278
+ followId: z.string(),
279
+ /** Close orders placed (each may fill in part). */
280
+ closeOrdersPlaced: z.number(),
281
+ /** Copy positions still open after the batch (for example a thin or halted market). */
282
+ positionsNotClosed: z.number(),
283
+ });
284
+ /** A follow whose close could not run. */
285
+ export const FollowCloseFailureSchema = z.object({
286
+ /** The follow's id. */
287
+ followId: z.string(),
288
+ /** Why the close could not run, as a fixed sentence; retry the close. */
289
+ reason: z.string(),
290
+ });
291
+ /** Result of closing all your copy positions. */
292
+ export const CloseAllCopyPositionsResponseSchema = z.object({
293
+ /**
294
+ * Every live follow whose stop is not in progress and whose close ran,
295
+ * including one with nothing to close (0 orders placed, 0 positions not closed).
296
+ */
297
+ follows: z.array(CloseFollowPositionsResponseSchema),
298
+ /** Follows whose stop is in progress: their stop closes their positions. */
299
+ stoppingFollowIds: z.array(z.string()),
300
+ /** Follows whose close could not run; the other follows still closed. */
301
+ failedFollows: z.array(FollowCloseFailureSchema),
302
+ });
303
+ /** Result of adding margin to one of your copy positions. */
304
+ export const AddFollowPositionMarginResponseSchema = z.object({
305
+ /** The follow's id. */
306
+ followId: z.string(),
307
+ /** Trading pair of the copy position. */
308
+ tradingPairId: z.string(),
309
+ /** The copy position's isolated risk bucket. */
310
+ riskBucketId: z.string(),
311
+ /** The copy position's id. */
312
+ positionId: z.string(),
313
+ /** The copy position's margin after the add, in quote units. */
314
+ positionMargin: z.string(),
315
+ /** What the copy account can still put into this position after the add, in quote units. */
316
+ copyAccountAvailable: z.string(),
317
+ });
@@ -4,6 +4,7 @@ export type DelegatedAgentAction = "CREATE_ORDER" | "CANCEL_ORDER" | "REPLACE_OR
4
4
  export interface UpsertDelegatedAgentRequest {
5
5
  agentAddress: string;
6
6
  name?: string;
7
+ /** Delegation expiry (ISO 8601); ends reads, trading, and session refresh. */
7
8
  expiresAt?: string;
8
9
  /** Required. An empty list permits no actions. */
9
10
  allowedActions: DelegatedAgentAction[];
@@ -61,6 +62,7 @@ export interface CreateDelegatedSessionRequest {
61
62
  sessionPublicKey: string;
62
63
  }
63
64
  export interface CreateDelegatedSessionResponse {
65
+ /** Unix seconds; bounded by delegation expiry. Revocation may end access sooner. */
64
66
  expiresAt: number;
65
67
  delegationId: string;
66
68
  ownerUserId: string;
@@ -41,6 +41,9 @@ export interface FeesAPI extends BaseAPI {
41
41
  * spot/perp breakdown), the volume still needed to reach the next tier, and the
42
42
  * requested pair's six-row fee schedule (threshold plus maker/taker bps).
43
43
  *
44
+ * The tier and volumes are wallet-wide: the caller's wallet total across every
45
+ * application it trades through, so they read the same from any application.
46
+ *
44
47
  * @param params - Parameters for the lookup
45
48
  * @param params.tradingPairId - Trading pair whose fee schedule to return
46
49
  * @returns Promise resolving to the caller's tier and the pair's schedule
@@ -126,13 +126,13 @@ export const FeeTierScheduleRowSchema = z.object({
126
126
  * Zod schema for the "my fee tier" response
127
127
  */
128
128
  export const GetMyFeeTierResponseSchema = z.object({
129
- /** Caller's resolved tier (1–6) from stored weighted 14-day volume */
129
+ /** Caller's resolved tier (1–6) from their wallet's stored weighted 14-day volume */
130
130
  currentTierLevel: z.number().int(),
131
- /** Caller's weighted 14-day volume (perp + 2.5× spot) */
131
+ /** Caller's weighted 14-day volume (perp + 2.5× spot), summed across every application the wallet trades through */
132
132
  weightedVolume14d: z.string(),
133
- /** Caller's rolling 14-day spot volume */
133
+ /** Caller's rolling 14-day spot volume, summed across every application the wallet trades through */
134
134
  spotVolume14d: z.string(),
135
- /** Caller's rolling 14-day perp volume */
135
+ /** Caller's rolling 14-day perp volume, summed across every application the wallet trades through */
136
136
  perpVolume14d: z.string(),
137
137
  /** Additional weighted volume needed to reach the next tier; absent at tier 6 */
138
138
  volumeToNextTier: z.string().nullable().optional(),
@@ -70,6 +70,16 @@ export declare const PreviewFollowSchema: z.ZodObject<{
70
70
  allocation: z.ZodString;
71
71
  tradingPairIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
72
72
  }, z.core.$strict>;
73
+ /**
74
+ * Params for adding margin to one of your copy positions: `amount` moves from
75
+ * the follow's copy account into the margin of its isolated copy position on
76
+ * `tradingPairId`. The follow id is sent in the path, the rest in the body.
77
+ */
78
+ export declare const AddFollowPositionMarginSchema: z.ZodObject<{
79
+ followId: z.ZodUUID;
80
+ tradingPairId: z.ZodUUID;
81
+ amount: z.ZodString;
82
+ }, z.core.$strict>;
73
83
  /** Params for the public leaderboard. */
74
84
  export declare const ListLeadTradersSchema: z.ZodObject<{
75
85
  pageSize: z.ZodOptional<z.ZodNumber>;
@@ -107,6 +117,7 @@ export declare const ListMyFollowersSchema: z.ZodObject<{
107
117
  export type UpsertLeadTraderParams = z.input<typeof UpsertLeadTraderSchema>;
108
118
  export type UpsertFollowParams = z.input<typeof UpsertFollowSchema>;
109
119
  export type PreviewFollowParams = z.input<typeof PreviewFollowSchema>;
120
+ export type AddFollowPositionMarginParams = z.input<typeof AddFollowPositionMarginSchema>;
110
121
  export type ListLeadTradersParams = z.input<typeof ListLeadTradersSchema>;
111
122
  export type ListLeadTraderClosedTradesParams = z.input<typeof ListLeadTraderClosedTradesSchema>;
112
123
  export type ListMyFollowsParams = z.input<typeof ListMyFollowsSchema>;
@@ -123,6 +123,21 @@ export const PreviewFollowSchema = z
123
123
  })
124
124
  .strict()
125
125
  .superRefine((params, ctx) => termRules(params, ctx));
126
+ /**
127
+ * Params for adding margin to one of your copy positions: `amount` moves from
128
+ * the follow's copy account into the margin of its isolated copy position on
129
+ * `tradingPairId`. The follow id is sent in the path, the rest in the body.
130
+ */
131
+ export const AddFollowPositionMarginSchema = z
132
+ .object({
133
+ /** The follow's id. */
134
+ followId: UUIDSchema,
135
+ /** Trading pair of the copy position to add margin to. */
136
+ tradingPairId: UUIDSchema,
137
+ /** Margin to add, in quote units, taken from the follow's copy account. */
138
+ amount: PositiveDecimalStringSchema,
139
+ })
140
+ .strict();
126
141
  /** Params for the public leaderboard. */
127
142
  export const ListLeadTradersSchema = z
128
143
  .object({
@@ -107,7 +107,7 @@ export interface PositionEventData {
107
107
  /**
108
108
  * What triggered the update. Free-form, but the server uses a canonical set:
109
109
  * `trade`, `close`, `liquidation`, `adl`, `funding`, `margin_added`,
110
- * `margin_reduced`, `margin_collateral_transfer`.
110
+ * `margin_reduced`.
111
111
  */
112
112
  reason: string;
113
113
  /**
@@ -147,8 +147,8 @@ export interface PositionEventData {
147
147
  * anything was persisted. Four cases reach it: the frame came from a
148
148
  * producer that predates this field; the emit path wrote no row;
149
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
150
+ * (`funding`), so the mutation did advance the persisted version; or the
151
+ * frame is a different projection of the row
152
152
  * than persistence stores (terminal frames report `size` 0 and
153
153
  * `LIQUIDATED`, while the stored row keeps its size and records `CLOSED`).
154
154
  * In the last two, a REST read or a fresh snapshot ranks the mutation.
@@ -172,13 +172,17 @@ export interface PositionEventData {
172
172
  * mutation — up to the one-hour funding interval.
173
173
  *
174
174
  * 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.
175
+ * persisted at that sequence: fills that leave a position OPEN, direct
176
+ * isolated-position margin adds/reductions, and copy-position margin adds.
177
+ * The copy add refreshes the isolated child and its copy-cross siblings at
178
+ * the same version. Cross-risk-bucket ALLOCATE/RELEASE and copy follow/stop
179
+ * 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
184
+ * position frame. Transfer frames use captured post-command state and are
185
+ * released only after durable acknowledgement.
182
186
  */
183
187
  version?: number;
184
188
  }
@@ -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", "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"];
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,6 +26,8 @@ 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",
29
32
  "create_challenge",
30
33
  "create_delegated_session",
@@ -621,9 +621,11 @@ export interface paths {
621
621
  * Refresh session expiry
622
622
  * @description Refresh session expiry.
623
623
  *
624
- * Extends the expiration of the current session. The request must be signed
624
+ * Refreshes the expiration of the current session. The request must be signed
625
625
  * by the session private key (RFC 9421 or legacy X-Monaco-* headers); no body is
626
- * required.
626
+ * required. Delegated sessions require an active, unexpired delegation;
627
+ * their resulting expiry is capped by the delegation expiry and may move
628
+ * earlier if the owner shortened that delegation.
627
629
  */
628
630
  post: operations["refresh_session"];
629
631
  delete?: never;
@@ -914,6 +916,36 @@ export interface paths {
914
916
  patch?: never;
915
917
  trace?: never;
916
918
  };
919
+ "/api/v1/copy-trading/follows/close-positions": {
920
+ parameters: {
921
+ query?: never;
922
+ header?: never;
923
+ path?: never;
924
+ cookie?: never;
925
+ };
926
+ get?: never;
927
+ put?: never;
928
+ /**
929
+ * Close all your copy positions
930
+ * @description Close all your copy positions.
931
+ *
932
+ * Closes the copy positions of every live follow of yours, as
933
+ * CloseFollowPositions does for one: one batch per follow, the follows
934
+ * kept, and the same limits (not a flatten guarantee; the follows keep
935
+ * mirroring). A follow whose stop is in progress is listed in
936
+ * `stoppingFollowIds` and left to its stop. A follow whose close could not
937
+ * run is listed in `failedFollows` and the others still close. Never gated
938
+ * by copy trading being switched off or by an operations block; only a
939
+ * delegated agent session is refused. Shares CloseFollowPositions' rate
940
+ * limit.
941
+ */
942
+ post: operations["close_all_copy_positions"];
943
+ delete?: never;
944
+ options?: never;
945
+ head?: never;
946
+ patch?: never;
947
+ trace?: never;
948
+ };
917
949
  "/api/v1/copy-trading/follows/preview": {
918
950
  parameters: {
919
951
  query?: never;
@@ -965,6 +997,41 @@ export interface paths {
965
997
  patch?: never;
966
998
  trace?: never;
967
999
  };
1000
+ "/api/v1/copy-trading/follows/{followId}/close-positions": {
1001
+ parameters: {
1002
+ query?: never;
1003
+ header?: never;
1004
+ path?: never;
1005
+ cookie?: never;
1006
+ };
1007
+ get?: never;
1008
+ put?: never;
1009
+ /**
1010
+ * Close a follow's copy positions
1011
+ * @description Close a follow's copy positions.
1012
+ *
1013
+ * Closes every position in the follow's copy account at market (reduce-only,
1014
+ * immediate-or-cancel) and cancels the resting orders and conditional
1015
+ * orders (TP/SL) on its copy risk buckets (a TWAP cannot run on a copy risk
1016
+ * bucket), but keeps the follow: it stays ACTIVE (or CLOSE_ONLY) and the
1017
+ * leader's next trades keep mirroring. StopFollow is the close-and-stop
1018
+ * path. The proceeds stay in the copy account. Not a flatten guarantee:
1019
+ * on a thin or halted market part of a position can stay open
1020
+ * (`positionsNotClosed`), and a leader trade after the close opens copy
1021
+ * positions again; stop the follow to end the copying. A close is never
1022
+ * gated by copy trading being switched off or by an operations block, and
1023
+ * only a delegated agent session is refused. Both close routes share a
1024
+ * small per-account rate limit (about one close per second, burst 5). The
1025
+ * response is sent once the batch is durably logged; each close's fills
1026
+ * arrive on the order, position and copy channels.
1027
+ */
1028
+ post: operations["close_follow_positions"];
1029
+ delete?: never;
1030
+ options?: never;
1031
+ head?: never;
1032
+ patch?: never;
1033
+ trace?: never;
1034
+ };
968
1035
  "/api/v1/copy-trading/follows/{followId}/leader-positions": {
969
1036
  parameters: {
970
1037
  query?: never;
@@ -989,6 +1056,41 @@ export interface paths {
989
1056
  patch?: never;
990
1057
  trace?: never;
991
1058
  };
1059
+ "/api/v1/copy-trading/follows/{followId}/position-margin": {
1060
+ parameters: {
1061
+ query?: never;
1062
+ header?: never;
1063
+ path?: never;
1064
+ cookie?: never;
1065
+ };
1066
+ get?: never;
1067
+ put?: never;
1068
+ /**
1069
+ * Add margin to a copy position
1070
+ * @description Add margin to a copy position (0XM-2971).
1071
+ *
1072
+ * Moves collateral from the follow's copy account into the margin of its
1073
+ * isolated copy position on one trading pair: the position's margin rises
1074
+ * by exactly `amount`, the copy account's remaining collateral falls by the
1075
+ * same, and your margin account is never touched. It lowers the position's
1076
+ * leverage and moves its liquidation price away; it opens no exposure, so
1077
+ * it works while copy trading is switched off and on a CLOSE_ONLY follow.
1078
+ * There is no margin reduction: a follow exits by being stopped. Follow
1079
+ * writes need a master account session (not a delegated agent or a
1080
+ * sub-account). 404 unless the follow is yours; 409 while it is stopping
1081
+ * or once it is stopped, and when copy trading is not available on the
1082
+ * platform at all (the platform then runs copy trading exits only). It
1083
+ * spends the per-user movement budget withdrawals and collateral transfers
1084
+ * share. It is not idempotent: a retry after a timeout whose first attempt
1085
+ * landed adds the amount twice, so read the follow before retrying.
1086
+ */
1087
+ post: operations["add_follow_position_margin"];
1088
+ delete?: never;
1089
+ options?: never;
1090
+ head?: never;
1091
+ patch?: never;
1092
+ trace?: never;
1093
+ };
992
1094
  "/api/v1/copy-trading/follows/{followId}/stop": {
993
1095
  parameters: {
994
1096
  query?: never;
@@ -1242,7 +1344,9 @@ export interface paths {
1242
1344
  * `ListDelegatedAgentOwners`) and a freshly generated session public key.
1243
1345
  * The new session acts as the owner but records the agent's address for
1244
1346
  * policy enforcement. Requires an active delegation for the (owner, agent)
1245
- * pair.
1347
+ * pair. Session expiry is bounded by the delegation expiry, if set. Every
1348
+ * authenticated request and periodic WebSocket session revalidation requires
1349
+ * the backing delegation to remain active and unexpired.
1246
1350
  */
1247
1351
  post: operations["create_delegated_session"];
1248
1352
  delete?: never;
@@ -1266,8 +1370,9 @@ export interface paths {
1266
1370
  * @description Revoke a delegated agent.
1267
1371
  *
1268
1372
  * Master accounts only. Revokes the delegation identified by
1269
- * `delegated_agent_id`. Existing delegated sessions are not invalidated; only
1270
- * future session creation is blocked.
1373
+ * `delegated_agent_id` and its existing delegated sessions. Subsequent signed
1374
+ * requests and session refresh fail; connected WebSockets lose access at
1375
+ * their next periodic session revalidation. Existing orders are not canceled.
1271
1376
  */
1272
1377
  delete: operations["revoke_delegated_agent"];
1273
1378
  options?: never;
@@ -1360,6 +1465,8 @@ export interface paths {
1360
1465
  /**
1361
1466
  * Get my fee tier and pair schedule
1362
1467
  * @description Return the caller's current fee tier, rolling 14-day volumes, and a pair's schedule.
1468
+ *
1469
+ * Volumes and the tier are wallet-wide: the caller's wallet total across every application.
1363
1470
  */
1364
1471
  get: operations["get_my_fee_tier"];
1365
1472
  put?: never;
@@ -3039,6 +3146,55 @@ export interface components {
3039
3146
  */
3040
3147
  version?: number | null;
3041
3148
  };
3149
+ AddFollowPositionMarginRequest: {
3150
+ /**
3151
+ * Format: uuid
3152
+ * @description The follow's id
3153
+ */
3154
+ followId?: string | null;
3155
+ /**
3156
+ * Format: uuid
3157
+ * @description Trading pair UUID of the copy position to add margin to
3158
+ */
3159
+ tradingPairId?: string | null;
3160
+ /**
3161
+ * @description Margin to add, in quote units: a positive decimal, taken from the follow's copy account
3162
+ * @example 25
3163
+ */
3164
+ amount?: string | null;
3165
+ };
3166
+ AddFollowPositionMarginResponse: {
3167
+ /**
3168
+ * Format: uuid
3169
+ * @description The follow's id
3170
+ */
3171
+ followId?: string | null;
3172
+ /**
3173
+ * Format: uuid
3174
+ * @description Trading pair UUID of the copy position
3175
+ */
3176
+ tradingPairId?: string | null;
3177
+ /**
3178
+ * Format: uuid
3179
+ * @description The copy position's isolated risk bucket
3180
+ */
3181
+ riskBucketId?: string | null;
3182
+ /**
3183
+ * Format: uuid
3184
+ * @description The copy position's id
3185
+ */
3186
+ positionId?: string | null;
3187
+ /**
3188
+ * @description The copy position's margin after the add, in quote units
3189
+ * @example 125
3190
+ */
3191
+ positionMargin?: string | null;
3192
+ /**
3193
+ * @description What the copy account can still put into this position, in quote units, after the add
3194
+ * @example 875
3195
+ */
3196
+ copyAccountAvailable?: string | null;
3197
+ };
3042
3198
  AppUser: {
3043
3199
  /**
3044
3200
  * Format: uuid
@@ -3973,6 +4129,37 @@ export interface components {
3973
4129
  /** @description Required when renewing an unexpired lease. Decimal string in JSON. */
3974
4130
  expectedGeneration?: string | null;
3975
4131
  };
4132
+ CloseAllCopyPositionsResponse: {
4133
+ /**
4134
+ * @description Every live follow whose stop is not in progress and whose close ran,
4135
+ * including one with nothing to close (0 orders placed, 0 positions not
4136
+ * closed).
4137
+ */
4138
+ follows?: components["schemas"]["CloseFollowPositionsResponse"][] | null;
4139
+ /** @description Follows whose stop is in progress: their stop closes their positions. */
4140
+ stoppingFollowIds?: string[] | null;
4141
+ /** @description Follows whose close could not run; the other follows still closed. */
4142
+ failedFollows?: components["schemas"]["FollowCloseFailure"][] | null;
4143
+ };
4144
+ CloseFollowPositionsResponse: {
4145
+ /**
4146
+ * Format: uuid
4147
+ * @description The follow's id
4148
+ */
4149
+ followId?: string | null;
4150
+ /**
4151
+ * Format: uint32
4152
+ * @description Reduce-only, immediate-or-cancel close orders placed; each may fill in part
4153
+ * @example 2
4154
+ */
4155
+ closeOrdersPlaced?: number | null;
4156
+ /**
4157
+ * Format: uint32
4158
+ * @description Copy positions still open after the batch (for example a thin or halted market); 0 when the copy account is flat
4159
+ * @example 0
4160
+ */
4161
+ positionsNotClosed?: number | null;
4162
+ };
3976
4163
  ClosePositionRequest: {
3977
4164
  quantity?: string | null;
3978
4165
  closeType?: string | null;
@@ -4097,7 +4284,7 @@ export interface components {
4097
4284
  };
4098
4285
  CreateDelegatedSessionResponse: {
4099
4286
  /**
4100
- * @description Session expiry as a Unix timestamp (seconds)
4287
+ * @description Session expiry as a Unix timestamp (seconds), bounded by the delegation expiry when set. Earlier revocation or policy expiry also ends access.
4101
4288
  * @example 1735689599
4102
4289
  */
4103
4290
  expiresAt?: string | null;
@@ -4684,6 +4871,19 @@ export interface components {
4684
4871
  /** @description FOLLOWER, STOP_LOSS, SKIP_LIMIT, ADMIN or LEADER_SUSPENDED */
4685
4872
  stopReason?: string | null;
4686
4873
  };
4874
+ /** @description A follow whose close could not run. */
4875
+ FollowCloseFailure: {
4876
+ /**
4877
+ * Format: uuid
4878
+ * @description The follow's id
4879
+ */
4880
+ followId?: string | null;
4881
+ /**
4882
+ * @description Why the close could not run, as a fixed sentence; retry the close
4883
+ * @example The copy positions could not be closed right now; retry shortly
4884
+ */
4885
+ reason?: string | null;
4886
+ };
4687
4887
  Follower: {
4688
4888
  /** @description The follower's wallet address (lowercase hex) */
4689
4889
  walletAddress?: string | null;
@@ -5337,22 +5537,22 @@ export interface components {
5337
5537
  GetMyFeeTierResponse: {
5338
5538
  /**
5339
5539
  * Format: int32
5340
- * @description Caller's resolved tier (1–6) from stored weighted 14-day volume
5540
+ * @description Caller's resolved tier (1–6) from their wallet's stored weighted 14-day volume
5341
5541
  * @example 2
5342
5542
  */
5343
5543
  currentTierLevel?: number | null;
5344
5544
  /**
5345
- * @description Caller's weighted 14-day volume (perp + 2.5× spot)
5545
+ * @description Caller's weighted 14-day volume (perp + 2.5× spot), summed across every application the wallet trades through
5346
5546
  * @example 7500000
5347
5547
  */
5348
5548
  weightedVolume14d?: string | null;
5349
5549
  /**
5350
- * @description Caller's rolling 14-day spot volume
5550
+ * @description Caller's rolling 14-day spot volume, summed across every application the wallet trades through
5351
5551
  * @example 1000000
5352
5552
  */
5353
5553
  spotVolume14d?: string | null;
5354
5554
  /**
5355
- * @description Caller's rolling 14-day perp volume
5555
+ * @description Caller's rolling 14-day perp volume, summed across every application the wallet trades through
5356
5556
  * @example 5000000
5357
5557
  */
5358
5558
  perpVolume14d?: string | null;
@@ -6071,7 +6271,7 @@ export interface components {
6071
6271
  cumFees?: string | null;
6072
6272
  /**
6073
6273
  * Format: int64
6074
- * @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, persists the account's snapshot and restamps the positions it changed), so the merge rule is per field group — on an equal version skip the versioned fields but still take all six from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL and can leave a stale margin requirement on screen. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. The version advances exactly when the row's versioned content changed at that sequence, a change undone within one persistence batch included; a position a command left unchanged keeps its version, so a RANKED live frame for an untouched sibling of a filled position can carry a higher version than the persisted row while describing identical content — rank it as newer, and nothing changes. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
6274
+ * @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. Ranked live frames include fills that leave a position open, direct isolated-position margin adds/reductions, and copy-position margin adds; the copy add refreshes its isolated child and copy-cross siblings at the same version. Cross-risk-bucket ALLOCATE/RELEASE and copy follow/stop refreshes use margin_added/margin_reduced but omit the version because those commands write no position rows. Funding omits it because it re-reads live state after sequencing; terminal frames omit it because they report size 0 and sometimes LIQUIDATED while the stored row keeps its size and records CLOSED. Wallet IN/OUT and plain isolated allocation send no position frame. Transfer frames use captured post-command state and are released only after durable acknowledgement. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, persists the account's snapshot and restamps the positions it changed), so the merge rule is per field group — on an equal version skip the versioned fields but still take all six from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL and can leave a stale margin requirement on screen. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. The version advances exactly when the row's versioned content changed at that sequence, a change undone within one persistence batch included; a position a command left unchanged keeps its version, so a RANKED live frame for an untouched sibling of a filled position can carry a higher version than the persisted row while describing identical content — rank it as newer, and nothing changes. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
6075
6275
  * @example 918342
6076
6276
  */
6077
6277
  version?: number | null;
@@ -7882,7 +8082,7 @@ export interface components {
7882
8082
  cumFees?: string | null;
7883
8083
  /**
7884
8084
  * Format: int64
7885
- * @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: it means the row predates this field or came from a producer that does not stamp it, so treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, persists the account's snapshot and restamps the positions it changed), so the merge rule is per field group — on an equal version skip the versioned fields but still take all six from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL and can leave a stale margin requirement on screen. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. The version advances exactly when the row's versioned content changed at that sequence, a change undone within one persistence batch included; a position a command left unchanged keeps its version, so a RANKED live frame for an untouched sibling of a filled position can carry a higher version than the persisted row while describing identical content — rank it as newer, and nothing changes. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
8085
+ * @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: it means the row predates this field or came from a producer that does not stamp it, so treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. Ranked live frames include fills that leave a position open, direct isolated-position margin adds/reductions, and copy-position margin adds; the copy add refreshes its isolated child and copy-cross siblings at the same version. Cross-risk-bucket ALLOCATE/RELEASE and copy follow/stop refreshes use margin_added/margin_reduced but omit the version because those commands write no position rows. Funding omits it because it re-reads live state after sequencing; terminal frames omit it because they report size 0 and sometimes LIQUIDATED while the stored row keeps its size and records CLOSED. Wallet IN/OUT and plain isolated allocation send no position frame. Transfer frames use captured post-command state and are released only after durable acknowledgement. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, persists the account's snapshot and restamps the positions it changed), so the merge rule is per field group — on an equal version skip the versioned fields but still take all six from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL and can leave a stale margin requirement on screen. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. The version advances exactly when the row's versioned content changed at that sequence, a change undone within one persistence batch included; a position a command left unchanged keeps its version, so a RANKED live frame for an untouched sibling of a filled position can carry a higher version than the persisted row while describing identical content — rank it as newer, and nothing changes. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
7886
8086
  * @example 918342
7887
8087
  */
7888
8088
  version?: number | null;
@@ -8300,7 +8500,7 @@ export interface components {
8300
8500
  RefreshResponse: {
8301
8501
  /**
8302
8502
  * Format: int32
8303
- * @description Unix timestamp when the session expires after refresh
8503
+ * @description Unix timestamp when the session expires after refresh. For delegated sessions, bounded by the active delegation expiry when set.
8304
8504
  * @example 1699876543
8305
8505
  */
8306
8506
  expiresAt?: number | null;
@@ -9785,7 +9985,7 @@ export interface components {
9785
9985
  */
9786
9986
  name?: string | null;
9787
9987
  /**
9788
- * @description Optional delegation expiry timestamp (ISO 8601). Omit for no expiry.
9988
+ * @description Optional delegation expiry timestamp (ISO 8601). Ends delegated reads, trading, and session refresh. Omit for no delegation expiry; session expiry still applies.
9789
9989
  * @example 2026-12-31T23:59:59Z
9790
9990
  */
9791
9991
  expiresAt?: string | null;
@@ -12122,6 +12322,75 @@ export interface operations {
12122
12322
  };
12123
12323
  };
12124
12324
  };
12325
+ close_all_copy_positions: {
12326
+ parameters: {
12327
+ query?: never;
12328
+ header?: never;
12329
+ path?: never;
12330
+ cookie?: never;
12331
+ };
12332
+ requestBody?: never;
12333
+ responses: {
12334
+ /** @description OK */
12335
+ 200: {
12336
+ headers: {
12337
+ [name: string]: unknown;
12338
+ };
12339
+ content: {
12340
+ "application/json": components["schemas"]["CloseAllCopyPositionsResponse"];
12341
+ };
12342
+ };
12343
+ /** @description The close was refused */
12344
+ 400: {
12345
+ headers: {
12346
+ [name: string]: unknown;
12347
+ };
12348
+ content?: never;
12349
+ };
12350
+ /** @description Authentication required */
12351
+ 401: {
12352
+ headers: {
12353
+ [name: string]: unknown;
12354
+ };
12355
+ content?: never;
12356
+ };
12357
+ /** @description Delegated agent sessions cannot close copy positions */
12358
+ 403: {
12359
+ headers: {
12360
+ [name: string]: unknown;
12361
+ };
12362
+ content?: never;
12363
+ };
12364
+ /** @description Copy trading is not available */
12365
+ 409: {
12366
+ headers: {
12367
+ [name: string]: unknown;
12368
+ };
12369
+ content?: never;
12370
+ };
12371
+ /** @description Copy position close rate limit exceeded; retry after the interval in details.retryAfter */
12372
+ 429: {
12373
+ headers: {
12374
+ [name: string]: unknown;
12375
+ };
12376
+ content?: never;
12377
+ };
12378
+ /** @description Internal server error */
12379
+ 500: {
12380
+ headers: {
12381
+ [name: string]: unknown;
12382
+ };
12383
+ content?: never;
12384
+ };
12385
+ /** @description The matching engine is unavailable; retry */
12386
+ 503: {
12387
+ headers: {
12388
+ [name: string]: unknown;
12389
+ };
12390
+ content?: never;
12391
+ };
12392
+ };
12393
+ };
12125
12394
  preview_follow: {
12126
12395
  parameters: {
12127
12396
  query?: never;
@@ -12259,6 +12528,84 @@ export interface operations {
12259
12528
  };
12260
12529
  };
12261
12530
  };
12531
+ close_follow_positions: {
12532
+ parameters: {
12533
+ query?: never;
12534
+ header?: never;
12535
+ path: {
12536
+ followId: string;
12537
+ };
12538
+ cookie?: never;
12539
+ };
12540
+ requestBody?: never;
12541
+ responses: {
12542
+ /** @description OK */
12543
+ 200: {
12544
+ headers: {
12545
+ [name: string]: unknown;
12546
+ };
12547
+ content: {
12548
+ "application/json": components["schemas"]["CloseFollowPositionsResponse"];
12549
+ };
12550
+ };
12551
+ /** @description Invalid follow id, or the close was refused */
12552
+ 400: {
12553
+ headers: {
12554
+ [name: string]: unknown;
12555
+ };
12556
+ content?: never;
12557
+ };
12558
+ /** @description Authentication required */
12559
+ 401: {
12560
+ headers: {
12561
+ [name: string]: unknown;
12562
+ };
12563
+ content?: never;
12564
+ };
12565
+ /** @description Delegated agent sessions cannot close copy positions */
12566
+ 403: {
12567
+ headers: {
12568
+ [name: string]: unknown;
12569
+ };
12570
+ content?: never;
12571
+ };
12572
+ /** @description Follow not found */
12573
+ 404: {
12574
+ headers: {
12575
+ [name: string]: unknown;
12576
+ };
12577
+ content?: never;
12578
+ };
12579
+ /** @description The follow is stopped, or its stop is in progress (which closes its positions itself), or copy trading is not available */
12580
+ 409: {
12581
+ headers: {
12582
+ [name: string]: unknown;
12583
+ };
12584
+ content?: never;
12585
+ };
12586
+ /** @description Copy position close rate limit exceeded; retry after the interval in details.retryAfter */
12587
+ 429: {
12588
+ headers: {
12589
+ [name: string]: unknown;
12590
+ };
12591
+ content?: never;
12592
+ };
12593
+ /** @description Internal server error */
12594
+ 500: {
12595
+ headers: {
12596
+ [name: string]: unknown;
12597
+ };
12598
+ content?: never;
12599
+ };
12600
+ /** @description The close cannot run right now, or the matching engine is unavailable; retry */
12601
+ 503: {
12602
+ headers: {
12603
+ [name: string]: unknown;
12604
+ };
12605
+ content?: never;
12606
+ };
12607
+ };
12608
+ };
12262
12609
  list_follow_leader_positions: {
12263
12610
  parameters: {
12264
12611
  query?: never;
@@ -12330,6 +12677,88 @@ export interface operations {
12330
12677
  };
12331
12678
  };
12332
12679
  };
12680
+ add_follow_position_margin: {
12681
+ parameters: {
12682
+ query?: never;
12683
+ header?: never;
12684
+ path: {
12685
+ followId: string;
12686
+ };
12687
+ cookie?: never;
12688
+ };
12689
+ requestBody: {
12690
+ content: {
12691
+ "application/json": components["schemas"]["AddFollowPositionMarginRequest"];
12692
+ };
12693
+ };
12694
+ responses: {
12695
+ /** @description OK */
12696
+ 200: {
12697
+ headers: {
12698
+ [name: string]: unknown;
12699
+ };
12700
+ content: {
12701
+ "application/json": components["schemas"]["AddFollowPositionMarginResponse"];
12702
+ };
12703
+ };
12704
+ /** @description Invalid follow id, trading pair or amount, or refused by the engine with code COPY_TRADING_REJECTED (no copy position on the pair, the position or the margin account is being liquidated, the position has lost more than its margin, more than the copy account holds; the message names the rule) */
12705
+ 400: {
12706
+ headers: {
12707
+ [name: string]: unknown;
12708
+ };
12709
+ content?: never;
12710
+ };
12711
+ /** @description Authentication required */
12712
+ 401: {
12713
+ headers: {
12714
+ [name: string]: unknown;
12715
+ };
12716
+ content?: never;
12717
+ };
12718
+ /** @description Only a master account session can add margin (not a delegated agent or a sub-account) */
12719
+ 403: {
12720
+ headers: {
12721
+ [name: string]: unknown;
12722
+ };
12723
+ content?: never;
12724
+ };
12725
+ /** @description Follow not found */
12726
+ 404: {
12727
+ headers: {
12728
+ [name: string]: unknown;
12729
+ };
12730
+ content?: never;
12731
+ };
12732
+ /** @description The follow is stopping or stopped, or code COPY_TRADING_UNAVAILABLE: copy trading is not available on the platform */
12733
+ 409: {
12734
+ headers: {
12735
+ [name: string]: unknown;
12736
+ };
12737
+ content?: never;
12738
+ };
12739
+ /** @description Movement rate limit exceeded — withdrawals and collateral transfers share a per-user budget; retry after the interval in details.retryAfter */
12740
+ 429: {
12741
+ headers: {
12742
+ [name: string]: unknown;
12743
+ };
12744
+ content?: never;
12745
+ };
12746
+ /** @description Internal server error */
12747
+ 500: {
12748
+ headers: {
12749
+ [name: string]: unknown;
12750
+ };
12751
+ content?: never;
12752
+ };
12753
+ /** @description Matching engine unavailable; retry */
12754
+ 503: {
12755
+ headers: {
12756
+ [name: string]: unknown;
12757
+ };
12758
+ content?: never;
12759
+ };
12760
+ };
12761
+ };
12333
12762
  stop_follow: {
12334
12763
  parameters: {
12335
12764
  query?: never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/types",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "type": "module",
5
5
  "homepage": "https://docs.0xmonaco.com/sdk/typescript",
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "lint": "biome lint ."
17
17
  },
18
18
  "dependencies": {
19
- "@0xmonaco/contracts": "1.0.70",
19
+ "@0xmonaco/contracts": "1.0.72",
20
20
  "zod": "^4.1.12"
21
21
  },
22
22
  "peerDependencies": {