@0xmonaco/core 0.1.1 → 0.1.6

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.
Files changed (60) hide show
  1. package/dist/api/applications/api.d.ts +45 -0
  2. package/dist/api/applications/api.d.ts.map +1 -0
  3. package/dist/api/applications/api.js +61 -0
  4. package/dist/api/applications/api.js.map +1 -0
  5. package/dist/api/applications/index.d.ts +6 -0
  6. package/dist/api/applications/index.d.ts.map +1 -0
  7. package/dist/api/applications/index.js +5 -0
  8. package/dist/api/applications/index.js.map +1 -0
  9. package/dist/api/auth/api.d.ts +7 -7
  10. package/dist/api/auth/api.d.ts.map +1 -1
  11. package/dist/api/auth/api.js +6 -6
  12. package/dist/api/auth/api.js.map +1 -1
  13. package/dist/api/base.d.ts +99 -0
  14. package/dist/api/base.d.ts.map +1 -0
  15. package/dist/api/base.js +132 -0
  16. package/dist/api/base.js.map +1 -0
  17. package/dist/api/index.d.ts +5 -1
  18. package/dist/api/index.d.ts.map +1 -1
  19. package/dist/api/index.js +5 -1
  20. package/dist/api/index.js.map +1 -1
  21. package/dist/api/profile/api.d.ts +54 -0
  22. package/dist/api/profile/api.d.ts.map +1 -0
  23. package/dist/api/profile/api.js +77 -0
  24. package/dist/api/profile/api.js.map +1 -0
  25. package/dist/api/profile/index.d.ts +7 -0
  26. package/dist/api/profile/index.d.ts.map +1 -0
  27. package/dist/api/profile/index.js +7 -0
  28. package/dist/api/profile/index.js.map +1 -0
  29. package/dist/api/trading/api.d.ts +77 -22
  30. package/dist/api/trading/api.d.ts.map +1 -1
  31. package/dist/api/trading/api.js +128 -42
  32. package/dist/api/trading/api.js.map +1 -1
  33. package/dist/api/vault/api.d.ts +15 -11
  34. package/dist/api/vault/api.d.ts.map +1 -1
  35. package/dist/api/vault/api.js +57 -41
  36. package/dist/api/vault/api.js.map +1 -1
  37. package/dist/api/websocket/client.d.ts +57 -0
  38. package/dist/api/websocket/client.d.ts.map +1 -0
  39. package/dist/api/websocket/client.js +207 -0
  40. package/dist/api/websocket/client.js.map +1 -0
  41. package/dist/api/websocket/index.d.ts +7 -0
  42. package/dist/api/websocket/index.d.ts.map +1 -0
  43. package/dist/api/websocket/index.js +7 -0
  44. package/dist/api/websocket/index.js.map +1 -0
  45. package/dist/errors.d.ts.map +1 -1
  46. package/dist/errors.js.map +1 -1
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/networks.js +1 -1
  51. package/dist/networks.js.map +1 -1
  52. package/dist/sdk.d.ts +32 -35
  53. package/dist/sdk.d.ts.map +1 -1
  54. package/dist/sdk.js +113 -127
  55. package/dist/sdk.js.map +1 -1
  56. package/package.json +7 -5
  57. package/dist/chains.d.ts +0 -90
  58. package/dist/chains.d.ts.map +0 -1
  59. package/dist/chains.js +0 -56
  60. package/dist/chains.js.map +0 -1
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Profile API Implementation
3
+ *
4
+ * Handles user profile operations including fetching profile information.
5
+ * All operations use JWT authentication and go through the API Gateway.
6
+ *
7
+ * This class provides a complete interface for profile operations on the Monaco protocol,
8
+ * including fetching user profile data from the /api/v1/accounts/me endpoint.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const profileAPI = new ProfileAPIImpl(apiUrl);
13
+ * profileAPI.setAccessToken(jwtToken);
14
+ *
15
+ * // Get user profile
16
+ * const profile = await profileAPI.getProfile();
17
+ * console.log(`User: ${profile.username} (${profile.address})`);
18
+ * ```
19
+ */
20
+ import { APIError } from "../../errors";
21
+ import { BaseAPI } from "../base";
22
+ export class ProfileAPIImpl extends BaseAPI {
23
+ /**
24
+ * Creates a new ProfileAPI instance.
25
+ *
26
+ * @param apiUrl - The base URL for the Monaco API Gateway
27
+ */
28
+ constructor(apiUrl) {
29
+ super(apiUrl);
30
+ }
31
+ /**
32
+ * Get the current user's profile information.
33
+ *
34
+ * Fetches the profile data for the authenticated user using the /api/v1/accounts/me endpoint.
35
+ * Requires a valid access token to be set.
36
+ *
37
+ * @returns Promise resolving to the user's profile information
38
+ * @throws {APIError} When the request fails or user is not authenticated
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // Set access token first
43
+ * profileAPI.setAccessToken(authResult.accessToken);
44
+ *
45
+ * // Get profile
46
+ * const profile = await profileAPI.getProfile();
47
+ * console.log(`User ID: ${profile.id}`);
48
+ * console.log(`Address: ${profile.address}`);
49
+ * console.log(`Username: ${profile.username}`);
50
+ * console.log(`Account type: ${profile.account_type}`);
51
+ * console.log(`Can withdraw: ${profile.can_withdraw}`);
52
+ * ```
53
+ */
54
+ async getProfile() {
55
+ try {
56
+ const data = await this.makeAuthenticatedRequest("/api/v1/accounts/me");
57
+ return {
58
+ id: data.id,
59
+ address: data.address,
60
+ username: data.username,
61
+ account_type: data.account_type,
62
+ can_withdraw: data.can_withdraw,
63
+ created_at: data.created_at,
64
+ balances: data.balances || [],
65
+ recent_movements: data.recent_movements || [],
66
+ recent_orders: data.recent_orders || [],
67
+ };
68
+ }
69
+ catch (error) {
70
+ if (error instanceof APIError) {
71
+ throw error;
72
+ }
73
+ throw new APIError("Failed to fetch user profile", "/api/v1/accounts/me", undefined);
74
+ }
75
+ }
76
+ }
77
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/api/profile/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,OAAO,cAAe,SAAQ,OAAO;IAC1C;;;;OAIG;IACH,YAAY,MAAc;QACzB,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,UAAU;QACf,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAM,qBAAqB,CAAC,CAAC;YAE7E,OAAO;gBACN,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;gBAC7B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,EAAE;gBAC7C,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,EAAE;aACvC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;gBAC/B,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,IAAI,QAAQ,CACjB,8BAA8B,EAC9B,qBAAqB,EACrB,SAAS,CACT,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Profile API Module
3
+ *
4
+ * Exports the ProfileAPI implementation for user profile operations.
5
+ */
6
+ export * from "./api";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/profile/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Profile API Module
3
+ *
4
+ * Exports the ProfileAPI implementation for user profile operations.
5
+ */
6
+ export * from "./api";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/profile/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAC"}
@@ -24,30 +24,15 @@
24
24
  * const openOrders = await tradingAPI.getOpenOrders({ market: "ETH-USD" });
