@0xmonaco/core 1.0.81 → 1.0.83

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.
package/README.md CHANGED
@@ -54,7 +54,7 @@ The SDK supports the following documented preset networks. Configure the network
54
54
 
55
55
  **Preset Networks:**
56
56
  - `"staging"` - Staging environment (https://staging.apimonaco.xyz)
57
- - `"mainnet"` - Production environment (https://api.monaco.xyz)
57
+ - `"mainnet"` - Production environment (https://apimonaco.xyz)
58
58
 
59
59
  WebSocket URLs are automatically resolved per network.
60
60
 
@@ -22,6 +22,7 @@ export * from "./profile";
22
22
  export * from "./pulse";
23
23
  export * from "./sub-accounts";
24
24
  export * from "./sweeper";
25
+ export * from "./tradercodes";
25
26
  export * from "./trades";
26
27
  export * from "./trading";
27
28
  export * from "./vault";
package/dist/api/index.js CHANGED
@@ -22,6 +22,7 @@ export * from "./profile";
22
22
  export * from "./pulse";
23
23
  export * from "./sub-accounts";
24
24
  export * from "./sweeper";
25
+ export * from "./tradercodes";
25
26
  export * from "./trades";
26
27
  export * from "./trading";
27
28
  export * from "./vault";
@@ -35,6 +35,11 @@ export declare const perpRoutes: {
35
35
  }) => string;
36
36
  readonly getTwap: (twapOrderId: string) => string;
37
37
  readonly getTwapTca: (twapOrderId: string) => string;
38
+ readonly listTwapSlices: (twapOrderId: string, params?: {
39
+ orderBy?: string;
40
+ pageSize?: number;
41
+ pageToken?: string;
42
+ }) => string;
38
43
  readonly cancelTwap: (twapOrderId: string) => string;
39
44
  };
40
45
  readonly delegatedAgents: {
@@ -33,6 +33,7 @@ export const perpRoutes = {
33
33
  listTwap: (params) => withQuery(`${API_V1}/orders/twap`, params),
34
34
  getTwap: (twapOrderId) => `${API_V1}/orders/twap/${encodeSegment(twapOrderId)}`,
35
35
  getTwapTca: (twapOrderId) => `${API_V1}/orders/twap/${encodeSegment(twapOrderId)}/tca`,
36
+ listTwapSlices: (twapOrderId, params) => withQuery(`${API_V1}/orders/twap/${encodeSegment(twapOrderId)}/slices`, params),
36
37
  cancelTwap: (twapOrderId) => `${API_V1}/orders/twap/${encodeSegment(twapOrderId)}/cancel`,
37
38
  },
38
39
  delegatedAgents: {
@@ -1,6 +1,13 @@
1
1
  /**
2
- * TraderCodes API Module (`sdk.pitpass`)
2
+ * Deprecated PitPass name for the TraderCodes API implementation (`sdk.pitpass`).
3
3
  *
4
- * Exports the TraderCodes API implementation.
4
+ * PitPass is the umbrella over TraderCodes and BuilderCodes; this surface only
5
+ * ever covered TraderCodes. Use `TraderCodesAPIImpl` (`sdk.tradercodes`).
5
6
  */
6
- export { PitpassAPIImpl } from "./api";
7
+ import { TraderCodesAPIImpl } from "../tradercodes";
8
+ /**
9
+ * @deprecated Use {@link TraderCodesAPIImpl}. It calls the same
10
+ * `/api/v1/tradercodes/...` endpoints; removed after at least two SDK releases.
11
+ */
12
+ export declare class PitpassAPIImpl extends TraderCodesAPIImpl {
13
+ }
@@ -1,6 +1,13 @@
1
1
  /**
2
- * TraderCodes API Module (`sdk.pitpass`)
2
+ * Deprecated PitPass name for the TraderCodes API implementation (`sdk.pitpass`).
3
3
  *
4
- * Exports the TraderCodes API implementation.
4
+ * PitPass is the umbrella over TraderCodes and BuilderCodes; this surface only
5
+ * ever covered TraderCodes. Use `TraderCodesAPIImpl` (`sdk.tradercodes`).
5
6
  */
6
- export { PitpassAPIImpl } from "./api";
7
+ import { TraderCodesAPIImpl } from "../tradercodes";
8
+ /**
9
+ * @deprecated Use {@link TraderCodesAPIImpl}. It calls the same
10
+ * `/api/v1/tradercodes/...` endpoints; removed after at least two SDK releases.
11
+ */
12
+ export class PitpassAPIImpl extends TraderCodesAPIImpl {
13
+ }
@@ -48,6 +48,8 @@ export class PositionsAPIImpl extends BaseAPI {
48
48
  method: "POST",
49
49
  body: JSON.stringify({
50
50
  tradingPairId: request?.tradingPairId,
51
+ tradingPairIds: request?.tradingPairIds,
52
+ side: request?.side,
51
53
  slippageToleranceBps: request?.slippageToleranceBps,
52
54
  }),
53
55
  });
@@ -193,10 +193,17 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
193
193
  * Fetches the user's executed trades from the /api/v1/accounts/trades endpoint.
194
194
  * Requires a valid access token to be set.
195
195
  *
196
- * When neither `page` nor `pageToken` is passed, the SDK drives cursor (pageToken)
197
- * pagination: it starts a cursor walk from the newest row and the response's
198
- * `nextPageToken` resumes it. Responses carry no item count: the `trades`
199
- * table is too large to count behind a filter.
196
+ * Cursor-paginated: omitting `pageToken` starts a walk from the newest row, and
197
+ * the response's `nextPageToken` resumes it. There is no page-number mode: a
198
+ * `page` param is rejected with a `ValidationError` before the request is sent
199
+ * (the REST endpoint itself answers `400`).
200
+ *
201
+ * An unfiltered response carries `total` and `totalPages`, bounded by the
202
+ * server count ceiling; `totalCapped` is `true` when more than that matched,
203
+ * so `total` is a lower bound. A response filtered by `tradingPairId` carries
204
+ * neither (counting one pair would read the user's whole trade history), nor
205
+ * does one whose count ran out of its server time budget: treat absent as
206
+ * unknown. Do not drive a paging loop off `total`; follow `nextPageToken`.
200
207
  *
201
208
  * @param params - Optional query parameters for pagination and filtering
202
209
  * @param params.pageSize - Number of items per page (default: 20; up to 1000)
@@ -254,10 +254,17 @@ export class ProfileAPIImpl extends BaseAPI {
254
254
  * Fetches the user's executed trades from the /api/v1/accounts/trades endpoint.
255
255
  * Requires a valid access token to be set.
256
256
  *
257
- * When neither `page` nor `pageToken` is passed, the SDK drives cursor (pageToken)
258
- * pagination: it starts a cursor walk from the newest row and the response's
259
- * `nextPageToken` resumes it. Responses carry no item count: the `trades`
260
- * table is too large to count behind a filter.
257
+ * Cursor-paginated: omitting `pageToken` starts a walk from the newest row, and
258
+ * the response's `nextPageToken` resumes it. There is no page-number mode: a
259
+ * `page` param is rejected with a `ValidationError` before the request is sent
260
+ * (the REST endpoint itself answers `400`).
261
+ *
262
+ * An unfiltered response carries `total` and `totalPages`, bounded by the
263
+ * server count ceiling; `totalCapped` is `true` when more than that matched,
264
+ * so `total` is a lower bound. A response filtered by `tradingPairId` carries
265
+ * neither (counting one pair would read the user's whole trade history), nor
266
+ * does one whose count ran out of its server time budget: treat absent as
267
+ * unknown. Do not drive a paging loop off `total`; follow `nextPageToken`.
261
268
  *
262
269
  * @param params - Optional query parameters for pagination and filtering
263
270
  * @param params.pageSize - Number of items per page (default: 20; up to 1000)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TraderCodes API Implementation (`sdk.pitpass`)
2
+ * TraderCodes API Implementation (`sdk.tradercodes`)
3
3
  *
4
4
  * Provides methods for the TraderCodes referral program: reading your wallet-derived
5
5
  * TraderCode, a public lookup to validate a referral code at sign-up, reading
@@ -12,30 +12,30 @@
12
12
  * @example
13
13
  * ```typescript
14
14
  * // Read your own code (authenticated)
15
- * const { code } = await sdk.pitpass.getMyTraderCode();
15
+ * const { code } = await sdk.tradercodes.getMyTraderCode();
16
16
  * console.log(`Share code: Monaco - ${code}`);
17
17
  *
18
18
  * // Validate a referral code at sign-up (public)
19
- * const info = await sdk.pitpass.getTraderCodeInfo("0xabc...");
19
+ * const info = await sdk.tradercodes.getTraderCodeInfo("0xabc...");
20
20
  * console.log(`Referrer code: ${info.code}`);
21
21
  *
22
22
  * // Read accrued rewards balance (authenticated)
23
- * const { balances } = await sdk.pitpass.getRewardsBalance();
23
+ * const { balances } = await sdk.tradercodes.getRewardsBalance();
24
24
  * for (const b of balances) {
25
25
  * console.log(`${b.token}: ${b.available}`);
26
26
  * }
27
27
  *
28
28
  * // Transfer rewards into trading balance (authenticated)
29
- * const result = await sdk.pitpass.transferRewards({
29
+ * const result = await sdk.tradercodes.transferRewards({
30
30
  * token: "0xusdc...",
31
31
  * amount: "1000000",
32
32
  * });
33
33
  * console.log(`Rewards remaining: ${result.rewardsBalance}`);
34
34
  * ```
35
35
  */
36
- import type { GetMyReferralDownlineParams, GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, PitpassAPI, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "@0xmonaco/types";
36
+ import type { GetMyReferralDownlineParams, GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TraderCodesAPI, TransferRewardsParams, TransferRewardsResponse } from "@0xmonaco/types";
37
37
  import { BaseAPI } from "../base";
38
- export declare class PitpassAPIImpl extends BaseAPI implements PitpassAPI {
38
+ export declare class TraderCodesAPIImpl extends BaseAPI implements TraderCodesAPI {
39
39
  /**
40
40
  * Return the authenticated caller's TraderCode.
41
41
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TraderCodes API Implementation (`sdk.pitpass`)
2
+ * TraderCodes API Implementation (`sdk.tradercodes`)
3
3
  *
4
4
  * Provides methods for the TraderCodes referral program: reading your wallet-derived
5
5
  * TraderCode, a public lookup to validate a referral code at sign-up, reading
@@ -12,21 +12,21 @@
12
12
  * @example
13
13
  * ```typescript
14
14
  * // Read your own code (authenticated)
15
- * const { code } = await sdk.pitpass.getMyTraderCode();
15
+ * const { code } = await sdk.tradercodes.getMyTraderCode();
16
16
  * console.log(`Share code: Monaco - ${code}`);
17
17
  *
18
18
  * // Validate a referral code at sign-up (public)
19
- * const info = await sdk.pitpass.getTraderCodeInfo("0xabc...");
19
+ * const info = await sdk.tradercodes.getTraderCodeInfo("0xabc...");
20
20
  * console.log(`Referrer code: ${info.code}`);
21
21
  *
22
22
  * // Read accrued rewards balance (authenticated)
23
- * const { balances } = await sdk.pitpass.getRewardsBalance();
23
+ * const { balances } = await sdk.tradercodes.getRewardsBalance();
24
24
  * for (const b of balances) {
25
25
  * console.log(`${b.token}: ${b.available}`);
26
26
  * }
27
27
  *
28
28
  * // Transfer rewards into trading balance (authenticated)
29
- * const result = await sdk.pitpass.transferRewards({
29
+ * const result = await sdk.tradercodes.transferRewards({
30
30
  * token: "0xusdc...",
31
31
  * amount: "1000000",
32
32
  * });
@@ -35,7 +35,7 @@
35
35
  */
36
36
  import { GetMyReferralDownlineParamsSchema, GetMyReferralTreeParamsSchema, SetTraderCodeParamsSchema, TransferRewardsParamsSchema, validate, } from "@0xmonaco/types";
37
37
  import { BaseAPI } from "../base";
38
- export class PitpassAPIImpl extends BaseAPI {
38
+ export class TraderCodesAPIImpl extends BaseAPI {
39
39
  /**
40
40
  * Return the authenticated caller's TraderCode.
41
41
  *
@@ -43,7 +43,7 @@ export class PitpassAPIImpl extends BaseAPI {
43
43
  * custom-handle fields (`customCode`, `isCustom`, `display`).
44
44
  */
45
45
  async getMyTraderCode() {
46
- return await this.makeAuthenticatedRequest("/api/v1/pitpass/codes/me", { method: "GET" });
46
+ return await this.makeAuthenticatedRequest("/api/v1/tradercodes/codes/me", { method: "GET" });
47
47
  }
48
48
  /**
49
49
  * Claim or edit the caller's custom (vanity) TraderCode handle.
@@ -54,7 +54,7 @@ export class PitpassAPIImpl extends BaseAPI {
54
54
  */
55
55
  async setTraderCode(code) {
56
56
  const validated = validate(SetTraderCodeParamsSchema, { code });
57
- return await this.makeAuthenticatedRequest("/api/v1/pitpass/codes/me/custom", {
57
+ return await this.makeAuthenticatedRequest("/api/v1/tradercodes/codes/me/custom", {
58
58
  method: "PUT",
59
59
  body: JSON.stringify({ code: validated.code }),
60
60
  });
@@ -64,7 +64,7 @@ export class PitpassAPIImpl extends BaseAPI {
64
64
  * default. The freed handle enters a cooldown before it can be reclaimed.
65
65
  */
66
66
  async clearTraderCode() {
67
- return await this.makeAuthenticatedRequest("/api/v1/pitpass/codes/me/custom", { method: "DELETE" });
67
+ return await this.makeAuthenticatedRequest("/api/v1/tradercodes/codes/me/custom", { method: "DELETE" });
68
68
  }
69
69
  /**
70
70
  * Public advisory check of whether a custom TraderCode handle is available.
@@ -76,7 +76,7 @@ export class PitpassAPIImpl extends BaseAPI {
76
76
  // Trim to mirror the claim path (setTraderCode validates a trimmed handle),
77
77
  // so the advisory check and the eventual claim agree on padded input.
78
78
  const query = new URLSearchParams({ code: code.trim() }).toString();
79
- const raw = await this.makePublicRequest(`/api/v1/pitpass/codes/available?${query}`, {
79
+ const raw = await this.makePublicRequest(`/api/v1/tradercodes/codes/available?${query}`, {
80
80
  method: "GET",
81
81
  });
82
82
  // The API always serializes `reason`, sending "" (proto3 string default)
@@ -90,20 +90,20 @@ export class PitpassAPIImpl extends BaseAPI {
90
90
  */
91
91
  async getTraderCodeInfo(code) {
92
92
  const encoded = encodeURIComponent(code.trim());
93
- return await this.makePublicRequest(`/api/v1/pitpass/codes/${encoded}`, { method: "GET" });
93
+ return await this.makePublicRequest(`/api/v1/tradercodes/codes/${encoded}`, { method: "GET" });
94
94
  }
95
95
  /**
96
96
  * Return the caller's current TraderCodes rewards-bucket balances.
97
97
  */
98
98
  async getRewardsBalance() {
99
- return await this.makeAuthenticatedRequest("/api/v1/pitpass/rewards/balance", { method: "GET" });
99
+ return await this.makeAuthenticatedRequest("/api/v1/tradercodes/rewards/balance", { method: "GET" });
100
100
  }
101
101
  /**
102
102
  * Transfer earned TraderCodes rewards into a trading balance.
103
103
  */
104
104
  async transferRewards(params) {
105
105
  const validated = validate(TransferRewardsParamsSchema, params);
106
- return await this.makeAuthenticatedRequest("/api/v1/pitpass/rewards/transfer", {
106
+ return await this.makeAuthenticatedRequest("/api/v1/tradercodes/rewards/transfer", {
107
107
  method: "POST",
108
108
  body: JSON.stringify({ token: validated.token, amount: validated.amount }),
109
109
  });
@@ -117,7 +117,7 @@ export class PitpassAPIImpl extends BaseAPI {
117
117
  * referral levels.
118
118
  */
119
119
  async getMyReferralPosition() {
120
- return await this.makeAuthenticatedRequest("/api/v1/pitpass/referrals/me", {
120
+ return await this.makeAuthenticatedRequest("/api/v1/tradercodes/referrals/me", {
121
121
  method: "GET",
122
122
  });
123
123
  }
@@ -141,7 +141,7 @@ export class PitpassAPIImpl extends BaseAPI {
141
141
  searchParams.append("pageToken", params.pageToken);
142
142
  }
143
143
  const query = searchParams.toString();
144
- const path = query ? `/api/v1/pitpass/referrals/me/downline?${query}` : "/api/v1/pitpass/referrals/me/downline";
144
+ const path = query ? `/api/v1/tradercodes/referrals/me/downline?${query}` : "/api/v1/tradercodes/referrals/me/downline";
145
145
  return await this.makeAuthenticatedRequest(path, { method: "GET" });
146
146
  }
147
147
  /**
@@ -166,7 +166,7 @@ export class PitpassAPIImpl extends BaseAPI {
166
166
  searchParams.append("pageToken", params.pageToken);
167
167
  }
168
168
  const query = searchParams.toString();
169
- const path = query ? `/api/v1/pitpass/referrals/me/tree?${query}` : "/api/v1/pitpass/referrals/me/tree";
169
+ const path = query ? `/api/v1/tradercodes/referrals/me/tree?${query}` : "/api/v1/tradercodes/referrals/me/tree";
170
170
  return await this.makeAuthenticatedRequest(path, { method: "GET" });
171
171
  }
172
172
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * TraderCodes API Module (`sdk.tradercodes`)
3
+ *
4
+ * Exports the TraderCodes API implementation.
5
+ */
6
+ export { TraderCodesAPIImpl } from "./api";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * TraderCodes API Module (`sdk.tradercodes`)
3
+ *
4
+ * Exports the TraderCodes API implementation.
5
+ */
6
+ export { TraderCodesAPIImpl } from "./api";
@@ -21,7 +21,7 @@
21
21
  * );
22
22
  * ```
23
23
  */
24
- import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MarginMode, OrderSide, ParentTpSlLegParams, ParentTrailingStopLegParams, PositionSide, ReplaceOrderResponse, SelfTradePreventionMode, TimeInForce, TradingAPI, TradingMode, TwapOrder } from "@0xmonaco/types";
24
+ import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrderSlicesParams, ListTwapOrderSlicesResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MarginMode, OrderSide, ParentTpSlLegParams, ParentTrailingStopLegParams, PositionSide, ReplaceOrderResponse, SelfTradePreventionMode, TimeInForce, TradingAPI, TradingMode, TwapOrder } from "@0xmonaco/types";
25
25
  import { BaseAPI } from "../base";
26
26
  export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
27
27
  /**
@@ -318,7 +318,8 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
318
318
  * Every row is a BOOK order (`LIMIT` or `MARKET`); filter `status` to
319
319
  * `["SUBMITTED", "PARTIALLY_FILLED"]` for the resting working set. TWAP parents and
320
320
  * conditional (TP/SL) orders are not rows here — list them with `listTwapOrders`
321
- * and `listConditionalOrders`.
321
+ * and `listConditionalOrders`. Nor are a TWAP's slices, the child orders that carry
322
+ * `parentOrderId`: read them with `listTwapOrderSlices`.
322
323
  * When neither `page` nor `pageToken` is passed, the SDK drives cursor (pageToken)
323
324
  * pagination: it starts a cursor walk from the newest (or oldest, for
324
325
  * `orderBy: "ASC"`) row and the response's `nextPageToken` resumes it. Both modes
@@ -536,4 +537,30 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
536
537
  * ```
537
538
  */
538
539
  listTwapOrders(params?: ListTwapOrdersParams): Promise<ListTwapOrdersResponse>;
540
+ /**
541
+ * Lists one TWAP parent's slices: the child orders it placed, each as
542
+ * `getOrder` returns it and carrying the parent's id in `parentOrderId`.
543
+ *
544
+ * Resting and finished slices are both listed, oldest first unless
545
+ * `orderBy: "DESC"`. A `PASSIVE` parent's reprices and deadline sweeps are
546
+ * child orders too, so a parent can have more slices than `slicesPlaced`.
547
+ * Cursor (pageToken) pagination is the only mode: follow `nextPageToken`
548
+ * until it comes back empty. Users can only access their own TWAP orders.
549
+ *
550
+ * @param twapOrderId - The TWAP parent order UUID
551
+ * @param params - Optional sort direction, page size (up to 1000) and cursor
552
+ * @returns Promise resolving to one page of slices
553
+ * @throws {APIError} When API communication fails or the TWAP order is not found
554
+ *
555
+ * @example
556
+ * ```typescript
557
+ * let pageToken = "";
558
+ * do {
559
+ * const page = await tradingAPI.listTwapOrderSlices(twapOrderId, { pageSize: 100, pageToken });
560
+ * for (const slice of page.slices) console.log(slice.id, slice.status, slice.filledQuantity);
561
+ * pageToken = page.nextPageToken;
562
+ * } while (pageToken);
563
+ * ```
564
+ */
565
+ listTwapOrderSlices(twapOrderId: string, params?: ListTwapOrderSlicesParams): Promise<ListTwapOrderSlicesResponse>;
539
566
  }
@@ -21,7 +21,7 @@
21
21
  * );
22
22
  * ```
23
23
  */
24
- import { BatchCreateOrdersSchema, BatchReplaceOrdersSchema, CancelConditionalOrderSchema, CancelOrderSchema, CancelTwapOrderSchema, CreateTwapOrderSchema, GetPaginatedOrdersSchema, ListConditionalOrdersSchema, ListTwapOrdersSchema, PlaceLimitOrderSchema, PlaceMarketOrderSchema, ReplaceOrderSchema, validate, } from "@0xmonaco/types";
24
+ import { BatchCreateOrdersSchema, BatchReplaceOrdersSchema, CancelConditionalOrderSchema, CancelOrderSchema, CancelTwapOrderSchema, CreateTwapOrderSchema, GetPaginatedOrdersSchema, ListConditionalOrdersSchema, ListTwapOrderSlicesSchema, ListTwapOrdersSchema, PlaceLimitOrderSchema, PlaceMarketOrderSchema, ReplaceOrderSchema, validate, } from "@0xmonaco/types";
25
25
  import { BaseAPI } from "../base";
26
26
  import { perpRoutes } from "../perp";
27
27
  function parentTpSlLegToRequest(leg) {
@@ -498,7 +498,8 @@ export class TradingAPIImpl extends BaseAPI {
498
498
  * Every row is a BOOK order (`LIMIT` or `MARKET`); filter `status` to
499
499
  * `["SUBMITTED", "PARTIALLY_FILLED"]` for the resting working set. TWAP parents and
500
500
  * conditional (TP/SL) orders are not rows here — list them with `listTwapOrders`
501
- * and `listConditionalOrders`.
501
+ * and `listConditionalOrders`. Nor are a TWAP's slices, the child orders that carry
502
+ * `parentOrderId`: read them with `listTwapOrderSlices`.
502
503
  * When neither `page` nor `pageToken` is passed, the SDK drives cursor (pageToken)
503
504
  * pagination: it starts a cursor walk from the newest (or oldest, for
504
505
  * `orderBy: "ASC"`) row and the response's `nextPageToken` resumes it. Both modes
@@ -839,4 +840,43 @@ export class TradingAPIImpl extends BaseAPI {
839
840
  pageToken: pageToken ?? "",
840
841
  }), { method: "GET" });
841
842
  }
843
+ /**
844
+ * Lists one TWAP parent's slices: the child orders it placed, each as
845
+ * `getOrder` returns it and carrying the parent's id in `parentOrderId`.
846
+ *
847
+ * Resting and finished slices are both listed, oldest first unless
848
+ * `orderBy: "DESC"`. A `PASSIVE` parent's reprices and deadline sweeps are
849
+ * child orders too, so a parent can have more slices than `slicesPlaced`.
850
+ * Cursor (pageToken) pagination is the only mode: follow `nextPageToken`
851
+ * until it comes back empty. Users can only access their own TWAP orders.
852
+ *
853
+ * @param twapOrderId - The TWAP parent order UUID
854
+ * @param params - Optional sort direction, page size (up to 1000) and cursor
855
+ * @returns Promise resolving to one page of slices
856
+ * @throws {APIError} When API communication fails or the TWAP order is not found
857
+ *
858
+ * @example
859
+ * ```typescript
860
+ * let pageToken = "";
861
+ * do {
862
+ * const page = await tradingAPI.listTwapOrderSlices(twapOrderId, { pageSize: 100, pageToken });
863
+ * for (const slice of page.slices) console.log(slice.id, slice.status, slice.filledQuantity);
864
+ * pageToken = page.nextPageToken;
865
+ * } while (pageToken);
866
+ * ```
867
+ */
868
+ async listTwapOrderSlices(twapOrderId, params) {
869
+ // The positional id is what the path is built from, so it is what gets
870
+ // validated: a `twapOrderId` smuggled in through `params` must not stand
871
+ // in for it.
872
+ validate(ListTwapOrderSlicesSchema, { ...params, twapOrderId });
873
+ const { orderBy, pageSize = 20, pageToken } = params || {};
874
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.listTwapSlices(twapOrderId, {
875
+ orderBy,
876
+ pageSize,
877
+ // Sent even as the empty string: the server starts a walk on the
878
+ // token's PRESENCE, not its value.
879
+ pageToken: pageToken ?? "",
880
+ }), { method: "GET" });
881
+ }
842
882
  }
@@ -16,6 +16,11 @@ const RECONNECT_BASE_DELAY = 1000;
16
16
  */
17
17
  const MAX_SKEW_AUTH_RETRIES = 3;
18
18
  const SKEW_REJECTION = /timestamp outside allowed skew/i;
19
+ // The server's INVALID_MESSAGE texts when it refuses a whole Subscribe /
20
+ // Unsubscribe for listing too many channels, after parsing it (ws-api
21
+ // `oversized_channel_list_message`) or before (`too_many_elements_message`).
22
+ // No ack follows either.
23
+ const OVERSIZED_REQUEST = /^(?:(?:Subscribe|Unsubscribe) lists \d+ channels; at most \d+ per request|Message lists too many elements; at most \d+ channels per request)$/;
19
24
  function isRecord(value) {
20
25
  return typeof value === "object" && value !== null && !Array.isArray(value);
21
26
  }
@@ -548,6 +553,8 @@ function parseOHLCVSnapshotCandle(raw, interval) {
548
553
  v: readString(raw, "volume"),
549
554
  i: interval,
550
555
  n: readSequence(raw, "trades_count"),
556
+ openInterestBase: readOptionalString(raw, "open_interest_base"),
557
+ openInterestNotional: readOptionalString(raw, "open_interest_notional"),
551
558
  };
552
559
  }
553
560
  function parseInstrumentEventData(raw) {
@@ -965,6 +972,20 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
965
972
  // subscriber unsubscribes — the next first subscriber triggers a fresh wire
966
973
  // Subscribe whose snapshot is authoritative, never the stale cache.
967
974
  const instrumentBaseline = new Map();
975
+ // `handlers` holds what the caller WANTS; this tracks what the server has
976
+ // acknowledged on the current socket. The server handles one connection's
977
+ // messages strictly in order and answers every Subscribe / Unsubscribe with
978
+ // an ack naming only the channels that request changed (a rejected or
979
+ // already-held channel is omitted), or, for an over-long one, with an
980
+ // INVALID_MESSAGE and no ack. So the oldest outstanding request is always
981
+ // the one being answered. All of it is per socket: a new connection starts
982
+ // with nothing confirmed and re-requests what is wanted.
983
+ const confirmedChannels = new Set();
984
+ let pendingRequests = [];
985
+ // Wanted channels the server rejected with AUTH_REQUIRED on this socket,
986
+ // re-requested once when the connection next authenticates.
987
+ const authRejectedChannels = new Set();
988
+ const subscriptionListeners = new Set();
968
989
  const getStatus = () => {
969
990
  if (!ws)
970
991
  return reconnectTimer ? "reconnecting" : "disconnected";
@@ -1104,16 +1125,74 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1104
1125
  ws.send(JSON.stringify(data));
1105
1126
  }
1106
1127
  };
1128
+ const sendSubscribe = (channels) => {
1129
+ if (channels.length === 0 || ws?.readyState !== WebSocket.OPEN)
1130
+ return;
1131
+ pendingRequests.push({ kind: "subscribe", channels });
1132
+ send({ type: "Subscribe", channels });
1133
+ };
1134
+ const sendUnsubscribe = (channels) => {
1135
+ if (channels.length === 0 || ws?.readyState !== WebSocket.OPEN)
1136
+ return;
1137
+ pendingRequests.push({ kind: "unsubscribe", channels });
1138
+ send({ type: "Unsubscribe", channels });
1139
+ };
1140
+ /** Forget everything the server confirmed or was asked on the old socket. */
1141
+ const resetSubscriptionAcks = () => {
1142
+ confirmedChannels.clear();
1143
+ pendingRequests = [];
1144
+ authRejectedChannels.clear();
1145
+ };
1146
+ const isRequested = (kind, channel) => pendingRequests.some((request) => request.kind === kind && request.channels.includes(channel));
1147
+ const getSubscriptionState = (channel) => {
1148
+ if (handlers.has(channel)) {
1149
+ if (isRequested("subscribe", channel))
1150
+ return "pending";
1151
+ return confirmedChannels.has(channel) ? "subscribed" : "unconfirmed";
1152
+ }
1153
+ // Released: the server can still hold it only if it confirmed it, or if
1154
+ // its Subscribe is still unanswered. An Unsubscribe alone proves nothing
1155
+ // (the channel may have been rejected), so it does not count here.
1156
+ if (confirmedChannels.has(channel) || isRequested("subscribe", channel))
1157
+ return "unsubscribing";
1158
+ return "idle";
1159
+ };
1160
+ /**
1161
+ * Report a server-confirmed change. A listener's error is logged, never
1162
+ * propagated: it must not stop the ack bookkeeping or other listeners.
1163
+ */
1164
+ const emitSubscriptionChange = (change) => {
1165
+ const logListenerError = (err) => console.error("WebSocket: onSubscriptionChange listener threw", err);
1166
+ for (const listener of subscriptionListeners) {
1167
+ try {
1168
+ const result = listener(change);
1169
+ // An async listener is assignable to the void-returning type; log its
1170
+ // rejection rather than leave it unhandled (any thenable, as in
1171
+ // emitStatus).
1172
+ if (typeof result?.then === "function") {
1173
+ Promise.resolve(result).catch(logListenerError);
1174
+ }
1175
+ }
1176
+ catch (err) {
1177
+ logListenerError(err);
1178
+ }
1179
+ }
1180
+ };
1181
+ const onSubscriptionChange = (listener) => {
1182
+ subscriptionListeners.add(listener);
1183
+ return () => {
1184
+ subscriptionListeners.delete(listener);
1185
+ };
1186
+ };
1187
+ /** Channel strings of an ack frame; anything malformed reads as none. */
1188
+ const ackChannels = (raw) => (Array.isArray(raw) ? raw.filter((channel) => typeof channel === "string") : []);
1107
1189
  const resubscribeAll = () => {
1108
1190
  // Every re-sent Subscribe is genuinely new to the server (new
1109
1191
  // connection), so fresh authoritative snapshots are inbound: the
1110
1192
  // pre-outage instrument cache is stale — markets may have been delisted
1111
1193
  // during the gap — and must not be replayed to late subscribers.
1112
1194
  instrumentBaseline.clear();
1113
- const channels = Array.from(handlers.keys());
1114
- if (channels.length > 0) {
1115
- send({ type: "Subscribe", channels });
1116
- }
1195
+ sendSubscribe(Array.from(handlers.keys()));
1117
1196
  };
1118
1197
  // A subscription channel matches a frame when it is identical, is a prefix of
1119
1198
  // the frame's dotted-by-colon path, or ends in a `:*` wildcard segment whose
@@ -1154,6 +1233,18 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1154
1233
  // frame just before the close; the close event decides from it.
1155
1234
  // Recorded before any application code runs, so a throwing onError
1156
1235
  // cannot make the close look transient.
1236
+ // A wanted channel the server refused for want of authentication is
1237
+ // retried once the connection authenticates.
1238
+ if (msg.code === "AUTH_REQUIRED" && typeof msg.channel === "string" && handlers.has(msg.channel)) {
1239
+ authRejectedChannels.add(msg.channel);
1240
+ }
1241
+ // A Subscribe / Unsubscribe whose channel list is too long is refused
1242
+ // whole with a connection-wide INVALID_MESSAGE and no ack. It is the
1243
+ // oldest outstanding request: retire it, or every later ack would
1244
+ // pair with the wrong request.
1245
+ if (msg.code === "INVALID_MESSAGE" && OVERSIZED_REQUEST.test(msg.message)) {
1246
+ pendingRequests.shift();
1247
+ }
1157
1248
  if (msg.code === "AUTH_FAILED") {
1158
1249
  lastAuthError = { code: msg.code, message: msg.message, session: pendingAuthSessions.shift() };
1159
1250
  }
@@ -1174,6 +1265,42 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1174
1265
  if (msg.type === "Authenticated") {
1175
1266
  confirmedSession = pendingAuthSessions.shift();
1176
1267
  skewAuthRetries = 0;
1268
+ // Retry, once, each channel refused for want of authentication that is
1269
+ // still wanted and neither held nor already re-requested.
1270
+ const retry = Array.from(authRejectedChannels).filter((channel) => handlers.has(channel) && !confirmedChannels.has(channel) && !isRequested("subscribe", channel));
1271
+ authRejectedChannels.clear();
1272
+ sendSubscribe(retry);
1273
+ return;
1274
+ }
1275
+ if (msg.type === "Subscribed") {
1276
+ // It answers the oldest outstanding request; with none, or another
1277
+ // kind, it is a duplicate or stray ack and changes nothing.
1278
+ if (pendingRequests[0]?.kind !== "subscribe")
1279
+ return;
1280
+ const request = pendingRequests.shift()?.channels ?? [];
1281
+ for (const channel of ackChannels(msg.channels)) {
1282
+ if (!request.includes(channel))
1283
+ continue;
1284
+ // The server holds it now, wanted or not; a channel released while
1285
+ // its Subscribe was in flight is held until its Unsubscribe lands,
1286
+ // and is never reported as subscribed.
1287
+ confirmedChannels.add(channel);
1288
+ if (handlers.has(channel)) {
1289
+ emitSubscriptionChange({ channel, state: "subscribed" });
1290
+ }
1291
+ }
1292
+ return;
1293
+ }
1294
+ if (msg.type === "Unsubscribed") {
1295
+ if (pendingRequests[0]?.kind !== "unsubscribe")
1296
+ return;
1297
+ const request = pendingRequests.shift()?.channels ?? [];
1298
+ for (const channel of ackChannels(msg.channels)) {
1299
+ if (!request.includes(channel))
1300
+ continue;
1301
+ confirmedChannels.delete(channel);
1302
+ emitSubscriptionChange({ channel, state: "unsubscribed" });
1303
+ }
1177
1304
  return;
1178
1305
  }
1179
1306
  if (!msg.channel)
@@ -1210,6 +1337,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1210
1337
  lastAuthError = null;
1211
1338
  pendingAuthSessions = [];
1212
1339
  confirmedSession = undefined;
1340
+ resetSubscriptionAcks();
1213
1341
  const timeout = setTimeout(() => {
1214
1342
  if (ws !== socket) {
1215
1343
  resolve();
@@ -1282,6 +1410,8 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1282
1410
  }
1283
1411
  ws = null;
1284
1412
  stopHeartbeat();
1413
+ // The server dropped every subscription with the connection.
1414
+ resetSubscriptionAcks();
1285
1415
  // Terminal authentication loss: the server revoked the session
1286
1416
  // (SESSION_INVALID, then 1008) or rejected this connection's
1287
1417
  // handshake (AUTH_FAILED, then a close). Reconnecting would replay
@@ -1375,6 +1505,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1375
1505
  handlers.clear();
1376
1506
  snapshotHandlers.clear();
1377
1507
  instrumentBaseline.clear();
1508
+ resetSubscriptionAcks();
1378
1509
  ws?.close(1000, "Client disconnect");
1379
1510
  ws = null;
1380
1511
  hasConnected = false;
@@ -1394,8 +1525,8 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1394
1525
  snapshotHandlers.get(channel)?.add(snapshotHandler);
1395
1526
  }
1396
1527
  // Only send Subscribe message on first subscriber for this channel
1397
- if (isFirstSubscriber && ws?.readyState === WebSocket.OPEN) {
1398
- send({ type: "Subscribe", channels: [channel] });
1528
+ if (isFirstSubscriber) {
1529
+ sendSubscribe([channel]);
1399
1530
  }
1400
1531
  // Return unsubscribe function
1401
1532
  return () => {
@@ -1412,9 +1543,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1412
1543
  // Only send Unsubscribe on last subscriber for this channel
1413
1544
  if (channelHandlers.size === 0) {
1414
1545
  handlers.delete(channel);
1415
- if (ws?.readyState === WebSocket.OPEN) {
1416
- send({ type: "Unsubscribe", channels: [channel] });
1417
- }
1546
+ sendUnsubscribe([channel]);
1418
1547
  }
1419
1548
  }
1420
1549
  };
@@ -1535,6 +1664,8 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1535
1664
  s: data.symbol,
1536
1665
  i: data.interval,
1537
1666
  n: ohlcvData.trades_count || 0,
1667
+ openInterestBase: readOptionalString(ohlcvData, "open_interest_base"),
1668
+ openInterestNotional: readOptionalString(ohlcvData, "open_interest_notional"),
1538
1669
  },
1539
1670
  };
1540
1671
  handler(event);
@@ -1997,6 +2128,8 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
1997
2128
  disconnect,
1998
2129
  isConnected: () => ws?.readyState === WebSocket.OPEN,
1999
2130
  getStatus,
2131
+ getSubscriptionState,
2132
+ onSubscriptionChange,
2000
2133
  setSessionKeypair: (credentials) => {
2001
2134
  session = credentials ?? undefined;
2002
2135
  skewAuthRetries = 0;
@@ -31,6 +31,7 @@ export declare const COVERED: {
31
31
  get_twap_order: string;
32
32
  get_twap_order_tca: string;
33
33
  list_twap_orders: string;
34
+ list_twap_order_slices: string;
34
35
  close_position: string;
35
36
  create_challenge: string;
36
37
  create_delegated_session: string;
@@ -149,4 +150,14 @@ export declare const COVERED: {
149
150
  /** operationId → reason it is intentionally not covered by @0xmonaco/core. */
150
151
  export declare const INTENTIONALLY_EXCLUDED: {
151
152
  health_check: string;
153
+ pitpass_get_my_trader_code: string;
154
+ pitpass_set_trader_code: string;
155
+ pitpass_clear_trader_code: string;
156
+ pitpass_check_trader_code_availability: string;
157
+ pitpass_get_trader_code_info: string;
158
+ pitpass_get_rewards_balance: string;
159
+ pitpass_transfer_rewards: string;
160
+ pitpass_get_my_referral_position: string;
161
+ pitpass_get_my_referral_downline: string;
162
+ pitpass_get_my_referral_tree: string;
152
163
  };
package/dist/coverage.js CHANGED
@@ -31,6 +31,7 @@ export const COVERED = {
31
31
  get_twap_order: "getTwapOrder",
32
32
  get_twap_order_tca: "getTwapOrderTca",
33
33
  list_twap_orders: "listTwapOrders",
34
+ list_twap_order_slices: "listTwapOrderSlices",
34
35
  close_position: "closePosition",
35
36
  create_challenge: "createChallenge",
36
37
  create_delegated_session: "createDelegatedSession",
@@ -58,17 +59,17 @@ export const COVERED = {
58
59
  claim_managed_market_lease: "managedMarkets.claimLease",
59
60
  refresh_managed_market_quotes: "managedMarkets.refreshQuotes",
60
61
  get_sweeper_chains: "sweeper.getChains",
61
- get_my_trader_code: "pitpass.getMyTraderCode",
62
- get_rewards_balance: "pitpass.getRewardsBalance",
63
- get_my_referral_position: "pitpass.getMyReferralPosition",
64
- get_my_referral_downline: "pitpass.getMyReferralDownline",
65
- get_my_referral_tree: "pitpass.getMyReferralTree",
62
+ get_my_trader_code: "tradercodes.getMyTraderCode",
63
+ get_rewards_balance: "tradercodes.getRewardsBalance",
64
+ get_my_referral_position: "tradercodes.getMyReferralPosition",
65
+ get_my_referral_downline: "tradercodes.getMyReferralDownline",
66
+ get_my_referral_tree: "tradercodes.getMyReferralTree",
66
67
  get_self_trade_prevention_default: "profile.getSelfTradePreventionDefault",
67
- get_trader_code_info: "pitpass.getTraderCodeInfo",
68
+ get_trader_code_info: "tradercodes.getTraderCodeInfo",
68
69
  set_self_trade_prevention_default: "profile.setSelfTradePreventionDefault",
69
- set_trader_code: "pitpass.setTraderCode",
70
- clear_trader_code: "pitpass.clearTraderCode",
71
- check_trader_code_availability: "pitpass.checkTraderCodeAvailability",
70
+ set_trader_code: "tradercodes.setTraderCode",
71
+ clear_trader_code: "tradercodes.clearTraderCode",
72
+ check_trader_code_availability: "tradercodes.checkTraderCodeAvailability",
72
73
  get_open_interest: "getOpenInterest",
73
74
  get_order_by_id: "getOrder",
74
75
  get_orderbook_snapshot: "getOrderbook",
@@ -141,7 +142,7 @@ export const COVERED = {
141
142
  transfer_collateral_from_sub_account: "transferCollateralFromSubAccount",
142
143
  claim_buildercode_rewards: "buildercodes.claimBuildercodeRewards",
143
144
  set_builder_fee: "buildercodes.setBuilderFee",
144
- transfer_rewards: "pitpass.transferRewards",
145
+ transfer_rewards: "tradercodes.transferRewards",
145
146
  update_sub_account_limit: "subAccounts.updateLimit",
146
147
  upsert_delegated_agent: "upsertDelegatedAgent",
147
148
  verify_signature: "verifySignature",
@@ -149,4 +150,14 @@ export const COVERED = {
149
150
  /** operationId → reason it is intentionally not covered by @0xmonaco/core. */
150
151
  export const INTENTIONALLY_EXCLUDED = {
151
152
  health_check: "Infrastructure liveness probe (GET /health); not part of the data SDK surface.",
153
+ pitpass_get_my_trader_code: "Deprecated /api/v1/pitpass alias of get_my_trader_code; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
154
+ pitpass_set_trader_code: "Deprecated /api/v1/pitpass alias of set_trader_code; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
155
+ pitpass_clear_trader_code: "Deprecated /api/v1/pitpass alias of clear_trader_code; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
156
+ pitpass_check_trader_code_availability: "Deprecated /api/v1/pitpass alias of check_trader_code_availability; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
157
+ pitpass_get_trader_code_info: "Deprecated /api/v1/pitpass alias of get_trader_code_info; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
158
+ pitpass_get_rewards_balance: "Deprecated /api/v1/pitpass alias of get_rewards_balance; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
159
+ pitpass_transfer_rewards: "Deprecated /api/v1/pitpass alias of transfer_rewards; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
160
+ pitpass_get_my_referral_position: "Deprecated /api/v1/pitpass alias of get_my_referral_position; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
161
+ pitpass_get_my_referral_downline: "Deprecated /api/v1/pitpass alias of get_my_referral_downline; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
162
+ pitpass_get_my_referral_tree: "Deprecated /api/v1/pitpass alias of get_my_referral_tree; the client calls the canonical /api/v1/tradercodes path via tradercodes.",
152
163
  };
@@ -10,7 +10,9 @@
10
10
  const LOCAL_URL = "http://localhost:8080";
11
11
  const DEVELOPMENT_URL = "https://develop.apimonaco.xyz";
12
12
  const STAGING_URL = "https://staging.apimonaco.xyz";
13
- const MAINNET_URL = "https://api.monaco.xyz";
13
+ // https://api.monaco.xyz never resolved (the monaco.xyz zone has no NS
14
+ // delegation), so this is not a behavior change for any working client.
15
+ const MAINNET_URL = "https://apimonaco.xyz";
14
16
  const DEFAULT_API_URLS = {
15
17
  local: LOCAL_URL,
16
18
  development: DEVELOPMENT_URL,
package/dist/sdk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ApplicationsAPI, AuthAPI, AuthState, BuildercodesAPI, CopyTradingAPI, DelegatedAgentsAPI, FaucetAPI, FeesAPI, ManagedMarketsAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PitpassAPI, PortfolioAPI, PositionsAPI, ProfileAPI, PulseAPI, SDKConfig, SubAccountsAPI, SweeperAPI, TradingAPI, VaultAPI, WhitelistAPI, WithdrawalsAPI } from "@0xmonaco/types";
1
+ import type { ApplicationsAPI, AuthAPI, AuthState, BuildercodesAPI, CopyTradingAPI, DelegatedAgentsAPI, FaucetAPI, FeesAPI, ManagedMarketsAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PitpassAPI, PortfolioAPI, PositionsAPI, ProfileAPI, PulseAPI, SDKConfig, SubAccountsAPI, SweeperAPI, TraderCodesAPI, TradingAPI, VaultAPI, WhitelistAPI, WithdrawalsAPI } from "@0xmonaco/types";
2
2
  import { type Address, type PublicClient, type TransactionReceipt, type WalletClient } from "viem";
3
3
  import { type MonacoWebSocket, OrderbookAPIImpl, TradesAPIImpl } from "./api";
4
4
  export declare class MonacoSDKImpl implements MonacoSDK {
@@ -8,6 +8,12 @@ export declare class MonacoSDKImpl implements MonacoSDK {
8
8
  fees: FeesAPI;
9
9
  buildercodes: BuildercodesAPI;
10
10
  copyTrading: CopyTradingAPI;
11
+ tradercodes: TraderCodesAPI;
12
+ /**
13
+ * The same instance as {@link tradercodes}.
14
+ *
15
+ * @deprecated Use `tradercodes`. Removed after at least two SDK releases.
16
+ */
11
17
  pitpass: PitpassAPI;
12
18
  vault: VaultAPI;
13
19
  withdrawals: WithdrawalsAPI;
package/dist/sdk.js CHANGED
@@ -11,13 +11,13 @@ import { FeesAPIImpl } from "./api/fees";
11
11
  import { ManagedMarketsAPIImpl } from "./api/managed-markets";
12
12
  import { MarginAccountsAPIImpl } from "./api/margin-accounts";
13
13
  import { MarketAPIImpl } from "./api/market";
14
- import { PitpassAPIImpl } from "./api/pitpass";
15
14
  import { PortfolioAPIImpl } from "./api/portfolio";
16
15
  import { PositionsAPIImpl } from "./api/positions";
17
16
  import { ProfileAPIImpl } from "./api/profile";
18
17
  import { PulseAPIImpl } from "./api/pulse";
19
18
  import { SubAccountsAPIImpl } from "./api/sub-accounts";
20
19
  import { SweeperAPIImpl } from "./api/sweeper";
20
+ import { TraderCodesAPIImpl } from "./api/tradercodes";
21
21
  import { TradingAPIImpl } from "./api/trading";
22
22
  import { VaultAPIImpl } from "./api/vault";
23
23
  import { WhitelistAPIImpl } from "./api/whitelist";
@@ -50,6 +50,12 @@ export class MonacoSDKImpl {
50
50
  fees;
51
51
  buildercodes;
52
52
  copyTrading;
53
+ tradercodes;
54
+ /**
55
+ * The same instance as {@link tradercodes}.
56
+ *
57
+ * @deprecated Use `tradercodes`. Removed after at least two SDK releases.
58
+ */
53
59
  pitpass;
54
60
  vault;
55
61
  withdrawals;
@@ -84,7 +90,7 @@ export class MonacoSDKImpl {
84
90
  this.fees.setSessionKeypair(credentials);
85
91
  this.buildercodes.setSessionKeypair(credentials);
86
92
  this.copyTrading.setSessionKeypair(credentials);
87
- this.pitpass.setSessionKeypair(credentials);
93
+ this.tradercodes.setSessionKeypair(credentials);
88
94
  this.vault.setSessionKeypair(credentials);
89
95
  this.withdrawals.setSessionKeypair(credentials);
90
96
  this.trading.setSessionKeypair(credentials);
@@ -174,7 +180,9 @@ export class MonacoSDKImpl {
174
180
  this.fees = configureSigning(new FeesAPIImpl(apiUrl));
175
181
  this.buildercodes = configureSigning(new BuildercodesAPIImpl(apiUrl));
176
182
  this.copyTrading = configureSigning(new CopyTradingAPIImpl(apiUrl));
177
- this.pitpass = configureSigning(new PitpassAPIImpl(apiUrl));
183
+ this.tradercodes = configureSigning(new TraderCodesAPIImpl(apiUrl));
184
+ // Deprecated alias: the same instance, so session and signing state are shared.
185
+ this.pitpass = this.tradercodes;
178
186
  this.profile = configureSigning(new ProfileAPIImpl(apiUrl));
179
187
  this.vault = configureSigning(new VaultAPIImpl(this.publicClient, this.walletClient, this.chain, this.applications, this.profile, apiUrl));
180
188
  this.withdrawals = configureSigning(new WithdrawalsAPIImpl(apiUrl));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/core",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "type": "module",
5
5
  "homepage": "https://docs.0xmonaco.com/sdk/typescript",
6
6
  "main": "./dist/index.js",
@@ -19,8 +19,8 @@
19
19
  "viem": "^2.45.2"
20
20
  },
21
21
  "dependencies": {
22
- "@0xmonaco/contracts": "1.0.81",
23
- "@0xmonaco/types": "1.0.81",
22
+ "@0xmonaco/contracts": "1.0.83",
23
+ "@0xmonaco/types": "1.0.83",
24
24
  "@noble/curves": "^1.9.1",
25
25
  "@noble/hashes": "^2.4.0",
26
26
  "http-status-codes": "^2.3.0"