@0xmonaco/types 1.0.73 → 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 (50) 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/buildercodes/responses.d.ts +2 -3
  9. package/dist/buildercodes/responses.js +2 -3
  10. package/dist/copy-trading/index.d.ts +7 -7
  11. package/dist/delegated-agents/index.d.ts +15 -5
  12. package/dist/fees/responses.js +2 -2
  13. package/dist/margin-accounts/index.d.ts +185 -21
  14. package/dist/market/index.d.ts +76 -6
  15. package/dist/pitpass/index.d.ts +31 -11
  16. package/dist/pitpass/index.js +1 -1
  17. package/dist/pitpass/responses.d.ts +67 -0
  18. package/dist/pitpass/responses.js +92 -8
  19. package/dist/portfolio/index.d.ts +36 -14
  20. package/dist/positions/index.d.ts +81 -14
  21. package/dist/profile/index.d.ts +114 -44
  22. package/dist/trading/index.d.ts +1 -1
  23. package/dist/trading/orders.d.ts +6 -32
  24. package/dist/trading/responses.d.ts +9 -14
  25. package/dist/validation/applications.d.ts +51 -0
  26. package/dist/validation/applications.js +45 -0
  27. package/dist/validation/index.d.ts +1 -0
  28. package/dist/validation/index.js +1 -0
  29. package/dist/validation/margin-accounts.d.ts +44 -3
  30. package/dist/validation/margin-accounts.js +57 -6
  31. package/dist/validation/market.d.ts +24 -0
  32. package/dist/validation/market.js +22 -0
  33. package/dist/validation/positions.d.ts +5 -3
  34. package/dist/validation/positions.js +12 -5
  35. package/dist/validation/profile.d.ts +19 -2
  36. package/dist/validation/profile.js +36 -4
  37. package/dist/validation/trading.d.ts +2 -2
  38. package/dist/websocket/base.d.ts +56 -6
  39. package/dist/websocket/client.d.ts +8 -3
  40. package/dist/websocket/events/index.d.ts +1 -0
  41. package/dist/websocket/events/index.js +1 -0
  42. package/dist/websocket/events/liquidation-events.d.ts +3 -3
  43. package/dist/websocket/events/orders-events.d.ts +6 -0
  44. package/dist/websocket/events/position-events.d.ts +33 -15
  45. package/dist/websocket/events/position-valuation-events.d.ts +60 -0
  46. package/dist/websocket/events/position-valuation-events.js +15 -0
  47. package/dist/wire/operations.d.ts +1 -1
  48. package/dist/wire/operations.js +7 -0
  49. package/dist/wire/schema.d.ts +1441 -307
  50. package/package.json +2 -2
@@ -118,11 +118,20 @@ export const ReferralRewardEntrySchema = z.object({
118
118
  /** RFC 3339 timestamp when the reward row was recorded. */
119
119
  createdAt: z.string(),
120
120
  });
121
+ /** One ancestor in the caller's referral chain. */
122
+ export const ReferralUplineEntrySchema = z.object({
123
+ /** Public wallet address of the ancestor. */
124
+ wallet: z.string(),
125
+ /** Human-facing name for the ancestor: their custom handle if claimed, else the wallet. */
126
+ display: z.string(),
127
+ /** How far above the caller this ancestor is: 1 (direct referrer), 2, or 3. */
128
+ level: z.number(),
129
+ });
121
130
  /** The caller's own referral position: who referred them and what they've earned. */
