@0xmonaco/core 1.0.39 → 1.0.40
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/margin-accounts/api.js +1 -0
- package/dist/api/perp/routes.d.ts +0 -2
- package/dist/api/perp/routes.js +0 -2
- package/dist/api/positions/api.d.ts +1 -3
- package/dist/api/positions/api.js +1 -20
- package/dist/api/websocket/websocket.js +17 -5
- package/dist/coverage.d.ts +0 -2
- package/dist/coverage.js +0 -2
- package/package.json +3 -3
|
@@ -170,8 +170,6 @@ export declare const perpRoutes: {
|
|
|
170
170
|
readonly close: (positionId: string) => string;
|
|
171
171
|
readonly batchCloseAll: () => string;
|
|
172
172
|
readonly risk: (positionId: string) => string;
|
|
173
|
-
readonly addMargin: (positionId: string) => string;
|
|
174
|
-
readonly reduceMargin: (positionId: string) => string;
|
|
175
173
|
readonly attachTpSl: (positionId: string) => string;
|
|
176
174
|
readonly history: (params?: {
|
|
177
175
|
positionId?: string;
|
package/dist/api/perp/routes.js
CHANGED
|
@@ -94,8 +94,6 @@ export const perpRoutes = {
|
|
|
94
94
|
close: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/close`,
|
|
95
95
|
batchCloseAll: () => `${API_V1}/positions/batch-close-all`,
|
|
96
96
|
risk: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/risk`,
|
|
97
|
-
addMargin: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/margin/add`,
|
|
98
|
-
reduceMargin: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/margin/reduce`,
|
|
99
97
|
attachTpSl: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/tp-sl`,
|
|
100
98
|
history: (params) => withQuery(`${API_V1}/positions/history`, params),
|
|
101
99
|
pnlHistory: (positionId, params) => withQuery(`${API_V1}/positions/${encodeSegment(positionId)}/pnl/history`, params),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AttachPositionTpSlRequest, AttachPositionTpSlResponse, BatchCloseAllRequest, BatchCloseAllResponse, ClosePositionRequest, ClosePositionResponse, GetPositionPnlHistoryParams, GetPositionPnlHistoryResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionRisk, PositionsAPI } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
export declare class PositionsAPIImpl extends BaseAPI implements PositionsAPI {
|
|
4
4
|
listPositions(params?: ListPositionsParams): Promise<ListPositionsResponse>;
|
|
@@ -6,8 +6,6 @@ export declare class PositionsAPIImpl extends BaseAPI implements PositionsAPI {
|
|
|
6
6
|
closePosition(positionId: string, request: ClosePositionRequest): Promise<ClosePositionResponse>;
|
|
7
7
|
batchCloseAllPositions(request?: BatchCloseAllRequest): Promise<BatchCloseAllResponse>;
|
|
8
8
|
getPositionRisk(positionId: string): Promise<PositionRisk>;
|
|
9
|
-
addPositionMargin(positionId: string, request: AddPositionMarginRequest): Promise<PositionMarginResponse>;
|
|
10
|
-
reducePositionMargin(positionId: string, request: ReducePositionMarginRequest): Promise<PositionMarginResponse>;
|
|
11
9
|
attachPositionTpSl(positionId: string, request: AttachPositionTpSlRequest): Promise<AttachPositionTpSlResponse>;
|
|
12
10
|
listPositionHistory(params?: ListPositionHistoryParams): Promise<ListPositionHistoryResponse>;
|
|
13
11
|
getPositionPnlHistory(positionId: string, params: GetPositionPnlHistoryParams): Promise<GetPositionPnlHistoryResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachPositionTpSlSchema, BatchCloseAllSchema, ClosePositionSchema, GetPositionPnlHistorySchema, GetPositionRiskSchema, GetPositionSchema, ListPositionHistorySchema, ListPositionsSchema, validate, } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
import { perpRoutes } from "../perp";
|
|
4
4
|
export class PositionsAPIImpl extends BaseAPI {
|
|
@@ -40,25 +40,6 @@ export class PositionsAPIImpl extends BaseAPI {
|
|
|
40
40
|
validate(GetPositionRiskSchema, { positionId });
|
|
41
41
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.risk(positionId));
|
|
42
42
|
}
|
|
43
|
-
async addPositionMargin(positionId, request) {
|
|
44
|
-
validate(AddPositionMarginSchema, { positionId, request });
|
|
45
|
-
return await this.makeAuthenticatedRequest(perpRoutes.positions.addMargin(positionId), {
|
|
46
|
-
method: "POST",
|
|
47
|
-
body: JSON.stringify({
|
|
48
|
-
amount: request.amount,
|
|
49
|
-
asset: request.asset,
|
|
50
|
-
}),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
async reducePositionMargin(positionId, request) {
|
|
54
|
-
validate(ReducePositionMarginSchema, { positionId, request });
|
|
55
|
-
return await this.makeAuthenticatedRequest(perpRoutes.positions.reduceMargin(positionId), {
|
|
56
|
-
method: "POST",
|
|
57
|
-
body: JSON.stringify({
|
|
58
|
-
amount: request.amount,
|
|
59
|
-
}),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
43
|
async attachPositionTpSl(positionId, request) {
|
|
63
44
|
validate(AttachPositionTpSlSchema, { positionId, request });
|
|
64
45
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.attachTpSl(positionId), {
|
|
@@ -133,6 +133,8 @@ function parsePositionEvent(rawData) {
|
|
|
133
133
|
liquidationPrice: readOptionalString(data, "liquidationPrice"),
|
|
134
134
|
isolatedMargin: readString(data, "isolatedMargin"),
|
|
135
135
|
leverage: readString(data, "leverage"),
|
|
136
|
+
tradeId: readOptionalString(data, "tradeId"),
|
|
137
|
+
orderId: readOptionalString(data, "orderId"),
|
|
136
138
|
reason: readString(data, "reason"),
|
|
137
139
|
updatedAt: readString(data, "updatedAt"),
|
|
138
140
|
},
|
|
@@ -488,15 +490,21 @@ export function createMonacoWebSocket(baseUrl, options = {}) {
|
|
|
488
490
|
quantity: level.quantity,
|
|
489
491
|
orderCount: level.order_count || 0,
|
|
490
492
|
})),
|
|
491
|
-
|
|
492
|
-
|
|
493
|
+
// Rust sends `null` for an empty side; normalize the nullable
|
|
494
|
+
// `Option` to `undefined` so it matches the `string | undefined` type
|
|
495
|
+
// rather than leaking `null` past the cast.
|
|
496
|
+
bestBid: orderbookData?.best_bid ?? undefined,
|
|
497
|
+
bestAsk: orderbookData?.best_ask ?? undefined,
|
|
493
498
|
bidVolume: orderbookData?.bid_volume || undefined,
|
|
494
499
|
askVolume: orderbookData?.ask_volume || undefined,
|
|
495
500
|
priceChange: orderbookData?.price_change
|
|
496
501
|
? {
|
|
497
502
|
side: orderbookData.price_change.side,
|
|
498
|
-
|
|
499
|
-
|
|
503
|
+
// Normalize nullable Rust `Option` prices to `undefined` (a
|
|
504
|
+
// level-add has no old price, a level-remove no new price) so
|
|
505
|
+
// neither leaks `null` past the `string | undefined` type.
|
|
506
|
+
oldPrice: orderbookData.price_change.old_price ?? undefined,
|
|
507
|
+
newPrice: orderbookData.price_change.new_price ?? undefined,
|
|
500
508
|
levelRemoved: orderbookData.price_change.level_removed || false,
|
|
501
509
|
levelAdded: orderbookData.price_change.level_added || false,
|
|
502
510
|
}
|
|
@@ -584,7 +592,10 @@ export function createMonacoWebSocket(baseUrl, options = {}) {
|
|
|
584
592
|
id: movementData.id,
|
|
585
593
|
entryType: movementData.entry_type,
|
|
586
594
|
transactionType: movementData.transaction_type,
|
|
587
|
-
|
|
595
|
+
status: movementData.status,
|
|
596
|
+
token: (movementData.token ?? movementData.token_address),
|
|
597
|
+
tokenAddress: (movementData.token ?? movementData.token_address),
|
|
598
|
+
assetId: movementData.asset_id,
|
|
588
599
|
amount: String(movementData.amount),
|
|
589
600
|
amountRaw: movementData.amount_raw,
|
|
590
601
|
balanceBefore: movementData.balance_before != null ? String(movementData.balance_before) : undefined,
|
|
@@ -595,6 +606,7 @@ export function createMonacoWebSocket(baseUrl, options = {}) {
|
|
|
595
606
|
referenceType: movementData.reference_type,
|
|
596
607
|
description: movementData.description,
|
|
597
608
|
txHash: movementData.tx_hash,
|
|
609
|
+
blockNumber: movementData.block_number,
|
|
598
610
|
createdAt: movementData.created_at,
|
|
599
611
|
decimals: movementData.decimals,
|
|
600
612
|
},
|
package/dist/coverage.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** operationId → the @0xmonaco/core client method that covers it. */
|
|
2
2
|
export declare const COVERED: {
|
|
3
|
-
add_position_margin: string;
|
|
4
3
|
attach_position_tp_sl: string;
|
|
5
4
|
batch_cancel_all: string;
|
|
6
5
|
batch_cancel_all_by_pair: string;
|
|
@@ -84,7 +83,6 @@ export declare const COVERED: {
|
|
|
84
83
|
list_sub_accounts_with_balances: string;
|
|
85
84
|
list_trading_pairs: string;
|
|
86
85
|
mint_tokens: string;
|
|
87
|
-
reduce_position_margin: string;
|
|
88
86
|
refresh_session: string;
|
|
89
87
|
replace_order: string;
|
|
90
88
|
revoke_delegated_agent: string;
|
package/dist/coverage.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** operationId → the @0xmonaco/core client method that covers it. */
|
|
2
2
|
export const COVERED = {
|
|
3
|
-
add_position_margin: "addPositionMargin",
|
|
4
3
|
attach_position_tp_sl: "attachPositionTpSl",
|
|
5
4
|
batch_cancel_all: "batchCancelAll",
|
|
6
5
|
batch_cancel_all_by_pair: "batchCancelAll (with tradingPairId)",
|
|
@@ -84,7 +83,6 @@ export const COVERED = {
|
|
|
84
83
|
list_sub_accounts_with_balances: "subAccounts.list",
|
|
85
84
|
list_trading_pairs: "getPaginatedTradingPairs",
|
|
86
85
|
mint_tokens: "faucet.mint",
|
|
87
|
-
reduce_position_margin: "reducePositionMargin",
|
|
88
86
|
refresh_session: "refreshSession",
|
|
89
87
|
replace_order: "replaceOrder",
|
|
90
88
|
revoke_delegated_agent: "revokeDelegatedAgent",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"viem": "^2.45.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@0xmonaco/contracts": "1.0.
|
|
27
|
-
"@0xmonaco/types": "1.0.
|
|
26
|
+
"@0xmonaco/contracts": "1.0.40",
|
|
27
|
+
"@0xmonaco/types": "1.0.40",
|
|
28
28
|
"@noble/curves": "^1.9.1",
|
|
29
29
|
"@noble/hashes": "^1.8.0",
|
|
30
30
|
"http-status-codes": "^2.3.0"
|