@0xmonaco/types 1.0.74 → 1.0.76

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 (58) 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/index.d.ts +3 -4
  9. package/dist/buildercodes/responses.d.ts +10 -3
  10. package/dist/buildercodes/responses.js +24 -4
  11. package/dist/fees/responses.js +2 -2
  12. package/dist/managed-markets/index.d.ts +21 -2
  13. package/dist/margin-accounts/index.d.ts +72 -12
  14. package/dist/market/index.d.ts +76 -6
  15. package/dist/pitpass/index.d.ts +16 -11
  16. package/dist/pitpass/index.js +1 -1
  17. package/dist/pitpass/responses.d.ts +21 -0
  18. package/dist/pitpass/responses.js +43 -14
  19. package/dist/positions/index.d.ts +81 -14
  20. package/dist/profile/index.d.ts +114 -44
  21. package/dist/sdk/index.d.ts +12 -4
  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 +2 -0
  28. package/dist/validation/index.js +2 -0
  29. package/dist/validation/managed-markets.d.ts +17 -0
  30. package/dist/validation/managed-markets.js +17 -0
  31. package/dist/validation/margin-accounts.d.ts +10 -3
  32. package/dist/validation/margin-accounts.js +17 -6
  33. package/dist/validation/market.d.ts +45 -0
  34. package/dist/validation/market.js +43 -0
  35. package/dist/validation/positions.d.ts +5 -3
  36. package/dist/validation/positions.js +12 -5
  37. package/dist/validation/profile.d.ts +19 -2
  38. package/dist/validation/profile.js +36 -4
  39. package/dist/validation/trading.d.ts +2 -2
  40. package/dist/validation/vault.d.ts +14 -0
  41. package/dist/validation/vault.js +14 -0
  42. package/dist/websocket/base.d.ts +56 -6
  43. package/dist/websocket/client.d.ts +8 -3
  44. package/dist/websocket/events/index.d.ts +1 -0
  45. package/dist/websocket/events/index.js +1 -0
  46. package/dist/websocket/events/instrument-events.d.ts +27 -1
  47. package/dist/websocket/events/instrument-events.js +6 -1
  48. package/dist/websocket/events/market-stats-events.d.ts +41 -5
  49. package/dist/websocket/events/market-stats-events.js +3 -2
  50. package/dist/websocket/events/orders-events.d.ts +30 -3
  51. package/dist/websocket/events/position-events.d.ts +15 -0
  52. package/dist/websocket/events/position-valuation-events.d.ts +60 -0
  53. package/dist/websocket/events/position-valuation-events.js +15 -0
  54. package/dist/wire/operations.d.ts +1 -1
  55. package/dist/wire/operations.js +2 -0
  56. package/dist/wire/schema.d.ts +906 -284
  57. package/dist/withdrawals/index.d.ts +27 -6
  58. package/package.json +2 -2
@@ -42,7 +42,8 @@ export interface MarginAccountSummary {
42
42
  * liquidation or frozen as bad debt) and on one whose realized loss has used
43
43
  * up its allocation; the parent margin account is charged at most a risk
44
44
  * bucket's allocation. Size transfers against this field, not
45
- * `freeCollateral`.
45
+ * `freeCollateral`. Truncated toward zero at the quote asset's precision,
46
+ * so the printed amount itself is always accepted.
46
47
  */
47
48
  withdrawableCollateral: string;
48
49
  totalPositionNotional: string;
@@ -88,7 +89,8 @@ export interface MarginAccountSummary {
88
89
  *
89
90
  * Present only on risk-bucket rows served from a live risk engine snapshot;
90
91
  * absent (the key is omitted, never null) on parent rows and on
91
- * persisted-fallback reads.
92
+ * persisted-fallback reads. Truncated toward zero at the quote asset's
93
+ * precision, like `withdrawableCollateral`.
92
94
  */
93
95
  availableOrderCollateral?: string;
94
96
  /**
@@ -105,8 +107,29 @@ export interface MarginAccountSummary {
105
107
  copyLeaderHandle?: string;
106
108
  }
107
109
  export interface ListMarginAccountsParams {
108
- page?: number;
110
+ /** Number of items per page, 1 to 1000 (default 20) */
109
111
  pageSize?: number;
112
+ /**
113
+ * Pagination cursor with two states:
114
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
115
+ * no prior position, from the lowest margin account id.
116
+ * - Non-empty: an opaque cursor from a previous response's
117
+ * `nextPageToken`; results resume immediately after that position.
118
+ *
119
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
120
+ * sending one is a `400`. The walk seeks on
121
+ * `(marginAccountId, tradingPairId, riskBucketId, strategyKey)` over the
122
+ * repriced set the server builds per request — the parent account row ahead
123
+ * of its own bucket rows — so a bucket that opens or closes mid-walk no
124
+ * longer shifts the rows behind it across the resume point. The strategy key
125
+ * is part of the key because an auto bucket the engine has not materialized
126
+ * yet carries no `riskBucketId`, and one account and pair can hold several
127
+ * strategies; such a row sorts under the id its bucket will carry once the
128
+ * engine projects it, so provisioning completing mid-walk cannot serve the
129
+ * same risk bucket twice. The filters must match the request that minted the
130
+ * token.
131
+ */
132
+ pageToken?: string;
110
133
  /**
111
134
  * Keep only risk-bucket rows in this state (see
112
135
  * {@link MarginAccountSummary.riskBucketState}). A parent margin account row
@@ -117,9 +140,19 @@ export interface ListMarginAccountsParams {
117
140
  }
118
141
  export interface ListMarginAccountsResponse {
119
142
  accounts: MarginAccountSummary[];
143
+ /**
144
+ * Rows matching the filters. Exact — a user's margin accounts and risk
145
+ * buckets are a small bounded set, counted in memory after the repricing
146
+ * pass.
147
+ */
120
148
  total: number;
121
- page: number;
122
149
  pageSize: number;
150
+ /**
151
+ * Cursor for the next page, `""` once the walk is exhausted. The whole set
152
+ * is already in memory, so each page over-fetches one row and an empty token
153
+ * is definitive — follow a non-empty token, stop on an empty one.
154
+ */
155
+ nextPageToken: string;
123
156
  }
