@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
|
@@ -3,11 +3,11 @@ export declare const perpRoutes: {
|
|
|
3
3
|
readonly create: () => string;
|
|
4
4
|
readonly list: (params?: {
|
|
5
5
|
page?: number;
|
|
6
|
-
|
|
6
|
+
pageSize?: number;
|
|
7
7
|
status?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
tradingPair?: string;
|
|
9
|
+
tradingMode?: string;
|
|
10
|
+
marginAccountId?: string;
|
|
11
11
|
}) => string;
|
|
12
12
|
readonly get: (orderId: string) => string;
|
|
13
13
|
readonly replace: (orderId: string) => string;
|
|
@@ -18,11 +18,11 @@ export declare const perpRoutes: {
|
|
|
18
18
|
readonly batchCreate: () => string;
|
|
19
19
|
readonly batchReplace: () => string;
|
|
20
20
|
readonly listConditional: (params?: {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
marginAccountId?: string;
|
|
22
|
+
tradingPairId?: string;
|
|
23
23
|
state?: string;
|
|
24
24
|
page?: number;
|
|
25
|
-
|
|
25
|
+
pageSize?: number;
|
|
26
26
|
}) => string;
|
|
27
27
|
readonly cancelConditional: (conditionalOrderId: string) => string;
|
|
28
28
|
};
|
|
@@ -35,20 +35,24 @@ export declare const perpRoutes: {
|
|
|
35
35
|
readonly withdrawals: {
|
|
36
36
|
readonly initiate: () => string;
|
|
37
37
|
readonly byIndex: (withdrawalIndex: number) => string;
|
|
38
|
+
readonly list: (params?: {
|
|
39
|
+
page?: number;
|
|
40
|
+
pageSize?: number;
|
|
41
|
+
}) => string;
|
|
38
42
|
};
|
|
39
43
|
readonly market: {
|
|
40
44
|
readonly listTradingPairs: (params?: {
|
|
41
45
|
page?: number;
|
|
42
46
|
limit?: number;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
marketType?: string;
|
|
48
|
+
baseToken?: string;
|
|
49
|
+
quoteToken?: string;
|
|
50
|
+
isActive?: boolean;
|
|
47
51
|
}) => string;
|
|
48
52
|
readonly getTradingPair: (tradingPairId: string) => string;
|
|
49
53
|
readonly getCandles: (tradingPairId: string, interval: string, params?: {
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
startTime?: number;
|
|
55
|
+
endTime?: number;
|
|
52
56
|
limit?: number;
|
|
53
57
|
}) => string;
|
|
54
58
|
readonly getMarketMetadata: (tradingPairId: string) => string;
|
|
@@ -58,17 +62,17 @@ export declare const perpRoutes: {
|
|
|
58
62
|
readonly getIndexPrice: (tradingPairId: string) => string;
|
|
59
63
|
readonly getFundingState: (tradingPairId: string) => string;
|
|
60
64
|
readonly listFundingHistory: (tradingPairId: string, params?: {
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
startTime?: string;
|
|
66
|
+
endTime?: string;
|
|
63
67
|
page?: number;
|
|
64
|
-
|
|
68
|
+
pageSize?: number;
|
|
65
69
|
}) => string;
|
|
66
70
|
readonly getOpenInterest: (tradingPairId: string) => string;
|
|
67
71
|
readonly getScreener: (params?: {
|
|
68
72
|
page?: number;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
pageSize?: number;
|
|
74
|
+
marketType?: string;
|
|
75
|
+
isActive?: boolean;
|
|
72
76
|
category?: string;
|
|
73
77
|
}) => string;
|
|
74
78
|
readonly getMarketStats: () => string;
|
|
@@ -76,7 +80,7 @@ export declare const perpRoutes: {
|
|
|
76
80
|
readonly orderbook: {
|
|
77
81
|
readonly get: (tradingPairId: string, params?: {
|
|
78
82
|
levels?: number;
|
|
79
|
-
|
|
83
|
+
tradingMode?: string;
|
|
80
84
|
magnitude?: string | number;
|
|
81
85
|
denomination?: string;
|
|
82
86
|
}) => string;
|
|
@@ -88,42 +92,42 @@ export declare const perpRoutes: {
|
|
|
88
92
|
}) => string;
|
|
89
93
|
readonly byId: (tradeId: string) => string;
|
|
90
94
|
readonly user: (params?: {
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
marginAccountId?: string;
|
|
96
|
+
tradingPairId?: string;
|
|
93
97
|
page?: number;
|
|
94
|
-
|
|
98
|
+
pageSize?: number;
|
|
95
99
|
}) => string;
|
|
96
100
|
};
|
|
97
101
|
readonly applications: {
|
|
98
102
|
readonly orders: (params?: {
|
|
99
103
|
page?: number;
|
|
100
|
-
|
|
104
|
+
pageSize?: number;
|
|
101
105
|
status?: string;
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
userId?: string;
|
|
107
|
+
tradingPairId?: string;
|
|
104
108
|
side?: string;
|
|
105
|
-
|
|
109
|
+
orderType?: string;
|
|
106
110
|
}) => string;
|
|
107
111
|
readonly users: (params?: {
|
|
108
112
|
page?: number;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
pageSize?: number;
|
|
114
|
+
isActive?: boolean;
|
|
115
|
+
accountType?: string;
|
|
112
116
|
address?: string;
|
|
113
117
|
}) => string;
|
|
114
118
|
readonly movements: (params?: {
|
|
115
119
|
page?: number;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
pageSize?: number;
|
|
121
|
+
userId?: string;
|
|
122
|
+
transactionType?: string;
|
|
123
|
+
entryType?: string;
|
|
124
|
+
assetId?: string;
|
|
121
125
|
}) => string;
|
|
122
126
|
readonly balances: (params?: {
|
|
123
127
|
page?: number;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
pageSize?: number;
|
|
129
|
+
userId?: string;
|
|
130
|
+
assetId?: string;
|
|
127
131
|
}) => string;
|
|
128
132
|
readonly stats: (params?: {
|
|
129
133
|
since?: string;
|
|
@@ -143,11 +147,11 @@ export declare const perpRoutes: {
|
|
|
143
147
|
};
|
|
144
148
|
readonly positions: {
|
|
145
149
|
readonly list: (params?: {
|
|
146
|
-
|
|
147
|
-
|
|
150
|
+
marginAccountId?: string;
|
|
151
|
+
tradingPairId?: string;
|
|
148
152
|
status?: string;
|
|
149
153
|
page?: number;
|
|
150
|
-
|
|
154
|
+
pageSize?: number;
|
|
151
155
|
}) => string;
|
|
152
156
|
readonly get: (positionId: string) => string;
|
|
153
157
|
readonly close: (positionId: string) => string;
|
|
@@ -157,25 +161,25 @@ export declare const perpRoutes: {
|
|
|
157
161
|
readonly reduceMargin: (positionId: string) => string;
|
|
158
162
|
readonly attachTpSl: (positionId: string) => string;
|
|
159
163
|
readonly history: (params?: {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
positionId?: string;
|
|
165
|
+
marginAccountId?: string;
|
|
166
|
+
tradingPairId?: string;
|
|
163
167
|
page?: number;
|
|
164
|
-
|
|
168
|
+
pageSize?: number;
|
|
165
169
|
}) => string;
|
|
166
170
|
};
|
|
167
171
|
readonly marginAccounts: {
|
|
168
172
|
readonly list: (params?: {
|
|
169
173
|
page?: number;
|
|
170
|
-
|
|
174
|
+
pageSize?: number;
|
|
171
175
|
state?: string;
|
|
172
|
-
|
|
176
|
+
tradingPairId?: string;
|
|
173
177
|
}) => string;
|
|
174
178
|
readonly parentSummary: (params?: {
|
|
175
|
-
|
|
179
|
+
tradingPairId?: string;
|
|
176
180
|
}) => string;
|
|
177
181
|
readonly summary: (marginAccountId: string, params?: {
|
|
178
|
-
|
|
182
|
+
tradingPairId?: string;
|
|
179
183
|
}) => string;
|
|
180
184
|
readonly availableCollateral: (params?: {
|
|
181
185
|
asset?: string;
|
|
@@ -186,14 +190,14 @@ export declare const perpRoutes: {
|
|
|
186
190
|
readonly transferOut: (marginAccountId: string) => string;
|
|
187
191
|
readonly transferOutParent: () => string;
|
|
188
192
|
readonly movements: (marginAccountId: string, params?: {
|
|
189
|
-
|
|
193
|
+
movementType?: string;
|
|
190
194
|
page?: number;
|
|
191
|
-
|
|
195
|
+
pageSize?: number;
|
|
192
196
|
}) => string;
|
|
193
197
|
readonly parentMovements: (params?: {
|
|
194
|
-
|
|
198
|
+
movementType?: string;
|
|
195
199
|
page?: number;
|
|
196
|
-
|
|
200
|
+
pageSize?: number;
|
|
197
201
|
}) => string;
|
|
198
202
|
readonly simulateParentMarginOrderRisk: () => string;
|
|
199
203
|
readonly simulateOrderRisk: (marginAccountId: string) => string;
|
package/dist/api/perp/routes.js
CHANGED
|
@@ -38,6 +38,7 @@ export const perpRoutes = {
|
|
|
38
38
|
withdrawals: {
|
|
39
39
|
initiate: () => `${API_V1}/withdrawals`,
|
|
40
40
|
byIndex: (withdrawalIndex) => `${API_V1}/withdrawals/${encodeSegment(String(withdrawalIndex))}`,
|
|
41
|
+
list: (params) => withQuery(`${API_V1}/withdrawals`, params),
|
|
41
42
|
},
|
|
42
43
|
market: {
|
|
43
44
|
listTradingPairs: (params) => withQuery(`${API_V1}/market/pairs`, params),
|
|
@@ -17,9 +17,9 @@ export class PositionsAPIImpl extends BaseAPI {
|
|
|
17
17
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.close(positionId), {
|
|
18
18
|
method: "POST",
|
|
19
19
|
body: JSON.stringify({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
closeType: request.closeType,
|
|
21
|
+
limitPrice: request.limitPrice,
|
|
22
|
+
slippageToleranceBps: request.slippageToleranceBps,
|
|
23
23
|
quantity: request.quantity,
|
|
24
24
|
}),
|
|
25
25
|
});
|
|
@@ -31,8 +31,8 @@ export class PositionsAPIImpl extends BaseAPI {
|
|
|
31
31
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.batchCloseAll(), {
|
|
32
32
|
method: "POST",
|
|
33
33
|
body: JSON.stringify({
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
tradingPairId: request?.tradingPairId,
|
|
35
|
+
slippageToleranceBps: request?.slippageToleranceBps,
|
|
36
36
|
}),
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -64,26 +64,26 @@ export class PositionsAPIImpl extends BaseAPI {
|
|
|
64
64
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.attachTpSl(positionId), {
|
|
65
65
|
method: "POST",
|
|
66
66
|
body: JSON.stringify({
|
|
67
|
-
|
|
67
|
+
takeProfit: request.takeProfit
|
|
68
68
|
? {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
triggerPrice: request.takeProfit.triggerPrice,
|
|
70
|
+
orderType: request.takeProfit.orderType,
|
|
71
|
+
limitPrice: request.takeProfit.limitPrice,
|
|
72
72
|
quantity: request.takeProfit.quantity,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
timeInForce: request.takeProfit.timeInForce,
|
|
74
|
+
slippageToleranceBps: request.takeProfit.slippageToleranceBps,
|
|
75
|
+
expiresAt: request.takeProfit.expiresAt,
|
|
76
76
|
}
|
|
77
77
|
: undefined,
|
|
78
|
-
|
|
78
|
+
stopLoss: request.stopLoss
|
|
79
79
|
? {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
triggerPrice: request.stopLoss.triggerPrice,
|
|
81
|
+
orderType: request.stopLoss.orderType,
|
|
82
|
+
limitPrice: request.stopLoss.limitPrice,
|
|
83
83
|
quantity: request.stopLoss.quantity,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
timeInForce: request.stopLoss.timeInForce,
|
|
85
|
+
slippageToleranceBps: request.stopLoss.slippageToleranceBps,
|
|
86
|
+
expiresAt: request.stopLoss.expiresAt,
|
|
87
87
|
}
|
|
88
88
|
: undefined,
|
|
89
89
|
}),
|
|
@@ -39,8 +39,8 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
39
39
|
* console.log(`User ID: ${profile.id}`);
|
|
40
40
|
* console.log(`Address: ${profile.address}`);
|
|
41
41
|
* console.log(`Username: ${profile.username}`);
|
|
42
|
-
* console.log(`Account type: ${profile.
|
|
43
|
-
* console.log(`Can withdraw: ${profile.
|
|
42
|
+
* console.log(`Account type: ${profile.accountType}`);
|
|
43
|
+
* console.log(`Can withdraw: ${profile.canWithdraw}`);
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
getProfile(): Promise<UserProfile>;
|
|
@@ -53,27 +53,27 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
53
53
|
* @param params - Optional query parameters for pagination and filtering
|
|
54
54
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
55
55
|
* @param params.limit - Number of items per page (default: 20, max: 100)
|
|
56
|
-
* @param params.
|
|
57
|
-
* @param params.
|
|
58
|
-
* @param params.
|
|
56
|
+
* @param params.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
|
|
57
|
+
* @param params.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
|
|
58
|
+
* @param params.assetId - Filter by asset ID (UUID)
|
|
59
59
|
* @returns Promise resolving to paginated movements response
|
|
60
60
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```typescript
|
|
64
|
-
* // Get first page with default
|
|
64
|
+
* // Get first page with default pageSize (20)
|
|
65
65
|
* const movements = await profileAPI.getPaginatedUserMovements();
|
|
66
66
|
* console.log(`Total movements: ${movements.total}`);
|
|
67
67
|
*
|
|
68
|
-
* // Get second page with custom
|
|
69
|
-
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2,
|
|
70
|
-
* console.log(`Page ${page2.page} of ${page2.
|
|
68
|
+
* // Get second page with custom pageSize
|
|
69
|
+
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, pageSize: 50 });
|
|
70
|
+
* console.log(`Page ${page2.page} of ${page2.totalPages}`);
|
|
71
71
|
*
|
|
72
72
|
* // Filter by entry type and transaction type
|
|
73
|
-
* const deposits = await profileAPI.getPaginatedUserMovements({
|
|
73
|
+
* const deposits = await profileAPI.getPaginatedUserMovements({ entryType: "CREDIT", transactionType: "DEPOSIT" });
|
|
74
74
|
*
|
|
75
75
|
* // Filter by asset
|
|
76
|
-
* const usdcMovements = await profileAPI.getPaginatedUserMovements({
|
|
76
|
+
* const usdcMovements = await profileAPI.getPaginatedUserMovements({ assetId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
79
|
getPaginatedUserMovements(params?: GetUserMovementsParams): Promise<GetPaginatedUserMovementsResponse>;
|
|
@@ -85,7 +85,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
85
85
|
*
|
|
86
86
|
* @param params - Optional query parameters for pagination
|
|
87
87
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
88
|
-
* @param params.
|
|
88
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 100)
|
|
89
89
|
* @returns Promise resolving to paginated balances response
|
|
90
90
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
91
91
|
*
|
|
@@ -95,11 +95,11 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
95
95
|
* const balances = await profileAPI.getUserBalances();
|
|
96
96
|
* console.log(`Total balances: ${balances.total}`);
|
|
97
97
|
* balances.balances.forEach(balance => {
|
|
98
|
-
* console.log(`${balance.symbol}: ${balance.
|
|
98
|
+
* console.log(`${balance.symbol}: ${balance.availableBalance}`);
|
|
99
99
|
* });
|
|
100
100
|
*
|
|
101
101
|
* // Get page 2 with 50 items per page
|
|
102
|
-
* const nextBalances = await profileAPI.getUserBalances({ page: 2,
|
|
102
|
+
* const nextBalances = await profileAPI.getUserBalances({ page: 2, pageSize: 50 });
|
|
103
103
|
* console.log(`Returned ${nextBalances.balances.length} balances`);
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
@@ -107,7 +107,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
107
107
|
/**
|
|
108
108
|
* Get the current user's balance for a specific asset.
|
|
109
109
|
*
|
|
110
|
-
* Fetches the user's balance for a specific asset from the /api/v1/accounts/balances/{
|
|
110
|
+
* Fetches the user's balance for a specific asset from the /api/v1/accounts/balances/{assetId} endpoint.
|
|
111
111
|
* Requires a valid access token to be set. If no balance exists for a valid asset, returns zero balances.
|
|
112
112
|
*
|
|
113
113
|
* @param assetId - The asset identifier (UUID)
|
|
@@ -118,9 +118,9 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
118
118
|
* ```typescript
|
|
119
119
|
* // Get balance for a specific asset
|
|
120
120
|
* const balance = await profileAPI.getUserBalanceByAssetId('123e4567-e89b-12d3-a456-426614174000');
|
|
121
|
-
* console.log(`${balance.symbol}: ${balance.
|
|
122
|
-
* console.log(`Locked: ${balance.
|
|
123
|
-
* console.log(`Total: ${balance.
|
|
121
|
+
* console.log(`${balance.symbol}: ${balance.availableBalance}`);
|
|
122
|
+
* console.log(`Locked: ${balance.lockedBalance}`);
|
|
123
|
+
* console.log(`Total: ${balance.totalBalance}`);
|
|
124
124
|
* ```
|
|
125
125
|
*/
|
|
126
126
|
getUserBalanceByAssetId(assetId: string): Promise<AccountBalance>;
|
|
@@ -139,7 +139,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
139
139
|
* const stats = await profileAPI.getPortfolioStats("30d");
|
|
140
140
|
* console.log(`PnL: ${stats.pnl}`);
|
|
141
141
|
* console.log(`Volume: ${stats.volume}`);
|
|
142
|
-
* console.log(`Total equity: ${stats.
|
|
142
|
+
* console.log(`Total equity: ${stats.totalEquity}`);
|
|
143
143
|
* ```
|
|
144
144
|
*/
|
|
145
145
|
getPortfolioStats(period: PortfolioPeriod): Promise<PortfolioStats>;
|
|
@@ -171,8 +171,8 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
171
171
|
*
|
|
172
172
|
* @param params - Optional query parameters for pagination and filtering
|
|
173
173
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
174
|
-
* @param params.
|
|
175
|
-
* @param params.
|
|
174
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 100)
|
|
175
|
+
* @param params.tradingPairId - Filter by trading pair ID (UUID)
|
|
176
176
|
* @returns Promise resolving to paginated trades response
|
|
177
177
|
* @throws {ValidationError} When the provided params fail client-side validation
|
|
178
178
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
@@ -184,7 +184,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
184
184
|
* console.log(`Total trades: ${trades.total}`);
|
|
185
185
|
*
|
|
186
186
|
* // Filter by trading pair
|
|
187
|
-
* const pairTrades = await profileAPI.getUserTrades({
|
|
187
|
+
* const pairTrades = await profileAPI.getUserTrades({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
190
|
getUserTrades(params?: GetUserTradesParams): Promise<GetUserTradesResponse>;
|
|
@@ -200,7 +200,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
200
200
|
*
|
|
201
201
|
* @example
|
|
202
202
|
* ```typescript
|
|
203
|
-
* const funding = await profileAPI.listFundingPayments({
|
|
203
|
+
* const funding = await profileAPI.listFundingPayments({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
204
204
|
* console.log(`Total funding payments: ${funding.total}`);
|
|
205
205
|
* ```
|
|
206
206
|
*/
|
package/dist/api/profile/api.js
CHANGED
|
@@ -40,8 +40,8 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
40
40
|
* console.log(`User ID: ${profile.id}`);
|
|
41
41
|
* console.log(`Address: ${profile.address}`);
|
|
42
42
|
* console.log(`Username: ${profile.username}`);
|
|
43
|
-
* console.log(`Account type: ${profile.
|
|
44
|
-
* console.log(`Can withdraw: ${profile.
|
|
43
|
+
* console.log(`Account type: ${profile.accountType}`);
|
|
44
|
+
* console.log(`Can withdraw: ${profile.canWithdraw}`);
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
async getProfile() {
|
|
@@ -56,27 +56,27 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
56
56
|
* @param params - Optional query parameters for pagination and filtering
|
|
57
57
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
58
58
|
* @param params.limit - Number of items per page (default: 20, max: 100)
|
|
59
|
-
* @param params.
|
|
60
|
-
* @param params.
|
|
61
|
-
* @param params.
|
|
59
|
+
* @param params.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
|
|
60
|
+
* @param params.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
|
|
61
|
+
* @param params.assetId - Filter by asset ID (UUID)
|
|
62
62
|
* @returns Promise resolving to paginated movements response
|
|
63
63
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
64
64
|
*
|
|
65
65
|
* @example
|
|
66
66
|
* ```typescript
|
|
67
|
-
* // Get first page with default
|
|
67
|
+
* // Get first page with default pageSize (20)
|
|
68
68
|
* const movements = await profileAPI.getPaginatedUserMovements();
|
|
69
69
|
* console.log(`Total movements: ${movements.total}`);
|
|
70
70
|
*
|
|
71
|
-
* // Get second page with custom
|
|
72
|
-
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2,
|
|
73
|
-
* console.log(`Page ${page2.page} of ${page2.
|
|
71
|
+
* // Get second page with custom pageSize
|
|
72
|
+
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, pageSize: 50 });
|
|
73
|
+
* console.log(`Page ${page2.page} of ${page2.totalPages}`);
|
|
74
74
|
*
|
|
75
75
|
* // Filter by entry type and transaction type
|
|
76
|
-
* const deposits = await profileAPI.getPaginatedUserMovements({
|
|
76
|
+
* const deposits = await profileAPI.getPaginatedUserMovements({ entryType: "CREDIT", transactionType: "DEPOSIT" });
|
|
77
77
|
*
|
|
78
78
|
* // Filter by asset
|
|
79
|
-
* const usdcMovements = await profileAPI.getPaginatedUserMovements({
|
|
79
|
+
* const usdcMovements = await profileAPI.getPaginatedUserMovements({ assetId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
82
|
async getPaginatedUserMovements(params) {
|
|
@@ -87,17 +87,17 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
87
87
|
if (params?.page !== undefined) {
|
|
88
88
|
searchParams.append("page", params.page.toString());
|
|
89
89
|
}
|
|
90
|
-
if (params?.
|
|
91
|
-
searchParams.append("
|
|
90
|
+
if (params?.pageSize !== undefined) {
|
|
91
|
+
searchParams.append("pageSize", params.pageSize.toString());
|
|
92
92
|
}
|
|
93
|
-
if (params?.
|
|
94
|
-
searchParams.append("
|
|
93
|
+
if (params?.entryType !== undefined) {
|
|
94
|
+
searchParams.append("entryType", params.entryType);
|
|
95
95
|
}
|
|
96
|
-
if (params?.
|
|
97
|
-
searchParams.append("
|
|
96
|
+
if (params?.transactionType !== undefined) {
|
|
97
|
+
searchParams.append("transactionType", params.transactionType);
|
|
98
98
|
}
|
|
99
|
-
if (params?.
|
|
100
|
-
searchParams.append("
|
|
99
|
+
if (params?.assetId !== undefined) {
|
|
100
|
+
searchParams.append("assetId", params.assetId);
|
|
101
101
|
}
|
|
102
102
|
const queryString = searchParams.toString();
|
|
103
103
|
const url = queryString ? `/api/v1/accounts/movements?${queryString}` : "/api/v1/accounts/movements";
|
|
@@ -111,7 +111,7 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
111
111
|
*
|
|
112
112
|
* @param params - Optional query parameters for pagination
|
|
113
113
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
114
|
-
* @param params.
|
|
114
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 100)
|
|
115
115
|
* @returns Promise resolving to paginated balances response
|
|
116
116
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
117
117
|
*
|
|
@@ -121,11 +121,11 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
121
121
|
* const balances = await profileAPI.getUserBalances();
|
|
122
122
|
* console.log(`Total balances: ${balances.total}`);
|
|
123
123
|
* balances.balances.forEach(balance => {
|
|
124
|
-
* console.log(`${balance.symbol}: ${balance.
|
|
124
|
+
* console.log(`${balance.symbol}: ${balance.availableBalance}`);
|
|
125
125
|
* });
|
|
126
126
|
*
|
|
127
127
|
* // Get page 2 with 50 items per page
|
|
128
|
-
* const nextBalances = await profileAPI.getUserBalances({ page: 2,
|
|
128
|
+
* const nextBalances = await profileAPI.getUserBalances({ page: 2, pageSize: 50 });
|
|
129
129
|
* console.log(`Returned ${nextBalances.balances.length} balances`);
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
@@ -134,8 +134,8 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
134
134
|
if (params?.page !== undefined) {
|
|
135
135
|
searchParams.append("page", params.page.toString());
|
|
136
136
|
}
|
|
137
|
-
if (params?.
|
|
138
|
-
searchParams.append("
|
|
137
|
+
if (params?.pageSize !== undefined) {
|
|
138
|
+
searchParams.append("pageSize", params.pageSize.toString());
|
|
139
139
|
}
|
|
140
140
|
const queryString = searchParams.toString();
|
|
141
141
|
const url = queryString ? `/api/v1/accounts/balances?${queryString}` : "/api/v1/accounts/balances";
|
|
@@ -144,7 +144,7 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
144
144
|
/**
|
|
145
145
|
* Get the current user's balance for a specific asset.
|
|
146
146
|
*
|
|
147
|
-
* Fetches the user's balance for a specific asset from the /api/v1/accounts/balances/{
|
|
147
|
+
* Fetches the user's balance for a specific asset from the /api/v1/accounts/balances/{assetId} endpoint.
|
|
148
148
|
* Requires a valid access token to be set. If no balance exists for a valid asset, returns zero balances.
|
|
149
149
|
*
|
|
150
150
|
* @param assetId - The asset identifier (UUID)
|
|
@@ -155,15 +155,15 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
155
155
|
* ```typescript
|
|
156
156
|
* // Get balance for a specific asset
|
|
157
157
|
* const balance = await profileAPI.getUserBalanceByAssetId('123e4567-e89b-12d3-a456-426614174000');
|
|
158
|
-
* console.log(`${balance.symbol}: ${balance.
|
|
159
|
-
* console.log(`Locked: ${balance.
|
|
160
|
-
* console.log(`Total: ${balance.
|
|
158
|
+
* console.log(`${balance.symbol}: ${balance.availableBalance}`);
|
|
159
|
+
* console.log(`Locked: ${balance.lockedBalance}`);
|
|
160
|
+
* console.log(`Total: ${balance.totalBalance}`);
|
|
161
161
|
* ```
|
|
162
162
|
*/
|
|
163
163
|
async getUserBalanceByAssetId(assetId) {
|
|
164
164
|
if (!assetId || assetId.trim() === "") {
|
|
165
165
|
throw new APIError("assetId is required and cannot be empty", {
|
|
166
|
-
endpoint: "/api/v1/accounts/balances/{
|
|
166
|
+
endpoint: "/api/v1/accounts/balances/{assetId}",
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
const url = `/api/v1/accounts/balances/${assetId}`;
|
|
@@ -184,7 +184,7 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
184
184
|
* const stats = await profileAPI.getPortfolioStats("30d");
|
|
185
185
|
* console.log(`PnL: ${stats.pnl}`);
|
|
186
186
|
* console.log(`Volume: ${stats.volume}`);
|
|
187
|
-
* console.log(`Total equity: ${stats.
|
|
187
|
+
* console.log(`Total equity: ${stats.totalEquity}`);
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
190
|
async getPortfolioStats(period) {
|
|
@@ -222,8 +222,8 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
222
222
|
*
|
|
223
223
|
* @param params - Optional query parameters for pagination and filtering
|
|
224
224
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
225
|
-
* @param params.
|
|
226
|
-
* @param params.
|
|
225
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 100)
|
|
226
|
+
* @param params.tradingPairId - Filter by trading pair ID (UUID)
|
|
227
227
|
* @returns Promise resolving to paginated trades response
|
|
228
228
|
* @throws {ValidationError} When the provided params fail client-side validation
|
|
229
229
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
@@ -235,7 +235,7 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
235
235
|
* console.log(`Total trades: ${trades.total}`);
|
|
236
236
|
*
|
|
237
237
|
* // Filter by trading pair
|
|
238
|
-
* const pairTrades = await profileAPI.getUserTrades({
|
|
238
|
+
* const pairTrades = await profileAPI.getUserTrades({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
239
239
|
* ```
|
|
240
240
|
*/
|
|
241
241
|
async getUserTrades(params) {
|
|
@@ -246,11 +246,11 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
246
246
|
if (params?.page !== undefined) {
|
|
247
247
|
searchParams.append("page", params.page.toString());
|
|
248
248
|
}
|
|
249
|
-
if (params?.
|
|
250
|
-
searchParams.append("
|
|
249
|
+
if (params?.pageSize !== undefined) {
|
|
250
|
+
searchParams.append("pageSize", params.pageSize.toString());
|
|
251
251
|
}
|
|
252
|
-
if (params?.
|
|
253
|
-
searchParams.append("
|
|
252
|
+
if (params?.tradingPairId !== undefined) {
|
|
253
|
+
searchParams.append("tradingPairId", params.tradingPairId);
|
|
254
254
|
}
|
|
255
255
|
const queryString = searchParams.toString();
|
|
256
256
|
const url = queryString ? `/api/v1/accounts/trades?${queryString}` : "/api/v1/accounts/trades";
|
|
@@ -268,7 +268,7 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
268
268
|
*
|
|
269
269
|
* @example
|
|
270
270
|
* ```typescript
|
|
271
|
-
* const funding = await profileAPI.listFundingPayments({
|
|
271
|
+
* const funding = await profileAPI.listFundingPayments({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
272
272
|
* console.log(`Total funding payments: ${funding.total}`);
|
|
273
273
|
* ```
|
|
274
274
|
*/
|
|
@@ -280,17 +280,17 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
280
280
|
if (params?.page !== undefined) {
|
|
281
281
|
searchParams.append("page", params.page.toString());
|
|
282
282
|
}
|
|
283
|
-
if (params?.
|
|
284
|
-
searchParams.append("
|
|
283
|
+
if (params?.pageSize !== undefined) {
|
|
284
|
+
searchParams.append("pageSize", params.pageSize.toString());
|
|
285
285
|
}
|
|
286
|
-
if (params?.
|
|
287
|
-
searchParams.append("
|
|
286
|
+
if (params?.tradingPairId !== undefined) {
|
|
287
|
+
searchParams.append("tradingPairId", params.tradingPairId);
|
|
288
288
|
}
|
|
289
|
-
if (params?.
|
|
290
|
-
searchParams.append("
|
|
289
|
+
if (params?.positionId !== undefined) {
|
|
290
|
+
searchParams.append("positionId", params.positionId);
|
|
291
291
|
}
|
|
292
|
-
if (params?.
|
|
293
|
-
searchParams.append("
|
|
292
|
+
if (params?.marginAccountId !== undefined) {
|
|
293
|
+
searchParams.append("marginAccountId", params.marginAccountId);
|
|
294
294
|
}
|
|
295
295
|
const queryString = searchParams.toString();
|
|
296
296
|
const url = queryString ? `/api/v1/accounts/funding-payments?${queryString}` : "/api/v1/accounts/funding-payments";
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
|
-
* const {
|
|
13
|
-
* await sdk.subAccounts.createLimit({
|
|
12
|
+
* const { subAccounts } = await sdk.subAccounts.list();
|
|
13
|
+
* await sdk.subAccounts.createLimit({ subAccountId, assetId, maxAmount: "1000.00" });
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
import type { CreateSubAccountLimitRequest, CreateSubAccountLimitResponse, GetSubAccountLimitsResponse, ListSubAccountsResponse, SubAccountsAPI, UpdateSubAccountLimitBody, UpdateSubAccountLimitResponse } from "@0xmonaco/types";
|