25
25
  * ```
26
26
  */
27
- import type { TradingAPI, CreateOrderResponse, CancelOrderResponse, UpdateOrderResponse, OrderSide } from "@0xmonaco/types";
28
- export declare class TradingAPIImpl implements TradingAPI {
29
- private readonly apiUrl;
30
- private accessToken?;
27
+ import type { TradingAPI, CreateOrderResponse, CancelOrderResponse, UpdateOrderResponse, ReplaceOrderResponse, GetPaginatedOrdersResponse, GetPaginatedOrdersParams, GetOrderResponse, OrderSide } from "@0xmonaco/types";
28
+ import { BaseAPI } from "../base";
29
+ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
31
30
  /**
32
31
  * Creates a new TradingAPI instance.
33
32
  *
34
33
  * @param apiUrl - The base URL for the Monaco API Gateway
35
34
  */
36
35
  constructor(apiUrl: string);
37
- /**
38
- * Set the access token for the TradingAPI
39
- * @param token - The access token to set
40
- */
41
- setAccessToken(token: string): void;
42
- /**
43
- * Internal method to make authenticated API requests.
44
- *
45
- * @param endpoint - The API endpoint to call
46
- * @param options - Request options
47
- * @returns Promise resolving to the response data
48
- * @throws {APIError} When API communication fails
49
- */
50
- private makeRequest;
51
36
  /**
52
37
  * Places a limit order on the order book.
53
38
  *
@@ -60,22 +45,38 @@ export declare class TradingAPIImpl implements TradingAPI {
60
45
  * @param price - The limit price as string
61
46
  * @param options - Optional parameters for the limit order
62
47
  * @param options.tradingMode - Trading mode (e.g., "SPOT")
48
+ * @param options.useMasterBalance - Whether to use master balance for sub-accounts
49
+ * @param options.expirationDate - Optional expiration date for GTC orders (ISO 8601 format)
63
50
  * @returns Promise resolving to CreateOrderResponse with order details
64
51
  *
65
52
  * @example
66
53
  * ```typescript