124
157
  export interface GetMarginAccountSummaryParams {
125
158
  tradingPairId?: string;
@@ -247,6 +280,10 @@ export interface TransferCollateralResponse {
247
280
  status: string;
248
281
  newEquity: string;
249
282
  newTotalCollateralValue: string;
283
+ /**
284
+ * The largest amount a further transfer-out will accept after this one,
285
+ * truncated toward zero at the collateral asset's precision.
286
+ */
250
287
  newWithdrawableCollateral: string;
251
288
  /**
252
289
  * Whether the transfer was committed to a position's stored margin. Present
@@ -261,8 +298,21 @@ export interface TransferCollateralResponse {
261
298
  }
262
299
  export interface GetMarginAccountMovementsParams {
263
300
  movementType?: string;
264
- page?: number;
301
+ /** Items per page, 1 to 1000 (default 20). */
265
302
  pageSize?: number;
303
+ /**
304
+ * Pagination cursor with two states:
305
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
306
+ * no prior position, from the newest row — this listing always sorts
307
+ * newest-first.
308
+ * - Non-empty: an opaque cursor from a previous response's
309
+ * `nextPageToken`; results resume immediately after that position.
310
+ *
311
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
312
+ * sending one is a 400. Filters must match the request that produced the
313
+ * token, or the request is rejected.
314
+ */
315
+ pageToken?: string;
266
316
  }
267
317
  export interface MarginAccountMovement {
268
318
  movementId: string;
@@ -274,15 +324,17 @@ export interface MarginAccountMovement {
274
324
  }
275
325
  export interface GetMarginAccountMovementsResponse {
276
326
  movements: MarginAccountMovement[];
327
+ pageSize: number;
277
328
  /**
278
- * Matching movements. Exact up to 10,000 pages of the requested page size
279
- * (`pageSize` x 10,000 rows) and saturates there, so a caller with more
280
- * movements than the listing can page through reads the cap, not its
281
- * lifetime total. `page` is capped at 10,000.
329
+ * Cursor for the next page, minted from the last row of an over-fetched
330
+ * page: this listing is one ordered read, so a page shorter than `pageSize`
331
+ * proves the walk is exhausted and this is `""`. A non-empty token always
332
+ * has at least one further row behind it.
333
+ *
334
+ * The response carries no item count: the underlying ledger is too large to
335
+ * count behind a filter.
282
336
  */
283
- total: number;
284
- page: number;
285
- pageSize: number;
337
+ nextPageToken: string;
286
338
  }
287
339
  export interface SimulateOrderRiskRequest {
288
340
  tradingPairId: string;
@@ -521,6 +573,14 @@ export interface MarginAccountsAPI extends BaseAPI {
521
573
  /** One of the caller's margin accounts' own realized and unrealized PnL. */
522
574
  getMarginAccountPnl(marginAccountId: string): Promise<MarginAccountPnl>;
523
575
  transferMarginCollateral(request: TransferMarginCollateralRequest): Promise<TransferMarginCollateralResponse>;
576
+ /**
577
+ * Move collateral from the default margin account to one of the caller's sub-accounts, in one
578
+ * sequenced step. The default margin account itself is refused; fund it with the
579
+ * parent-margin-account routes.
580
+ */
581
+ transferCollateralToSubAccount(marginAccountId: string, amount: string): Promise<TransferMarginCollateralResponse>;
582
+ /** Move collateral from one of the caller's sub-accounts back to the default margin account. */
583
+ transferCollateralFromSubAccount(marginAccountId: string, amount: string): Promise<TransferMarginCollateralResponse>;
524
584
  listMarginAccounts(params?: ListMarginAccountsParams): Promise<ListMarginAccountsResponse>;
525
585
  getParentMarginAccountSummary(params?: GetMarginAccountSummaryParams): Promise<MarginAccountSummary>;
526
586
  /**
@@ -48,6 +48,12 @@ export interface TradingPair {
48
48
  category: string;
49
49
  /** Whether the market is active */
50
50
  isActive: boolean;
51
+ /**
52
+ * Isolated-only market: cross margin may only reduce a position here. A
53
+ * CROSS order that is not reduce-only is rejected with the error code
54
+ * `CROSS_MARGIN_NOT_ALLOWED`; open the position with `marginMode: "ISOLATED"`.
55
+ */
56
+ isolatedOnly: boolean;
51
57
  /** Maker fee in basis points */
52
58
  makerFeeBps: number;
53
59
  /** Taker fee in basis points */
@@ -486,30 +492,94 @@ export interface FundingRecord {
486
492
  export interface ListFundingHistoryParams {
487
493
  startTime?: string;
488
494
  endTime?: string;
489
- page?: number;
495
+ /** Number of items per page, 1 to 1000 (default 50) */
490
496
  pageSize?: number;
491
- /** Sort direction for epoch: "ASC" or "DESC" (default DESC). */
497
+ /** Sort direction for `settledAt`: "ASC" or "DESC" (default DESC). */
492
498
  orderBy?: "ASC" | "DESC";
499
+ /**
500
+ * Pagination cursor with two states:
501
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
502
+ * no prior position, from the newest settlement (the oldest when
503
+ * `orderBy` is `"ASC"`).
504
+ * - Non-empty: an opaque cursor from a previous response's
505
+ * `nextPageToken`; results resume immediately after that position.
506
+ *
507
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
508
+ * sending one is a `400`. The walk seeks on `(settledAt, id)` in the
509
+ * requested direction. Filters and `orderBy` must match the request that
510
+ * minted the token.
511
+ */
512
+ pageToken?: string;
493
513
  }
494
514
  export interface ListFundingHistoryResponse {
495
515
  records: FundingRecord[];
516
+ /**
517
+ * Settlements matching the filter, bounded by the server count ceiling — see
518
+ * `totalCapped`. A lower bound when `totalCapped` is `true`.
519
+ */
496
520
  total: number;
497
- page: number;
521
+ /** Items per page */
498
522
  pageSize: number;
523
+ /**
524
+ * Cursor for the next page, minted from the last row of an over-fetched
525
+ * page. This listing is one ordered read, so a page shorter than `pageSize`
526
+ * proves the walk is exhausted and this is `""`. A non-empty token always
527
+ * has at least one further row behind it.
528
+ */
529
+ nextPageToken: string;
530
+ /**
531
+ * `true` when MORE than the server ceiling of settlements matched, so the
532
+ * count stopped at the ceiling and `total` is a lower bound. `false` when
533
+ * `total` is the exact count — including exactly the ceiling, which is
534
+ * still reported exactly.
535
+ */
536
+ totalCapped: boolean;
499
537
  }
500
538
  export interface ListAllFundingHistoryParams {
501
539
  startTime?: string;
502
540
  endTime?: string;
503
- page?: number;
541
+ /** Number of items per page, 1 to 1000 (default 50) */
504
542
  pageSize?: number;
505
- /** Sort direction for settledAt (default DESC). */
543
+ /** Sort direction for `settledAt` (default DESC). */
506
544
  orderBy?: "ASC" | "DESC";
545
+ /**
546
+ * Pagination cursor with two states:
547
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
548
+ * no prior position, from the newest settlement (the oldest when
549
+ * `orderBy` is `"ASC"`).
550
+ * - Non-empty: an opaque cursor from a previous response's
551
+ * `nextPageToken`; results resume immediately after that position.
552
+ *
553
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
554
+ * sending one is a `400`. The walk seeks on `(settledAt, id)` in the
555
+ * requested direction. Filters and `orderBy` must match the request that
556
+ * minted the token.
557
+ */
558
+ pageToken?: string;
507
559
  }
508
560
  export interface ListAllFundingHistoryResponse {
509
561
  records: FundingRecord[];
562
+ /**
563
+ * Settlements matching the filter, bounded by the server count ceiling — see
564
+ * `totalCapped`. A lower bound when `totalCapped` is `true`.
565
+ */
510
566
  total: number;
511
- page: number;
567
+ /** Items per page */
512
568
  pageSize: number;
569
+ /**
570
+ * Cursor for the next page, minted from the last row of an over-fetched
571
+ * page. This listing is one ordered read, so a page shorter than `pageSize`
572
+ * proves the walk is exhausted and this is `""`. A non-empty token always
573
+ * has at least one further row behind it.
574
+ */
575
+ nextPageToken: string;
576
+ /**
577
+ * `true` when MORE than the server ceiling of settlements matched, so the
578
+ * count stopped at the ceiling and `total` is a lower bound. `false` when
579
+ * `total` is the exact count — including exactly the ceiling, which is
580
+ * still reported exactly.
581
+ */
582
+ totalCapped: boolean;
513
583
  }
514
584
  export interface OpenInterest {
515
585
  tradingPairId: string;
@@ -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