@0xmonaco/core 0.8.14 → 0.8.15
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/applications/api.js +4 -4
- package/dist/api/auth/api.d.ts +1 -1
- package/dist/api/auth/api.js +10 -10
- package/dist/api/base.d.ts +2 -2
- package/dist/api/base.js +2 -2
- package/dist/api/delegated-agents/api.js +12 -12
- package/dist/api/faucet/api.d.ts +1 -1
- package/dist/api/faucet/api.js +1 -1
- package/dist/api/fees/api.d.ts +13 -13
- package/dist/api/fees/api.js +18 -18
- package/dist/api/margin-accounts/api.js +23 -23
- package/dist/api/market/api.js +16 -16
- package/dist/api/orderbook/api.js +13 -13
- package/dist/api/perp/routes.d.ts +57 -53
- package/dist/api/perp/routes.js +1 -0
- package/dist/api/positions/api.js +19 -19
- package/dist/api/profile/api.d.ts +23 -23
- package/dist/api/profile/api.js +46 -46
- package/dist/api/sub-accounts/api.d.ts +2 -2
- package/dist/api/sub-accounts/api.js +2 -2
- package/dist/api/trades/api.d.ts +11 -11
- package/dist/api/trades/api.js +10 -10
- package/dist/api/trading/api.d.ts +6 -6
- package/dist/api/trading/api.js +69 -69
- package/dist/api/vault/api.js +4 -4
- package/dist/api/whitelist/api.d.ts +2 -2
- package/dist/api/whitelist/api.js +2 -2
- package/dist/api/withdrawals/api.d.ts +3 -2
- package/dist/api/withdrawals/api.js +7 -2
- package/dist/coverage.d.ts +1 -0
- package/dist/coverage.js +1 -0
- package/dist/sdk.js +3 -3
- package/package.json +3 -3
|
@@ -48,10 +48,10 @@ export class ApplicationsAPIImpl extends BaseAPI {
|
|
|
48
48
|
return {
|
|
49
49
|
id: data.id,
|
|
50
50
|
name: data.name,
|
|
51
|
-
allowedOrigins: data.
|
|
52
|
-
webhookUrl: data.
|
|
53
|
-
vaultContractAddress: data.
|
|
54
|
-
clientId: data.
|
|
51
|
+
allowedOrigins: data.allowedOrigins,
|
|
52
|
+
webhookUrl: data.webhookUrl,
|
|
53
|
+
vaultContractAddress: data.vaultContractAddress,
|
|
54
|
+
clientId: data.clientId,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
/**
|
package/dist/api/auth/api.d.ts
CHANGED
|
@@ -142,7 +142,7 @@ export declare class AuthAPIImpl extends BaseAPI implements AuthAPI {
|
|
|
142
142
|
* Extends the current session's expiry.
|
|
143
143
|
*
|
|
144
144
|
* The request is signed with the active session key (set via
|
|
145
|
-
* {@link setSessionKeypair}); the server bumps the session's `
|
|
145
|
+
* {@link setSessionKeypair}); the server bumps the session's `expiresAt`.
|
|
146
146
|
* No new credential is issued — the same keypair keeps working.
|
|
147
147
|
*
|
|
148
148
|
* @returns Promise resolving to the new expiry
|
package/dist/api/auth/api.js
CHANGED
|
@@ -157,15 +157,15 @@ export class AuthAPIImpl extends BaseAPI {
|
|
|
157
157
|
method: "POST",
|
|
158
158
|
body: JSON.stringify({
|
|
159
159
|
address,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
clientId: clientId,
|
|
161
|
+
chainId: this.chain.id,
|
|
162
|
+
sessionPublicKey: sessionPublicKey,
|
|
163
163
|
}),
|
|
164
164
|
});
|
|
165
165
|
return {
|
|
166
166
|
nonce: responseBody.nonce,
|
|
167
167
|
message: responseBody.message,
|
|
168
|
-
expiresAt: responseBody.
|
|
168
|
+
expiresAt: responseBody.expiresAt,
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
@@ -199,15 +199,15 @@ export class AuthAPIImpl extends BaseAPI {
|
|
|
199
199
|
address,
|
|
200
200
|
signature,
|
|
201
201
|
nonce,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
clientId: clientId,
|
|
203
|
+
chainId: this.chain.id,
|
|
204
|
+
sessionPublicKey: session.publicKey,
|
|
205
205
|
}),
|
|
206
206
|
});
|
|
207
207
|
return {
|
|
208
208
|
sessionPublicKey: session.publicKey,
|
|
209
209
|
sessionPrivateKey: session.privateKey,
|
|
210
|
-
expiresAt: responseBody.
|
|
210
|
+
expiresAt: responseBody.expiresAt,
|
|
211
211
|
user: {
|
|
212
212
|
id: responseBody.user.id,
|
|
213
213
|
address: responseBody.user.address,
|
|
@@ -219,7 +219,7 @@ export class AuthAPIImpl extends BaseAPI {
|
|
|
219
219
|
* Extends the current session's expiry.
|
|
220
220
|
*
|
|
221
221
|
* The request is signed with the active session key (set via
|
|
222
|
-
* {@link setSessionKeypair}); the server bumps the session's `
|
|
222
|
+
* {@link setSessionKeypair}); the server bumps the session's `expiresAt`.
|
|
223
223
|
* No new credential is issued — the same keypair keeps working.
|
|
224
224
|
*
|
|
225
225
|
* @returns Promise resolving to the new expiry
|
|
@@ -236,7 +236,7 @@ export class AuthAPIImpl extends BaseAPI {
|
|
|
236
236
|
method: "POST",
|
|
237
237
|
});
|
|
238
238
|
return {
|
|
239
|
-
expiresAt: responseBody.
|
|
239
|
+
expiresAt: responseBody.expiresAt,
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
242
|
/**
|
package/dist/api/base.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export declare abstract class BaseAPI {
|
|
|
99
99
|
* '/api/v1/orders',
|
|
100
100
|
* {
|
|
101
101
|
* method: 'POST',
|
|
102
|
-
* body: JSON.stringify({
|
|
102
|
+
* body: JSON.stringify({ tradingPair: 'ETH-USD', side: 'BUY' })
|
|
103
103
|
* }
|
|
104
104
|
* );
|
|
105
105
|
* ```
|
|
@@ -155,7 +155,7 @@ export declare abstract class BaseAPI {
|
|
|
155
155
|
* '/api/v1/auth/challenge',
|
|
156
156
|
* {
|
|
157
157
|
* method: 'POST',
|
|
158
|
-
* body: JSON.stringify({ address,
|
|
158
|
+
* body: JSON.stringify({ address, clientId: clientId })
|
|
159
159
|
* }
|
|
160
160
|
* );
|
|
161
161
|
* ```
|
package/dist/api/base.js
CHANGED
|
@@ -241,7 +241,7 @@ export class BaseAPI {
|
|
|
241
241
|
* '/api/v1/orders',
|
|
242
242
|
* {
|
|
243
243
|
* method: 'POST',
|
|
244
|
-
* body: JSON.stringify({
|
|
244
|
+
* body: JSON.stringify({ tradingPair: 'ETH-USD', side: 'BUY' })
|
|
245
245
|
* }
|
|
246
246
|
* );
|
|
247
247
|
* ```
|
|
@@ -350,7 +350,7 @@ export class BaseAPI {
|
|
|
350
350
|
* '/api/v1/auth/challenge',
|
|
351
351
|
* {
|
|
352
352
|
* method: 'POST',
|
|
353
|
-
* body: JSON.stringify({ address,
|
|
353
|
+
* body: JSON.stringify({ address, clientId: clientId })
|
|
354
354
|
* }
|
|
355
355
|
* );
|
|
356
356
|
* ```
|
|
@@ -5,17 +5,17 @@ export class DelegatedAgentsAPIImpl extends BaseAPI {
|
|
|
5
5
|
return this.makeAuthenticatedRequest(perpRoutes.delegatedAgents.list(), {
|
|
6
6
|
method: "POST",
|
|
7
7
|
body: JSON.stringify({
|
|
8
|
-
|
|
8
|
+
agentAddress: request.agentAddress,
|
|
9
9
|
name: request.name,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
expiresAt: request.expiresAt,
|
|
11
|
+
allowedActions: request.allowedActions,
|
|
12
|
+
allowedTradingPairIds: request.allowedTradingPairIds,
|
|
13
|
+
allowedMarginAccountIds: request.allowedMarginAccountIds,
|
|
14
|
+
allowedOrderTypes: request.allowedOrderTypes,
|
|
15
|
+
allowedTimeInForce: request.allowedTimeInForce,
|
|
16
|
+
maxLeverage: request.maxLeverage,
|
|
17
|
+
maxOrderNotional: request.maxOrderNotional,
|
|
18
|
+
maxOpenOrders: request.maxOpenOrders,
|
|
19
19
|
}),
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -34,8 +34,8 @@ export class DelegatedAgentsAPIImpl extends BaseAPI {
|
|
|
34
34
|
return this.makeAuthenticatedRequest(perpRoutes.delegatedAgents.sessions(), {
|
|
35
35
|
method: "POST",
|
|
36
36
|
body: JSON.stringify({
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
ownerUserId: request.ownerUserId,
|
|
38
|
+
sessionPublicKey: request.sessionPublicKey,
|
|
39
39
|
}),
|
|
40
40
|
});
|
|
41
41
|
}
|
package/dist/api/faucet/api.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* const { minted, failed,
|
|
11
|
+
* const { minted, failed, remainingRequests24h } = await sdk.faucet.mint();
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
import type { FaucetAPI, MintTokensResponse } from "@0xmonaco/types";
|
package/dist/api/faucet/api.js
CHANGED
package/dist/api/fees/api.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* // Simulate fees for an order
|
|
16
16
|
* const feeDetails = await feesAPI.simulateFees({
|
|
17
|
-
*
|
|
17
|
+
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
18
18
|
* side: "BUY",
|
|
19
19
|
* price: "40000.00",
|
|
20
20
|
* quantity: "0.5"
|
|
@@ -31,41 +31,41 @@ export declare class FeesAPIImpl extends BaseAPI implements FeesAPI {
|
|
|
31
31
|
* application fees, and total amounts the taker must pay or maker will receive.
|
|
32
32
|
*
|
|
33
33
|
* @param params - Parameters for fee simulation
|
|
34
|
-
* @param params.
|
|
34
|
+
* @param params.tradingPairId - The trading pair UUID
|
|
35
35
|
* @param params.side - The order side ("BUY" or "SELL")
|
|
36
36
|
* @param params.price - The price per unit as string
|
|
37
37
|
* @param params.quantity - The quantity to trade as string
|
|
38
|
-
* @param params.
|
|
39
|
-
* @param params.
|
|
38
|
+
* @param params.orderType - Order type: "LIMIT" (default) or "MARKET"
|
|
39
|
+
* @param params.slippageToleranceBps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
|
|
40
40
|
* @returns Promise resolving to SimulateFeeResponse with fee breakdown
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
43
|
* ```typescript
|
|
44
44
|
* // Simulate fees for a buy order
|
|
45
45
|
* const buyFees = await feesAPI.simulateFees({
|
|
46
|
-
*
|
|
46
|
+
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
47
47
|
* side: "BUY",
|
|
48
48
|
* price: "40000.00",
|
|
49
49
|
* quantity: "0.5"
|
|
50
50
|
* });
|
|
51
51
|
*
|
|
52
52
|
* console.log(`Notional value: ${buyFees.notional}`);
|
|
53
|
-
* console.log(`Monaco taker fee: ${buyFees.
|
|
54
|
-
* console.log(`Application taker fee: ${buyFees.
|
|
55
|
-
* console.log(`Total taker fees: ${buyFees.
|
|
56
|
-
* console.log(`Total payment required: ${buyFees.
|
|
57
|
-
* console.log(`Lock amount for BUY: ${buyFees.
|
|
53
|
+
* console.log(`Monaco taker fee: ${buyFees.monacoTakerFee}`);
|
|
54
|
+
* console.log(`Application taker fee: ${buyFees.applicationTakerFee}`);
|
|
55
|
+
* console.log(`Total taker fees: ${buyFees.totalTakerFees}`);
|
|
56
|
+
* console.log(`Total payment required: ${buyFees.takerTotalPayment}`);
|
|
57
|
+
* console.log(`Lock amount for BUY: ${buyFees.buyOrderLockAmount}`);
|
|
58
58
|
*
|
|
59
59
|
* // Simulate fees for a sell order
|
|
60
60
|
* const sellFees = await feesAPI.simulateFees({
|
|
61
|
-
*
|
|
61
|
+
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
62
62
|
* side: "SELL",
|
|
63
63
|
* price: "40000.00",
|
|
64
64
|
* quantity: "0.5"
|
|
65
65
|
* });
|
|
66
66
|
*
|
|
67
|
-
* console.log(`Maker rebate: ${sellFees.
|
|
68
|
-
* console.log(`Maker total receipt: ${sellFees.
|
|
67
|
+
* console.log(`Maker rebate: ${sellFees.monacoMakerRebate}`);
|
|
68
|
+
* console.log(`Maker total receipt: ${sellFees.makerTotalReceipt}`);
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
simulateFees(params: SimulateFeeParams): Promise<SimulateFeeResponse>;
|
package/dist/api/fees/api.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* // Simulate fees for an order
|
|
16
16
|
* const feeDetails = await feesAPI.simulateFees({
|
|
17
|
-
*
|
|
17
|
+
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
18
18
|
* side: "BUY",
|
|
19
19
|
* price: "40000.00",
|
|
20
20
|
* quantity: "0.5"
|
|
@@ -31,56 +31,56 @@ export class FeesAPIImpl extends BaseAPI {
|
|
|
31
31
|
* application fees, and total amounts the taker must pay or maker will receive.
|
|
32
32
|
*
|
|
33
33
|
* @param params - Parameters for fee simulation
|
|
34
|
-
* @param params.
|
|
34
|
+
* @param params.tradingPairId - The trading pair UUID
|
|
35
35
|
* @param params.side - The order side ("BUY" or "SELL")
|
|
36
36
|
* @param params.price - The price per unit as string
|
|
37
37
|
* @param params.quantity - The quantity to trade as string
|
|
38
|
-
* @param params.
|
|
39
|
-
* @param params.
|
|
38
|
+
* @param params.orderType - Order type: "LIMIT" (default) or "MARKET"
|
|
39
|
+
* @param params.slippageToleranceBps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
|
|
40
40
|
* @returns Promise resolving to SimulateFeeResponse with fee breakdown
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
43
|
* ```typescript
|
|
44
44
|
* // Simulate fees for a buy order
|
|
45
45
|
* const buyFees = await feesAPI.simulateFees({
|
|
46
|
-
*
|
|
46
|
+
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
47
47
|
* side: "BUY",
|
|
48
48
|
* price: "40000.00",
|
|
49
49
|
* quantity: "0.5"
|
|
50
50
|
* });
|
|
51
51
|
*
|
|
52
52
|
* console.log(`Notional value: ${buyFees.notional}`);
|
|
53
|
-
* console.log(`Monaco taker fee: ${buyFees.
|
|
54
|
-
* console.log(`Application taker fee: ${buyFees.
|
|
55
|
-
* console.log(`Total taker fees: ${buyFees.
|
|
56
|
-
* console.log(`Total payment required: ${buyFees.
|
|
57
|
-
* console.log(`Lock amount for BUY: ${buyFees.
|
|
53
|
+
* console.log(`Monaco taker fee: ${buyFees.monacoTakerFee}`);
|
|
54
|
+
* console.log(`Application taker fee: ${buyFees.applicationTakerFee}`);
|
|
55
|
+
* console.log(`Total taker fees: ${buyFees.totalTakerFees}`);
|
|
56
|
+
* console.log(`Total payment required: ${buyFees.takerTotalPayment}`);
|
|
57
|
+
* console.log(`Lock amount for BUY: ${buyFees.buyOrderLockAmount}`);
|
|
58
58
|
*
|
|
59
59
|
* // Simulate fees for a sell order
|
|
60
60
|
* const sellFees = await feesAPI.simulateFees({
|
|
61
|
-
*
|
|
61
|
+
* tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
|
|
62
62
|
* side: "SELL",
|
|
63
63
|
* price: "40000.00",
|
|
64
64
|
* quantity: "0.5"
|
|
65
65
|
* });
|
|
66
66
|
*
|
|
67
|
-
* console.log(`Maker rebate: ${sellFees.
|
|
68
|
-
* console.log(`Maker total receipt: ${sellFees.
|
|
67
|
+
* console.log(`Maker rebate: ${sellFees.monacoMakerRebate}`);
|
|
68
|
+
* console.log(`Maker total receipt: ${sellFees.makerTotalReceipt}`);
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
async simulateFees(params) {
|
|
72
72
|
// Validate parameters using the validate helper
|
|
73
73
|
const validatedParams = validate(SimulateFeeParamsSchema, params);
|
|
74
74
|
const searchParams = new URLSearchParams();
|
|
75
|
-
searchParams.append("
|
|
75
|
+
searchParams.append("tradingPairId", validatedParams.tradingPairId);
|
|
76
76
|
searchParams.append("side", validatedParams.side);
|
|
77
77
|
searchParams.append("price", validatedParams.price);
|
|
78
78
|
searchParams.append("quantity", validatedParams.quantity);
|
|
79
|
-
if (validatedParams.
|
|
80
|
-
searchParams.append("
|
|
79
|
+
if (validatedParams.orderType !== undefined) {
|
|
80
|
+
searchParams.append("orderType", validatedParams.orderType);
|
|
81
81
|
}
|
|
82
|
-
if (validatedParams.
|
|
83
|
-
searchParams.append("
|
|
82
|
+
if (validatedParams.slippageToleranceBps !== undefined) {
|
|
83
|
+
searchParams.append("slippageToleranceBps", String(validatedParams.slippageToleranceBps));
|
|
84
84
|
}
|
|
85
85
|
const endpoint = `/api/v1/fees/simulate?${searchParams.toString()}`;
|
|
86
86
|
return await this.makeAuthenticatedRequest(endpoint, {
|
|
@@ -9,19 +9,19 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
9
9
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.list(params
|
|
10
10
|
? {
|
|
11
11
|
page: params.page,
|
|
12
|
-
|
|
12
|
+
pageSize: params.pageSize,
|
|
13
13
|
state: params.state,
|
|
14
|
-
|
|
14
|
+
tradingPairId: params.tradingPairId,
|
|
15
15
|
}
|
|
16
16
|
: undefined));
|
|
17
17
|
}
|
|
18
18
|
async getMarginAccountSummary(marginAccountId, params) {
|
|
19
19
|
validate(GetMarginAccountSummarySchema, { marginAccountId, ...params });
|
|
20
|
-
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.summary(marginAccountId, {
|
|
20
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.summary(marginAccountId, { tradingPairId: params?.tradingPairId }));
|
|
21
21
|
}
|
|
22
22
|
async getParentMarginAccountSummary(params) {
|
|
23
23
|
validate(GetParentMarginAccountSummarySchema, params);
|
|
24
|
-
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.parentSummary({
|
|
24
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.parentSummary({ tradingPairId: params?.tradingPairId }));
|
|
25
25
|
}
|
|
26
26
|
async getAvailableCollateral(params) {
|
|
27
27
|
validate(GetAvailableCollateralSchema, params);
|
|
@@ -34,8 +34,8 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
34
34
|
body: JSON.stringify({
|
|
35
35
|
asset: request.asset,
|
|
36
36
|
amount: request.amount,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
tradingPairId: request.tradingPairId,
|
|
38
|
+
strategyKey: request.strategyKey,
|
|
39
39
|
}),
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -56,8 +56,8 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
56
56
|
body: JSON.stringify({
|
|
57
57
|
asset: request.asset,
|
|
58
58
|
amount: request.amount,
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
tradingPairId: request.tradingPairId,
|
|
60
|
+
strategyKey: request.strategyKey,
|
|
61
61
|
}),
|
|
62
62
|
});
|
|
63
63
|
}
|
|
@@ -68,8 +68,8 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
68
68
|
body: JSON.stringify({
|
|
69
69
|
asset: request.asset,
|
|
70
70
|
amount: request.amount,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
tradingPairId: request.tradingPairId,
|
|
72
|
+
strategyKey: request.strategyKey,
|
|
73
73
|
}),
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -96,14 +96,14 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
96
96
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateOrderRisk(marginAccountId), {
|
|
97
97
|
method: "POST",
|
|
98
98
|
body: JSON.stringify({
|
|
99
|
-
|
|
99
|
+
tradingPairId: request.tradingPairId,
|
|
100
100
|
side: request.side,
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
positionSide: request.positionSide,
|
|
102
|
+
orderType: request.orderType,
|
|
103
103
|
price: request.price,
|
|
104
104
|
quantity: request.quantity,
|
|
105
105
|
leverage: request.leverage,
|
|
106
|
-
|
|
106
|
+
reduceOnly: request.reduceOnly,
|
|
107
107
|
}),
|
|
108
108
|
});
|
|
109
109
|
}
|
|
@@ -112,14 +112,14 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
112
112
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateParentMarginOrderRisk(), {
|
|
113
113
|
method: "POST",
|
|
114
114
|
body: JSON.stringify({
|
|
115
|
-
|
|
115
|
+
tradingPairId: request.tradingPairId,
|
|
116
116
|
side: request.side,
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
positionSide: request.positionSide,
|
|
118
|
+
orderType: request.orderType,
|
|
119
119
|
price: request.price,
|
|
120
120
|
quantity: request.quantity,
|
|
121
121
|
leverage: request.leverage,
|
|
122
|
-
|
|
122
|
+
reduceOnly: request.reduceOnly,
|
|
123
123
|
}),
|
|
124
124
|
});
|
|
125
125
|
}
|
|
@@ -128,15 +128,15 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
128
128
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateRiskBucketOrderRisk(), {
|
|
129
129
|
method: "POST",
|
|
130
130
|
body: JSON.stringify({
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
tradingPairId: request.tradingPairId,
|
|
132
|
+
strategyKey: request.strategyKey,
|
|
133
133
|
side: request.side,
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
positionSide: request.positionSide,
|
|
135
|
+
orderType: request.orderType,
|
|
136
136
|
price: request.price,
|
|
137
137
|
quantity: request.quantity,
|
|
138
138
|
leverage: request.leverage,
|
|
139
|
-
|
|
139
|
+
reduceOnly: request.reduceOnly,
|
|
140
140
|
}),
|
|
141
141
|
});
|
|
142
142
|
}
|
package/dist/api/market/api.js
CHANGED
|
@@ -12,20 +12,20 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
12
12
|
if (params?.page !== undefined) {
|
|
13
13
|
searchParams.append("page", params.page.toString());
|
|
14
14
|
}
|
|
15
|
-
if (params?.
|
|
16
|
-
searchParams.append("
|
|
15
|
+
if (params?.pageSize !== undefined) {
|
|
16
|
+
searchParams.append("pageSize", params.pageSize.toString());
|
|
17
17
|
}
|
|
18
|
-
if (params?.
|
|
19
|
-
searchParams.append("
|
|
18
|
+
if (params?.marketType) {
|
|
19
|
+
searchParams.append("marketType", params.marketType);
|
|
20
20
|
}
|
|
21
|
-
if (params?.
|
|
22
|
-
searchParams.append("
|
|
21
|
+
if (params?.baseToken) {
|
|
22
|
+
searchParams.append("baseToken", params.baseToken);
|
|
23
23
|
}
|
|
24
|
-
if (params?.
|
|
25
|
-
searchParams.append("
|
|
24
|
+
if (params?.quoteToken) {
|
|
25
|
+
searchParams.append("quoteToken", params.quoteToken);
|
|
26
26
|
}
|
|
27
|
-
if (params?.
|
|
28
|
-
searchParams.append("
|
|
27
|
+
if (params?.isActive !== undefined) {
|
|
28
|
+
searchParams.append("isActive", params.isActive.toString());
|
|
29
29
|
}
|
|
30
30
|
if (params?.category) {
|
|
31
31
|
searchParams.append("category", params.category);
|
|
@@ -37,14 +37,14 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
37
37
|
async getTradingPair(tradingPairId) {
|
|
38
38
|
validate(GetMarketMetadataSchema, { tradingPairId });
|
|
39
39
|
const response = await this.makePublicRequest(perpRoutes.market.getTradingPair(tradingPairId));
|
|
40
|
-
return response.
|
|
40
|
+
return response.tradingPair;
|
|
41
41
|
}
|
|
42
42
|
async getTradingPairBySymbol(symbol, marketType) {
|
|
43
43
|
// Backend endpoint expects UUID, not symbol, so we fetch all pairs and filter.
|
|
44
|
-
// An optional
|
|
44
|
+
// An optional marketType narrows the listing so a symbol present in both
|
|
45
45
|
// SPOT and MARGIN resolves unambiguously instead of returning the first match.
|
|
46
|
-
const response = await this.getPaginatedTradingPairs({
|
|
47
|
-
return response.
|
|
46
|
+
const response = await this.getPaginatedTradingPairs({ pageSize: 100, marketType: marketType });
|
|
47
|
+
return response.tradingPairs.find((pair) => pair.symbol === symbol);
|
|
48
48
|
}
|
|
49
49
|
async getCandlesticks(tradingPairId, interval, params) {
|
|
50
50
|
// Validate inputs using the trading pair ID schema
|
|
@@ -57,10 +57,10 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
57
57
|
});
|
|
58
58
|
const searchParams = new URLSearchParams();
|
|
59
59
|
if (params?.startTime !== undefined) {
|
|
60
|
-
searchParams.append("
|
|
60
|
+
searchParams.append("startTime", params.startTime.toString());
|
|
61
61
|
}
|
|
62
62
|
if (params?.endTime !== undefined) {
|
|
63
|
-
searchParams.append("
|
|
63
|
+
searchParams.append("endTime", params.endTime.toString());
|
|
64
64
|
}
|
|
65
65
|
if (params?.limit !== undefined) {
|
|
66
66
|
searchParams.append("limit", params.limit.toString());
|
|
@@ -5,34 +5,34 @@ export class OrderbookAPIImpl extends BaseAPI {
|
|
|
5
5
|
const params = new URLSearchParams();
|
|
6
6
|
params.set("levels", String(depth));
|
|
7
7
|
if (tradingMode)
|
|
8
|
-
params.set("
|
|
8
|
+
params.set("tradingMode", tradingMode);
|
|
9
9
|
if (magnitude !== undefined)
|
|
10
10
|
params.set("magnitude", String(magnitude));
|
|
11
11
|
if (denomination)
|
|
12
12
|
params.set("denomination", denomination.toLowerCase());
|
|
13
13
|
const response = await this.makePublicRequest(`/api/v1/orderbook/${encodeURIComponent(tradingPairId)}?${params.toString()}`);
|
|
14
14
|
return {
|
|
15
|
-
// `
|
|
16
|
-
tradingPairId: response.
|
|
17
|
-
tradingMode: response.
|
|
15
|
+
// `tradingPairId` is the pair UUID; `symbol` is the display string.
|
|
16
|
+
tradingPairId: response.tradingPairId,
|
|
17
|
+
tradingMode: response.tradingMode,
|
|
18
18
|
bids: response.data.bids.map((level) => ({
|
|
19
19
|
price: level.price,
|
|
20
20
|
quantity: level.quantity,
|
|
21
|
-
orderCount: level.
|
|
21
|
+
orderCount: level.orderCount,
|
|
22
22
|
})),
|
|
23
23
|
asks: response.data.asks.map((level) => ({
|
|
24
24
|
price: level.price,
|
|
25
25
|
quantity: level.quantity,
|
|
26
|
-
orderCount: level.
|
|
26
|
+
orderCount: level.orderCount,
|
|
27
27
|
})),
|
|
28
|
-
bestBid: response.data.
|
|
29
|
-
bestAsk: response.data.
|
|
30
|
-
bidVolume: response.data.
|
|
31
|
-
askVolume: response.data.
|
|
32
|
-
baseDecimals: response.
|
|
33
|
-
quoteDecimals: response.
|
|
28
|
+
bestBid: response.data.bestBid,
|
|
29
|
+
bestAsk: response.data.bestAsk,
|
|
30
|
+
bidVolume: response.data.bidVolume,
|
|
31
|
+
askVolume: response.data.askVolume,
|
|
32
|
+
baseDecimals: response.baseDecimals,
|
|
33
|
+
quoteDecimals: response.quoteDecimals,
|
|
34
34
|
timestamp: response.timestamp,
|
|
35
|
-
sequence: response.
|
|
35
|
+
sequence: response.sequenceNumber,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
}
|