54
+ * // Regular limit order
67
55
  * const order = await tradingAPI.placeLimitOrder(
68
- * "ETH-USD",
56
+ * "BTC-USDC",
69
57
  * "BUY",
70
- * "1.5",
71
- * "2000.50",
58
+ * "0.5",
59
+ * "35000.00",
72
60
  * { tradingMode: "SPOT" }
73
61
  * );
74
- * console.log(`Limit order placed: ${order.order_id}`);
62
+ *
63
+ * // GTC order with custom expiration
64
+ * const gtcOrder = await tradingAPI.placeLimitOrder(
65
+ * "BTC-USDC",
66
+ * "BUY",
67
+ * "0.5",
68
+ * "35000.00",
69
+ * {
70
+ * tradingMode: "SPOT",
71
+ * expirationDate: "2024-12-31T23:59:59Z" // GTC until this date
72
+ * }
73
+ * );
75
74
  * ```
76
75
  */
77
76
  placeLimitOrder(market: string, side: OrderSide, quantity: string, price: string, options?: {
78
77
  tradingMode?: string;
78
+ useMasterBalance?: boolean;
79
+ expirationDate?: string;
79
80
  }): Promise<CreateOrderResponse>;
80
81
  /**
81
82
  * Places a market order for immediate execution.
@@ -148,5 +149,59 @@ export declare class TradingAPIImpl implements TradingAPI {
148
149
  price?: string;
149
150
  quantity?: string;
150
151
  }): Promise<UpdateOrderResponse>;
152
+ replaceOrder(orderId: string, newOrder: {
153
+ price?: string;
154
+ quantity: string;
155
+ useMasterBalance?: boolean;
156
+ }): Promise<ReplaceOrderResponse>;
157
+ /**
158
+ * Gets paginated orders based on query parameters with automatic pagination.
159
+ *
160
+ * Retrieves orders with optional filtering by status, trading pair, and pagination.
161
+ * Pagination parameters are always included with sensible defaults for consistent API behavior.
162
+ *
163
+ * @param params - Query parameters for filtering orders
164
+ * @param params.status - Filter by order status (e.g., "PENDING", "FILLED") (optional)
165
+ * @param params.trading_pair - Filter by trading pair (e.g., "USDCo/MTK") (optional)
166
+ * @param params.page - Page number for pagination (defaults to 1, must be > 0)
167
+ * @param params.page_size - Number of orders per page (defaults to 10, max 100, must be > 0)
168
+ * @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
169
+ * @throws {APIError} When API communication fails
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * // Get pending orders for a specific trading pair with custom pagination
174
+ * const orders = await tradingAPI.getPaginatedOrders({
175
+ * status: "PENDING",
176
+ * trading_pair: "USDCo/MTK",
177
+ * page: 1,
178
+ * page_size: 20
179
+ * });
180
+ * console.log(`Found ${orders.total} orders, showing page ${orders.page}`);
181
+ *
182
+ * // Get all orders with default pagination (page=1, page_size=10)
183
+ * const allOrders = await tradingAPI.getPaginatedOrders();
184
+ * ```
185
+ */
186
+ getPaginatedOrders(params?: GetPaginatedOrdersParams): Promise<GetPaginatedOrdersResponse>;
187
+ /**
188
+ * Gets a single order by its ID.
189
+ *
190
+ * Retrieves detailed information about a specific order using its unique identifier.
191
+ * This endpoint provides complete order details including status, quantities, and timestamps.
192
+ *
193
+ * @param orderId - The unique identifier of the order to retrieve
194
+ * @returns Promise resolving to GetOrderResponse with order details
195
+ * @throws {APIError} When API communication fails or order is not found
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * // Get order details by ID
200
+ * const orderDetails = await tradingAPI.getOrder("order_123");
201
+ * console.log(`Order status: ${orderDetails.order.status}`);
202
+ * console.log(`Remaining quantity: ${orderDetails.order.remaining_quantity}`);
203
+ * ```
204
+ */
205
+ getOrder(orderId: string): Promise<GetOrderResponse>;
151
206
  }
