@0xmonaco/core 1.0.73-develop.af0f5d0 → 1.0.74-develop.367860f

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.
@@ -47,8 +47,8 @@ export declare const perpRoutes: {
47
47
  readonly initiate: () => string;
48
48
  readonly byIndex: (withdrawalIndex: number) => string;
49
49
  readonly list: (params?: {
50
- page?: number;
51
50
  pageSize?: number;
51
+ pageToken?: string;
52
52
  }) => string;
53
53
  };
54
54
  readonly market: {
@@ -75,15 +75,15 @@ export declare const perpRoutes: {
75
75
  readonly listFundingHistory: (tradingPairId: string, params?: {
76
76
  startTime?: string;
77
77
  endTime?: string;
78
- page?: number;
79
78
  pageSize?: number;
79
+ pageToken?: string;
80
80
  orderBy?: string;
81
81
  }) => string;
82
82
  readonly listAllFundingHistory: (params?: {
83
83
  startTime?: string;
84
84
  endTime?: string;
85
- page?: number;
86
85
  pageSize?: number;
86
+ pageToken?: string;
87
87
  orderBy?: string;
88
88
  }) => string;
89
89
  readonly getOpenInterest: (tradingPairId: string) => string;
@@ -119,8 +119,9 @@ export declare const perpRoutes: {
119
119
  };
120
120
  readonly applications: {
121
121
  readonly orders: (params?: {
122
- page?: number;
122
+ clientId?: string;
123
123
  pageSize?: number;
124
+ pageToken?: string;
124
125
  status?: string;
125
126
  userId?: string;
126
127
  tradingPairId?: string;
@@ -128,27 +129,31 @@ export declare const perpRoutes: {
128
129
  orderType?: string;
129
130
  }) => string;
130
131
  readonly users: (params?: {
131
- page?: number;
132
+ clientId?: string;
132
133
  pageSize?: number;
134
+ pageToken?: string;
133
135
  isActive?: boolean;
134
136
  accountType?: string;
135
137
  address?: string;
136
138
  }) => string;
137
139
  readonly movements: (params?: {
138
- page?: number;
140
+ clientId?: string;
139
141
  pageSize?: number;
142
+ pageToken?: string;
140
143
  userId?: string;
141
144
  transactionType?: string;
142
145
  entryType?: string;
143
146
  assetId?: string;
144
147
  }) => string;
145
148
  readonly balances: (params?: {
146
- page?: number;
149
+ clientId?: string;
147
150
  pageSize?: number;
151
+ pageToken?: string;
148
152
  userId?: string;
149
153
  assetId?: string;
150
154
  }) => string;
151
155
  readonly stats: (params?: {
156
+ clientId?: string;
152
157
  since?: string;
153
158
  }) => string;
154
159
  };
@@ -174,8 +179,8 @@ export declare const perpRoutes: {
174
179
  marginAccountId?: string;
175
180
  tradingPairId?: string;
176
181
  status?: string;
177
- page?: number;
178
182
  pageSize?: number;
183
+ pageToken?: string;
179
184
  }) => string;
180
185
  readonly get: (positionId: string) => string;
181
186
  readonly close: (positionId: string) => string;
@@ -186,8 +191,8 @@ export declare const perpRoutes: {
186
191
  positionId?: string;
187
192
  marginAccountId?: string;
188
193
  tradingPairId?: string;
189
- page?: number;
190
194
  pageSize?: number;
195
+ pageToken?: string;
191
196
  reductionOnly?: boolean;
192
197
  }) => string;
193
198
  readonly pnlHistory: (positionId: string, params: {
@@ -198,8 +203,8 @@ export declare const perpRoutes: {
198
203
  };
199
204
  readonly marginAccounts: {
200
205
  readonly list: (params?: {
201
- page?: number;
202
206
  pageSize?: number;
207
+ pageToken?: string;
203
208
  state?: string;
204
209
  tradingPairId?: string;
205
210
  }) => string;
@@ -219,19 +224,21 @@ export declare const perpRoutes: {
219
224
  readonly transferOutParent: () => string;
220
225
  readonly movements: (marginAccountId: string, params?: {
221
226
  movementType?: string;
222
- page?: number;
223
227
  pageSize?: number;
228
+ pageToken?: string;
224
229
  }) => string;
225
230
  readonly parentMovements: (params?: {
226
231
  movementType?: string;
227
- page?: number;
228
232
  pageSize?: number;
233
+ pageToken?: string;
229
234
  }) => string;
230
235
  readonly simulateParentMarginOrderRisk: () => string;
231
236
  readonly simulateOrderRisk: (marginAccountId: string) => string;
232
237
  readonly simulateRiskBucketOrderRisk: () => string;
233
238
  readonly createSubAccount: () => string;
234
239
  readonly closeSubAccount: (marginAccountId: string) => string;
240
+ readonly subAccountTransferIn: (marginAccountId: string) => string;
241
+ readonly subAccountTransferOut: (marginAccountId: string) => string;
235
242
  readonly pnl: (marginAccountId: string) => string;
236
243
  readonly transferCollateral: () => string;
237
244
  };
@@ -121,6 +121,8 @@ export const perpRoutes = {
121
121
  simulateRiskBucketOrderRisk: () => `${API_V1}/margin/risk-buckets/simulate-order-risk`,
122
122
  createSubAccount: () => `${API_V1}/margin/sub-accounts`,
123
123
  closeSubAccount: (marginAccountId) => `${API_V1}/margin/sub-accounts/${encodeSegment(marginAccountId)}/close`,
124
+ subAccountTransferIn: (marginAccountId) => `${API_V1}/margin/sub-accounts/${encodeSegment(marginAccountId)}/collateral/transfer-in`,
125
+ subAccountTransferOut: (marginAccountId) => `${API_V1}/margin/sub-accounts/${encodeSegment(marginAccountId)}/collateral/transfer-out`,
124
126
  pnl: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/pnl`,
125
127
  transferCollateral: () => `${API_V1}/margin/collateral/transfer`,
126
128
  },
@@ -33,7 +33,7 @@
33
33
  * console.log(`Rewards remaining: ${result.rewardsBalance}`);
34
34
  * ```
35
35
  */
36
- import type { GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, PitpassAPI, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "@0xmonaco/types";
36
+ import type { GetMyReferralDownlineParams, GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, PitpassAPI, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "@0xmonaco/types";
37
37
  import { BaseAPI } from "../base";
38
38
  export declare class PitpassAPIImpl extends BaseAPI implements PitpassAPI {
39
39
  /**
@@ -77,23 +77,26 @@ export declare class PitpassAPIImpl extends BaseAPI implements PitpassAPI {
77
77
  */
78
78
  transferRewards(params: TransferRewardsParams): Promise<TransferRewardsResponse>;
79
79
  /**
80
- * Read the caller's own referral position: their upline (L1, L2, L3), their
80
+ * Read the caller's own referral position: their upline (L1, L2, ...), their
81
81
  * L1 referrer, total earned, and recent rewards. Self-scoped — no id is sent,
82
82
  * so it can only ever return your own chain. `referrer` is "" and `upline` is
83
83
  * empty when you were not referred.
84
84
  */
85
85
  getMyReferralPosition(): Promise<GetMyReferralPositionResponse>;
86
86
  /**
87
- * Read the caller's own downline: earnings by source across L1/L2/L3, the L1
88
- * direct-referee roster (including referees who haven't traded), and a
89
- * per-level earnings summary. Self-scoped, read-only.
87
+ * Read the caller's own downline: one page of earnings by source across
88
+ * every reward level (largest first), the L1 direct-referee roster
89
+ * (including referees who haven't traded), and a per-level earnings summary
90
+ * covering every level and source. Without paging params the server returns
91
+ * the first page (100 rows); follow `nextPageToken` until it is empty.
92
+ * Self-scoped, read-only.
90
93
  */
91
- getMyReferralDownline(): Promise<GetMyReferralDownlineResponse>;
94
+ getMyReferralDownline(params?: GetMyReferralDownlineParams): Promise<GetMyReferralDownlineResponse>;
92
95
  /**
93
96
  * Read one level of the caller's own referral tree: the wallets `parent`
94
97
  * directly referred (the caller when omitted), a page at a time, newest
95
- * first. `parent` must be the caller or one of their own L1/L2 referees;
96
- * any other wallet is a 404.
98
+ * first. `parent` must be the caller or one of their own referees above the
99
+ * deepest rewarded level; any other wallet is a 404.
97
100
  */
98
101
  getMyReferralTree(params?: GetMyReferralTreeParams): Promise<GetMyReferralTreeResponse>;
99
102
  }
@@ -33,7 +33,7 @@
33
33
  * console.log(`Rewards remaining: ${result.rewardsBalance}`);
34
34
  * ```
35
35
  */
36
- import { GetMyReferralTreeParamsSchema, SetTraderCodeParamsSchema, TransferRewardsParamsSchema, validate } from "@0xmonaco/types";
36
+ import { GetMyReferralDownlineParamsSchema, GetMyReferralTreeParamsSchema, SetTraderCodeParamsSchema, TransferRewardsParamsSchema, validate, } from "@0xmonaco/types";
37
37
  import { BaseAPI } from "../base";
38
38
  export class PitpassAPIImpl extends BaseAPI {
39
39
  /**
@@ -109,7 +109,7 @@ export class PitpassAPIImpl extends BaseAPI {
109
109
  });
110
110
  }
111
111
  /**
112
- * Read the caller's own referral position: their upline (L1, L2, L3), their
112
+ * Read the caller's own referral position: their upline (L1, L2, ...), their
113
113
  * L1 referrer, total earned, and recent rewards. Self-scoped — no id is sent,
114
114
  * so it can only ever return your own chain. `referrer` is "" and `upline` is
115
115
  * empty when you were not referred.
@@ -120,20 +120,33 @@ export class PitpassAPIImpl extends BaseAPI {
120
120
  });
121
121
  }
122
122
  /**
123
- * Read the caller's own downline: earnings by source across L1/L2/L3, the L1
124
- * direct-referee roster (including referees who haven't traded), and a
125
- * per-level earnings summary. Self-scoped, read-only.
123
+ * Read the caller's own downline: one page of earnings by source across
124
+ * every reward level (largest first), the L1 direct-referee roster
125
+ * (including referees who haven't traded), and a per-level earnings summary
126
+ * covering every level and source. Without paging params the server returns
127
+ * the first page (100 rows); follow `nextPageToken` until it is empty.
128
+ * Self-scoped, read-only.
126
129
  */
127
- async getMyReferralDownline() {
128
- return await this.makeAuthenticatedRequest("/api/v1/pitpass/referrals/me/downline", {
129
- method: "GET",
130
- });
130
+ async getMyReferralDownline(params) {
131
+ if (params) {
132
+ validate(GetMyReferralDownlineParamsSchema, params);
133
+ }
134
+ const searchParams = new URLSearchParams();
135
+ if (params?.pageSize !== undefined) {
136
+ searchParams.append("pageSize", params.pageSize.toString());
137
+ }
138
+ if (params?.pageToken !== undefined) {
139
+ searchParams.append("pageToken", params.pageToken);
140
+ }
141
+ const query = searchParams.toString();
142
+ const path = query ? `/api/v1/pitpass/referrals/me/downline?${query}` : "/api/v1/pitpass/referrals/me/downline";
143
+ return await this.makeAuthenticatedRequest(path, { method: "GET" });
131
144
  }
132
145
  /**
133
146
  * Read one level of the caller's own referral tree: the wallets `parent`
134
147
  * directly referred (the caller when omitted), a page at a time, newest
135
- * first. `parent` must be the caller or one of their own L1/L2 referees;
136
- * any other wallet is a 404.
148
+ * first. `parent` must be the caller or one of their own referees above the
149
+ * deepest rewarded level; any other wallet is a 404.
137
150
  */
138
151
  async getMyReferralTree(params) {
139
152
  if (params) {
@@ -2,10 +2,19 @@ import type { AttachPositionTpSlRequest, AttachPositionTpSlResponse, BatchCloseA
2
2
  import { BaseAPI } from "../base";
3
3
  export declare class PositionsAPIImpl extends BaseAPI implements PositionsAPI {
4
4
  /**
5
- * List the caller's positions with page-number pagination. The response
6
- * `total` is bounded by the listing's pagination reach: exact up to
7
- * `pageSize` x 10,000 rows and saturating there, so a `page` above 10,000 is
8
- * rejected rather than served past the last page `total` can report.
5
+ * List the caller's positions, cursor paged (0XM-2788): omit `pageToken` or
6
+ * pass `""` to start, then follow `nextPageToken` until it comes back
7
+ * empty. There is no `page` — sending one is a `400`.
8
+ *
9
+ * `total` is bounded by the server count ceiling; `totalCapped` is `true`
10
+ * when more than that matched, so it is a lower bound. Do not drive a
11
+ * paging loop off it — follow `nextPageToken`.
12
+ *
13
+ * Order depends on the filter: `status: "OPEN"` is served from the engine's
14
+ * live view in `(marginAccountId, tradingPairId, positionId)` order, every
15
+ * other filter from persisted rows newest-opened first. The two are
16
+ * separate cursor spaces, so a token is only valid in the one that minted
17
+ * it.
9
18
  */
10
19
  listPositions(params?: ListPositionsParams): Promise<ListPositionsResponse>;
11
20
  getPosition(positionId: string): Promise<GetPositionResponse>;
@@ -14,10 +23,13 @@ export declare class PositionsAPIImpl extends BaseAPI implements PositionsAPI {
14
23
  getPositionRisk(positionId: string): Promise<PositionRisk>;
15
24
  attachPositionTpSl(positionId: string, request: AttachPositionTpSlRequest): Promise<AttachPositionTpSlResponse>;
16
25
  /**
17
- * List the caller's position-history events with page-number pagination. The
18
- * response `total` is bounded by the listing's pagination reach: exact up to
19
- * `pageSize` x 10,000 rows and saturating there, so a `page` above 10,000 is
20
- * rejected rather than served past the last page `total` can report.
26
+ * List the caller's position-history events, cursor paged (0XM-2788): omit
27
+ * `pageToken` or pass `""` to start, then follow `nextPageToken` until it
28
+ * comes back empty. There is no `page` — sending one is a `400`.
29
+ *
30
+ * The response carries no item count: this listing spans the hot table and
31
+ * the archive, so counting behind a filter would walk the caller's whole
32
+ * lifetime prefix on every page.
21
33
  */
22
34
  listPositionHistory(params?: ListPositionHistoryParams): Promise<ListPositionHistoryResponse>;
23
35
  getPositionPnlHistory(positionId: string, params: GetPositionPnlHistoryParams): Promise<GetPositionPnlHistoryResponse>;
@@ -3,10 +3,19 @@ import { BaseAPI } from "../base";
3
3
  import { perpRoutes } from "../perp";
4
4
  export class PositionsAPIImpl extends BaseAPI {
5
5
  /**
6
- * List the caller's positions with page-number pagination. The response
7
- * `total` is bounded by the listing's pagination reach: exact up to
8
- * `pageSize` x 10,000 rows and saturating there, so a `page` above 10,000 is
9
- * rejected rather than served past the last page `total` can report.
6
+ * List the caller's positions, cursor paged (0XM-2788): omit `pageToken` or
7
+ * pass `""` to start, then follow `nextPageToken` until it comes back
8
+ * empty. There is no `page` — sending one is a `400`.
9
+ *
10
+ * `total` is bounded by the server count ceiling; `totalCapped` is `true`
11
+ * when more than that matched, so it is a lower bound. Do not drive a
12
+ * paging loop off it — follow `nextPageToken`.
13
+ *
14
+ * Order depends on the filter: `status: "OPEN"` is served from the engine's
15
+ * live view in `(marginAccountId, tradingPairId, positionId)` order, every
16
+ * other filter from persisted rows newest-opened first. The two are
17
+ * separate cursor spaces, so a token is only valid in the one that minted
18
+ * it.
10
19
  */
11
20
  async listPositions(params) {
12
21
  if (params) {
@@ -90,10 +99,13 @@ export class PositionsAPIImpl extends BaseAPI {
90
99
  });
91
100
  }
92
101
  /**
93
- * List the caller's position-history events with page-number pagination. The
94
- * response `total` is bounded by the listing's pagination reach: exact up to
95
- * `pageSize` x 10,000 rows and saturating there, so a `page` above 10,000 is
96
- * rejected rather than served past the last page `total` can report.
102
+ * List the caller's position-history events, cursor paged (0XM-2788): omit
103
+ * `pageToken` or pass `""` to start, then follow `nextPageToken` until it
104
+ * comes back empty. There is no `page` — sending one is a `400`.
105
+ *
106
+ * The response carries no item count: this listing spans the hot table and
107
+ * the archive, so counting behind a filter would walk the caller's whole
108
+ * lifetime prefix on every page.
97
109
  */
98
110
  async listPositionHistory(params) {
99
111
  if (params) {
@@ -50,14 +50,19 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
50
50
  * Fetches the user's transaction history from the /api/v1/accounts/movements endpoint.
51
51
  * Requires a valid access token to be set.
52
52
  *
53
- * The response `total` and `totalPages` are bounded by the listing's pagination reach:
54
- * exact up to `pageSize` x 10,000 rows (10,000 pages) and saturating there, so a user
55
- * with more matching movements than the listing can page through reads the cap, not
56
- * their lifetime total. A `page` above 10,000 is rejected.
53
+ * Cursor paged (0XM-2788/0XM-2820): omit `pageToken` or pass `""` to start,
54
+ * then follow `nextPageToken` from each response until it comes back empty.
55
+ * There is no `page` — sending one is a `400`.
56
+ *
57
+ * The response `total` and `totalPages` are bounded by the server count
58
+ * ceiling; `totalCapped` is `true` when more than that matched, so `total`
59
+ * is a lower bound. Do not drive a paging loop off `total`: a user past the
60
+ * ceiling would stop early. Follow `nextPageToken`.
57
61
  *
58
62
  * @param params - Optional query parameters for pagination and filtering
59
- * @param params.page - Page number (starts from 1, default: 1, at most 10,000)
60
- * @param params.limit - Number of items per page (default: 20, max: 100)
63
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
64
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
65
+ * @param params.orderBy - Sort direction for `createdAt` (default: `"DESC"`)
61
66
  * @param params.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
62
67
  * @param params.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
63
68
  * @param params.assetId - Filter by asset ID (UUID)
@@ -70,9 +75,14 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
70
75
  * const movements = await profileAPI.getPaginatedUserMovements();
71
76
  * console.log(`Total movements: ${movements.total}`);
72
77
  *
73
- * // Get second page with custom pageSize
74
- * const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, pageSize: 50 });
75
- * console.log(`Page ${page2.page} of ${page2.totalPages}`);
78
+ * // Walk every page
79
+ * let pageToken = "";
80
+ * for (;;) {
81
+ * const page = await profileAPI.getPaginatedUserMovements({ pageToken, pageSize: 50 });
82
+ * console.log(page.movements.length);
83
+ * if (page.nextPageToken === "") break;
84
+ * pageToken = page.nextPageToken;
85
+ * }
76
86
  *
77
87
  * // Filter by entry type and transaction type
78
88
  * const deposits = await profileAPI.getPaginatedUserMovements({ entryType: "CREDIT", transactionType: "DEPOSIT" });
@@ -88,9 +98,13 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
88
98
  * Fetches the user's token balances from the /api/v1/accounts/balances endpoint.
89
99
  * Requires a valid access token to be set.
90
100
  *
101
+ * Cursor paged (0XM-2788/0XM-2821): omit `pageToken` or pass `""` to start,
102
+ * then follow `nextPageToken` until it comes back empty. There is no `page`
103
+ * — sending one is a `400`.
104
+ *
91
105
  * @param params - Optional query parameters for pagination
92
- * @param params.page - Page number (starts from 1, default: 1)
93
- * @param params.pageSize - Number of items per page (default: 20, max: 100)
106
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
107
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
94
108
  * @returns Promise resolving to paginated balances response
95
109
  * @throws {APIError} When the request fails or user is not authenticated
96
110
  *
@@ -103,9 +117,14 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
103
117
  * console.log(`${balance.symbol}: ${balance.availableBalance}`);
104
118
  * });
105
119
  *
106
- * // Get page 2 with 50 items per page
107
- * const nextBalances = await profileAPI.getUserBalances({ page: 2, pageSize: 50 });
108
- * console.log(`Returned ${nextBalances.balances.length} balances`);
120
+ * // Walk every page
121
+ * let pageToken = "";
122
+ * for (;;) {
123
+ * const page = await profileAPI.getUserBalances({ pageToken, pageSize: 50 });
124
+ * console.log(page.balances.length);
125
+ * if (page.nextPageToken === "") break;
126
+ * pageToken = page.nextPageToken;
127
+ * }
109
128
  * ```
110
129
  */
111
130
  getUserBalances(params?: GetUserBalancesParams): Promise<GetUserBalancesResponse>;
@@ -233,12 +252,21 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
233
252
  * Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
234
253
  * Requires a valid access token to be set.
235
254
  *
236
- * The response `total` and `totalPages` are bounded by the listing's pagination reach:
237
- * exact up to `pageSize` x 10,000 rows (10,000 pages) and saturating there, so a user
238
- * with more matching payments than the listing can page through reads the cap, not
239
- * their lifetime total. A `page` above 10,000 is rejected.
255
+ * Cursor paged (0XM-2788/0XM-2818): omit `pageToken` or pass `""` to start,
256
+ * then follow `nextPageToken` from each response until it comes back empty.
257
+ * There is no `page` — sending one is a `400`.
258
+ *
259
+ * The response `total` and `totalPages` are bounded by the server count
260
+ * ceiling; `totalCapped` is `true` when more than that matched, so `total`
261
+ * is a lower bound. Do not drive a paging loop off `total`: a user past the
262
+ * ceiling would stop early. Follow `nextPageToken`.
240
263
  *
241
264
  * @param params - Optional query parameters for pagination and filtering
265
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
266
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
267
+ * @param params.tradingPairId - Filter by trading pair ID (UUID)
268
+ * @param params.positionId - Filter by margin position ID (UUID)
269
+ * @param params.marginAccountId - Filter by margin account ID (UUID)
242
270
  * @returns Promise resolving to paginated funding payments response
243
271
  * @throws {APIError} When the request fails or user is not authenticated
244
272
  *
@@ -246,6 +274,15 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
246
274
  * ```typescript
247
275
  * const funding = await profileAPI.listFundingPayments({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
248
276
  * console.log(`Total funding payments: ${funding.total}`);
277
+ *
278
+ * // Walk every page
279
+ * let pageToken = "";
280
+ * for (;;) {
281
+ * const page = await profileAPI.listFundingPayments({ pageToken, pageSize: 100 });
282
+ * console.log(page.records.length);
283
+ * if (page.nextPageToken === "") break;
284
+ * pageToken = page.nextPageToken;
285
+ * }
249
286
  * ```
250
287
  */
251
288
  listFundingPayments(params?: ListFundingPaymentsParams): Promise<ListFundingPaymentsResponse>;
@@ -17,7 +17,7 @@
17
17
  * console.log(`User: ${profile.username} (${profile.address})`);
18
18
  * ```
19
19
  */
20
- import { GetUserMovementsSchema, GetUserTradesSchema, ListFundingPaymentsSchema, SetSelfTradePreventionDefaultSchema, validate } from "@0xmonaco/types";
20
+ import { GetUserBalancesSchema, GetUserMovementsSchema, GetUserTradesSchema, ListFundingPaymentsSchema, SetSelfTradePreventionDefaultSchema, validate, } from "@0xmonaco/types";
21
21
  import { APIError } from "../../errors";
22
22
  import { BaseAPI } from "../base";
23
23
  export class ProfileAPIImpl extends BaseAPI {
@@ -53,14 +53,19 @@ export class ProfileAPIImpl extends BaseAPI {
53
53
  * Fetches the user's transaction history from the /api/v1/accounts/movements endpoint.
54
54
  * Requires a valid access token to be set.
55
55
  *
56
- * The response `total` and `totalPages` are bounded by the listing's pagination reach:
57
- * exact up to `pageSize` x 10,000 rows (10,000 pages) and saturating there, so a user
58
- * with more matching movements than the listing can page through reads the cap, not
59
- * their lifetime total. A `page` above 10,000 is rejected.
56
+ * Cursor paged (0XM-2788/0XM-2820): omit `pageToken` or pass `""` to start,
57
+ * then follow `nextPageToken` from each response until it comes back empty.
58
+ * There is no `page` — sending one is a `400`.
59
+ *
60
+ * The response `total` and `totalPages` are bounded by the server count
61
+ * ceiling; `totalCapped` is `true` when more than that matched, so `total`
62
+ * is a lower bound. Do not drive a paging loop off `total`: a user past the
63
+ * ceiling would stop early. Follow `nextPageToken`.
60
64
  *
61
65
  * @param params - Optional query parameters for pagination and filtering
62
- * @param params.page - Page number (starts from 1, default: 1, at most 10,000)
63
- * @param params.limit - Number of items per page (default: 20, max: 100)
66
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
67
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
68
+ * @param params.orderBy - Sort direction for `createdAt` (default: `"DESC"`)
64
69
  * @param params.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
65
70
  * @param params.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
66
71
  * @param params.assetId - Filter by asset ID (UUID)
@@ -73,9 +78,14 @@ export class ProfileAPIImpl extends BaseAPI {
73
78
  * const movements = await profileAPI.getPaginatedUserMovements();
74
79
  * console.log(`Total movements: ${movements.total}`);
75
80
  *
76
- * // Get second page with custom pageSize
77
- * const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, pageSize: 50 });
78
- * console.log(`Page ${page2.page} of ${page2.totalPages}`);
81
+ * // Walk every page
82
+ * let pageToken = "";
83
+ * for (;;) {
84
+ * const page = await profileAPI.getPaginatedUserMovements({ pageToken, pageSize: 50 });
85
+ * console.log(page.movements.length);
86
+ * if (page.nextPageToken === "") break;
87
+ * pageToken = page.nextPageToken;
88
+ * }
79
89
  *
80
90
  * // Filter by entry type and transaction type
81
91
  * const deposits = await profileAPI.getPaginatedUserMovements({ entryType: "CREDIT", transactionType: "DEPOSIT" });
@@ -89,12 +99,17 @@ export class ProfileAPIImpl extends BaseAPI {
89
99
  validate(GetUserMovementsSchema, params);
90
100
  }
91
101
  const searchParams = new URLSearchParams();
92
- if (params?.page !== undefined) {
93
- searchParams.append("page", params.page.toString());
94
- }
95
102
  if (params?.pageSize !== undefined) {
96
103
  searchParams.append("pageSize", params.pageSize.toString());
97
104
  }
105
+ // An empty token is a distinct, meaningful value — "start the walk" — so
106
+ // it must reach the wire rather than be dropped as falsy.
107
+ if (params?.pageToken !== undefined) {
108
+ searchParams.append("pageToken", params.pageToken);
109
+ }
110
+ if (params?.orderBy !== undefined) {
111
+ searchParams.append("orderBy", params.orderBy);
112
+ }
98
113
  if (params?.entryType !== undefined) {
99
114
  searchParams.append("entryType", params.entryType);
100
115
  }
@@ -114,9 +129,13 @@ export class ProfileAPIImpl extends BaseAPI {
114
129
  * Fetches the user's token balances from the /api/v1/accounts/balances endpoint.
115
130
  * Requires a valid access token to be set.
116
131
  *
132
+ * Cursor paged (0XM-2788/0XM-2821): omit `pageToken` or pass `""` to start,
133
+ * then follow `nextPageToken` until it comes back empty. There is no `page`
134
+ * — sending one is a `400`.
135
+ *
117
136
  * @param params - Optional query parameters for pagination
118
- * @param params.page - Page number (starts from 1, default: 1)
119
- * @param params.pageSize - Number of items per page (default: 20, max: 100)
137
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
138
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
120
139
  * @returns Promise resolving to paginated balances response
121
140
  * @throws {APIError} When the request fails or user is not authenticated
122
141
  *
@@ -129,19 +148,29 @@ export class ProfileAPIImpl extends BaseAPI {
129
148
  * console.log(`${balance.symbol}: ${balance.availableBalance}`);
130
149
  * });
131
150
  *
132
- * // Get page 2 with 50 items per page
133
- * const nextBalances = await profileAPI.getUserBalances({ page: 2, pageSize: 50 });
134
- * console.log(`Returned ${nextBalances.balances.length} balances`);
151
+ * // Walk every page
152
+ * let pageToken = "";
153
+ * for (;;) {
154
+ * const page = await profileAPI.getUserBalances({ pageToken, pageSize: 50 });
155
+ * console.log(page.balances.length);
156
+ * if (page.nextPageToken === "") break;
157
+ * pageToken = page.nextPageToken;
158
+ * }
135
159
  * ```
136
160
  */
137
161
  async getUserBalances(params) {
138
- const searchParams = new URLSearchParams();
139
- if (params?.page !== undefined) {
140
- searchParams.append("page", params.page.toString());
162
+ if (params) {
163
+ validate(GetUserBalancesSchema, params);
141
164
  }
165
+ const searchParams = new URLSearchParams();
142
166
  if (params?.pageSize !== undefined) {
143
167
  searchParams.append("pageSize", params.pageSize.toString());
144
168
  }
169
+ // An empty token is a distinct, meaningful value — "start the walk" — so
170
+ // it must reach the wire rather than be dropped as falsy.
171
+ if (params?.pageToken !== undefined) {
172
+ searchParams.append("pageToken", params.pageToken);
173
+ }
145
174
  const queryString = searchParams.toString();
146
175
  const url = queryString ? `/api/v1/accounts/balances?${queryString}` : "/api/v1/accounts/balances";
147
176
  return await this.makeAuthenticatedRequest(url);
@@ -315,12 +344,21 @@ export class ProfileAPIImpl extends BaseAPI {
315
344
  * Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
316
345
  * Requires a valid access token to be set.
317
346
  *
318
- * The response `total` and `totalPages` are bounded by the listing's pagination reach:
319
- * exact up to `pageSize` x 10,000 rows (10,000 pages) and saturating there, so a user
320
- * with more matching payments than the listing can page through reads the cap, not
321
- * their lifetime total. A `page` above 10,000 is rejected.
347
+ * Cursor paged (0XM-2788/0XM-2818): omit `pageToken` or pass `""` to start,
348
+ * then follow `nextPageToken` from each response until it comes back empty.
349
+ * There is no `page` — sending one is a `400`.
350
+ *
351
+ * The response `total` and `totalPages` are bounded by the server count
352
+ * ceiling; `totalCapped` is `true` when more than that matched, so `total`
353
+ * is a lower bound. Do not drive a paging loop off `total`: a user past the
354
+ * ceiling would stop early. Follow `nextPageToken`.
322
355
  *
323
356
  * @param params - Optional query parameters for pagination and filtering
357
+ * @param params.pageToken - Cursor from a previous response's `nextPageToken`
358
+ * @param params.pageSize - Number of items per page (default: 20, max: 1000)
359
+ * @param params.tradingPairId - Filter by trading pair ID (UUID)
360
+ * @param params.positionId - Filter by margin position ID (UUID)
361
+ * @param params.marginAccountId - Filter by margin account ID (UUID)
324
362
  * @returns Promise resolving to paginated funding payments response
325
363
  * @throws {APIError} When the request fails or user is not authenticated
326
364
  *
@@ -328,6 +366,15 @@ export class ProfileAPIImpl extends BaseAPI {
328
366
  * ```typescript
329
367
  * const funding = await profileAPI.listFundingPayments({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
330
368
  * console.log(`Total funding payments: ${funding.total}`);
369
+ *
370
+ * // Walk every page
371
+ * let pageToken = "";
372
+ * for (;;) {
373
+ * const page = await profileAPI.listFundingPayments({ pageToken, pageSize: 100 });
374
+ * console.log(page.records.length);
375
+ * if (page.nextPageToken === "") break;
376
+ * pageToken = page.nextPageToken;
377
+ * }
331
378
  * ```
332
379
  */
333
380
  async listFundingPayments(params) {
@@ -335,12 +382,14 @@ export class ProfileAPIImpl extends BaseAPI {
335
382
  validate(ListFundingPaymentsSchema, params);
336
383
  }
337
384
  const searchParams = new URLSearchParams();
338
- if (params?.page !== undefined) {
339
- searchParams.append("page", params.page.toString());
340
- }
341
385
  if (params?.pageSize !== undefined) {
342
386
  searchParams.append("pageSize", params.pageSize.toString());
343
387
  }
388
+ // An empty token is a distinct, meaningful value — "start the walk" — so
389
+ // it must reach the wire rather than be dropped as falsy.
390
+ if (params?.pageToken !== undefined) {
391
+ searchParams.append("pageToken", params.pageToken);
392
+ }
344
393
  if (params?.tradingPairId !== undefined) {
345
394
  searchParams.append("tradingPairId", params.tradingPairId);
346
395
  }