@0xmonaco/core 0.8.4 → 0.8.7
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateMarginAccountRequest, CreateMarginAccountResponse, GetAvailableCollateralParams, GetAvailableCollateralResponse, GetMarginAccountMovementsParams, GetMarginAccountMovementsResponse, ListMarginAccountsParams, ListMarginAccountsResponse, MarginAccountSummary, MarginAccountsAPI, SimulateOrderRiskRequest, SimulateOrderRiskResponse, TransferCollateralRequest, TransferCollateralResponse } from "@0xmonaco/types";
|
|
1
|
+
import type { CreateMarginAccountRequest, CreateMarginAccountResponse, GetAvailableCollateralParams, GetAvailableCollateralResponse, GetMarginAccountMovementsParams, GetMarginAccountMovementsResponse, ListMarginAccountsParams, ListMarginAccountsResponse, MarginAccountSummary, MarginAccountsAPI, SimulateOrderRiskRequest, SimulateOrderRiskResponse, TransferCollateralRequest, TransferCollateralResponse, TransferCollateralToAutoMarginAccountRequest } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
export declare class MarginAccountsAPIImpl extends BaseAPI implements MarginAccountsAPI {
|
|
4
4
|
listMarginAccounts(params?: ListMarginAccountsParams): Promise<ListMarginAccountsResponse>;
|
|
@@ -6,7 +6,9 @@ export declare class MarginAccountsAPIImpl extends BaseAPI implements MarginAcco
|
|
|
6
6
|
getMarginAccountSummary(marginAccountId: string): Promise<MarginAccountSummary>;
|
|
7
7
|
getAvailableCollateral(params?: GetAvailableCollateralParams): Promise<GetAvailableCollateralResponse>;
|
|
8
8
|
transferCollateralToMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
|
|
9
|
+
transferCollateralToAutoMarginAccount(request: TransferCollateralToAutoMarginAccountRequest): Promise<TransferCollateralResponse>;
|
|
9
10
|
transferCollateralFromMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
|
|
10
11
|
getMarginAccountMovements(marginAccountId: string, params?: GetMarginAccountMovementsParams): Promise<GetMarginAccountMovementsResponse>;
|
|
11
12
|
simulateOrderRisk(marginAccountId: string, request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
|
|
13
|
+
simulateAutoMarginOrderRisk(request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
|
|
12
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateMarginAccountSchema, GetAvailableCollateralSchema, GetMarginAccountMovementsSchema, GetMarginAccountSummarySchema, ListMarginAccountsSchema, SimulateOrderRiskSchema, TransferCollateralSchema, validate, } from "@0xmonaco/types";
|
|
1
|
+
import { CreateMarginAccountSchema, GetAvailableCollateralSchema, GetMarginAccountMovementsSchema, GetMarginAccountSummarySchema, ListMarginAccountsSchema, SimulateAutoMarginOrderRiskSchema, SimulateOrderRiskSchema, TransferCollateralSchema, TransferCollateralToAutoMarginAccountSchema, validate, } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
import { perpRoutes } from "../perp";
|
|
4
4
|
export class MarginAccountsAPIImpl extends BaseAPI {
|
|
@@ -6,7 +6,14 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
6
6
|
if (params) {
|
|
7
7
|
validate(ListMarginAccountsSchema, params);
|
|
8
8
|
}
|
|
9
|
-
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.list(params
|
|
9
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.list(params
|
|
10
|
+
? {
|
|
11
|
+
page: params.page,
|
|
12
|
+
page_size: params.page_size,
|
|
13
|
+
state: params.state,
|
|
14
|
+
trading_pair_id: params.tradingPairId,
|
|
15
|
+
}
|
|
16
|
+
: undefined));
|
|
10
17
|
}
|
|
11
18
|
async createMarginAccount(request) {
|
|
12
19
|
validate(CreateMarginAccountSchema, request);
|
|
@@ -36,6 +43,18 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
36
43
|
}),
|
|
37
44
|
});
|
|
38
45
|
}
|
|
46
|
+
async transferCollateralToAutoMarginAccount(request) {
|
|
47
|
+
validate(TransferCollateralToAutoMarginAccountSchema, { request });
|
|
48
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.transferInAuto(), {
|
|
49
|
+
method: "POST",
|
|
50
|
+
body: JSON.stringify({
|
|
51
|
+
asset: request.asset,
|
|
52
|
+
amount: request.amount,
|
|
53
|
+
trading_pair_id: request.tradingPairId,
|
|
54
|
+
strategy_key: request.strategyKey,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
39
58
|
async transferCollateralFromMarginAccount(marginAccountId, request) {
|
|
40
59
|
validate(TransferCollateralSchema, { marginAccountId, request });
|
|
41
60
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.transferOut(marginAccountId), {
|
|
@@ -56,6 +75,24 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
56
75
|
method: "POST",
|
|
57
76
|
body: JSON.stringify({
|
|
58
77
|
trading_pair_id: request.tradingPairId,
|
|
78
|
+
strategy_key: request.strategyKey,
|
|
79
|
+
side: request.side,
|
|
80
|
+
position_side: request.positionSide,
|
|
81
|
+
order_type: request.orderType,
|
|
82
|
+
price: request.price,
|
|
83
|
+
quantity: request.quantity,
|
|
84
|
+
leverage: request.leverage,
|
|
85
|
+
reduce_only: request.reduceOnly,
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async simulateAutoMarginOrderRisk(request) {
|
|
90
|
+
validate(SimulateAutoMarginOrderRiskSchema, { request });
|
|
91
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateOrderRiskAuto(), {
|
|
92
|
+
method: "POST",
|
|
93
|
+
body: JSON.stringify({
|
|
94
|
+
trading_pair_id: request.tradingPairId,
|
|
95
|
+
strategy_key: request.strategyKey,
|
|
59
96
|
side: request.side,
|
|
60
97
|
position_side: request.positionSide,
|
|
61
98
|
order_type: request.orderType,
|
|
@@ -108,6 +108,7 @@ export declare const perpRoutes: {
|
|
|
108
108
|
page?: number;
|
|
109
109
|
page_size?: number;
|
|
110
110
|
state?: string;
|
|
111
|
+
trading_pair_id?: string;
|
|
111
112
|
}) => string;
|
|
112
113
|
readonly create: () => string;
|
|
113
114
|
readonly summary: (marginAccountId: string) => string;
|
|
@@ -115,6 +116,7 @@ export declare const perpRoutes: {
|
|
|
115
116
|
asset?: string;
|
|
116
117
|
}) => string;
|
|
117
118
|
readonly transferIn: (marginAccountId: string) => string;
|
|
119
|
+
readonly transferInAuto: () => string;
|
|
118
120
|
readonly transferOut: (marginAccountId: string) => string;
|
|
119
121
|
readonly movements: (marginAccountId: string, params?: {
|
|
120
122
|
movement_type?: string;
|
|
@@ -122,6 +124,7 @@ export declare const perpRoutes: {
|
|
|
122
124
|
page_size?: number;
|
|
123
125
|
}) => string;
|
|
124
126
|
readonly simulateOrderRisk: (marginAccountId: string) => string;
|
|
127
|
+
readonly simulateOrderRiskAuto: () => string;
|
|
125
128
|
};
|
|
126
129
|
readonly streams: {
|
|
127
130
|
readonly orderbook: () => string;
|
package/dist/api/perp/routes.js
CHANGED
|
@@ -71,9 +71,11 @@ export const perpRoutes = {
|
|
|
71
71
|
summary: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}`,
|
|
72
72
|
availableCollateral: (params) => withQuery(`${API_V1}/margin/collateral/available`, params),
|
|
73
73
|
transferIn: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/collateral/transfer-in`,
|
|
74
|
+
transferInAuto: () => `${API_V1}/margin/collateral/transfer-in`,
|
|
74
75
|
transferOut: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/collateral/transfer-out`,
|
|
75
76
|
movements: (marginAccountId, params) => withQuery(`${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/movements`, params),
|
|
76
77
|
simulateOrderRisk: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/simulate-order-risk`,
|
|
78
|
+
simulateOrderRiskAuto: () => `${API_V1}/margin/simulate-order-risk`,
|
|
77
79
|
},
|
|
78
80
|
streams: {
|
|
79
81
|
orderbook: () => `${API_V1}/streaming/orderbook`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
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": "0.8.
|
|
27
|
-
"@0xmonaco/types": "0.8.
|
|
26
|
+
"@0xmonaco/contracts": "0.8.7",
|
|
27
|
+
"@0xmonaco/types": "0.8.7",
|
|
28
28
|
"http-status-codes": "^2.3.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|