152
207
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/api/trading/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EAEV,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,cAAe,YAAW,UAAU;IAQnC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPnC,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B;;;;OAIG;gBAC0B,MAAM,EAAE,MAAM;IAE3C;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC;;;;;;;OAOG;YACW,WAAW;IAgCzB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,IAA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} from "../../errors";
28
- export class TradingAPIImpl {
28
+ import { BaseAPI } from "../base";
29
+ export class TradingAPIImpl extends BaseAPI {
29
30
  /**
30
31
  * Creates a new TradingAPI instance.
31
32
  *
32
33
  * @param apiUrl - The base URL for the Monaco API Gateway
33
34
  */
34
35
  constructor(apiUrl) {
35
- this.apiUrl = apiUrl;
36
- }
37
- /**
38
- * Set the access token for the TradingAPI
39
- * @param token - The access token to set
40
- */
41
- setAccessToken(token) {
42
- this.accessToken = token;
43
- }
44
- /**
45
- * Internal method to make authenticated API requests.
46
- *
47
- * @param endpoint - The API endpoint to call
48
- * @param options - Request options
49
- * @returns Promise resolving to the response data
50
- * @throws {APIError} When API communication fails
51
- */
52
- async makeRequest(endpoint, options = {}) {
53
- if (!this.accessToken) {
54
- throw new APIError("Access token not set. Call setAccessToken() first.", endpoint, 401);
55
- }
56
- const response = await fetch(`${this.apiUrl}${endpoint}`, {
57
- headers: {
58
- "Content-Type": "application/json",
59
- "Authorization": `Bearer ${this.accessToken}`,
60
- ...options.headers,
61
- },
62
- ...options,
63
- });
64
- if (!response.ok) {
65
- throw new APIError(`API request failed: ${response.status}`, endpoint, response.status);
66
- }
67
- return response.json();
36
+ super(apiUrl);
68
37
  }
69
38
  /**
70
39
  * Places a limit order on the order book.
@@ -78,18 +47,32 @@ export class TradingAPIImpl {
78
47
  * @param price - The limit price as string
79
48
  * @param options - Optional parameters for the limit order
80
49
  * @param options.tradingMode - Trading mode (e.g., "SPOT")
50
+ * @param options.useMasterBalance - Whether to use master balance for sub-accounts
51
+ * @param options.expirationDate - Optional expiration date for GTC orders (ISO 8601 format)
81
52
  * @returns Promise resolving to CreateOrderResponse with order details
82
53
  *
83
54
  * @example
84
55
  * ```typescript
56
+ * // Regular limit order
85
57
  * const order = await tradingAPI.placeLimitOrder(
86
- * "ETH-USD",
58
+ * "BTC-USDC",
87
59
  * "BUY",
88
- * "1.5",
89
- * "2000.50",
60
+ * "0.5",
61
+ * "35000.00",
90
62
  * { tradingMode: "SPOT" }
91
63
  * );
92
- * console.log(`Limit order placed: ${order.order_id}`);
64
+ *
65
+ * // GTC order with custom expiration
66
+ * const gtcOrder = await tradingAPI.placeLimitOrder(
67
+ * "BTC-USDC",
68
+ * "BUY",
69
+ * "0.5",
70
+ * "35000.00",
71
+ * {
72
+ * tradingMode: "SPOT",
73
+ * expirationDate: "2024-12-31T23:59:59Z" // GTC until this date
74
+ * }
75
+ * );
93
76
  * ```
94
77
  */
95
78
  async placeLimitOrder(market, side, quantity, price, options) {
@@ -101,8 +84,10 @@ export class TradingAPIImpl {
101
84
  price,
102
85
  quantity,
103
86
  trading_mode: options?.tradingMode || "SPOT",
87
+ use_master_balance: options?.useMasterBalance,
88
+ expiration_date: options?.expirationDate,
104
89
  };
105
- return await this.makeRequest("/api/v1/orders", {
90
+ return await this.makeAuthenticatedRequest("/api/v1/orders", {
106
91
  method: "POST",
107
92
  body: JSON.stringify(requestBody),
108
93
  });
@@ -144,7 +129,7 @@ export class TradingAPIImpl {
144
129
  quantity,
145
130
  trading_mode: options?.tradingMode || "SPOT",
146
131
  };
147
- return await this.makeRequest("/api/v1/orders", {
132
+ return await this.makeAuthenticatedRequest("/api/v1/orders", {
148
133
  method: "POST",
149
134
  body: JSON.stringify(requestBody),
150
135
  });
@@ -175,7 +160,7 @@ export class TradingAPIImpl {
175
160
  const requestBody = {
176
161
  order_id: orderId,
177
162
  };
178
- return await this.makeRequest("/api/v1/orders/cancel", {
163
+ return await this.makeAuthenticatedRequest("/api/v1/orders/cancel", {
179
164
  method: "POST",
180
165
  body: JSON.stringify(requestBody),
181
166
  });
@@ -216,7 +201,7 @@ export class TradingAPIImpl {
216
201
  if (updates.quantity !== undefined) {
217
202
  requestBody.quantity = updates.quantity;
218
203
  }
219
- return await this.makeRequest(`/api/v1/orders/${orderId}`, {
204
+ return await this.makeAuthenticatedRequest(`/api/v1/orders/${orderId}`, {
220
205
  method: "PUT",
221
206
  body: JSON.stringify(requestBody),
222
207
  });
@@ -225,5 +210,106 @@ export class TradingAPIImpl {
225
210
  throw new OrderError(`Failed to update order ${orderId}: ${error instanceof Error ? error.message : "Unknown error"}`, undefined, orderId);
226
211
  }
227
212
  }
213
+ async replaceOrder(orderId, newOrder) {
214
+ try {
215
+ const requestBody = {
216
+ quantity: newOrder.quantity,
217
+ use_master_balance: newOrder.useMasterBalance ?? false,
218
+ };
219
+ if (newOrder.price !== undefined) {
220
+ requestBody.price = newOrder.price;
221
+ }
222
+ return await this.makeAuthenticatedRequest(`/api/v1/orders/${orderId}`, {
223
+ method: "PUT",
224
+ body: JSON.stringify(requestBody),
225
+ });
226
+ }
227
+ catch (error) {
228
+ throw new OrderError(`Failed to replace order ${orderId}: ${error instanceof Error ? error.message : "Unknown error"}`, undefined, orderId);
229
+ }
230
+ }
231
+ /**
232
+ * Gets paginated orders based on query parameters with automatic pagination.
233
+ *
234
+ * Retrieves orders with optional filtering by status, trading pair, and pagination.
235
+ * Pagination parameters are always included with sensible defaults for consistent API behavior.
236
+ *
237
+ * @param params - Query parameters for filtering orders
238
+ * @param params.status - Filter by order status (e.g., "PENDING", "FILLED") (optional)
239
+ * @param params.trading_pair - Filter by trading pair (e.g., "USDCo/MTK") (optional)
240
+ * @param params.page - Page number for pagination (defaults to 1, must be > 0)
241
+ * @param params.page_size - Number of orders per page (defaults to 10, max 100, must be > 0)
242
+ * @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
243
+ * @throws {APIError} When API communication fails
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * // Get pending orders for a specific trading pair with custom pagination
248
+ * const orders = await tradingAPI.getPaginatedOrders({
249
+ * status: "PENDING",
250
+ * trading_pair: "USDCo/MTK",
251
+ * page: 1,
252
+ * page_size: 20
253
+ * });
254
+ * console.log(`Found ${orders.total} orders, showing page ${orders.page}`);
255
+ *
256
+ * // Get all orders with default pagination (page=1, page_size=10)
257
+ * const allOrders = await tradingAPI.getPaginatedOrders();
258
+ * ```
259
+ */
260
+ async getPaginatedOrders(params) {
261
+ try {
262
+ // Set pagination defaults with destructuring and validation
263
+ const { page = 1, page_size = 10, status, trading_pair } = params || {};
264
+ const validPage = page > 0 ? page : 1;
265
+ const validPageSize = page_size > 0 ? page_size : 10;
266
+ const pageSize = Math.min(validPageSize, 100);
267
+ const searchParams = new URLSearchParams();
268
+ // Always include pagination parameters for consistent API behavior
269
+ searchParams.append("page", validPage.toString());
270
+ searchParams.append("page_size", pageSize.toString());
271
+ if (status) {
272
+ searchParams.append("status", status);
273
+ }
274
+ if (trading_pair) {
275
+ searchParams.append("trading_pair", trading_pair);
276
+ }
277
+ const endpoint = `/api/v1/orders?${searchParams.toString()}`;
278
+ return await this.makeAuthenticatedRequest(endpoint, {
279
+ method: "GET",
280
+ });
281
+ }
282
+ catch (error) {
283
+ throw new APIError(`Failed to get orders: ${error instanceof Error ? error.message : "Unknown error"}`, "/api/v1/orders", undefined);
284
+ }
285
+ }
286
+ /**
287
+ * Gets a single order by its ID.
288
+ *
289
+ * Retrieves detailed information about a specific order using its unique identifier.
290
+ * This endpoint provides complete order details including status, quantities, and timestamps.
291
+ *
292
+ * @param orderId - The unique identifier of the order to retrieve
293
+ * @returns Promise resolving to GetOrderResponse with order details
294
+ * @throws {APIError} When API communication fails or order is not found
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * // Get order details by ID
299
+ * const orderDetails = await tradingAPI.getOrder("order_123");
300
+ * console.log(`Order status: ${orderDetails.order.status}`);
301
+ * console.log(`Remaining quantity: ${orderDetails.order.remaining_quantity}`);
302
+ * ```
303
+ */
304
+ async getOrder(orderId) {
305
+ try {
306
+ return await this.makeAuthenticatedRequest(`/api/v1/orders/${orderId}`, {
307
+ method: "GET",
308
+ });
309
+ }
310
+ catch (error) {
311
+ throw new APIError(`Failed to get order ${orderId}: ${error instanceof Error ? error.message : "Unknown error"}`, `/api/v1/orders/${orderId}`, undefined);
312
+ }
313
+ }
228
314
  }
229
315
  //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"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,CAAC;YAE7D,OAAO,MAAM,IAAI,CAAC,wBAAwB,CAA6B,QAAQ,EAAE;gBAC/E,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,QAAQ,CAChB,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,EACnF,gBAAgB,EAChB,SAAS,CACV,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC5B,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,wBAAwB,CACxC,kBAAkB,OAAO,EAAE,EAC3B;gBACE,MAAM,EAAE,KAAK;aACd,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,QAAQ,CAChB,uBAAuB,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,EAC7F,kBAAkB,OAAO,EAAE,EAC3B,SAAS,CACV,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -27,30 +27,34 @@
27
27
  * console.log(`Deposit transaction: ${result.hash}`);
28
28
  * ```
29
29
  */
30
- import { type PublicClient, type WalletClient, type Address, type Chain } from "viem";
31
- import { type VaultAPI, type Balance, type TransactionResult } from "@0xmonaco/types";
32
- export declare class VaultAPIImpl implements VaultAPI {
30
+ import type { Balance, TransactionResult, VaultAPI } from "@0xmonaco/types";
31
+ import { type Address, type Chain, type PublicClient, type WalletClient } from "viem";
32
+ import { BaseAPI } from "../base";
33
+ export declare class VaultAPIImpl extends BaseAPI implements VaultAPI {
33
34
  private readonly publicClient;
34
35
  private readonly walletClient;
35
- private readonly vaultAddress;
36
- private readonly apiUrl;
37
36
  private readonly chain;
38
- private accessToken?;
37
+ vaultAddress?: Address;
39
38
  /**
40
39
  * Creates a new VaultAPI instance.
41
40
  *
42
41
  * @param publicClient - The viem public client for reading blockchain state
43
42
  * @param walletClient - The viem wallet client for signing transactions
44
- * @param vaultAddress - The address of the Monaco vault contract
45
43
  * @param apiUrl - The base URL for the Monaco API Gateway
46
44
  * @param chain - The blockchain network configuration
47
45
  */
48
- constructor(publicClient: PublicClient, walletClient: WalletClient, vaultAddress: Address, apiUrl: string, chain: Chain);
46
+ constructor(publicClient: PublicClient, walletClient: WalletClient, apiUrl: string, chain: Chain);
49
47
  /**
50
- * Set the access token for the VaultAPI
51
- * @param token - The access token to set
48
+ * Set the address of the vault.
49
+ * @param vaultAddress - Address of the vault
50
+ * @returns void
52
51
  */
53
- setAccessToken(token: string): void;
52
+ setVaultAddress(vaultAddress: Address): void;
53
+ /**
54
+ * Get the address of the vault.
55
+ * @returns Address of the vault
56
+ */
57
+ getVaultAddress(): Address | undefined;
54
58
  /**
55
59
  * Approves the vault contract to spend tokens on behalf of the user.
56
60
  *
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/api/vault/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,KAAK,EAMX,MAAM,MAAM,CAAC;AACd,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AASzB,qBAAa,YAAa,YAAW,QAAQ;IAazC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAhBxB,OAAO,CAAC,WAAW,CAAC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