@0xmonaco/core 1.0.80 → 1.0.82
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/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/perp/routes.d.ts +5 -0
- package/dist/api/perp/routes.js +1 -0
- package/dist/api/pitpass/index.d.ts +10 -3
- package/dist/api/pitpass/index.js +10 -3
- package/dist/api/positions/api.js +2 -0
- package/dist/api/profile/api.d.ts +11 -4
- package/dist/api/profile/api.js +11 -4
- package/dist/api/{pitpass → tradercodes}/api.d.ts +10 -10
- package/dist/api/{pitpass → tradercodes}/api.js +19 -19
- package/dist/api/tradercodes/index.d.ts +6 -0
- package/dist/api/tradercodes/index.js +6 -0
- package/dist/api/trading/api.d.ts +27 -1
- package/dist/api/trading/api.js +40 -1
- package/dist/api/websocket/websocket.js +168 -11
- package/dist/coverage.d.ts +11 -0
- package/dist/coverage.js +21 -10
- package/dist/sdk.d.ts +7 -1
- package/dist/sdk.js +11 -3
- package/package.json +3 -3
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
|
@@ -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: {
|
package/dist/api/perp/routes.js
CHANGED
|
@@ -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
|
-
* PitPass API
|
|
2
|
+
* Deprecated PitPass name for the TraderCodes API implementation (`sdk.pitpass`).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* PitPass is the umbrella over TraderCodes and BuilderCodes; this surface only
|
|
5
|
+
* ever covered TraderCodes. Use `TraderCodesAPIImpl` (`sdk.tradercodes`).
|
|
5
6
|
*/
|
|
6
|
-
|
|
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
|
-
* PitPass API
|
|
2
|
+
* Deprecated PitPass name for the TraderCodes API implementation (`sdk.pitpass`).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* PitPass is the umbrella over TraderCodes and BuilderCodes; this surface only
|
|
5
|
+
* ever covered TraderCodes. Use `TraderCodesAPIImpl` (`sdk.tradercodes`).
|
|
5
6
|
*/
|
|
6
|
-
|
|
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
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* `
|
|
199
|
-
*
|
|
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)
|
package/dist/api/profile/api.js
CHANGED
|
@@ -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
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* `
|
|
260
|
-
*
|
|
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,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* TraderCodes API Implementation (`sdk.tradercodes`)
|
|
3
3
|
*
|
|
4
|
-
* Provides methods for the
|
|
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
|
|
6
6
|
* your accrued rewards balance, and transferring rewards into a tradeable balance.
|
|
7
7
|
*
|
|
@@ -12,30 +12,30 @@
|
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
14
14
|
* // Read your own code (authenticated)
|
|
15
|
-
* const { code } = await sdk.
|
|
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.
|
|
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.
|
|
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.
|
|
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,
|
|
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
|
|
38
|
+
export declare class TraderCodesAPIImpl extends BaseAPI implements TraderCodesAPI {
|
|
39
39
|
/**
|
|
40
40
|
* Return the authenticated caller's TraderCode.
|
|
41
41
|
*
|
|
@@ -69,11 +69,11 @@ export declare class PitpassAPIImpl extends BaseAPI implements PitpassAPI {
|
|
|
69
69
|
*/
|
|
70
70
|
getTraderCodeInfo(code: string): Promise<TraderCodeInfoResponse>;
|
|
71
71
|
/**
|
|
72
|
-
* Return the caller's current
|
|
72
|
+
* Return the caller's current TraderCodes rewards-bucket balances.
|
|
73
73
|
*/
|
|
74
74
|
getRewardsBalance(): Promise<GetRewardsBalanceResponse>;
|
|
75
75
|
/**
|
|
76
|
-
* Transfer earned
|
|
76
|
+
* Transfer earned TraderCodes rewards into a trading balance.
|
|
77
77
|
*/
|
|
78
78
|
transferRewards(params: TransferRewardsParams): Promise<TransferRewardsResponse>;
|
|
79
79
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* TraderCodes API Implementation (`sdk.tradercodes`)
|
|
3
3
|
*
|
|
4
|
-
* Provides methods for the
|
|
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
|
|
6
6
|
* your accrued rewards balance, and transferring rewards into a tradeable balance.
|
|
7
7
|
*
|
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
14
14
|
* // Read your own code (authenticated)
|
|
15
|
-
* const { code } = await sdk.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
93
|
+
return await this.makePublicRequest(`/api/v1/tradercodes/codes/${encoded}`, { method: "GET" });
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
|
-
* Return the caller's current
|
|
96
|
+
* Return the caller's current TraderCodes rewards-bucket balances.
|
|
97
97
|
*/
|
|
98
98
|
async getRewardsBalance() {
|
|
99
|
-
return await this.makeAuthenticatedRequest("/api/v1/
|
|
99
|
+
return await this.makeAuthenticatedRequest("/api/v1/tradercodes/rewards/balance", { method: "GET" });
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
* Transfer earned
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
}
|
|
@@ -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
|
/**
|
|
@@ -536,4 +536,30 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
536
536
|
* ```
|
|
537
537
|
*/
|
|
538
538
|
listTwapOrders(params?: ListTwapOrdersParams): Promise<ListTwapOrdersResponse>;
|
|
539
|
+
/**
|
|
540
|
+
* Lists one TWAP parent's slices: the child orders it placed, each as
|
|
541
|
+
* `getOrder` returns it and carrying the parent's id in `parentOrderId`.
|
|
542
|
+
*
|
|
543
|
+
* Resting and finished slices are both listed, oldest first unless
|
|
544
|
+
* `orderBy: "DESC"`. A `PASSIVE` parent's reprices and deadline sweeps are
|
|
545
|
+
* child orders too, so a parent can have more slices than `slicesPlaced`.
|
|
546
|
+
* Cursor (pageToken) pagination is the only mode: follow `nextPageToken`
|
|
547
|
+
* until it comes back empty. Users can only access their own TWAP orders.
|
|
548
|
+
*
|
|
549
|
+
* @param twapOrderId - The TWAP parent order UUID
|
|
550
|
+
* @param params - Optional sort direction, page size (up to 1000) and cursor
|
|
551
|
+
* @returns Promise resolving to one page of slices
|
|
552
|
+
* @throws {APIError} When API communication fails or the TWAP order is not found
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* ```typescript
|
|
556
|
+
* let pageToken = "";
|
|
557
|
+
* do {
|
|
558
|
+
* const page = await tradingAPI.listTwapOrderSlices(twapOrderId, { pageSize: 100, pageToken });
|
|
559
|
+
* for (const slice of page.slices) console.log(slice.id, slice.status, slice.filledQuantity);
|
|
560
|
+
* pageToken = page.nextPageToken;
|
|
561
|
+
* } while (pageToken);
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
listTwapOrderSlices(twapOrderId: string, params?: ListTwapOrderSlicesParams): Promise<ListTwapOrderSlicesResponse>;
|
|
539
565
|
}
|
package/dist/api/trading/api.js
CHANGED
|
@@ -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) {
|
|
@@ -839,4 +839,43 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
839
839
|
pageToken: pageToken ?? "",
|
|
840
840
|
}), { method: "GET" });
|
|
841
841
|
}
|
|
842
|
+
/**
|
|
843
|
+
* Lists one TWAP parent's slices: the child orders it placed, each as
|
|
844
|
+
* `getOrder` returns it and carrying the parent's id in `parentOrderId`.
|
|
845
|
+
*
|
|
846
|
+
* Resting and finished slices are both listed, oldest first unless
|
|
847
|
+
* `orderBy: "DESC"`. A `PASSIVE` parent's reprices and deadline sweeps are
|
|
848
|
+
* child orders too, so a parent can have more slices than `slicesPlaced`.
|
|
849
|
+
* Cursor (pageToken) pagination is the only mode: follow `nextPageToken`
|
|
850
|
+
* until it comes back empty. Users can only access their own TWAP orders.
|
|
851
|
+
*
|
|
852
|
+
* @param twapOrderId - The TWAP parent order UUID
|
|
853
|
+
* @param params - Optional sort direction, page size (up to 1000) and cursor
|
|
854
|
+
* @returns Promise resolving to one page of slices
|
|
855
|
+
* @throws {APIError} When API communication fails or the TWAP order is not found
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* ```typescript
|
|
859
|
+
* let pageToken = "";
|
|
860
|
+
* do {
|
|
861
|
+
* const page = await tradingAPI.listTwapOrderSlices(twapOrderId, { pageSize: 100, pageToken });
|
|
862
|
+
* for (const slice of page.slices) console.log(slice.id, slice.status, slice.filledQuantity);
|
|
863
|
+
* pageToken = page.nextPageToken;
|
|
864
|
+
* } while (pageToken);
|
|
865
|
+
* ```
|
|
866
|
+
*/
|
|
867
|
+
async listTwapOrderSlices(twapOrderId, params) {
|
|
868
|
+
// The positional id is what the path is built from, so it is what gets
|
|
869
|
+
// validated: a `twapOrderId` smuggled in through `params` must not stand
|
|
870
|
+
// in for it.
|
|
871
|
+
validate(ListTwapOrderSlicesSchema, { ...params, twapOrderId });
|
|
872
|
+
const { orderBy, pageSize = 20, pageToken } = params || {};
|
|
873
|
+
return await this.makeAuthenticatedRequest(perpRoutes.orders.listTwapSlices(twapOrderId, {
|
|
874
|
+
orderBy,
|
|
875
|
+
pageSize,
|
|
876
|
+
// Sent even as the empty string: the server starts a walk on the
|
|
877
|
+
// token's PRESENCE, not its value.
|
|
878
|
+
pageToken: pageToken ?? "",
|
|
879
|
+
}), { method: "GET" });
|
|
880
|
+
}
|
|
842
881
|
}
|
|
@@ -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
|
}
|
|
@@ -256,6 +261,9 @@ function parsePositionEventData(raw) {
|
|
|
256
261
|
// every `>=` comparison, so the server omits the key rather than sending
|
|
257
262
|
// zero.
|
|
258
263
|
version: readOptionalSequence(data, "version"),
|
|
264
|
+
// Lifetime funding since open. Optional: an older deployment does not
|
|
265
|
+
// send it, and the server omits it when it cannot serve the whole value.
|
|
266
|
+
fundingPaid: readOptionalString(data, "fundingPaid"),
|
|
259
267
|
};
|
|
260
268
|
}
|
|
261
269
|
function parsePositionEvent(rawData) {
|
|
@@ -522,6 +530,31 @@ function parseTradeEventData(raw) {
|
|
|
522
530
|
executedAt: readString(raw, "executed_at"),
|
|
523
531
|
};
|
|
524
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Parse one `ohlcv` snapshot row: the live candle frame's `data` body.
|
|
535
|
+
*
|
|
536
|
+
* Strict, unlike the live OHLCV handler's casts: a snapshot is delivered
|
|
537
|
+
* all-or-nothing, so a row with a missing or mistyped field must throw for
|
|
538
|
+
* {@link snapshotFrameHandler} to withhold the frame. The output is the live
|
|
539
|
+
* candlestick minus `s`; `i` is the subscription's interval, since the row
|
|
540
|
+
* carries no envelope.
|
|
541
|
+
*/
|
|
542
|
+
function parseOHLCVSnapshotCandle(raw, interval) {
|
|
543
|
+
if (!isRecord(raw)) {
|
|
544
|
+
throw new Error("Invalid ohlcv snapshot row: must be an object");
|
|
545
|
+
}
|
|
546
|
+
return {
|
|
547
|
+
T: readSequence(raw, "period_start"),
|
|
548
|
+
t: readSequence(raw, "period_end"),
|
|
549
|
+
o: readString(raw, "open"),
|
|
550
|
+
h: readString(raw, "high"),
|
|
551
|
+
l: readString(raw, "low"),
|
|
552
|
+
c: readString(raw, "close"),
|
|
553
|
+
v: readString(raw, "volume"),
|
|
554
|
+
i: interval,
|
|
555
|
+
n: readSequence(raw, "trades_count"),
|
|
556
|
+
};
|
|
557
|
+
}
|
|
525
558
|
function parseInstrumentEventData(raw) {
|
|
526
559
|
if (!isRecord(raw)) {
|
|
527
560
|
throw new Error("Invalid instrument event: data must be an object");
|
|
@@ -937,6 +970,20 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
937
970
|
// subscriber unsubscribes — the next first subscriber triggers a fresh wire
|
|
938
971
|
// Subscribe whose snapshot is authoritative, never the stale cache.
|
|
939
972
|
const instrumentBaseline = new Map();
|
|
973
|
+
// `handlers` holds what the caller WANTS; this tracks what the server has
|
|
974
|
+
// acknowledged on the current socket. The server handles one connection's
|
|
975
|
+
// messages strictly in order and answers every Subscribe / Unsubscribe with
|
|
976
|
+
// an ack naming only the channels that request changed (a rejected or
|
|
977
|
+
// already-held channel is omitted), or, for an over-long one, with an
|
|
978
|
+
// INVALID_MESSAGE and no ack. So the oldest outstanding request is always
|
|
979
|
+
// the one being answered. All of it is per socket: a new connection starts
|
|
980
|
+
// with nothing confirmed and re-requests what is wanted.
|
|
981
|
+
const confirmedChannels = new Set();
|
|
982
|
+
let pendingRequests = [];
|
|
983
|
+
// Wanted channels the server rejected with AUTH_REQUIRED on this socket,
|
|
984
|
+
// re-requested once when the connection next authenticates.
|
|
985
|
+
const authRejectedChannels = new Set();
|
|
986
|
+
const subscriptionListeners = new Set();
|
|
940
987
|
const getStatus = () => {
|
|
941
988
|
if (!ws)
|
|
942
989
|
return reconnectTimer ? "reconnecting" : "disconnected";
|
|
@@ -1076,16 +1123,74 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1076
1123
|
ws.send(JSON.stringify(data));
|
|
1077
1124
|
}
|
|
1078
1125
|
};
|
|
1126
|
+
const sendSubscribe = (channels) => {
|
|
1127
|
+
if (channels.length === 0 || ws?.readyState !== WebSocket.OPEN)
|
|
1128
|
+
return;
|
|
1129
|
+
pendingRequests.push({ kind: "subscribe", channels });
|
|
1130
|
+
send({ type: "Subscribe", channels });
|
|
1131
|
+
};
|
|
1132
|
+
const sendUnsubscribe = (channels) => {
|
|
1133
|
+
if (channels.length === 0 || ws?.readyState !== WebSocket.OPEN)
|
|
1134
|
+
return;
|
|
1135
|
+
pendingRequests.push({ kind: "unsubscribe", channels });
|
|
1136
|
+
send({ type: "Unsubscribe", channels });
|
|
1137
|
+
};
|
|
1138
|
+
/** Forget everything the server confirmed or was asked on the old socket. */
|
|
1139
|
+
const resetSubscriptionAcks = () => {
|
|
1140
|
+
confirmedChannels.clear();
|
|
1141
|
+
pendingRequests = [];
|
|
1142
|
+
authRejectedChannels.clear();
|
|
1143
|
+
};
|
|
1144
|
+
const isRequested = (kind, channel) => pendingRequests.some((request) => request.kind === kind && request.channels.includes(channel));
|
|
1145
|
+
const getSubscriptionState = (channel) => {
|
|
1146
|
+
if (handlers.has(channel)) {
|
|
1147
|
+
if (isRequested("subscribe", channel))
|
|
1148
|
+
return "pending";
|
|
1149
|
+
return confirmedChannels.has(channel) ? "subscribed" : "unconfirmed";
|
|
1150
|
+
}
|
|
1151
|
+
// Released: the server can still hold it only if it confirmed it, or if
|
|
1152
|
+
// its Subscribe is still unanswered. An Unsubscribe alone proves nothing
|
|
1153
|
+
// (the channel may have been rejected), so it does not count here.
|
|
1154
|
+
if (confirmedChannels.has(channel) || isRequested("subscribe", channel))
|
|
1155
|
+
return "unsubscribing";
|
|
1156
|
+
return "idle";
|
|
1157
|
+
};
|
|
1158
|
+
/**
|
|
1159
|
+
* Report a server-confirmed change. A listener's error is logged, never
|
|
1160
|
+
* propagated: it must not stop the ack bookkeeping or other listeners.
|
|
1161
|
+
*/
|
|
1162
|
+
const emitSubscriptionChange = (change) => {
|
|
1163
|
+
const logListenerError = (err) => console.error("WebSocket: onSubscriptionChange listener threw", err);
|
|
1164
|
+
for (const listener of subscriptionListeners) {
|
|
1165
|
+
try {
|
|
1166
|
+
const result = listener(change);
|
|
1167
|
+
// An async listener is assignable to the void-returning type; log its
|
|
1168
|
+
// rejection rather than leave it unhandled (any thenable, as in
|
|
1169
|
+
// emitStatus).
|
|
1170
|
+
if (typeof result?.then === "function") {
|
|
1171
|
+
Promise.resolve(result).catch(logListenerError);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
catch (err) {
|
|
1175
|
+
logListenerError(err);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
const onSubscriptionChange = (listener) => {
|
|
1180
|
+
subscriptionListeners.add(listener);
|
|
1181
|
+
return () => {
|
|
1182
|
+
subscriptionListeners.delete(listener);
|
|
1183
|
+
};
|
|
1184
|
+
};
|
|
1185
|
+
/** Channel strings of an ack frame; anything malformed reads as none. */
|
|
1186
|
+
const ackChannels = (raw) => (Array.isArray(raw) ? raw.filter((channel) => typeof channel === "string") : []);
|
|
1079
1187
|
const resubscribeAll = () => {
|
|
1080
1188
|
// Every re-sent Subscribe is genuinely new to the server (new
|
|
1081
1189
|
// connection), so fresh authoritative snapshots are inbound: the
|
|
1082
1190
|
// pre-outage instrument cache is stale — markets may have been delisted
|
|
1083
1191
|
// during the gap — and must not be replayed to late subscribers.
|
|
1084
1192
|
instrumentBaseline.clear();
|
|
1085
|
-
|
|
1086
|
-
if (channels.length > 0) {
|
|
1087
|
-
send({ type: "Subscribe", channels });
|
|
1088
|
-
}
|
|
1193
|
+
sendSubscribe(Array.from(handlers.keys()));
|
|
1089
1194
|
};
|
|
1090
1195
|
// A subscription channel matches a frame when it is identical, is a prefix of
|
|
1091
1196
|
// the frame's dotted-by-colon path, or ends in a `:*` wildcard segment whose
|
|
@@ -1126,6 +1231,18 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1126
1231
|
// frame just before the close; the close event decides from it.
|
|
1127
1232
|
// Recorded before any application code runs, so a throwing onError
|
|
1128
1233
|
// cannot make the close look transient.
|
|
1234
|
+
// A wanted channel the server refused for want of authentication is
|
|
1235
|
+
// retried once the connection authenticates.
|
|
1236
|
+
if (msg.code === "AUTH_REQUIRED" && typeof msg.channel === "string" && handlers.has(msg.channel)) {
|
|
1237
|
+
authRejectedChannels.add(msg.channel);
|
|
1238
|
+
}
|
|
1239
|
+
// A Subscribe / Unsubscribe whose channel list is too long is refused
|
|
1240
|
+
// whole with a connection-wide INVALID_MESSAGE and no ack. It is the
|
|
1241
|
+
// oldest outstanding request: retire it, or every later ack would
|
|
1242
|
+
// pair with the wrong request.
|
|
1243
|
+
if (msg.code === "INVALID_MESSAGE" && OVERSIZED_REQUEST.test(msg.message)) {
|
|
1244
|
+
pendingRequests.shift();
|
|
1245
|
+
}
|
|
1129
1246
|
if (msg.code === "AUTH_FAILED") {
|
|
1130
1247
|
lastAuthError = { code: msg.code, message: msg.message, session: pendingAuthSessions.shift() };
|
|
1131
1248
|
}
|
|
@@ -1146,6 +1263,42 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1146
1263
|
if (msg.type === "Authenticated") {
|
|
1147
1264
|
confirmedSession = pendingAuthSessions.shift();
|
|
1148
1265
|
skewAuthRetries = 0;
|
|
1266
|
+
// Retry, once, each channel refused for want of authentication that is
|
|
1267
|
+
// still wanted and neither held nor already re-requested.
|
|
1268
|
+
const retry = Array.from(authRejectedChannels).filter((channel) => handlers.has(channel) && !confirmedChannels.has(channel) && !isRequested("subscribe", channel));
|
|
1269
|
+
authRejectedChannels.clear();
|
|
1270
|
+
sendSubscribe(retry);
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
if (msg.type === "Subscribed") {
|
|
1274
|
+
// It answers the oldest outstanding request; with none, or another
|
|
1275
|
+
// kind, it is a duplicate or stray ack and changes nothing.
|
|
1276
|
+
if (pendingRequests[0]?.kind !== "subscribe")
|
|
1277
|
+
return;
|
|
1278
|
+
const request = pendingRequests.shift()?.channels ?? [];
|
|
1279
|
+
for (const channel of ackChannels(msg.channels)) {
|
|
1280
|
+
if (!request.includes(channel))
|
|
1281
|
+
continue;
|
|
1282
|
+
// The server holds it now, wanted or not; a channel released while
|
|
1283
|
+
// its Subscribe was in flight is held until its Unsubscribe lands,
|
|
1284
|
+
// and is never reported as subscribed.
|
|
1285
|
+
confirmedChannels.add(channel);
|
|
1286
|
+
if (handlers.has(channel)) {
|
|
1287
|
+
emitSubscriptionChange({ channel, state: "subscribed" });
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
if (msg.type === "Unsubscribed") {
|
|
1293
|
+
if (pendingRequests[0]?.kind !== "unsubscribe")
|
|
1294
|
+
return;
|
|
1295
|
+
const request = pendingRequests.shift()?.channels ?? [];
|
|
1296
|
+
for (const channel of ackChannels(msg.channels)) {
|
|
1297
|
+
if (!request.includes(channel))
|
|
1298
|
+
continue;
|
|
1299
|
+
confirmedChannels.delete(channel);
|
|
1300
|
+
emitSubscriptionChange({ channel, state: "unsubscribed" });
|
|
1301
|
+
}
|
|
1149
1302
|
return;
|
|
1150
1303
|
}
|
|
1151
1304
|
if (!msg.channel)
|
|
@@ -1182,6 +1335,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1182
1335
|
lastAuthError = null;
|
|
1183
1336
|
pendingAuthSessions = [];
|
|
1184
1337
|
confirmedSession = undefined;
|
|
1338
|
+
resetSubscriptionAcks();
|
|
1185
1339
|
const timeout = setTimeout(() => {
|
|
1186
1340
|
if (ws !== socket) {
|
|
1187
1341
|
resolve();
|
|
@@ -1254,6 +1408,8 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1254
1408
|
}
|
|
1255
1409
|
ws = null;
|
|
1256
1410
|
stopHeartbeat();
|
|
1411
|
+
// The server dropped every subscription with the connection.
|
|
1412
|
+
resetSubscriptionAcks();
|
|
1257
1413
|
// Terminal authentication loss: the server revoked the session
|
|
1258
1414
|
// (SESSION_INVALID, then 1008) or rejected this connection's
|
|
1259
1415
|
// handshake (AUTH_FAILED, then a close). Reconnecting would replay
|
|
@@ -1347,6 +1503,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1347
1503
|
handlers.clear();
|
|
1348
1504
|
snapshotHandlers.clear();
|
|
1349
1505
|
instrumentBaseline.clear();
|
|
1506
|
+
resetSubscriptionAcks();
|
|
1350
1507
|
ws?.close(1000, "Client disconnect");
|
|
1351
1508
|
ws = null;
|
|
1352
1509
|
hasConnected = false;
|
|
@@ -1366,8 +1523,8 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1366
1523
|
snapshotHandlers.get(channel)?.add(snapshotHandler);
|
|
1367
1524
|
}
|
|
1368
1525
|
// Only send Subscribe message on first subscriber for this channel
|
|
1369
|
-
if (isFirstSubscriber
|
|
1370
|
-
|
|
1526
|
+
if (isFirstSubscriber) {
|
|
1527
|
+
sendSubscribe([channel]);
|
|
1371
1528
|
}
|
|
1372
1529
|
// Return unsubscribe function
|
|
1373
1530
|
return () => {
|
|
@@ -1384,9 +1541,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1384
1541
|
// Only send Unsubscribe on last subscriber for this channel
|
|
1385
1542
|
if (channelHandlers.size === 0) {
|
|
1386
1543
|
handlers.delete(channel);
|
|
1387
|
-
|
|
1388
|
-
send({ type: "Unsubscribe", channels: [channel] });
|
|
1389
|
-
}
|
|
1544
|
+
sendUnsubscribe([channel]);
|
|
1390
1545
|
}
|
|
1391
1546
|
}
|
|
1392
1547
|
};
|
|
@@ -1468,7 +1623,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1468
1623
|
}
|
|
1469
1624
|
});
|
|
1470
1625
|
};
|
|
1471
|
-
const subscribeOHLCV = (tradingPairId, tradingMode, interval, handler, priceType) => {
|
|
1626
|
+
const subscribeOHLCV = (tradingPairId, tradingMode, interval, handler, priceType, onSnapshot) => {
|
|
1472
1627
|
// Four-token channel selects the trade-derived candles (back-compat); the
|
|
1473
1628
|
// optional fifth token selects the price series (`mark` = close-only mark
|
|
1474
1629
|
// series, `*` = both).
|
|
@@ -1514,7 +1669,7 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1514
1669
|
catch (err) {
|
|
1515
1670
|
console.error("WebSocket: Error processing OHLCV event", err);
|
|
1516
1671
|
}
|
|
1517
|
-
});
|
|
1672
|
+
}, onSnapshot && snapshotFrameHandler("ohlcv", (raw) => parseOHLCVSnapshotCandle(raw, interval), onSnapshot));
|
|
1518
1673
|
};
|
|
1519
1674
|
const subscribeTrades = (tradingPairId, handler, onSnapshot) => {
|
|
1520
1675
|
const channel = `trades:${tradingPairId}`;
|
|
@@ -1969,6 +2124,8 @@ export function createMonacoWebSocket(baseUrl, options = {}, serverClock = new S
|
|
|
1969
2124
|
disconnect,
|
|
1970
2125
|
isConnected: () => ws?.readyState === WebSocket.OPEN,
|
|
1971
2126
|
getStatus,
|
|
2127
|
+
getSubscriptionState,
|
|
2128
|
+
onSubscriptionChange,
|
|
1972
2129
|
setSessionKeypair: (credentials) => {
|
|
1973
2130
|
session = credentials ?? undefined;
|
|
1974
2131
|
skewAuthRetries = 0;
|
package/dist/coverage.d.ts
CHANGED
|
@@ -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: "
|
|
62
|
-
get_rewards_balance: "
|
|
63
|
-
get_my_referral_position: "
|
|
64
|
-
get_my_referral_downline: "
|
|
65
|
-
get_my_referral_tree: "
|
|
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: "
|
|
68
|
+
get_trader_code_info: "tradercodes.getTraderCodeInfo",
|
|
68
69
|
set_self_trade_prevention_default: "profile.setSelfTradePreventionDefault",
|
|
69
|
-
set_trader_code: "
|
|
70
|
-
clear_trader_code: "
|
|
71
|
-
check_trader_code_availability: "
|
|
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: "
|
|
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
|
};
|
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.
|
|
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.
|
|
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.
|
|
3
|
+
"version": "1.0.82",
|
|
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.
|
|
23
|
-
"@0xmonaco/types": "1.0.
|
|
22
|
+
"@0xmonaco/contracts": "1.0.82",
|
|
23
|
+
"@0xmonaco/types": "1.0.82",
|
|
24
24
|
"@noble/curves": "^1.9.1",
|
|
25
25
|
"@noble/hashes": "^2.4.0",
|
|
26
26
|
"http-status-codes": "^2.3.0"
|