122
131
  export const GetMyReferralPositionResponseSchema = z.object({
123
132
  /**
124
133
  * Public wallet address of the caller's direct (L1) referrer. Empty string
125
- * when the caller was not referred. Only the direct referrer is exposed.
134
+ * when the caller was not referred. Same wallet as the first `upline` entry.
126
135
  */
127
136
  referrer: z.string(),
128
137
  /** Human-facing name for the referrer: their custom handle if claimed, else the wallet (empty when not referred). */
@@ -131,6 +140,13 @@ export const GetMyReferralPositionResponseSchema = z.object({
131
140
  totalEarned: z.string(),
132
141
  /** The caller's most recent reward rows, newest first (bounded server-side). */
133
142
  rewards: z.array(ReferralRewardEntrySchema),
143
+ /**
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.
148
+ */
149
+ upline: z.array(ReferralUplineEntrySchema),
134
150
  });
135
151
  /** One aggregated earnings row per (source trader, level, token) the caller earns from. */
136
152
  export const ReferralEarningsSourceSchema = z.object({
@@ -138,7 +154,7 @@ export const ReferralEarningsSourceSchema = z.object({
138
154
  source: z.string(),
139
155
  /** Human-facing name for the source: their custom handle if claimed, else the wallet. */
140
156
  sourceDisplay: z.string(),
141
- /** 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). */
142
158
  level: z.number(),
143
159
  /** Total earned from this source at this level and token, in RAW atomic units. */
144
160
  totalEarned: z.string(),
@@ -156,26 +172,94 @@ export const ReferralDirectRefereeSchema = z.object({
156
172
  /** Total the caller has earned from this referee's own (L1) trades, RAW units. `0` if they haven't traded. */
157
173
  totalEarned: z.string(),
158
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
+ });
159
182
  /** Per-level breakdown of the caller's total referral earnings. */
160
183
  export const ReferralEarningsSummarySchema = z.object({
161
184
  /** Total earned across all levels and tokens, in RAW atomic units. */
162
185
  totalEarned: z.string(),
163
- /** Total earned from direct (L1) referees, in RAW atomic units. */
186
+ /** @deprecated Use `byLevel`. Total earned from direct (L1) referees, in RAW atomic units. */
164
187
  level1Earned: z.string(),
165
- /** Total earned from L2 downline, in RAW atomic units. */
188
+ /** @deprecated Use `byLevel`. Total earned from L2 downline, in RAW atomic units. */
166
189
  level2Earned: z.string(),
167
- /** Total earned from L3 downline, in RAW atomic units. */
190
+ /** @deprecated Use `byLevel`. Total earned from L3 downline, in RAW atomic units. */
168
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(),
169
204
  });
170
205
  /** The caller's own downline: who they earn from, their L1 roster, and a summary. */
171
206
  export const GetMyReferralDownlineResponseSchema = z.object({
172
- /** 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
+ */
173
214
  earningsBySource: z.array(ReferralEarningsSourceSchema),
174
215
  /** The caller's direct (L1) referees, newest first, including those who haven't traded. */
175
216
  directReferees: z.array(ReferralDirectRefereeSchema),
176
217
  /**
177
- * Total earned broken down by level (L1/L2/L3). The server always populates
178
- * 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.
179
221
  */
180
222
  summary: ReferralEarningsSummarySchema,
223
+ /** Cursor for the next `earningsBySource` page; empty when there are no more rows. */
224
+ nextPageToken: z.string(),
225
+ });
226
+ /** Query parameters for reading one level of the caller's referral tree. */
227
+ export const GetMyReferralTreeParamsSchema = z.object({
228
+ /**
229
+ * Wallet whose direct referees to list. Omit for your own L1 referees; set to
230
+ * one of your referees above the deepest rewarded level to expand that node.
231
+ */
232
+ parent: z.string().optional(),
233
+ /** Nodes per page (1-200, default 50). */
234
+ pageSize: z.number().int().min(1).max(200).optional(),
235
+ /** Opaque cursor from a previous response's `nextPageToken`. Only valid with the same `parent`. */
236
+ pageToken: z.string().optional(),
237
+ });
238
+ /** One wallet in the caller's referral tree. */
239
+ export const ReferralTreeNodeSchema = z.object({
240
+ /** Public wallet address of this referee. */
241
+ wallet: z.string(),
242
+ /** Human-facing name: their custom handle if claimed, else the wallet. */
243
+ display: z.string(),
244
+ /** Depth below the caller: 1 (you referred them), 2, and so on up to the configured reward depth (at most 10). */
245
+ level: z.number(),
246
+ /** Wallet address of this node's referrer — your own wallet for a level-1 node. */
247
+ parent: z.string(),
248
+ /** RFC 3339 time this wallet signed up under its parent. */
249
+ referredAt: z.string(),
250
+ /** How many wallets this node has referred. Expandable when above 0; always 0 at the deepest rewarded level. */
251
+ refereeCount: z.number(),
252
+ /** What you have earned from this wallet's own trades, RAW atomic units. `0` if they haven't traded. */
253
+ totalEarned: z.string(),
254
+ });
255
+ /** One page of one level of the caller's referral tree. */
256
+ export const GetMyReferralTreeResponseSchema = z.object({
257
+ /** Wallet whose referees `nodes` lists — your own wallet when `parent` was omitted. */
258
+ parent: z.string(),
259
+ /** Depth of `parent` below you: 0 for yourself, otherwise the level of the expanded referee. */
260
+ parentLevel: z.number(),
261
+ /** The wallets `parent` referred, newest first. */
262
+ nodes: z.array(ReferralTreeNodeSchema),
263
+ /** Cursor for the next page; empty when there are no more. */
264
+ nextPageToken: z.string(),
181
265
  });
@@ -166,15 +166,15 @@ export interface PortfolioMarginTotal {
166
166
  * bound the engine enforces on transfers-out and withdrawals, and therefore
167
167
  * also the effective ceiling on funding new isolated or first-use order
168
168
  * capacity (allocating collateral to a risk bucket passes through the same
169
- * principal-gated door).
169
+ * capacity-gated door).
170
170
  *
171
171
  * NOT a clamped `parentAvailableCollateral`: that is an equity figure which
172
- * credits settled realized PnL, accrued funding, and unrealized gains that a
173
- * transfer-out cannot move. This bound never credits an unrealized gain, and
174
- * under the default capacity basis it also excludes non-principal balances —
175
- * `min(deposited principal - bucket allocations, freeCollateral - max(unrealizedPnl, 0))`,
176
- * floored at zero. Whatever the engine's configured capacity basis, this is
177
- * the bound its gates actually enforce. Size transfers-out, withdrawals, and
172
+ * credits unrealized gains and realized PnL still held in open risk
173
+ * buckets, which a transfer-out of the parent cannot move. This bound never
174
+ * credits an unrealized gain; it counts net deposits plus the account's
175
+ * settled realized PnL and funding, less what risk buckets have allocated —
176
+ * `min(net deposits + settled realized PnL - bucket allocations, freeCollateral - max(unrealizedPnl, 0))`,
177
+ * floored at zero. This is the bound the engine's gates actually enforce. Size transfers-out, withdrawals, and
178
178
  * new isolated or first-use positions from this field;
179
179
  * `parentAvailableCollateral` remains the trading-margin headroom for
180
180
  * existing cross exposure.
@@ -196,12 +196,14 @@ export interface PortfolioRiskBucket {
196
196
  positionCount: number;
197
197
  /**
198
198
  * The largest transfer-out of this risk bucket the engine will actually
199
- * accept. NOT a clamped `freeCollateral`: capped by the bucket's settled
200
- * capacity (its allocated collateral, under the default capacity basis),
201
- * and an unrealized gain never raises it. This is the largest
202
- * accepted transfer-out, not a promise that every smaller one is accepted —
203
- * an underwater flat bucket accepts its full close-out while refusing
204
- * partial withdrawals below it.
199
+ * accept. NOT a clamped `freeCollateral`: the bucket's allocated
200
+ * collateral plus its realized PnL, less funding paid, unrealized losses
201
+ * and the margin its positions and resting orders require. Realized profit
202
+ * can leave a live bucket this way (the bucket's allocation may go
203
+ * negative); an unrealized gain never raises it. This is the largest
204
+ * accepted transfer-out, and every smaller amount is accepted too. It is
205
+ * zero on a risk bucket that is not `NORMAL` and on one whose realized loss
206
+ * has used up its allocation.
205
207
  */
206
208
  withdrawableCollateral: string;
207
209
  /**
@@ -267,11 +269,31 @@ export interface PortfolioRiskBucket {
267
269
  */
268
270
  tradingPairId?: string;
269
271
  }
272
+ /** One of the caller's open margin accounts in the owner rollup. */
273
+ export interface PortfolioMarginAccount {
274
+ marginAccountId: string;
275
+ /** `default` for the default margin account, else the sub-account's key. */
276
+ subaccountKey: string;
277
+ /** The account's totals; `withdrawableCollateral` is the persisted reconstruction of the engine's bound. */
278
+ total: PortfolioMarginTotal;
279
+ }
270
280
  export interface PortfolioMargin {
271
281
  asOf: string;
272
282
  total: PortfolioMarginTotal;
273
283
  positions: PortfolioMarginPositionCounts;
274
284
  riskBuckets: PortfolioRiskBucket[];
285
+ /** The margin account `total`, `positions` and `riskBuckets` describe; absent before the first margin account. */
286
+ marginAccountId?: string;
287
+ /** With `includeAccounts`: every open margin account, the default one first. */
288
+ accounts?: PortfolioMarginAccount[];
289
+ /** With `includeAccounts`: the sum of `accounts`' totals (the owner rollup). */
290
+ ownerTotal?: PortfolioMarginTotal;
291
+ }
292
+ export interface PortfolioMarginParams {
293
+ /** One of your margin accounts (default or a sub-account) to describe instead of the default one. */
294
+ marginAccountId?: string;
295
+ /** Also return every open margin account's totals and their sum. */
296
+ includeAccounts?: boolean;
275
297
  }
276
298
  /** Authoritative, application-scoped portfolio analytics. */
277
299
  export interface PortfolioAPI extends BaseAPI {
@@ -279,5 +301,5 @@ export interface PortfolioAPI extends BaseAPI {
279
301
  getPerformance(params?: PortfolioPeriodParams): Promise<PortfolioPerformance>;
280
302
  getRealizedPnl(params?: PortfolioPeriodParams): Promise<PortfolioRealizedPnl>;
281
303
  getAssets(params?: PortfolioPeriodParams): Promise<PortfolioAssets>;
282
- getMargin(): Promise<PortfolioMargin>;
304
+ getMargin(params?: PortfolioMarginParams): Promise<PortfolioMargin>;
283
305
  }
@@ -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";