@0xmonaco/core 0.8.7-develop.5d0e403 → 0.8.7-develop.a107b34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -12
- package/dist/api/margin-accounts/api.d.ts +9 -5
- package/dist/api/margin-accounts/api.js +57 -20
- package/dist/api/market/api.d.ts +3 -2
- package/dist/api/market/api.js +11 -3
- package/dist/api/perp/routes.d.ts +19 -6
- package/dist/api/perp/routes.js +10 -6
- package/dist/api/positions/api.d.ts +2 -1
- package/dist/api/positions/api.js +13 -1
- package/dist/api/profile/api.d.ts +18 -1
- package/dist/api/profile/api.js +41 -1
- package/dist/api/trading/api.d.ts +5 -6
- package/dist/api/trading/api.js +7 -30
- package/dist/api/vault/api.d.ts +70 -26
- package/dist/api/vault/api.js +124 -39
- package/dist/api/vault/index.d.ts +1 -1
- package/dist/api/vault/index.js +1 -1
- package/dist/api/withdrawals/api.d.ts +6 -4
- package/dist/api/withdrawals/api.js +7 -4
- package/dist/coverage.d.ts +87 -2
- package/dist/coverage.js +87 -2
- package/dist/sdk.d.ts +9 -0
- package/dist/sdk.js +37 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -62,26 +62,17 @@ npm install viem@^2.31.7
|
|
|
62
62
|
|
|
63
63
|
## Network Support
|
|
64
64
|
|
|
65
|
-
The SDK supports the following preset networks. Configure the network by providing the `network` and `seiRpcUrl` parameters:
|
|
65
|
+
The SDK supports the following documented preset networks. Configure the network by providing the `network` and `seiRpcUrl` parameters:
|
|
66
66
|
|
|
67
67
|
**Preset Networks:**
|
|
68
|
-
- `"development"` - Development environment (https://develop.apimonaco.xyz)
|
|
69
68
|
- `"staging"` - Staging environment (https://staging.apimonaco.xyz)
|
|
70
69
|
- `"mainnet"` - Production environment (https://api.monaco.xyz)
|
|
71
|
-
- `"local"` - Local development (http://localhost:8080)
|
|
72
70
|
|
|
73
71
|
WebSocket URLs are automatically resolved per network.
|
|
74
72
|
|
|
75
73
|
```typescript
|
|
76
74
|
import { MonacoSDK } from "@0xmonaco/core";
|
|
77
75
|
|
|
78
|
-
// Development configuration
|
|
79
|
-
const devSdk = new MonacoSDK({
|
|
80
|
-
walletClient,
|
|
81
|
-
network: "development",
|
|
82
|
-
seiRpcUrl: "https://evm-rpc-testnet.sei-apis.com",
|
|
83
|
-
});
|
|
84
|
-
|
|
85
76
|
// Staging configuration
|
|
86
77
|
const stagingSdk = new MonacoSDK({
|
|
87
78
|
walletClient,
|
|
@@ -114,7 +105,7 @@ const walletClient = createWalletClient({
|
|
|
114
105
|
|
|
115
106
|
const monaco = new MonacoSDK({
|
|
116
107
|
walletClient,
|
|
117
|
-
network: "
|
|
108
|
+
network: "staging", // or "mainnet"
|
|
118
109
|
seiRpcUrl: "https://evm-rpc-testnet.sei-apis.com", // or https://evm-rpc.sei-apis.com for mainnet
|
|
119
110
|
});
|
|
120
111
|
|
|
@@ -251,7 +242,7 @@ interface SDKConfig {
|
|
|
251
242
|
/** Wallet client for signing operations (optional - can be set later via setWalletClient) */
|
|
252
243
|
walletClient?: WalletClient;
|
|
253
244
|
|
|
254
|
-
/**
|
|
245
|
+
/** Use "staging" for public testnet or "mainnet" for production. */
|
|
255
246
|
network: Network;
|
|
256
247
|
|
|
257
248
|
/** RPC URL for Sei blockchain interactions */
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GetAvailableCollateralParams, GetAvailableCollateralResponse, GetMarginAccountMovementsParams, GetMarginAccountMovementsResponse, GetMarginAccountSummaryParams, ListMarginAccountsParams, ListMarginAccountsResponse, MarginAccountSummary, MarginAccountsAPI, SimulateOrderRiskRequest, SimulateOrderRiskResponse, SimulateRiskBucketOrderRiskRequest, TransferCollateralFromParentMarginAccountRequest, TransferCollateralRequest, TransferCollateralResponse, TransferCollateralToParentMarginAccountRequest, TransferCollateralToRiskBucketRequest } 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>;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
getMarginAccountSummary(marginAccountId: string, params?: GetMarginAccountSummaryParams): Promise<MarginAccountSummary>;
|
|
6
|
+
getParentMarginAccountSummary(params?: GetMarginAccountSummaryParams): Promise<MarginAccountSummary>;
|
|
7
7
|
getAvailableCollateral(params?: GetAvailableCollateralParams): Promise<GetAvailableCollateralResponse>;
|
|
8
8
|
transferCollateralToMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
|
|
9
|
-
|
|
9
|
+
transferCollateralToParentMarginAccount(request: TransferCollateralToParentMarginAccountRequest): Promise<TransferCollateralResponse>;
|
|
10
|
+
transferCollateralToRiskBucket(request: TransferCollateralToRiskBucketRequest): Promise<TransferCollateralResponse>;
|
|
10
11
|
transferCollateralFromMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
|
|
12
|
+
transferCollateralFromParentMarginAccount(request: TransferCollateralFromParentMarginAccountRequest): Promise<TransferCollateralResponse>;
|
|
11
13
|
getMarginAccountMovements(marginAccountId: string, params?: GetMarginAccountMovementsParams): Promise<GetMarginAccountMovementsResponse>;
|
|
14
|
+
getParentMarginAccountMovements(params?: GetMarginAccountMovementsParams): Promise<GetMarginAccountMovementsResponse>;
|
|
12
15
|
simulateOrderRisk(marginAccountId: string, request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
|
|
13
|
-
|
|
16
|
+
simulateParentMarginOrderRisk(request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
|
|
17
|
+
simulateRiskBucketOrderRisk(request: SimulateRiskBucketOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
|
|
14
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GetAvailableCollateralSchema, GetMarginAccountMovementsSchema, GetMarginAccountSummarySchema, GetParentMarginAccountMovementsSchema, GetParentMarginAccountSummarySchema, ListMarginAccountsSchema, SimulateOrderRiskSchema, SimulateParentMarginOrderRiskSchema, SimulateRiskBucketOrderRiskSchema, TransferCollateralFromParentMarginAccountSchema, TransferCollateralSchema, TransferCollateralToParentMarginAccountSchema, TransferCollateralToRiskBucketSchema, validate, } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
import { perpRoutes } from "../perp";
|
|
4
4
|
export class MarginAccountsAPIImpl extends BaseAPI {
|
|
@@ -15,19 +15,13 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
15
15
|
}
|
|
16
16
|
: undefined));
|
|
17
17
|
}
|
|
18
|
-
async
|
|
19
|
-
validate(
|
|
20
|
-
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.
|
|
21
|
-
method: "POST",
|
|
22
|
-
body: JSON.stringify({
|
|
23
|
-
label: request?.label,
|
|
24
|
-
collateral_asset: request?.collateralAsset,
|
|
25
|
-
}),
|
|
26
|
-
});
|
|
18
|
+
async getMarginAccountSummary(marginAccountId, params) {
|
|
19
|
+
validate(GetMarginAccountSummarySchema, { marginAccountId, ...params });
|
|
20
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.summary(marginAccountId, { trading_pair_id: params?.tradingPairId }));
|
|
27
21
|
}
|
|
28
|
-
async
|
|
29
|
-
validate(
|
|
30
|
-
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.
|
|
22
|
+
async getParentMarginAccountSummary(params) {
|
|
23
|
+
validate(GetParentMarginAccountSummarySchema, params);
|
|
24
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.parentSummary({ trading_pair_id: params?.tradingPairId }));
|
|
31
25
|
}
|
|
32
26
|
async getAvailableCollateral(params) {
|
|
33
27
|
validate(GetAvailableCollateralSchema, params);
|
|
@@ -40,12 +34,24 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
40
34
|
body: JSON.stringify({
|
|
41
35
|
asset: request.asset,
|
|
42
36
|
amount: request.amount,
|
|
37
|
+
trading_pair_id: request.tradingPairId,
|
|
38
|
+
strategy_key: request.strategyKey,
|
|
43
39
|
}),
|
|
44
40
|
});
|
|
45
41
|
}
|
|
46
|
-
async
|
|
47
|
-
validate(
|
|
48
|
-
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.
|
|
42
|
+
async transferCollateralToParentMarginAccount(request) {
|
|
43
|
+
validate(TransferCollateralToParentMarginAccountSchema, { request });
|
|
44
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.transferInParent(), {
|
|
45
|
+
method: "POST",
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
asset: request.asset,
|
|
48
|
+
amount: request.amount,
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async transferCollateralToRiskBucket(request) {
|
|
53
|
+
validate(TransferCollateralToRiskBucketSchema, { request });
|
|
54
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.transferInRiskBucket(), {
|
|
49
55
|
method: "POST",
|
|
50
56
|
body: JSON.stringify({
|
|
51
57
|
asset: request.asset,
|
|
@@ -58,6 +64,18 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
58
64
|
async transferCollateralFromMarginAccount(marginAccountId, request) {
|
|
59
65
|
validate(TransferCollateralSchema, { marginAccountId, request });
|
|
60
66
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.transferOut(marginAccountId), {
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: JSON.stringify({
|
|
69
|
+
asset: request.asset,
|
|
70
|
+
amount: request.amount,
|
|
71
|
+
trading_pair_id: request.tradingPairId,
|
|
72
|
+
strategy_key: request.strategyKey,
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async transferCollateralFromParentMarginAccount(request) {
|
|
77
|
+
validate(TransferCollateralFromParentMarginAccountSchema, { request });
|
|
78
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.transferOutParent(), {
|
|
61
79
|
method: "POST",
|
|
62
80
|
body: JSON.stringify({
|
|
63
81
|
asset: request.asset,
|
|
@@ -69,13 +87,16 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
69
87
|
validate(GetMarginAccountMovementsSchema, { marginAccountId, ...params });
|
|
70
88
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.movements(marginAccountId, params));
|
|
71
89
|
}
|
|
90
|
+
async getParentMarginAccountMovements(params) {
|
|
91
|
+
validate(GetParentMarginAccountMovementsSchema, params);
|
|
92
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.parentMovements(params));
|
|
93
|
+
}
|
|
72
94
|
async simulateOrderRisk(marginAccountId, request) {
|
|
73
95
|
validate(SimulateOrderRiskSchema, { marginAccountId, request });
|
|
74
96
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateOrderRisk(marginAccountId), {
|
|
75
97
|
method: "POST",
|
|
76
98
|
body: JSON.stringify({
|
|
77
99
|
trading_pair_id: request.tradingPairId,
|
|
78
|
-
strategy_key: request.strategyKey,
|
|
79
100
|
side: request.side,
|
|
80
101
|
position_side: request.positionSide,
|
|
81
102
|
order_type: request.orderType,
|
|
@@ -86,9 +107,25 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
86
107
|
}),
|
|
87
108
|
});
|
|
88
109
|
}
|
|
89
|
-
async
|
|
90
|
-
validate(
|
|
91
|
-
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.
|
|
110
|
+
async simulateParentMarginOrderRisk(request) {
|
|
111
|
+
validate(SimulateParentMarginOrderRiskSchema, { request });
|
|
112
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateParentMarginOrderRisk(), {
|
|
113
|
+
method: "POST",
|
|
114
|
+
body: JSON.stringify({
|
|
115
|
+
trading_pair_id: request.tradingPairId,
|
|
116
|
+
side: request.side,
|
|
117
|
+
position_side: request.positionSide,
|
|
118
|
+
order_type: request.orderType,
|
|
119
|
+
price: request.price,
|
|
120
|
+
quantity: request.quantity,
|
|
121
|
+
leverage: request.leverage,
|
|
122
|
+
reduce_only: request.reduceOnly,
|
|
123
|
+
}),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async simulateRiskBucketOrderRisk(request) {
|
|
127
|
+
validate(SimulateRiskBucketOrderRiskSchema, { request });
|
|
128
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.simulateRiskBucketOrderRisk(), {
|
|
92
129
|
method: "POST",
|
|
93
130
|
body: JSON.stringify({
|
|
94
131
|
trading_pair_id: request.tradingPairId,
|
package/dist/api/market/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Candlestick, FundingState, GetCandlesticksParams, GetScreenerParams, GetScreenerResponse, GetTradingPairsParams, GetTradingPairsResponse, IndexPrice, Interval, ListFundingHistoryParams, ListFundingHistoryResponse, MarketAPI, MarketMetadata, MarkPrice, OpenInterest, PerpMarketConfig, PerpMarketSummary, TradingPair } from "@0xmonaco/types";
|
|
1
|
+
import type { Candlestick, FundingState, GetCandlesticksParams, GetScreenerParams, GetScreenerResponse, GetTradingPairsParams, GetTradingPairsResponse, IndexPrice, Interval, ListFundingHistoryParams, ListFundingHistoryResponse, MarketAPI, MarketMetadata, MarketStats, MarkPrice, OpenInterest, PerpMarketConfig, PerpMarketSummary, TradingMode, TradingPair } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
/**
|
|
4
4
|
* Market API Implementation
|
|
@@ -8,7 +8,7 @@ import { BaseAPI } from "../base";
|
|
|
8
8
|
export declare class MarketAPIImpl extends BaseAPI implements MarketAPI {
|
|
9
9
|
getPaginatedTradingPairs(params?: GetTradingPairsParams): Promise<GetTradingPairsResponse>;
|
|
10
10
|
getTradingPair(tradingPairId: string): Promise<TradingPair>;
|
|
11
|
-
getTradingPairBySymbol(symbol: string): Promise<TradingPair | undefined>;
|
|
11
|
+
getTradingPairBySymbol(symbol: string, marketType?: TradingMode): Promise<TradingPair | undefined>;
|
|
12
12
|
getCandlesticks(tradingPairId: string, interval: Interval, params?: GetCandlesticksParams): Promise<Candlestick[]>;
|
|
13
13
|
getMarketMetadata(tradingPairId: string): Promise<MarketMetadata>;
|
|
14
14
|
getPerpMarketConfig(tradingPairId: string): Promise<PerpMarketConfig>;
|
|
@@ -19,4 +19,5 @@ export declare class MarketAPIImpl extends BaseAPI implements MarketAPI {
|
|
|
19
19
|
listFundingHistory(tradingPairId: string, params?: ListFundingHistoryParams): Promise<ListFundingHistoryResponse>;
|
|
20
20
|
getOpenInterest(tradingPairId: string): Promise<OpenInterest>;
|
|
21
21
|
getScreener(params?: GetScreenerParams): Promise<GetScreenerResponse>;
|
|
22
|
+
getMarketStats(): Promise<MarketStats>;
|
|
22
23
|
}
|
package/dist/api/market/api.js
CHANGED
|
@@ -27,6 +27,9 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
27
27
|
if (params?.is_active !== undefined) {
|
|
28
28
|
searchParams.append("is_active", params.is_active.toString());
|
|
29
29
|
}
|
|
30
|
+
if (params?.category) {
|
|
31
|
+
searchParams.append("category", params.category);
|
|
32
|
+
}
|
|
30
33
|
const queryString = searchParams.toString();
|
|
31
34
|
const url = queryString ? `/api/v1/market/pairs?${queryString}` : "/api/v1/market/pairs";
|
|
32
35
|
return await this.makePublicRequest(url);
|
|
@@ -36,9 +39,11 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
36
39
|
const response = await this.makePublicRequest(perpRoutes.market.getTradingPair(tradingPairId));
|
|
37
40
|
return response.trading_pair;
|
|
38
41
|
}
|
|
39
|
-
async getTradingPairBySymbol(symbol) {
|
|
40
|
-
// Backend endpoint expects UUID, not symbol, so we fetch all pairs and filter
|
|
41
|
-
|
|
42
|
+
async getTradingPairBySymbol(symbol, marketType) {
|
|
43
|
+
// Backend endpoint expects UUID, not symbol, so we fetch all pairs and filter.
|
|
44
|
+
// An optional market_type narrows the listing so a symbol present in both
|
|
45
|
+
// SPOT and MARGIN resolves unambiguously instead of returning the first match.
|
|
46
|
+
const response = await this.getPaginatedTradingPairs({ page_size: 100, market_type: marketType });
|
|
42
47
|
return response.trading_pairs.find((pair) => pair.symbol === symbol);
|
|
43
48
|
}
|
|
44
49
|
async getCandlesticks(tradingPairId, interval, params) {
|
|
@@ -102,4 +107,7 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
102
107
|
async getScreener(params) {
|
|
103
108
|
return await this.makePublicRequest(perpRoutes.market.getScreener(params));
|
|
104
109
|
}
|
|
110
|
+
async getMarketStats() {
|
|
111
|
+
return await this.makePublicRequest(perpRoutes.market.getMarketStats());
|
|
112
|
+
}
|
|
105
113
|
}
|
|
@@ -17,7 +17,6 @@ export declare const perpRoutes: {
|
|
|
17
17
|
readonly batchCancelAllByPair: (tradingPairId: string) => string;
|
|
18
18
|
readonly batchCreate: () => string;
|
|
19
19
|
readonly batchReplace: () => string;
|
|
20
|
-
readonly createConditional: () => string;
|
|
21
20
|
readonly listConditional: (params?: {
|
|
22
21
|
margin_account_id?: string;
|
|
23
22
|
trading_pair_id?: string;
|
|
@@ -70,7 +69,9 @@ export declare const perpRoutes: {
|
|
|
70
69
|
page_size?: number;
|
|
71
70
|
market_type?: string;
|
|
72
71
|
is_active?: boolean;
|
|
72
|
+
category?: string;
|
|
73
73
|
}) => string;
|
|
74
|
+
readonly getMarketStats: () => string;
|
|
74
75
|
};
|
|
75
76
|
readonly orderbook: {
|
|
76
77
|
readonly get: (tradingPairId: string, params?: {
|
|
@@ -150,6 +151,7 @@ export declare const perpRoutes: {
|
|
|
150
151
|
}) => string;
|
|
151
152
|
readonly get: (positionId: string) => string;
|
|
152
153
|
readonly close: (positionId: string) => string;
|
|
154
|
+
readonly batchCloseAll: () => string;
|
|
153
155
|
readonly risk: (positionId: string) => string;
|
|
154
156
|
readonly addMargin: (positionId: string) => string;
|
|
155
157
|
readonly reduceMargin: (positionId: string) => string;
|
|
@@ -169,21 +171,33 @@ export declare const perpRoutes: {
|
|
|
169
171
|
state?: string;
|
|
170
172
|
trading_pair_id?: string;
|
|
171
173
|
}) => string;
|
|
172
|
-
readonly
|
|
173
|
-
|
|
174
|
+
readonly parentSummary: (params?: {
|
|
175
|
+
trading_pair_id?: string;
|
|
176
|
+
}) => string;
|
|
177
|
+
readonly summary: (marginAccountId: string, params?: {
|
|
178
|
+
trading_pair_id?: string;
|
|
179
|
+
}) => string;
|
|
174
180
|
readonly availableCollateral: (params?: {
|
|
175
181
|
asset?: string;
|
|
176
182
|
}) => string;
|
|
177
183
|
readonly transferIn: (marginAccountId: string) => string;
|
|
178
|
-
readonly
|
|
184
|
+
readonly transferInParent: () => string;
|
|
185
|
+
readonly transferInRiskBucket: () => string;
|
|
179
186
|
readonly transferOut: (marginAccountId: string) => string;
|
|
187
|
+
readonly transferOutParent: () => string;
|
|
180
188
|
readonly movements: (marginAccountId: string, params?: {
|
|
181
189
|
movement_type?: string;
|
|
182
190
|
page?: number;
|
|
183
191
|
page_size?: number;
|
|
184
192
|
}) => string;
|
|
193
|
+
readonly parentMovements: (params?: {
|
|
194
|
+
movement_type?: string;
|
|
195
|
+
page?: number;
|
|
196
|
+
page_size?: number;
|
|
197
|
+
}) => string;
|
|
198
|
+
readonly simulateParentMarginOrderRisk: () => string;
|
|
185
199
|
readonly simulateOrderRisk: (marginAccountId: string) => string;
|
|
186
|
-
readonly
|
|
200
|
+
readonly simulateRiskBucketOrderRisk: () => string;
|
|
187
201
|
};
|
|
188
202
|
readonly streams: {
|
|
189
203
|
readonly orderbook: () => string;
|
|
@@ -193,7 +207,6 @@ export declare const perpRoutes: {
|
|
|
193
207
|
readonly privateTrades: () => string;
|
|
194
208
|
readonly orders: () => string;
|
|
195
209
|
readonly positions: () => string;
|
|
196
|
-
readonly marginAccount: () => string;
|
|
197
210
|
readonly funding: () => string;
|
|
198
211
|
readonly liquidationAlerts: () => string;
|
|
199
212
|
};
|
package/dist/api/perp/routes.js
CHANGED
|
@@ -26,7 +26,6 @@ export const perpRoutes = {
|
|
|
26
26
|
batchCancelAllByPair: (tradingPairId) => `${API_V1}/orders/batch-cancel-all/${encodeSegment(tradingPairId)}`,
|
|
27
27
|
batchCreate: () => `${API_V1}/orders/batch-create`,
|
|
28
28
|
batchReplace: () => `${API_V1}/orders/batch-replace`,
|
|
29
|
-
createConditional: () => `${API_V1}/orders/conditional`,
|
|
30
29
|
listConditional: (params) => withQuery(`${API_V1}/orders/conditional`, params),
|
|
31
30
|
cancelConditional: (conditionalOrderId) => `${API_V1}/orders/conditional/${encodeSegment(conditionalOrderId)}`,
|
|
32
31
|
},
|
|
@@ -53,6 +52,7 @@ export const perpRoutes = {
|
|
|
53
52
|
listFundingHistory: (tradingPairId, params) => withQuery(`${API_V1}/market/pairs/${encodeSegment(tradingPairId)}/funding/history`, params),
|
|
54
53
|
getOpenInterest: (tradingPairId) => `${API_V1}/market/pairs/${encodeSegment(tradingPairId)}/open-interest`,
|
|
55
54
|
getScreener: (params) => withQuery(`${API_V1}/market/screener`, params),
|
|
55
|
+
getMarketStats: () => `${API_V1}/market/stats`,
|
|
56
56
|
},
|
|
57
57
|
orderbook: {
|
|
58
58
|
get: (tradingPairId, params) => withQuery(`${API_V1}/orderbook/${encodeSegment(tradingPairId)}`, params),
|
|
@@ -85,6 +85,7 @@ export const perpRoutes = {
|
|
|
85
85
|
list: (params) => withQuery(`${API_V1}/positions`, params),
|
|
86
86
|
get: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}`,
|
|
87
87
|
close: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/close`,
|
|
88
|
+
batchCloseAll: () => `${API_V1}/positions/batch-close-all`,
|
|
88
89
|
risk: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/risk`,
|
|
89
90
|
addMargin: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/margin/add`,
|
|
90
91
|
reduceMargin: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/margin/reduce`,
|
|
@@ -93,15 +94,19 @@ export const perpRoutes = {
|
|
|
93
94
|
},
|
|
94
95
|
marginAccounts: {
|
|
95
96
|
list: (params) => withQuery(`${API_V1}/margin/accounts`, params),
|
|
96
|
-
|
|
97
|
-
summary: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}`,
|
|
97
|
+
parentSummary: (params) => withQuery(`${API_V1}/margin/parent-margin-account`, params),
|
|
98
|
+
summary: (marginAccountId, params) => withQuery(`${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}`, params),
|
|
98
99
|
availableCollateral: (params) => withQuery(`${API_V1}/margin/collateral/available`, params),
|
|
99
100
|
transferIn: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/collateral/transfer-in`,
|
|
100
|
-
|
|
101
|
+
transferInParent: () => `${API_V1}/margin/parent-margin-account/collateral/transfer-in`,
|
|
102
|
+
transferInRiskBucket: () => `${API_V1}/margin/risk-buckets/collateral/transfer-in`,
|
|
101
103
|
transferOut: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/collateral/transfer-out`,
|
|
104
|
+
transferOutParent: () => `${API_V1}/margin/parent-margin-account/collateral/transfer-out`,
|
|
102
105
|
movements: (marginAccountId, params) => withQuery(`${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/movements`, params),
|
|
106
|
+
parentMovements: (params) => withQuery(`${API_V1}/margin/parent-margin-account/movements`, params),
|
|
107
|
+
simulateParentMarginOrderRisk: () => `${API_V1}/margin/parent-margin-account/simulate-order-risk`,
|
|
103
108
|
simulateOrderRisk: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/simulate-order-risk`,
|
|
104
|
-
|
|
109
|
+
simulateRiskBucketOrderRisk: () => `${API_V1}/margin/risk-buckets/simulate-order-risk`,
|
|
105
110
|
},
|
|
106
111
|
streams: {
|
|
107
112
|
orderbook: () => `${API_V1}/streaming/orderbook`,
|
|
@@ -111,7 +116,6 @@ export const perpRoutes = {
|
|
|
111
116
|
privateTrades: () => `${API_V1}/streaming/private-trades`,
|
|
112
117
|
orders: () => `${API_V1}/streaming/orders`,
|
|
113
118
|
positions: () => `${API_V1}/streaming/positions`,
|
|
114
|
-
marginAccount: () => `${API_V1}/streaming/margin-account`,
|
|
115
119
|
funding: () => `${API_V1}/streaming/funding`,
|
|
116
120
|
liquidationAlerts: () => `${API_V1}/streaming/liquidation-alerts`,
|
|
117
121
|
},
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { AddPositionMarginRequest, AttachPositionTpSlRequest, AttachPositionTpSlResponse, ClosePositionRequest, ClosePositionResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionMarginResponse, PositionRisk, PositionsAPI, ReducePositionMarginRequest } from "@0xmonaco/types";
|
|
1
|
+
import type { AddPositionMarginRequest, AttachPositionTpSlRequest, AttachPositionTpSlResponse, BatchCloseAllRequest, BatchCloseAllResponse, ClosePositionRequest, ClosePositionResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionMarginResponse, PositionRisk, PositionsAPI, ReducePositionMarginRequest } 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>;
|
|
5
5
|
getPosition(positionId: string): Promise<GetPositionResponse>;
|
|
6
6
|
closePosition(positionId: string, request: ClosePositionRequest): Promise<ClosePositionResponse>;
|
|
7
|
+
batchCloseAllPositions(request?: BatchCloseAllRequest): Promise<BatchCloseAllResponse>;
|
|
7
8
|
getPositionRisk(positionId: string): Promise<PositionRisk>;
|
|
8
9
|
addPositionMargin(positionId: string, request: AddPositionMarginRequest): Promise<PositionMarginResponse>;
|
|
9
10
|
reducePositionMargin(positionId: string, request: ReducePositionMarginRequest): Promise<PositionMarginResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddPositionMarginSchema, AttachPositionTpSlSchema, ClosePositionSchema, GetPositionRiskSchema, GetPositionSchema, ListPositionHistorySchema, ListPositionsSchema, ReducePositionMarginSchema, validate, } from "@0xmonaco/types";
|
|
1
|
+
import { AddPositionMarginSchema, AttachPositionTpSlSchema, BatchCloseAllSchema, ClosePositionSchema, GetPositionRiskSchema, GetPositionSchema, ListPositionHistorySchema, ListPositionsSchema, ReducePositionMarginSchema, validate, } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
import { perpRoutes } from "../perp";
|
|
4
4
|
export class PositionsAPIImpl extends BaseAPI {
|
|
@@ -24,6 +24,18 @@ export class PositionsAPIImpl extends BaseAPI {
|
|
|
24
24
|
}),
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
async batchCloseAllPositions(request) {
|
|
28
|
+
if (request) {
|
|
29
|
+
validate(BatchCloseAllSchema, request);
|
|
30
|
+
}
|
|
31
|
+
return await this.makeAuthenticatedRequest(perpRoutes.positions.batchCloseAll(), {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
trading_pair_id: request?.tradingPairId,
|
|
35
|
+
slippage_tolerance_bps: request?.slippageToleranceBps,
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
27
39
|
async getPositionRisk(positionId) {
|
|
28
40
|
validate(GetPositionRiskSchema, { positionId });
|
|
29
41
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.risk(positionId));
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* console.log(`User: ${profile.username} (${profile.address})`);
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import type { AccountBalance, GetPaginatedUserMovementsResponse, GetUserBalancesParams, GetUserBalancesResponse, GetUserMovementsParams, GetUserTradesParams, GetUserTradesResponse, PortfolioChartResponse, PortfolioMetric, PortfolioPeriod, PortfolioStats, ProfileAPI, UserProfile } from "@0xmonaco/types";
|
|
20
|
+
import type { AccountBalance, GetPaginatedUserMovementsResponse, GetUserBalancesParams, GetUserBalancesResponse, GetUserMovementsParams, GetUserTradesParams, GetUserTradesResponse, ListFundingPaymentsParams, ListFundingPaymentsResponse, PortfolioChartResponse, PortfolioMetric, PortfolioPeriod, PortfolioStats, ProfileAPI, UserProfile } from "@0xmonaco/types";
|
|
21
21
|
import { BaseAPI } from "../base";
|
|
22
22
|
export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
23
23
|
/**
|
|
@@ -188,4 +188,21 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
190
|
getUserTrades(params?: GetUserTradesParams): Promise<GetUserTradesResponse>;
|
|
191
|
+
/**
|
|
192
|
+
* List the current user's funding payment history with pagination and filters.
|
|
193
|
+
*
|
|
194
|
+
* Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
|
|
195
|
+
* Requires a valid access token to be set.
|
|
196
|
+
*
|
|
197
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
198
|
+
* @returns Promise resolving to paginated funding payments response
|
|
199
|
+
* @throws {APIError} When the request fails or user is not authenticated
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const funding = await profileAPI.listFundingPayments({ trading_pair_id: "550e8400-e29b-41d4-a716-446655440000" });
|
|
204
|
+
* console.log(`Total funding payments: ${funding.total}`);
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
listFundingPayments(params?: ListFundingPaymentsParams): Promise<ListFundingPaymentsResponse>;
|
|
191
208
|
}
|
package/dist/api/profile/api.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* console.log(`User: ${profile.username} (${profile.address})`);
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import { GetUserMovementsSchema, GetUserTradesSchema, validate } from "@0xmonaco/types";
|
|
20
|
+
import { GetUserMovementsSchema, GetUserTradesSchema, ListFundingPaymentsSchema, validate } from "@0xmonaco/types";
|
|
21
21
|
import { APIError } from "../../errors";
|
|
22
22
|
import { BaseAPI } from "../base";
|
|
23
23
|
export class ProfileAPIImpl extends BaseAPI {
|
|
@@ -256,4 +256,44 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
256
256
|
const url = queryString ? `/api/v1/accounts/trades?${queryString}` : "/api/v1/accounts/trades";
|
|
257
257
|
return await this.makeAuthenticatedRequest(url);
|
|
258
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* List the current user's funding payment history with pagination and filters.
|
|
261
|
+
*
|
|
262
|
+
* Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
|
|
263
|
+
* Requires a valid access token to be set.
|
|
264
|
+
*
|
|
265
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
266
|
+
* @returns Promise resolving to paginated funding payments response
|
|
267
|
+
* @throws {APIError} When the request fails or user is not authenticated
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const funding = await profileAPI.listFundingPayments({ trading_pair_id: "550e8400-e29b-41d4-a716-446655440000" });
|
|
272
|
+
* console.log(`Total funding payments: ${funding.total}`);
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
async listFundingPayments(params) {
|
|
276
|
+
if (params) {
|
|
277
|
+
validate(ListFundingPaymentsSchema, params);
|
|
278
|
+
}
|
|
279
|
+
const searchParams = new URLSearchParams();
|
|
280
|
+
if (params?.page !== undefined) {
|
|
281
|
+
searchParams.append("page", params.page.toString());
|
|
282
|
+
}
|
|
283
|
+
if (params?.page_size !== undefined) {
|
|
284
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
285
|
+
}
|
|
286
|
+
if (params?.trading_pair_id !== undefined) {
|
|
287
|
+
searchParams.append("trading_pair_id", params.trading_pair_id);
|
|
288
|
+
}
|
|
289
|
+
if (params?.position_id !== undefined) {
|
|
290
|
+
searchParams.append("position_id", params.position_id);
|
|
291
|
+
}
|
|
292
|
+
if (params?.margin_account_id !== undefined) {
|
|
293
|
+
searchParams.append("margin_account_id", params.margin_account_id);
|
|
294
|
+
}
|
|
295
|
+
const queryString = searchParams.toString();
|
|
296
|
+
const url = queryString ? `/api/v1/accounts/funding-payments?${queryString}` : "/api/v1/accounts/funding-payments";
|
|
297
|
+
return await this.makeAuthenticatedRequest(url);
|
|
298
|
+
}
|
|
259
299
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* );
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse,
|
|
24
|
+
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, OrderSide, ParentTpSlLegParams, PositionSide, ReplaceOrderResponse, TimeInForce, TradingAPI, TradingMode } from "@0xmonaco/types";
|
|
25
25
|
import { BaseAPI } from "../base";
|
|
26
26
|
export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
27
27
|
/**
|
|
@@ -80,8 +80,8 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
80
80
|
expirationDate?: string;
|
|
81
81
|
timeInForce?: TimeInForce;
|
|
82
82
|
marginAccountId?: string;
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
riskBucketId?: string;
|
|
84
|
+
riskBucketCollateral?: string;
|
|
85
85
|
strategyKey?: string;
|
|
86
86
|
positionSide?: PositionSide;
|
|
87
87
|
leverage?: string;
|
|
@@ -134,8 +134,8 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
134
134
|
tradingMode?: TradingMode;
|
|
135
135
|
slippageTolerance?: number;
|
|
136
136
|
marginAccountId?: string;
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
riskBucketId?: string;
|
|
138
|
+
riskBucketCollateral?: string;
|
|
139
139
|
strategyKey?: string;
|
|
140
140
|
positionSide?: PositionSide;
|
|
141
141
|
leverage?: string;
|
|
@@ -160,7 +160,6 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
160
160
|
* ```
|
|
161
161
|
*/
|
|
162
162
|
cancelOrder(orderId: string): Promise<CancelOrderResponse>;
|
|
163
|
-
createConditionalOrder(params: CreateConditionalOrderParams): Promise<CreateConditionalOrderResponse>;
|
|
164
163
|
cancelConditionalOrder(conditionalOrderId: string): Promise<CancelConditionalOrderResponse>;
|
|
165
164
|
listConditionalOrders(params?: ListConditionalOrdersParams): Promise<ListConditionalOrdersResponse>;
|
|
166
165
|
/**
|
package/dist/api/trading/api.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* );
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
import { BatchCreateOrdersSchema, BatchReplaceOrdersSchema, CancelConditionalOrderSchema, CancelOrderSchema,
|
|
24
|
+
import { BatchCreateOrdersSchema, BatchReplaceOrdersSchema, CancelConditionalOrderSchema, CancelOrderSchema, GetPaginatedOrdersSchema, ListConditionalOrdersSchema, PlaceLimitOrderSchema, PlaceMarketOrderSchema, ReplaceOrderSchema, validate, } from "@0xmonaco/types";
|
|
25
25
|
import { BaseAPI } from "../base";
|
|
26
26
|
import { perpRoutes } from "../perp";
|
|
27
27
|
function parentTpSlLegToRequest(leg) {
|
|
@@ -107,8 +107,8 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
107
107
|
expiration_date: options?.expirationDate,
|
|
108
108
|
time_in_force: options?.timeInForce,
|
|
109
109
|
margin_account_id: options?.marginAccountId,
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
risk_bucket_id: options?.riskBucketId,
|
|
111
|
+
risk_bucket_collateral: options?.riskBucketCollateral,
|
|
112
112
|
strategy_key: options?.strategyKey,
|
|
113
113
|
position_side: options?.positionSide,
|
|
114
114
|
leverage: options?.leverage,
|
|
@@ -179,8 +179,8 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
179
179
|
quantity,
|
|
180
180
|
trading_mode: options?.tradingMode || "SPOT",
|
|
181
181
|
margin_account_id: options?.marginAccountId,
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
risk_bucket_id: options?.riskBucketId,
|
|
183
|
+
risk_bucket_collateral: options?.riskBucketCollateral,
|
|
184
184
|
strategy_key: options?.strategyKey,
|
|
185
185
|
position_side: options?.positionSide,
|
|
186
186
|
leverage: options?.leverage,
|
|
@@ -220,29 +220,6 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
220
220
|
body: JSON.stringify(requestBody),
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
|
-
async createConditionalOrder(params) {
|
|
224
|
-
validate(CreateConditionalOrderSchema, params);
|
|
225
|
-
const requestBody = {
|
|
226
|
-
trading_pair_id: params.tradingPairId,
|
|
227
|
-
margin_account_id: params.marginAccountId,
|
|
228
|
-
condition_type: params.conditionType,
|
|
229
|
-
trigger_price: params.triggerPrice,
|
|
230
|
-
trigger_source: params.triggerSource ?? "MARK_PRICE",
|
|
231
|
-
side: params.side,
|
|
232
|
-
position_side: params.positionSide,
|
|
233
|
-
order_type: params.orderType,
|
|
234
|
-
limit_price: params.limitPrice,
|
|
235
|
-
quantity: params.quantity,
|
|
236
|
-
reduce_only: params.reduceOnly ?? true,
|
|
237
|
-
time_in_force: params.timeInForce,
|
|
238
|
-
slippage_tolerance_bps: params.slippageToleranceBps,
|
|
239
|
-
expires_at: params.expiresAt,
|
|
240
|
-
};
|
|
241
|
-
return await this.makeAuthenticatedRequest(perpRoutes.orders.createConditional(), {
|
|
242
|
-
method: "POST",
|
|
243
|
-
body: JSON.stringify(requestBody),
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
223
|
async cancelConditionalOrder(conditionalOrderId) {
|
|
247
224
|
validate(CancelConditionalOrderSchema, { conditionalOrderId });
|
|
248
225
|
return await this.makeAuthenticatedRequest(perpRoutes.orders.cancelConditional(conditionalOrderId), {
|
|
@@ -367,8 +344,8 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
367
344
|
expiration_date: order.expirationDate,
|
|
368
345
|
time_in_force: order.timeInForce,
|
|
369
346
|
margin_account_id: order.marginAccountId,
|
|
370
|
-
|
|
371
|
-
|
|
347
|
+
risk_bucket_id: order.riskBucketId,
|
|
348
|
+
risk_bucket_collateral: order.riskBucketCollateral,
|
|
372
349
|
strategy_key: order.strategyKey,
|
|
373
350
|
position_side: order.positionSide,
|
|
374
351
|
leverage: order.leverage,
|