@0xmonaco/types 1.0.74 → 1.0.75

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.
Files changed (43) hide show
  1. package/dist/api/index.d.ts +0 -7
  2. package/dist/applications/index.d.ts +14 -15
  3. package/dist/applications/index.js +2 -2
  4. package/dist/applications/requests.d.ts +70 -15
  5. package/dist/applications/requests.js +2 -3
  6. package/dist/applications/responses.d.ts +35 -39
  7. package/dist/applications/responses.js +1 -1
  8. package/dist/fees/responses.js +2 -2
  9. package/dist/margin-accounts/index.d.ts +72 -12
  10. package/dist/market/index.d.ts +76 -6
  11. package/dist/pitpass/index.d.ts +16 -11
  12. package/dist/pitpass/index.js +1 -1
  13. package/dist/pitpass/responses.d.ts +21 -0
  14. package/dist/pitpass/responses.js +43 -14
  15. package/dist/positions/index.d.ts +81 -14
  16. package/dist/profile/index.d.ts +114 -44
  17. package/dist/trading/index.d.ts +1 -1
  18. package/dist/trading/orders.d.ts +6 -32
  19. package/dist/trading/responses.d.ts +9 -14
  20. package/dist/validation/applications.d.ts +51 -0
  21. package/dist/validation/applications.js +45 -0
  22. package/dist/validation/index.d.ts +1 -0
  23. package/dist/validation/index.js +1 -0
  24. package/dist/validation/margin-accounts.d.ts +10 -3
  25. package/dist/validation/margin-accounts.js +17 -6
  26. package/dist/validation/market.d.ts +24 -0
  27. package/dist/validation/market.js +22 -0
  28. package/dist/validation/positions.d.ts +5 -3
  29. package/dist/validation/positions.js +12 -5
  30. package/dist/validation/profile.d.ts +19 -2
  31. package/dist/validation/profile.js +36 -4
  32. package/dist/validation/trading.d.ts +2 -2
  33. package/dist/websocket/base.d.ts +56 -6
  34. package/dist/websocket/client.d.ts +8 -3
  35. package/dist/websocket/events/index.d.ts +1 -0
  36. package/dist/websocket/events/index.js +1 -0
  37. package/dist/websocket/events/position-events.d.ts +15 -0
  38. package/dist/websocket/events/position-valuation-events.d.ts +60 -0
  39. package/dist/websocket/events/position-valuation-events.js +15 -0
  40. package/dist/wire/operations.d.ts +1 -1
  41. package/dist/wire/operations.js +2 -0
  42. package/dist/wire/schema.d.ts +748 -235
  43. package/package.json +2 -2
@@ -4,7 +4,7 @@
4
4
  * Types for PitPass TraderCode API: code lookup, rewards balance, and transfer.
5
5
  */
6
6
  import type { BaseAPI } from "../api";
