@0xmonaco/core 0.0.0-develop-20260323152825 → 0.0.0-develop-20260415185155
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 +4 -7
- package/dist/api/applications/api.d.ts +0 -1
- package/dist/api/applications/api.js +0 -1
- package/dist/api/applications/index.d.ts +0 -1
- package/dist/api/applications/index.js +0 -1
- package/dist/api/auth/api.d.ts +9 -9
- package/dist/api/auth/api.js +9 -12
- package/dist/api/auth/index.d.ts +0 -1
- package/dist/api/auth/index.js +0 -1
- package/dist/api/base.d.ts +0 -1
- package/dist/api/base.js +0 -1
- package/dist/api/fees/api.d.ts +2 -1
- package/dist/api/fees/api.js +8 -1
- package/dist/api/fees/index.d.ts +0 -1
- package/dist/api/fees/index.js +0 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/market/api.d.ts +0 -1
- package/dist/api/market/api.js +4 -5
- package/dist/api/market/index.d.ts +0 -1
- package/dist/api/market/index.js +0 -1
- package/dist/api/orderbook/api.d.ts +0 -1
- package/dist/api/orderbook/api.js +1 -2
- package/dist/api/orderbook/index.d.ts +0 -1
- package/dist/api/orderbook/index.js +0 -1
- package/dist/api/profile/api.d.ts +34 -10
- package/dist/api/profile/api.js +61 -18
- package/dist/api/profile/index.d.ts +0 -1
- package/dist/api/profile/index.js +0 -1
- package/dist/api/trades/api.d.ts +4 -5
- package/dist/api/trades/api.js +8 -9
- package/dist/api/trades/index.d.ts +0 -1
- package/dist/api/trades/index.js +0 -1
- package/dist/api/trading/api.d.ts +2 -3
- package/dist/api/trading/api.js +5 -6
- package/dist/api/trading/index.d.ts +0 -1
- package/dist/api/trading/index.js +0 -1
- package/dist/api/vault/api.d.ts +0 -1
- package/dist/api/vault/api.js +0 -1
- package/dist/api/vault/index.d.ts +0 -1
- package/dist/api/vault/index.js +0 -1
- package/dist/api/websocket/index.d.ts +0 -1
- package/dist/api/websocket/index.js +0 -1
- package/dist/api/websocket/types.d.ts +0 -1
- package/dist/api/websocket/types.js +0 -1
- package/dist/api/websocket/utils.d.ts +0 -1
- package/dist/api/websocket/utils.js +0 -1
- package/dist/api/websocket/websocket.d.ts +0 -1
- package/dist/api/websocket/websocket.js +4 -5
- package/dist/errors/errors.d.ts +0 -1
- package/dist/errors/errors.js +0 -1
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/networks/index.d.ts +0 -1
- package/dist/networks/index.js +0 -1
- package/dist/networks/networks.d.ts +0 -1
- package/dist/networks/networks.js +0 -1
- package/dist/sdk.d.ts +4 -5
- package/dist/sdk.js +5 -6
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/magnitude.d.ts +0 -1
- package/dist/utils/magnitude.js +0 -1
- package/package.json +3 -3
- package/dist/api/applications/api.d.ts.map +0 -1
- package/dist/api/applications/api.js.map +0 -1
- package/dist/api/applications/index.d.ts.map +0 -1
- package/dist/api/applications/index.js.map +0 -1
- package/dist/api/auth/api.d.ts.map +0 -1
- package/dist/api/auth/api.js.map +0 -1
- package/dist/api/auth/index.d.ts.map +0 -1
- package/dist/api/auth/index.js.map +0 -1
- package/dist/api/base.d.ts.map +0 -1
- package/dist/api/base.js.map +0 -1
- package/dist/api/fees/api.d.ts.map +0 -1
- package/dist/api/fees/api.js.map +0 -1
- package/dist/api/fees/index.d.ts.map +0 -1
- package/dist/api/fees/index.js.map +0 -1
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js.map +0 -1
- package/dist/api/market/api.d.ts.map +0 -1
- package/dist/api/market/api.js.map +0 -1
- package/dist/api/market/index.d.ts.map +0 -1
- package/dist/api/market/index.js.map +0 -1
- package/dist/api/orderbook/api.d.ts.map +0 -1
- package/dist/api/orderbook/api.js.map +0 -1
- package/dist/api/orderbook/index.d.ts.map +0 -1
- package/dist/api/orderbook/index.js.map +0 -1
- package/dist/api/profile/api.d.ts.map +0 -1
- package/dist/api/profile/api.js.map +0 -1
- package/dist/api/profile/index.d.ts.map +0 -1
- package/dist/api/profile/index.js.map +0 -1
- package/dist/api/trades/api.d.ts.map +0 -1
- package/dist/api/trades/api.js.map +0 -1
- package/dist/api/trades/index.d.ts.map +0 -1
- package/dist/api/trades/index.js.map +0 -1
- package/dist/api/trading/api.d.ts.map +0 -1
- package/dist/api/trading/api.js.map +0 -1
- package/dist/api/trading/index.d.ts.map +0 -1
- package/dist/api/trading/index.js.map +0 -1
- package/dist/api/vault/api.d.ts.map +0 -1
- package/dist/api/vault/api.js.map +0 -1
- package/dist/api/vault/index.d.ts.map +0 -1
- package/dist/api/vault/index.js.map +0 -1
- package/dist/api/websocket/index.d.ts.map +0 -1
- package/dist/api/websocket/index.js.map +0 -1
- package/dist/api/websocket/types.d.ts.map +0 -1
- package/dist/api/websocket/types.js.map +0 -1
- package/dist/api/websocket/utils.d.ts.map +0 -1
- package/dist/api/websocket/utils.js.map +0 -1
- package/dist/api/websocket/websocket.d.ts.map +0 -1
- package/dist/api/websocket/websocket.js.map +0 -1
- package/dist/errors/errors.d.ts.map +0 -1
- package/dist/errors/errors.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/networks/index.d.ts.map +0 -1
- package/dist/networks/index.js.map +0 -1
- package/dist/networks/networks.d.ts.map +0 -1
- package/dist/networks/networks.js.map +0 -1
- package/dist/sdk.d.ts.map +0 -1
- package/dist/sdk.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/magnitude.d.ts.map +0 -1
- package/dist/utils/magnitude.js.map +0 -1
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ async function authExample() {
|
|
|
125
125
|
console.log("Authenticated:", authState.user);
|
|
126
126
|
console.log("Tokens:", {
|
|
127
127
|
accessToken: authState.accessToken,
|
|
128
|
-
refreshToken: authState.refreshToken,
|
|
128
|
+
refreshToken: authState.refreshToken,
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
// Authenticated WebSocket channels are now connected - start receiving real-time updates
|
|
@@ -141,8 +141,7 @@ async function authExample() {
|
|
|
141
141
|
await monaco.logout();
|
|
142
142
|
|
|
143
143
|
// Or manually revoke the token
|
|
144
|
-
|
|
145
|
-
await monaco.auth.revokeToken(authState.refreshToken);
|
|
144
|
+
await monaco.auth.revokeToken();
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
// Market Data
|
|
@@ -277,11 +276,9 @@ interface AuthState {
|
|
|
277
276
|
}
|
|
278
277
|
```
|
|
279
278
|
|
|
280
|
-
**⚠️ Important:** The authentication response contains `refreshToken`, NOT `revokeToken`.
|
|
281
|
-
|
|
282
279
|
```typescript
|
|
283
|
-
//
|
|
284
|
-
await sdk.auth.revokeToken(
|
|
280
|
+
// Revoke the current session's token
|
|
281
|
+
await sdk.auth.revokeToken();
|
|
285
282
|
|
|
286
283
|
// 💡 TIP: Use the built-in logout method
|
|
287
284
|
await sdk.logout(); // Automatically calls revokeToken internally
|
package/dist/api/auth/api.d.ts
CHANGED
|
@@ -182,14 +182,15 @@ export declare class AuthAPIImpl extends BaseAPI implements AuthAPI {
|
|
|
182
182
|
*/
|
|
183
183
|
refreshToken(refreshToken: string): Promise<TokenRefreshResponse>;
|
|
184
184
|
/**
|
|
185
|
-
* Revokes
|
|
185
|
+
* Revokes the current session's refresh token.
|
|
186
186
|
*
|
|
187
|
-
* Invalidates
|
|
188
|
-
* new access tokens. This is useful
|
|
189
|
-
* a token has been compromised.
|
|
187
|
+
* Invalidates the refresh token associated with the current access token,
|
|
188
|
+
* preventing it from being used to obtain new access tokens. This is useful
|
|
189
|
+
* for logout functionality or when a token has been compromised.
|
|
190
|
+
*
|
|
191
|
+
* The server identifies the token to revoke from the access token in the
|
|
192
|
+
* Authorization header — no request body is needed.
|
|
190
193
|
*
|
|
191
|
-
* **Important:** Pass the `refreshToken` from the authentication response.
|
|
192
|
-
* @param refreshToken - The refresh token to revoke (from authResult.refreshToken)
|
|
193
194
|
* @returns Promise resolving when the token is revoked
|
|
194
195
|
* @throws {APIError} When token revocation fails
|
|
195
196
|
*
|
|
@@ -197,10 +198,9 @@ export declare class AuthAPIImpl extends BaseAPI implements AuthAPI {
|
|
|
197
198
|
* ```typescript
|
|
198
199
|
* // After authentication
|
|
199
200
|
* const authResult = await authAPI.authenticate(clientId);
|
|
200
|
-
* await authAPI.revokeToken(
|
|
201
|
+
* await authAPI.revokeToken();
|
|
201
202
|
* console.log("Token revoked successfully");
|
|
202
203
|
* ```
|
|
203
204
|
*/
|
|
204
|
-
revokeToken(
|
|
205
|
+
revokeToken(): Promise<void>;
|
|
205
206
|
}
|
|
206
|
-
//# sourceMappingURL=api.d.ts.map
|
package/dist/api/auth/api.js
CHANGED
|
@@ -277,14 +277,15 @@ export class AuthAPIImpl extends BaseAPI {
|
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
/**
|
|
280
|
-
* Revokes
|
|
280
|
+
* Revokes the current session's refresh token.
|
|
281
281
|
*
|
|
282
|
-
* Invalidates
|
|
283
|
-
* new access tokens. This is useful
|
|
284
|
-
* a token has been compromised.
|
|
282
|
+
* Invalidates the refresh token associated with the current access token,
|
|
283
|
+
* preventing it from being used to obtain new access tokens. This is useful
|
|
284
|
+
* for logout functionality or when a token has been compromised.
|
|
285
|
+
*
|
|
286
|
+
* The server identifies the token to revoke from the access token in the
|
|
287
|
+
* Authorization header — no request body is needed.
|
|
285
288
|
*
|
|
286
|
-
* **Important:** Pass the `refreshToken` from the authentication response.
|
|
287
|
-
* @param refreshToken - The refresh token to revoke (from authResult.refreshToken)
|
|
288
289
|
* @returns Promise resolving when the token is revoked
|
|
289
290
|
* @throws {APIError} When token revocation fails
|
|
290
291
|
*
|
|
@@ -292,17 +293,13 @@ export class AuthAPIImpl extends BaseAPI {
|
|
|
292
293
|
* ```typescript
|
|
293
294
|
* // After authentication
|
|
294
295
|
* const authResult = await authAPI.authenticate(clientId);
|
|
295
|
-
* await authAPI.revokeToken(
|
|
296
|
+
* await authAPI.revokeToken();
|
|
296
297
|
* console.log("Token revoked successfully");
|
|
297
298
|
* ```
|
|
298
299
|
*/
|
|
299
|
-
async revokeToken(
|
|
300
|
+
async revokeToken() {
|
|
300
301
|
await this.makeAuthenticatedRequest("/api/v1/auth/revoke", {
|
|
301
302
|
method: "POST",
|
|
302
|
-
body: JSON.stringify({
|
|
303
|
-
refresh_token: refreshToken,
|
|
304
|
-
}),
|
|
305
303
|
});
|
|
306
304
|
}
|
|
307
305
|
}
|
|
308
|
-
//# sourceMappingURL=api.js.map
|
package/dist/api/auth/index.d.ts
CHANGED
package/dist/api/auth/index.js
CHANGED
package/dist/api/base.d.ts
CHANGED
package/dist/api/base.js
CHANGED
package/dist/api/fees/api.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export declare class FeesAPIImpl extends BaseAPI implements FeesAPI {
|
|
|
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.order_type - Order type: "LIMIT" (default) or "MARKET"
|
|
39
|
+
* @param params.slippage_tolerance_bps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
|
|
38
40
|
* @returns Promise resolving to SimulateFeeResponse with fee breakdown
|
|
39
41
|
*
|
|
40
42
|
* @example
|
|
@@ -68,4 +70,3 @@ export declare class FeesAPIImpl extends BaseAPI implements FeesAPI {
|
|
|
68
70
|
*/
|
|
69
71
|
simulateFees(params: SimulateFeeParams): Promise<SimulateFeeResponse>;
|
|
70
72
|
}
|
|
71
|
-
//# sourceMappingURL=api.d.ts.map
|
package/dist/api/fees/api.js
CHANGED
|
@@ -35,6 +35,8 @@ export class FeesAPIImpl extends BaseAPI {
|
|
|
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.order_type - Order type: "LIMIT" (default) or "MARKET"
|
|
39
|
+
* @param params.slippage_tolerance_bps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
|
|
38
40
|
* @returns Promise resolving to SimulateFeeResponse with fee breakdown
|
|
39
41
|
*
|
|
40
42
|
* @example
|
|
@@ -74,10 +76,15 @@ export class FeesAPIImpl extends BaseAPI {
|
|
|
74
76
|
searchParams.append("side", validatedParams.side);
|
|
75
77
|
searchParams.append("price", validatedParams.price);
|
|
76
78
|
searchParams.append("quantity", validatedParams.quantity);
|
|
79
|
+
if (validatedParams.order_type !== undefined) {
|
|
80
|
+
searchParams.append("order_type", validatedParams.order_type);
|
|
81
|
+
}
|
|
82
|
+
if (validatedParams.slippage_tolerance_bps !== undefined) {
|
|
83
|
+
searchParams.append("slippage_tolerance_bps", String(validatedParams.slippage_tolerance_bps));
|
|
84
|
+
}
|
|
77
85
|
const endpoint = `/api/v1/fees/simulate?${searchParams.toString()}`;
|
|
78
86
|
return await this.makeAuthenticatedRequest(endpoint, {
|
|
79
87
|
method: "GET",
|
|
80
88
|
});
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
|
-
//# sourceMappingURL=api.js.map
|
package/dist/api/fees/index.d.ts
CHANGED
package/dist/api/fees/index.js
CHANGED
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
package/dist/api/market/api.d.ts
CHANGED
|
@@ -11,4 +11,3 @@ export declare class MarketAPIImpl extends BaseAPI implements MarketAPI {
|
|
|
11
11
|
getCandlesticks(tradingPairId: string, interval: Interval, params?: GetCandlesticksParams): Promise<Candlestick[]>;
|
|
12
12
|
getMarketMetadata(tradingPairId: string): Promise<MarketMetadata>;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=api.d.ts.map
|
package/dist/api/market/api.js
CHANGED
|
@@ -11,8 +11,8 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
11
11
|
if (params?.page !== undefined) {
|
|
12
12
|
searchParams.append("page", params.page.toString());
|
|
13
13
|
}
|
|
14
|
-
if (params?.
|
|
15
|
-
searchParams.append("
|
|
14
|
+
if (params?.page_size !== undefined) {
|
|
15
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
16
16
|
}
|
|
17
17
|
if (params?.market_type) {
|
|
18
18
|
searchParams.append("market_type", params.market_type);
|
|
@@ -32,8 +32,8 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
32
32
|
}
|
|
33
33
|
async getTradingPairBySymbol(symbol) {
|
|
34
34
|
// Backend endpoint expects UUID, not symbol, so we fetch all pairs and filter
|
|
35
|
-
const response = await this.getPaginatedTradingPairs({
|
|
36
|
-
return response.
|
|
35
|
+
const response = await this.getPaginatedTradingPairs({ page_size: 100 });
|
|
36
|
+
return response.trading_pairs.find((pair) => pair.symbol === symbol);
|
|
37
37
|
}
|
|
38
38
|
async getCandlesticks(tradingPairId, interval, params) {
|
|
39
39
|
// Validate inputs using the trading pair ID schema
|
|
@@ -67,4 +67,3 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
67
67
|
return await this.makePublicRequest(url);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
//# sourceMappingURL=api.js.map
|
package/dist/api/market/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export class OrderbookAPIImpl extends BaseAPI {
|
|
|
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
|
-
tradingPairId: response.
|
|
15
|
+
tradingPairId: response.symbol,
|
|
16
16
|
tradingMode: response.trading_mode,
|
|
17
17
|
bids: response.data.bids.map((level) => ({
|
|
18
18
|
price: level.price,
|
|
@@ -35,4 +35,3 @@ export class OrderbookAPIImpl extends BaseAPI {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
//# sourceMappingURL=api.js.map
|
|
@@ -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, PortfolioChartResponse, PortfolioMetric, PortfolioPeriod, PortfolioStats, ProfileAPI, UserProfile } from "@0xmonaco/types";
|
|
20
|
+
import type { AccountBalance, GetPaginatedUserMovementsResponse, GetUserBalancesParams, GetUserBalancesResponse, GetUserMovementsParams, GetUserTradesParams, GetUserTradesResponse, 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
|
/**
|
|
@@ -61,12 +61,12 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```typescript
|
|
64
|
-
* // Get first page with default
|
|
64
|
+
* // Get first page with default page_size (20)
|
|
65
65
|
* const movements = await profileAPI.getPaginatedUserMovements();
|
|
66
|
-
* console.log(`Total movements: ${movements.
|
|
66
|
+
* console.log(`Total movements: ${movements.total}`);
|
|
67
67
|
*
|
|
68
|
-
* // Get second page with custom
|
|
69
|
-
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2,
|
|
68
|
+
* // Get second page with custom page_size
|
|
69
|
+
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, page_size: 50 });
|
|
70
70
|
* console.log(`Page ${page2.page} of ${page2.total_pages}`);
|
|
71
71
|
*
|
|
72
72
|
* // Filter by entry type and transaction type
|
|
@@ -84,8 +84,8 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
84
84
|
* Requires a valid access token to be set.
|
|
85
85
|
*
|
|
86
86
|
* @param params - Optional query parameters for pagination
|
|
87
|
-
* @param params.
|
|
88
|
-
* @param params.
|
|
87
|
+
* @param params.page - Page number (starts from 1, default: 1)
|
|
88
|
+
* @param params.page_size - 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
|
*
|
|
@@ -98,8 +98,8 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
98
98
|
* console.log(`${balance.symbol}: ${balance.available_balance}`);
|
|
99
99
|
* });
|
|
100
100
|
*
|
|
101
|
-
* // Get
|
|
102
|
-
* const nextBalances = await profileAPI.getUserBalances({
|
|
101
|
+
* // Get page 2 with 50 items per page
|
|
102
|
+
* const nextBalances = await profileAPI.getUserBalances({ page: 2, page_size: 50 });
|
|
103
103
|
* console.log(`Returned ${nextBalances.balances.length} balances`);
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
@@ -163,5 +163,29 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
163
163
|
* ```
|
|
164
164
|
*/
|
|
165
165
|
getPortfolioChart(period: PortfolioPeriod, metric: PortfolioMetric): Promise<PortfolioChartResponse>;
|
|
166
|
+
/**
|
|
167
|
+
* Get the current user's trade history with pagination.
|
|
168
|
+
*
|
|
169
|
+
* Fetches the user's executed trades from the /api/v1/accounts/trades endpoint.
|
|
170
|
+
* Requires a valid access token to be set.
|
|
171
|
+
*
|
|
172
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
173
|
+
* @param params.page - Page number (starts from 1, default: 1)
|
|
174
|
+
* @param params.page_size - Number of items per page (default: 20, max: 100)
|
|
175
|
+
* @param params.trading_pair_id - Filter by trading pair ID (UUID)
|
|
176
|
+
* @returns Promise resolving to paginated trades response
|
|
177
|
+
* @throws {ValidationError} When the provided params fail client-side validation
|
|
178
|
+
* @throws {APIError} When the request fails or user is not authenticated
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* // Get first page of trades
|
|
183
|
+
* const trades = await profileAPI.getUserTrades();
|
|
184
|
+
* console.log(`Total trades: ${trades.total}`);
|
|
185
|
+
*
|
|
186
|
+
* // Filter by trading pair
|
|
187
|
+
* const pairTrades = await profileAPI.getUserTrades({ trading_pair_id: "550e8400-e29b-41d4-a716-446655440000" });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
getUserTrades(params?: GetUserTradesParams): Promise<GetUserTradesResponse>;
|
|
166
191
|
}
|
|
167
|
-
//# sourceMappingURL=api.d.ts.map
|
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, validate } from "@0xmonaco/types";
|
|
20
|
+
import { GetUserMovementsSchema, GetUserTradesSchema, validate } from "@0xmonaco/types";
|
|
21
21
|
import { APIError } from "../../errors";
|
|
22
22
|
import { BaseAPI } from "../base";
|
|
23
23
|
export class ProfileAPIImpl extends BaseAPI {
|
|
@@ -64,12 +64,12 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
64
64
|
*
|
|
65
65
|
* @example
|
|
66
66
|
* ```typescript
|
|
67
|
-
* // Get first page with default
|
|
67
|
+
* // Get first page with default page_size (20)
|
|
68
68
|
* const movements = await profileAPI.getPaginatedUserMovements();
|
|
69
|
-
* console.log(`Total movements: ${movements.
|
|
69
|
+
* console.log(`Total movements: ${movements.total}`);
|
|
70
70
|
*
|
|
71
|
-
* // Get second page with custom
|
|
72
|
-
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2,
|
|
71
|
+
* // Get second page with custom page_size
|
|
72
|
+
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, page_size: 50 });
|
|
73
73
|
* console.log(`Page ${page2.page} of ${page2.total_pages}`);
|
|
74
74
|
*
|
|
75
75
|
* // Filter by entry type and transaction type
|
|
@@ -87,8 +87,8 @@ 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?.page_size !== undefined) {
|
|
91
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
92
92
|
}
|
|
93
93
|
if (params?.entry_type !== undefined) {
|
|
94
94
|
searchParams.append("entry_type", params.entry_type);
|
|
@@ -110,8 +110,8 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
110
110
|
* Requires a valid access token to be set.
|
|
111
111
|
*
|
|
112
112
|
* @param params - Optional query parameters for pagination
|
|
113
|
-
* @param params.
|
|
114
|
-
* @param params.
|
|
113
|
+
* @param params.page - Page number (starts from 1, default: 1)
|
|
114
|
+
* @param params.page_size - 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
|
*
|
|
@@ -124,18 +124,18 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
124
124
|
* console.log(`${balance.symbol}: ${balance.available_balance}`);
|
|
125
125
|
* });
|
|
126
126
|
*
|
|
127
|
-
* // Get
|
|
128
|
-
* const nextBalances = await profileAPI.getUserBalances({
|
|
127
|
+
* // Get page 2 with 50 items per page
|
|
128
|
+
* const nextBalances = await profileAPI.getUserBalances({ page: 2, page_size: 50 });
|
|
129
129
|
* console.log(`Returned ${nextBalances.balances.length} balances`);
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
132
132
|
async getUserBalances(params) {
|
|
133
133
|
const searchParams = new URLSearchParams();
|
|
134
|
-
if (params?.
|
|
135
|
-
searchParams.append("
|
|
134
|
+
if (params?.page !== undefined) {
|
|
135
|
+
searchParams.append("page", params.page.toString());
|
|
136
136
|
}
|
|
137
|
-
if (params?.
|
|
138
|
-
searchParams.append("
|
|
137
|
+
if (params?.page_size !== undefined) {
|
|
138
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
139
139
|
}
|
|
140
140
|
const queryString = searchParams.toString();
|
|
141
141
|
const url = queryString ? `/api/v1/accounts/balances?${queryString}` : "/api/v1/accounts/balances";
|
|
@@ -188,7 +188,8 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
190
|
async getPortfolioStats(period) {
|
|
191
|
-
|
|
191
|
+
const searchParams = new URLSearchParams({ period });
|
|
192
|
+
return await this.makeAuthenticatedRequest(`/api/v1/accounts/me/portfolio?${searchParams}`);
|
|
192
193
|
}
|
|
193
194
|
/**
|
|
194
195
|
* Get the current user's portfolio chart time series for a given period and metric.
|
|
@@ -210,7 +211,49 @@ export class ProfileAPIImpl extends BaseAPI {
|
|
|
210
211
|
* ```
|
|
211
212
|
*/
|
|
212
213
|
async getPortfolioChart(period, metric) {
|
|
213
|
-
|
|
214
|
+
const searchParams = new URLSearchParams({ period, metric });
|
|
215
|
+
return await this.makeAuthenticatedRequest(`/api/v1/accounts/me/portfolio/chart?${searchParams}`);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get the current user's trade history with pagination.
|
|
219
|
+
*
|
|
220
|
+
* Fetches the user's executed trades from the /api/v1/accounts/trades endpoint.
|
|
221
|
+
* Requires a valid access token to be set.
|
|
222
|
+
*
|
|
223
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
224
|
+
* @param params.page - Page number (starts from 1, default: 1)
|
|
225
|
+
* @param params.page_size - Number of items per page (default: 20, max: 100)
|
|
226
|
+
* @param params.trading_pair_id - Filter by trading pair ID (UUID)
|
|
227
|
+
* @returns Promise resolving to paginated trades response
|
|
228
|
+
* @throws {ValidationError} When the provided params fail client-side validation
|
|
229
|
+
* @throws {APIError} When the request fails or user is not authenticated
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* // Get first page of trades
|
|
234
|
+
* const trades = await profileAPI.getUserTrades();
|
|
235
|
+
* console.log(`Total trades: ${trades.total}`);
|
|
236
|
+
*
|
|
237
|
+
* // Filter by trading pair
|
|
238
|
+
* const pairTrades = await profileAPI.getUserTrades({ trading_pair_id: "550e8400-e29b-41d4-a716-446655440000" });
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
async getUserTrades(params) {
|
|
242
|
+
if (params) {
|
|
243
|
+
validate(GetUserTradesSchema, params);
|
|
244
|
+
}
|
|
245
|
+
const searchParams = new URLSearchParams();
|
|
246
|
+
if (params?.page !== undefined) {
|
|
247
|
+
searchParams.append("page", params.page.toString());
|
|
248
|
+
}
|
|
249
|
+
if (params?.page_size !== undefined) {
|
|
250
|
+
searchParams.append("page_size", params.page_size.toString());
|
|
251
|
+
}
|
|
252
|
+
if (params?.trading_pair_id !== undefined) {
|
|
253
|
+
searchParams.append("trading_pair_id", params.trading_pair_id);
|
|
254
|
+
}
|
|
255
|
+
const queryString = searchParams.toString();
|
|
256
|
+
const url = queryString ? `/api/v1/accounts/trades?${queryString}` : "/api/v1/accounts/trades";
|
|
257
|
+
return await this.makeAuthenticatedRequest(url);
|
|
214
258
|
}
|
|
215
259
|
}
|
|
216
|
-
//# sourceMappingURL=api.js.map
|
package/dist/api/trades/api.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseAPI } from "../base";
|
|
|
5
5
|
*/
|
|
6
6
|
interface RawTradeEvent {
|
|
7
7
|
event_type: string;
|
|
8
|
-
|
|
8
|
+
trading_pair_id: string;
|
|
9
9
|
trading_mode: string;
|
|
10
10
|
data: {
|
|
11
11
|
trade_id: string;
|
|
@@ -23,10 +23,10 @@ export declare function parseRawTradeEvent(raw: RawTradeEvent): TradeEvent;
|
|
|
23
23
|
* Options for fetching trades
|
|
24
24
|
*/
|
|
25
25
|
export interface GetTradesOptions {
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/** Page number (starts from 1, default: 1) */
|
|
27
|
+
page?: number;
|
|
28
28
|
/** Maximum number of records to return (default: 25, max: 100) */
|
|
29
|
-
|
|
29
|
+
page_size?: number;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Trades API for fetching historical trade data
|
|
@@ -42,4 +42,3 @@ export declare class TradesAPIImpl extends BaseAPI {
|
|
|
42
42
|
getTrades(tradingPairId: string, options?: GetTradesOptions): Promise<TradeEvent[]>;
|
|
43
43
|
}
|
|
44
44
|
export {};
|
|
45
|
-
//# sourceMappingURL=api.d.ts.map
|
package/dist/api/trades/api.js
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseAPI } from "../base";
|
|
|
5
5
|
export function parseRawTradeEvent(raw) {
|
|
6
6
|
return {
|
|
7
7
|
eventType: "trade",
|
|
8
|
-
tradingPairId: raw.
|
|
8
|
+
tradingPairId: raw.trading_pair_id,
|
|
9
9
|
tradingMode: raw.trading_mode.toUpperCase(),
|
|
10
10
|
data: {
|
|
11
11
|
tradeId: raw.data.trade_id,
|
|
@@ -28,16 +28,15 @@ export class TradesAPIImpl extends BaseAPI {
|
|
|
28
28
|
* @returns Array of TradeEvent records sorted by executed_at descending (newest first)
|
|
29
29
|
*/
|
|
30
30
|
async getTrades(tradingPairId, options = {}) {
|
|
31
|
-
const {
|
|
32
|
-
// Ensure
|
|
33
|
-
const
|
|
31
|
+
const { page = 1 } = options;
|
|
32
|
+
// Ensure page_size is a positive number between 1 and 100, defaulting to 25
|
|
33
|
+
const page_size = options.page_size != null && options.page_size > 0 ? Math.min(options.page_size, 100) : 25;
|
|
34
34
|
const params = new URLSearchParams();
|
|
35
|
-
if (
|
|
36
|
-
params.set("
|
|
35
|
+
if (page > 1) {
|
|
36
|
+
params.set("page", String(page));
|
|
37
37
|
}
|
|
38
|
-
params.set("
|
|
38
|
+
params.set("page_size", String(page_size));
|
|
39
39
|
const response = await this.makePublicRequest(`/api/v1/trades/${encodeURIComponent(tradingPairId)}?${params.toString()}`);
|
|
40
|
-
return response.
|
|
40
|
+
return response.trades.map(parseRawTradeEvent);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
//# sourceMappingURL=api.js.map
|
package/dist/api/trades/index.js
CHANGED
|
@@ -242,7 +242,7 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
242
242
|
*
|
|
243
243
|
* @param params - Query parameters for filtering orders
|
|
244
244
|
* @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED") (optional)
|
|
245
|
-
* @param params.
|
|
245
|
+
* @param params.trading_pair_id - Filter by trading pair UUID (optional)
|
|
246
246
|
* @param params.page - Page number for pagination (defaults to 1, must be > 0)
|
|
247
247
|
* @param params.page_size - Number of orders per page (defaults to 10, max 100, must be > 0)
|
|
248
248
|
* @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
|
|
@@ -253,7 +253,7 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
253
253
|
* // Get submitted orders for a specific trading pair with custom pagination
|
|
254
254
|
* const orders = await tradingAPI.getPaginatedOrders({
|
|
255
255
|
* status: "SUBMITTED",
|
|
256
|
-
*
|
|
256
|
+
* trading_pair_id: "456e7890-e12b-12d3-a456-426614174000",
|
|
257
257
|
* page: 1,
|
|
258
258
|
* page_size: 20
|
|
259
259
|
* });
|
|
@@ -284,4 +284,3 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
284
284
|
*/
|
|
285
285
|
getOrder(orderId: string): Promise<GetOrderResponse>;
|
|
286
286
|
}
|
|
287
|
-
//# sourceMappingURL=api.d.ts.map
|