7
- import type { GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "./responses";
7
+ import type { GetMyReferralDownlineParams, GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "./responses";
8
8
  /**
9
9
  * PitPass TraderCode API interface.
10
10
  *
@@ -106,24 +106,29 @@ export interface PitpassAPI extends BaseAPI {
106
106
  */
107
107
  getMyReferralPosition(): Promise<GetMyReferralPositionResponse>;
108
108
  /**
109
- * Read your own downline: who you earn from and how much (earnings by source
110
- * across L1/L2/L3), your L1 direct-referee roster (including referees who have
111
- * not traded yet), and a per-level earnings summary.
109
+ * Read your own downline: one page of who you earn from and how much
110
+ * (earnings by source across every reward level, largest first), your L1
111
+ * direct-referee roster (including referees who have not traded yet), and a
112
+ * per-level earnings summary that covers every level and source on every
113
+ * page. Without `pageSize` / `pageToken` you get the first page (100 rows),
114
+ * not every row: follow `nextPageToken` until it is empty.
112
115
  *
113
116
  * Self-scoped and read-only. Every source and referee is a public wallet
114
117
  * address plus a `display` handle-or-wallet variant, never an internal id.
115
118
  *
116
- * @returns Promise resolving to earnings-by-source, the direct-referee roster, and a summary
119
+ * @param params - Optional `pageSize` (1-500, default 100) and `pageToken`
120
+ * @returns Promise resolving to the earnings page, the direct-referee roster, a summary, and the next page token
117
121
  */
118
- getMyReferralDownline(): Promise<GetMyReferralDownlineResponse>;
122
+ getMyReferralDownline(params?: GetMyReferralDownlineParams): Promise<GetMyReferralDownlineResponse>;
119
123
  /**
120
124
  * Read one level of your own referral tree: the wallets `parent` directly
121
125
  * referred (yourself when `parent` is omitted), a page at a time, newest
122
126
  * first. Expand a node by calling again with `parent` set to its wallet;
123
- * nodes with `refereeCount > 0` are expandable, down to level 3.
127
+ * nodes with `refereeCount > 0` are expandable, down to the deepest level
128
+ * PitPass rewards (configured by Monaco, at most 10).
124
129
  *
125
- * Self-scoped: `parent` must be you or one of your own L1/L2 referees — any
126
- * other wallet is a 404. Each wallet appears once, under the referrer that
130
+ * Self-scoped: `parent` must be you or one of your own referees above that
131
+ * deepest level — any other wallet is a 404. Each wallet appears once, under the referrer that
127
132
  * earns from it.
128
133
  *
129
134
  * @param params - Optional `parent` wallet, `pageSize` (1-200), and `pageToken`
@@ -131,5 +136,5 @@ export interface PitpassAPI extends BaseAPI {
131
136
  */
132
137
  getMyReferralTree(params?: GetMyReferralTreeParams): Promise<GetMyReferralTreeResponse>;
133
138
  }
134
- export type { GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, ReferralDirectReferee, ReferralEarningsSource, ReferralEarningsSummary, ReferralRewardEntry, ReferralTreeNode, ReferralUplineEntry, RewardsBalanceEntry, SetTraderCodeParams, TraderCodeAvailabilityReason, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse, } from "./responses";
135
- export { GetMyReferralDownlineResponseSchema, GetMyReferralPositionResponseSchema, GetMyReferralTreeParamsSchema, GetMyReferralTreeResponseSchema, GetRewardsBalanceResponseSchema, ReferralDirectRefereeSchema, ReferralEarningsSourceSchema, ReferralEarningsSummarySchema, ReferralRewardEntrySchema, ReferralTreeNodeSchema, ReferralUplineEntrySchema, RewardsBalanceEntrySchema, SetTraderCodeParamsSchema, TraderCodeAvailabilityReasonSchema, TraderCodeAvailabilityResponseSchema, TraderCodeInfoResponseSchema, TraderCodeResponseSchema, TransferRewardsParamsSchema, TransferRewardsResponseSchema, } from "./responses";
139
+ export type { GetMyReferralDownlineParams, GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, LevelEarnings, ReferralDirectReferee, ReferralEarningsSource, ReferralEarningsSummary, ReferralRewardEntry, ReferralTreeNode, ReferralUplineEntry, RewardsBalanceEntry, SetTraderCodeParams, TraderCodeAvailabilityReason, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse, } from "./responses";
140
+ export { GetMyReferralDownlineParamsSchema, GetMyReferralDownlineResponseSchema, GetMyReferralPositionResponseSchema, GetMyReferralTreeParamsSchema, GetMyReferralTreeResponseSchema, GetRewardsBalanceResponseSchema, LevelEarningsSchema, ReferralDirectRefereeSchema, ReferralEarningsSourceSchema, ReferralEarningsSummarySchema, ReferralRewardEntrySchema, ReferralTreeNodeSchema, ReferralUplineEntrySchema, RewardsBalanceEntrySchema, SetTraderCodeParamsSchema, TraderCodeAvailabilityReasonSchema, TraderCodeAvailabilityResponseSchema, TraderCodeInfoResponseSchema, TraderCodeResponseSchema, TransferRewardsParamsSchema, TransferRewardsResponseSchema, } from "./responses";
@@ -3,4 +3,4 @@
3
3
  *
4
4
  * Types for PitPass TraderCode API: code lookup, rewards balance, and transfer.
5
5
  */
6
- export { GetMyReferralDownlineResponseSchema, GetMyReferralPositionResponseSchema, GetMyReferralTreeParamsSchema, GetMyReferralTreeResponseSchema, GetRewardsBalanceResponseSchema, ReferralDirectRefereeSchema, ReferralEarningsSourceSchema, ReferralEarningsSummarySchema, ReferralRewardEntrySchema, ReferralTreeNodeSchema, ReferralUplineEntrySchema, RewardsBalanceEntrySchema, SetTraderCodeParamsSchema, TraderCodeAvailabilityReasonSchema, TraderCodeAvailabilityResponseSchema, TraderCodeInfoResponseSchema, TraderCodeResponseSchema, TransferRewardsParamsSchema, TransferRewardsResponseSchema, } from "./responses";
6
+ export { GetMyReferralDownlineParamsSchema, GetMyReferralDownlineResponseSchema, GetMyReferralPositionResponseSchema, GetMyReferralTreeParamsSchema, GetMyReferralTreeResponseSchema, GetRewardsBalanceResponseSchema, LevelEarningsSchema, ReferralDirectRefereeSchema, ReferralEarningsSourceSchema, ReferralEarningsSummarySchema, ReferralRewardEntrySchema, ReferralTreeNodeSchema, ReferralUplineEntrySchema, RewardsBalanceEntrySchema, SetTraderCodeParamsSchema, TraderCodeAvailabilityReasonSchema, TraderCodeAvailabilityResponseSchema, TraderCodeInfoResponseSchema, TraderCodeResponseSchema, TransferRewardsParamsSchema, TransferRewardsResponseSchema, } from "./responses";
@@ -118,12 +118,26 @@ export declare const ReferralDirectRefereeSchema: z.ZodObject<{
118
118
  referredAt: z.ZodString;
119
119
  totalEarned: z.ZodString;
120
120
  }, z.core.$strip>;
121
+ /** What the caller has earned at one referral level. */
122
+ export declare const LevelEarningsSchema: z.ZodObject<{
123
+ level: z.ZodNumber;
124
+ earned: z.ZodString;
125
+ }, z.core.$strip>;
121
126
  /** Per-level breakdown of the caller's total referral earnings. */
122
127
  export declare const ReferralEarningsSummarySchema: z.ZodObject<{
123
128
  totalEarned: z.ZodString;
124
129
  level1Earned: z.ZodString;
125
130
  level2Earned: z.ZodString;
126
131
  level3Earned: z.ZodString;
132
+ byLevel: z.ZodArray<z.ZodObject<{
133
+ level: z.ZodNumber;
134
+ earned: z.ZodString;
135
+ }, z.core.$strip>>;
136
+ }, z.core.$strip>;
137
+ /** Query parameters for reading the caller's downline. */
138
+ export declare const GetMyReferralDownlineParamsSchema: z.ZodObject<{
139
+ pageSize: z.ZodOptional<z.ZodNumber>;
140
+ pageToken: z.ZodOptional<z.ZodString>;
127
141
  }, z.core.$strip>;
128
142
  /** The caller's own downline: who they earn from, their L1 roster, and a summary. */
129
143
  export declare const GetMyReferralDownlineResponseSchema: z.ZodObject<{
@@ -145,7 +159,12 @@ export declare const GetMyReferralDownlineResponseSchema: z.ZodObject<{
145
159
  level1Earned: z.ZodString;
146
160
  level2Earned: z.ZodString;
147
161
  level3Earned: z.ZodString;
162
+ byLevel: z.ZodArray<z.ZodObject<{
163
+ level: z.ZodNumber;
164
+ earned: z.ZodString;
165
+ }, z.core.$strip>>;
148
166
  }, z.core.$strip>;
167
+ nextPageToken: z.ZodString;
149
168
  }, z.core.$strip>;
150
169
  /** Query parameters for reading one level of the caller's referral tree. */
151
170
  export declare const GetMyReferralTreeParamsSchema: z.ZodObject<{
@@ -192,6 +211,8 @@ export type GetMyReferralPositionResponse = z.infer<typeof GetMyReferralPosition
192
211
  export type ReferralEarningsSource = z.infer<typeof ReferralEarningsSourceSchema>;
193
212
  export type ReferralDirectReferee = z.infer<typeof ReferralDirectRefereeSchema>;
194
213
  export type ReferralEarningsSummary = z.infer<typeof ReferralEarningsSummarySchema>;
214
+ export type LevelEarnings = z.infer<typeof LevelEarningsSchema>;
215
+ export type GetMyReferralDownlineParams = z.infer<typeof GetMyReferralDownlineParamsSchema>;
195
216
  export type GetMyReferralDownlineResponse = z.infer<typeof GetMyReferralDownlineResponseSchema>;
196
217
  export type ReferralUplineEntry = z.infer<typeof ReferralUplineEntrySchema>;
197
218
  export type GetMyReferralTreeParams = z.infer<typeof GetMyReferralTreeParamsSchema>;
@@ -141,9 +141,10 @@ export const GetMyReferralPositionResponseSchema = z.object({
141
141
  /** The caller's most recent reward rows, newest first (bounded server-side). */
142
142
  rewards: z.array(ReferralRewardEntrySchema),
143
143
  /**
144
- * The caller's referral chain upward, nearest first: L1, L2, then L3. At most
145
- * three entries; empty when the caller was not referred. These are the
146
- * wallets the caller's own trades pay referral rewards to.
144
+ * The caller's referral chain upward, nearest first: L1, L2, and so on, at
145
+ * most as many entries as PitPass currently rewards levels (at most 10);
146
+ * empty when the caller was not referred. These are the wallets the caller's
147
+ * own trades pay referral rewards to.
147
148
  */
148
149
  upline: z.array(ReferralUplineEntrySchema),
149
150
  });
@@ -153,7 +154,7 @@ export const ReferralEarningsSourceSchema = z.object({
153
154
  source: z.string(),
154
155
  /** Human-facing name for the source: their custom handle if claimed, else the wallet. */
155
156
  sourceDisplay: z.string(),
156
- /** Referral level the caller earns from this source at (1/2/3). */
157
+ /** Referral level the caller earns from this source at: 1 (direct), 2, and so on (at most 10). */
157
158
  level: z.number(),
158
159
  /** Total earned from this source at this level and token, in RAW atomic units. */
159
160
  totalEarned: z.string(),
@@ -171,34 +172,62 @@ export const ReferralDirectRefereeSchema = z.object({
171
172
  /** Total the caller has earned from this referee's own (L1) trades, RAW units. `0` if they haven't traded. */
172
173
  totalEarned: z.string(),
173
174
  });
175
+ /** What the caller has earned at one referral level. */
176
+ export const LevelEarningsSchema = z.object({
177
+ /** Referral level: 1 for direct referees, 2 for their referees, and so on (at most 10). */
178
+ level: z.number(),
179
+ /** All-time credited earnings at this level, in RAW atomic units. */
180
+ earned: z.string(),
181
+ });
174
182
  /** Per-level breakdown of the caller's total referral earnings. */
175
183
  export const ReferralEarningsSummarySchema = z.object({
176
184
  /** Total earned across all levels and tokens, in RAW atomic units. */
177
185
  totalEarned: z.string(),
178
- /** Total earned from direct (L1) referees, in RAW atomic units. */
186
+ /** @deprecated Use `byLevel`. Total earned from direct (L1) referees, in RAW atomic units. */
179
187
  level1Earned: z.string(),
180
- /** Total earned from L2 downline, in RAW atomic units. */
188
+ /** @deprecated Use `byLevel`. Total earned from L2 downline, in RAW atomic units. */
181
189
  level2Earned: z.string(),
182
- /** Total earned from L3 downline, in RAW atomic units. */
190
+ /** @deprecated Use `byLevel`. Total earned from L3 downline, in RAW atomic units. */
183
191
  level3Earned: z.string(),
192
+ /**
193
+ * Earnings per level, ascending, one entry per level with earnings. Covers
194
+ * every level, including levels deeper than PitPass rewards today.
195
+ */
196
+ byLevel: z.array(LevelEarningsSchema),
197
+ });
198
+ /** Query parameters for reading the caller's downline. */
199
+ export const GetMyReferralDownlineParamsSchema = z.object({
200
+ /** `earningsBySource` rows per page (1-500, default 100). */
201
+ pageSize: z.number().int().min(1).max(500).optional(),
202
+ /** Opaque cursor from a previous response's `nextPageToken`. */
203
+ pageToken: z.string().optional(),
184
204
  });
185
205
  /** The caller's own downline: who they earn from, their L1 roster, and a summary. */
186
206
  export const GetMyReferralDownlineResponseSchema = z.object({
187
- /** One row per (source trader, level, token) the caller earns from, across L1/L2/L3. */
207
+ /**
208
+ * One page of rows, one per (source, level, token) the caller earns from,
209
+ * across every reward level, ordered by each source account's total,
210
+ * largest first; a wallet's per-application rows are merged within a page
211
+ * at the first row's position. Follow
212
+ * `nextPageToken` for the rest.
213
+ */
188
214
  earningsBySource: z.array(ReferralEarningsSourceSchema),
189
215
  /** The caller's direct (L1) referees, newest first, including those who haven't traded. */
190
216
  directReferees: z.array(ReferralDirectRefereeSchema),
191
217
  /**
192
- * Total earned broken down by level (L1/L2/L3). The server always populates
193
- * this — even a brand-new user gets a zeroed summary — so it is required.
218
+ * Total earned broken down by level, covering every level and source
219
+ * whatever the page. The server always populates this — even a brand-new
220
+ * user gets a zeroed summary — so it is required.
194
221
  */
195
222
  summary: ReferralEarningsSummarySchema,
223
+ /** Cursor for the next `earningsBySource` page; empty when there are no more rows. */
224
+ nextPageToken: z.string(),
196
225
  });
197
226
  /** Query parameters for reading one level of the caller's referral tree. */
198
227
  export const GetMyReferralTreeParamsSchema = z.object({
199
228
  /**
200
229
  * Wallet whose direct referees to list. Omit for your own L1 referees; set to
201
- * one of your L1 or L2 referees to expand that node.
230
+ * one of your referees above the deepest rewarded level to expand that node.
202
231
  */
203
232
  parent: z.string().optional(),
204
233
  /** Nodes per page (1-200, default 50). */
@@ -212,13 +241,13 @@ export const ReferralTreeNodeSchema = z.object({
212
241
  wallet: z.string(),
213
242
  /** Human-facing name: their custom handle if claimed, else the wallet. */
214
243
  display: z.string(),
215
- /** Depth below the caller: 1 (you referred them), 2, or 3. */
244
+ /** Depth below the caller: 1 (you referred them), 2, and so on up to the configured reward depth (at most 10). */
216
245
  level: z.number(),
217
246
  /** Wallet address of this node's referrer — your own wallet for a level-1 node. */
218
247
  parent: z.string(),
219
248
  /** RFC 3339 time this wallet signed up under its parent. */
220
249
  referredAt: z.string(),
221
- /** How many wallets this node has referred. Expandable when above 0; always 0 at level 3. */
250
+ /** How many wallets this node has referred. Expandable when above 0; always 0 at the deepest rewarded level. */
222
251
  refereeCount: z.number(),
223
252
  /** What you have earned from this wallet's own trades, RAW atomic units. `0` if they haven't traded. */
224
253
  totalEarned: z.string(),
@@ -227,7 +256,7 @@ export const ReferralTreeNodeSchema = z.object({
227
256
  export const GetMyReferralTreeResponseSchema = z.object({
228
257
  /** Wallet whose referees `nodes` lists — your own wallet when `parent` was omitted. */
229
258
  parent: z.string(),
230
- /** Depth of `parent` below you: 0 for yourself, 1 or 2 for an expanded referee. */
259
+ /** Depth of `parent` below you: 0 for yourself, otherwise the level of the expanded referee. */
231
260
  parentLevel: z.number(),
232
261
  /** The wallets `parent` referred, newest first. */
233
262
  nodes: z.array(ReferralTreeNodeSchema),
@@ -142,25 +142,80 @@ export interface Position {
142
142
  * holds the state but not the version, so it cannot rank itself.
143
143
  */
144
144
  version?: number;
145
+ /**
146
+ * When the position OPENED (ISO 8601): the fill that took its exposure from
147
+ * zero to non-zero. Time held is now minus `openedAt` for an OPEN position
148
+ * and `updatedAt` minus `openedAt` for a terminal one. It never changes for
149
+ * the life of `positionId`; a flip opens a new position with its own.
150
+ *
151
+ * `null` (or absent, from an older server) when the opening instant is
152
+ * unknown — never filled with the read time, so check for both before
153
+ * doing date arithmetic, and clamp the result at zero: the value can sit
154
+ * slightly ahead of the client's clock, and after a server restart it can
155
+ * move by the server's own clock drift. Positions opened before the field existed report
156
+ * the stored value, which can trail the opening fill by the server's
157
+ * persistence lag where that fill could not be recovered.
158
+ *
159
+ * Not versioned, and not guaranteed constant at a given `version`: a
160
+ * one-off server correction can move it earlier without a version change.
161
+ * Take it from the newest payload rather than skipping it on an equal
162
+ * version.
163
+ */
164
+ openedAt?: string | null;
145
165
  }
146
166
  export interface ListPositionsParams {
147
167
  marginAccountId?: string;
148
168
  tradingPairId?: string;
149
169
  status?: PositionStatusFilter;
150
- page?: number;
170
+ /** Items per page, 1 to 1000 (default 20). */
151
171
  pageSize?: number;
172
+ /**
173
+ * Pagination cursor with two states:
174
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
175
+ * no prior position.
176
+ * - Non-empty: an opaque cursor from a previous response's
177
+ * `nextPageToken`; results resume immediately after that position.
178
+ *
179
+ * **Order depends on the filter.** `status: "OPEN"` is answered from the
180
+ * matching engine's live view and is ordered by
181
+ * `(marginAccountId, tradingPairId, positionId)` ascending — stable, but
182
+ * UUID order, NOT newest-first. Every other filter reads persisted rows
183
+ * newest-opened first. The two are separate cursor spaces, so a token is
184
+ * only valid in the one that minted it, and crossing between them is
185
+ * ASYMMETRIC: a persisted token offered to `status: "OPEN"` is served by
186
+ * the persisted walk while the engine is reachable, but a LIVE token
187
+ * cannot cross — once the engine is unreachable the request is a 400 and
188
+ * the walk must restart, because the two relations share no sort key and
189
+ * resuming at a key from the wrong one would skip or repeat rows silently.
190
+ *
191
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
192
+ * sending one is a 400. Filters must match the request that produced the
193
+ * token, or the request is rejected.
194
+ */
195
+ pageToken?: string;
152
196
  }
153
197
  export interface ListPositionsResponse {
154
198
  positions: Position[];
155
199
  /**
156
- * Matching positions. Exact up to 10,000 pages of the requested page size
157
- * (`pageSize` x 10,000 rows) and saturates there, so a caller with more
158
- * matching positions than the listing can page through reads the cap, not
159
- * its lifetime total. `page` is capped at 10,000.
200
+ * Positions matching the filter, bounded by the server count ceiling — see
201
+ * `totalCapped`. A lower bound when `totalCapped` is `true`.
160
202
  */
161
203
  total: number;
162
- page: number;
163
204
  pageSize: number;
205
+ /**
206
+ * Cursor for the next page, minted from the last row of an over-fetched
207
+ * page: this listing is one ordered read, so a page shorter than `pageSize`
208
+ * proves the walk is exhausted and this is `""`. A non-empty token always
209
+ * has at least one further row behind it.
210
+ */
211
+ nextPageToken: string;
212
+ /**
213
+ * `true` when MORE than the server ceiling of positions matched, so the
214
+ * count stopped at the ceiling and `total` is a lower bound. `false` when
215
+ * `total` is the exact count — including exactly the ceiling, which is
216
+ * still reported exactly.
217
+ */
218
+ totalCapped: boolean;
164
219
  }
165
220
  export type GetPositionResponse = Position;
166
221
  export interface ClosePositionRequest {
@@ -309,10 +364,23 @@ export interface ListPositionHistoryParams {
309
364
  positionId?: string;
310
365
  marginAccountId?: string;
311
366
  tradingPairId?: string;
312
- page?: number;
367
+ /** Items per page, 1 to 1000 (default 20). */
313
368
  pageSize?: number;
314
369
  /** Return only per-execution position reductions, closes, and liquidations. */
315
370
  reductionOnly?: boolean;
371
+ /**
372
+ * Pagination cursor with two states:
373
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
374
+ * no prior position, from the newest row — this listing always sorts
375
+ * newest-first.
376
+ * - Non-empty: an opaque cursor from a previous response's
377
+ * `nextPageToken`; results resume immediately after that position.
378
+ *
379
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
380
+ * sending one is a 400. Filters must match the request that produced the
381
+ * token, or the request is rejected.
382
+ */
383
+ pageToken?: string;
316
384
  }
317
385
  export interface PositionHistoryEvent {
318
386
  /** Wire-format event ID. */
@@ -353,15 +421,14 @@ export interface PositionHistoryEvent {
353
421
  }
354
422
  export interface ListPositionHistoryResponse {
355
423
  events: PositionHistoryEvent[];
424
+ pageSize: number;
356
425
  /**
357
- * Matching position-history events. Exact up to 10,000 pages of the
358
- * requested page size (`pageSize` x 10,000 rows) and saturates there, so a
359
- * caller with more history than the listing can page through reads the cap,
360
- * not its lifetime total. `page` is capped at 10,000.
426
+ * Cursor for the next page, minted from the last row of an over-fetched
427
+ * page: this listing is one ordered read, so a page shorter than `pageSize`
428
+ * proves the walk is exhausted and this is `""`. A non-empty token always
429
+ * has at least one further row behind it.
361
430
  */
362
- total: number;
363
- page: number;
364
- pageSize: number;
431
+ nextPageToken: string;
365
432
  }
366
433
  /**
367
434
  * Sample interval for position PnL history queries (matches the candles
@@ -98,13 +98,24 @@ export type TransactionType = "DEPOSIT" | "WITHDRAWAL" | "TRADE" | "FEE" | "FUND
98
98
  * Query parameters for getting user movements
99
99
  */
100
100
  export interface GetUserMovementsParams {
101
+ /** Number of items per page, 1 to 1000 (default 20) */
102
+ pageSize?: number;
101
103
  /**
102
- * Page number (starts from 1, at most 10,000 — the last page this listing
103
- * counts towards; a larger page is rejected).
104
+ * Pagination cursor with two states:
105
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
106
+ * no prior position, from the newest row (or the oldest, when `orderBy`
107
+ * is `"ASC"`).
108
+ * - Non-empty: an opaque cursor from a previous response's
109
+ * `nextPageToken`; results resume immediately after that position.
110
+ *
111
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
112
+ * sending one is a `400`. Every walk covers the ledger and funding arms
113
+ * merged. Filters and `orderBy` must match the request that minted the
114
+ * token.
104
115
  */
105
- page?: number;
106
- /** Number of items per page (max 100) */
107
- pageSize?: number;
116
+ pageToken?: string;
117
+ /** Sort direction for `createdAt`: `"ASC"` or `"DESC"` (default `"DESC"`) */
118
+ orderBy?: "ASC" | "DESC";
108
119
  /** Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE) */
109
120
  entryType?: LedgerEntryType;
110
121
  /** Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD) */
@@ -116,10 +127,22 @@ export interface GetUserMovementsParams {
116
127
  * Query parameters for getting user balances
117
128
  */
118
129
  export interface GetUserBalancesParams {
119
- /** Page number (starts from 1) */
120
- page?: number;
121
- /** Number of items per page (max 100) */
130
+ /** Number of items per page, 1 to 1000 (default 20) */
122
131
  pageSize?: number;
132
+ /**
133
+ * Pagination cursor with two states:
134
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
135
+ * no prior position, from the lowest token address.
136
+ * - Non-empty: an opaque cursor from a previous response's
137
+ * `nextPageToken`; results resume immediately after that position.
138
+ *
139
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
140
+ * sending one is a `400`. The walk seeks on `(token, assetId)` over the
141
+ * balance set the server builds after overlaying the matching engine's
142
+ * authoritative amounts, so a balance that appears or is zeroed mid-walk no
143
+ * longer shifts the rows behind it across the resume point.
144
+ */
145
+ pageToken?: string;
123
146
  }
124
147
  /**
125
148
  * Response from getting user movements
@@ -127,22 +150,30 @@ export interface GetUserBalancesParams {
127
150
  export interface GetPaginatedUserMovementsResponse {
128
151
  /** All movements from PostgreSQL (historical, paginated) */
129
152
  movements: LedgerMovement[];
130
- /** Current page number */
131
- page: number;
132
153
  /** Items per page */
133
154
  pageSize: number;
134
155
  /**
135
- * Matching movements. Exact up to 10,000 pages of the requested `pageSize`
136
- * (`pageSize` x 10,000 rows) and saturates there, so a user with more
137
- * matching movements than the listing can page through reads the cap, not
138
- * their lifetime total.
156
+ * Movements matching the filter, bounded by the server count ceiling — see
157
+ * `totalCapped`. A lower bound when `totalCapped` is `true`.
139
158
  */
140
159
  total: number;
160
+ /** Pages at this `pageSize`, bounded by the same ceiling as `total`. */
161
+ totalPages: number;
141
162
  /**
142
- * Number of pages at the requested `pageSize`. Exact up to 10,000 and
143
- * saturates there, the last page this listing can reach.
163
+ * Cursor for the next page, minted from the last row of an over-fetched
164
+ * page. Each arm of the ledger+funding union is cut at the same
165
+ * over-fetched depth inside one statement, so a page shorter than
166
+ * `pageSize` means both arms are exhausted and this is `""`. A non-empty
167
+ * token always has at least one further row behind it.
144
168
  */
145
- totalPages: number;
169
+ nextPageToken: string;
170
+ /**
171
+ * `true` when MORE than the server ceiling of movements matched, so the
172
+ * count stopped at the ceiling and `total` / `totalPages` are a lower
173
+ * bound. `false` when `total` is the exact count — including exactly the
174
+ * ceiling, which is still reported exactly.
175
+ */
176
+ totalCapped: boolean;
146
177
  }
147
178
  /**
148
179
  * Response from getting user balances
@@ -150,14 +181,21 @@ export interface GetPaginatedUserMovementsResponse {
150
181
  export interface GetUserBalancesResponse {
151
182
  /** List of token balances for the user */
152
183
  balances: AccountBalance[];
153
- /** Total number of balances */
184
+ /**
185
+ * Total number of balances. Exact — the set is bounded by the asset universe
186
+ * and counted in memory after the live overlay, so no ceiling applies.
187
+ */
154
188
  total: number;
155
189
  /** Items per page */
156
190
  pageSize: number;
157
- /** Current page number */
158
- page: number;
159
191
  /** Total number of pages */
160
192
  totalPages: number;
193
+ /**
194
+ * Cursor for the next page, `""` once the walk is exhausted. The whole set
195
+ * is already in memory, so each page over-fetches one row and an empty token
196
+ * is definitive — follow a non-empty token, stop on an empty one.
197
+ */
198
+ nextPageToken: string;
161
199
  }
162
200
  /**
163
201
  * Order information for recent orders.
@@ -351,13 +389,21 @@ export interface FundingPayment {
351
389
  * Query parameters for listing funding payments.
352
390
  */
353
391
  export interface ListFundingPaymentsParams {
392
+ /** Number of items per page, 1 to 1000 (default 20) */
393
+ pageSize?: number;
354
394
  /**
355
- * Page number (starts from 1, at most 10,000 — the last page this listing
356
- * counts towards; a larger page is rejected).
395
+ * Pagination cursor with two states:
396
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
397
+ * no prior position, from the newest payment.
398
+ * - Non-empty: an opaque cursor from a previous response's
399
+ * `nextPageToken`; results resume immediately after that position.
400
+ *
401
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
402
+ * sending one is a `400`. The walk seeks on `(createdAt, id)` descending —
403
+ * not `periodEnd`, which the removed mode led its sort with and which is
404
+ * nullable. Filters must match the request that minted the token.
357
405
  */
358
- page?: number;
359
- /** Number of items per page (max 100) */
360
- pageSize?: number;
406
+ pageToken?: string;
361
407
  /** Filter by trading pair ID (UUID) */
362
408
  tradingPairId?: string;
363
409
  /** Filter by margin position ID (UUID) */
@@ -371,22 +417,29 @@ export interface ListFundingPaymentsParams {
371
417
  export interface ListFundingPaymentsResponse {
372
418
  /** List of funding payment records */
373
419
  records: FundingPayment[];
374
- /** Current page number */
375
- page: number;
376
420
  /** Items per page */
377
421
  pageSize: number;
378
422
  /**
379
- * Matching funding payment records. Exact up to 10,000 pages of the
380
- * requested `pageSize` (`pageSize` x 10,000 rows) and saturates there, so a
381
- * user with more matching payments than the listing can page through reads
382
- * the cap, not their lifetime total.
423
+ * Payments matching the filter, bounded by the server count ceiling — see
424
+ * `totalCapped`. A lower bound when `totalCapped` is `true`.
383
425
  */
384
426
  total: number;
427
+ /** Pages at this `pageSize`, bounded by the same ceiling as `total`. */
428
+ totalPages: number;
385
429
  /**
386
- * Number of pages at the requested `pageSize`. Exact up to 10,000 and
387
- * saturates there, the last page this listing can reach.
430
+ * Cursor for the next page, minted from the last row of an over-fetched
431
+ * page. This listing is one ordered read, so a page shorter than `pageSize`
432
+ * proves the walk is exhausted and this is `""`. A non-empty token always
433
+ * has at least one further row behind it.
388
434
  */
389
- totalPages: number;
435
+ nextPageToken: string;
436
+ /**
437
+ * `true` when MORE than the server ceiling of payments matched, so the count
438
+ * stopped at the ceiling and `total` / `totalPages` are a lower bound.
439
+ * `false` when `total` is the exact count — including exactly the ceiling,
440
+ * which is still reported exactly.
441
+ */
442
+ totalCapped: boolean;
390
443
  }
391
444
  /**
392
445
  * Time period for portfolio stats and chart queries.
@@ -539,9 +592,14 @@ export interface ProfileAPI extends BaseAPI {
539
592
  * Fetches the user's transaction history from the /api/v1/accounts/movements endpoint.
540
593
  * Requires a valid access token to be set.
541
594
  *
595
+ * Cursor paged (0XM-2788/0XM-2820): omit `pageToken` or pass `""` to start,
596
+ * then follow `nextPageToken` until it comes back empty. There is no `page`
597
+ * — sending one is a `400`.
598
+ *
542
599
  * @param params - Optional query parameters for pagination and filtering
543
- * @param params.page - Page number (starts from 1)
544
- * @param params.limit - Number of items per page (max 100)
600
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
601
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
602
+ * @param params.orderBy - Sort direction for `createdAt` (default `"DESC"`)
545
603
  * @param params.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
546
604
  * @param params.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
547
605
  * @param params.assetId - Filter by asset ID (UUID)
@@ -554,10 +612,15 @@ export interface ProfileAPI extends BaseAPI {
554
612
  * Fetches the user's token balances from the /api/v1/accounts/balances endpoint.
555
613
  * Requires a valid access token to be set.
556
614
  *
615
+ * Cursor paged (0XM-2788/0XM-2821): omit `pageToken` or pass `""` to start,
616
+ * then follow `nextPageToken` until it comes back empty. There is no `page`
617
+ * — sending one is a `400`.
618
+ *
557
619
  * @param params - Optional query parameters for pagination
558
- * @param params.limit - Number of items to return
559
- * @param params.offset - Number of items to skip
620
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
621
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
560
622
  * @returns Promise resolving to paginated balances response
623
+ * @throws ValidationError If the page size is invalid or `page` is sent; this may occur before any network request.
561
624
  */
562
625
  getUserBalances(params?: GetUserBalancesParams): Promise<GetUserBalancesResponse>;
563
626
  /**
@@ -597,12 +660,15 @@ export interface ProfileAPI extends BaseAPI {
597
660
  * Fetches the user's executed trades from the /api/v1/accounts/trades endpoint.
598
661
  * Requires a valid access token to be set.
599
662
  *
663
+ * Cursor paged (0XM-2963): omit `pageToken` or pass `""` to start, then
664
+ * follow `nextPageToken` until it comes back empty. There is no `page`.
665
+ *
600
666
  * @param params - Optional query parameters for pagination and filtering
601
- * @param params.page - Page number (starts from 1)
602
- * @param params.limit - Number of items per page (max 1000)
667
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
668
+ * @param params.pageSize - Number of items per page (max 1000)
603
669
  * @param params.tradingPairId - Filter by trading pair ID (UUID)
604
670
  * @returns Promise resolving to paginated trades response
605
- * @throws ValidationError If pagination params (page/limit) are invalid or tradingPairId is not a valid UUID; this may occur before any network request.
671
+ * @throws ValidationError If the page size is invalid, `page` is sent, or tradingPairId is not a valid UUID; this may occur before any network request.
606
672
  */
607
673
  getUserTrades(params?: GetUserTradesParams): Promise<GetUserTradesResponse>;
608
674
  /**
@@ -619,14 +685,18 @@ export interface ProfileAPI extends BaseAPI {
619
685
  * Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
620
686
  * Requires a valid access token to be set.
621
687
  *
688
+ * Cursor paged (0XM-2788/0XM-2818): omit `pageToken` or pass `""` to start,
689
+ * then follow `nextPageToken` until it comes back empty. There is no `page`
690
+ * — sending one is a `400`.
691
+ *
622
692
  * @param params - Optional query parameters for pagination and filtering
623
- * @param params.page - Page number (starts from 1)
624
- * @param params.pageSize - Number of items per page (max 100)
693
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
694
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
625
695
  * @param params.tradingPairId - Filter by trading pair ID (UUID)
626
696
  * @param params.positionId - Filter by margin position ID (UUID)
627
697
  * @param params.marginAccountId - Filter by margin account ID (UUID)
628
698
  * @returns Promise resolving to paginated funding payments response
629
- * @throws ValidationError If pagination params or a UUID filter are invalid; this may occur before any network request.
699
+ * @throws ValidationError If the page size is invalid, `page` is sent, or a UUID filter is invalid; this may occur before any network request.
630
700
  */
631
701
  listFundingPayments(params?: ListFundingPaymentsParams): Promise<ListFundingPaymentsResponse>;
632
702
  /**
@@ -267,6 +267,6 @@ export interface TradingAPI extends BaseAPI {
267
267
  */
268
268
  listTwapOrders(params?: ListTwapOrdersParams): Promise<ListTwapOrdersResponse>;
269
269
  }
270
- export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, ListedOrderType, Order, OrderRole, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState, } from "./orders";
270
+ export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState, } from "./orders";
271
271
  export { ORDER_STATUS_VALUES } from "./orders";
272
272
  export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MatchResult, ParentTpSlLegParams, ParentTrailingStopLegParams, ReplaceOrderResponse, TriggeredOrderSummary, TwapOrder, UpdatedFields, } from "./responses";