@0xmonaco/core 0.7.7 → 0.7.9

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 (77) hide show
  1. package/dist/api/applications/api.d.ts +43 -0
  2. package/dist/api/applications/api.js +54 -0
  3. package/dist/api/applications/index.d.ts +4 -0
  4. package/dist/api/applications/index.js +4 -0
  5. package/dist/api/auth/api.d.ts +206 -0
  6. package/dist/api/auth/api.js +305 -0
  7. package/dist/api/auth/index.d.ts +4 -0
  8. package/dist/api/auth/index.js +4 -0
  9. package/dist/api/base.d.ts +123 -0
  10. package/dist/api/base.js +286 -0
  11. package/dist/api/fees/api.d.ts +72 -0
  12. package/dist/api/fees/api.js +90 -0
  13. package/dist/api/fees/index.d.ts +6 -0
  14. package/dist/api/fees/index.js +6 -0
  15. package/dist/api/index.d.ts +18 -0
  16. package/dist/api/index.js +18 -0
  17. package/dist/api/margin-accounts/api.d.ts +12 -0
  18. package/dist/api/margin-accounts/api.js +69 -0
  19. package/dist/api/margin-accounts/index.d.ts +1 -0
  20. package/dist/api/margin-accounts/index.js +1 -0
  21. package/dist/api/market/api.d.ts +20 -0
  22. package/dist/api/market/api.js +97 -0
  23. package/dist/api/market/index.d.ts +1 -0
  24. package/dist/api/market/index.js +1 -0
  25. package/dist/api/orderbook/api.d.ts +15 -0
  26. package/dist/api/orderbook/api.js +37 -0
  27. package/dist/api/orderbook/index.d.ts +1 -0
  28. package/dist/api/orderbook/index.js +1 -0
  29. package/dist/api/perp/index.d.ts +1 -0
  30. package/dist/api/perp/index.js +1 -0
  31. package/dist/api/perp/routes.d.ts +133 -0
  32. package/dist/api/perp/routes.js +85 -0
  33. package/dist/api/positions/api.d.ts +12 -0
  34. package/dist/api/positions/api.js +86 -0
  35. package/dist/api/positions/index.d.ts +1 -0
  36. package/dist/api/positions/index.js +1 -0
  37. package/dist/api/profile/api.d.ts +191 -0
  38. package/dist/api/profile/api.js +259 -0
  39. package/dist/api/profile/index.d.ts +6 -0
  40. package/dist/api/profile/index.js +6 -0
  41. package/dist/api/trades/api.d.ts +44 -0
  42. package/dist/api/trades/api.js +42 -0
  43. package/dist/api/trades/index.d.ts +1 -0
  44. package/dist/api/trades/index.js +1 -0
  45. package/dist/api/trading/api.d.ts +301 -0
  46. package/dist/api/trading/api.js +497 -0
  47. package/dist/api/trading/index.d.ts +4 -0
  48. package/dist/api/trading/index.js +4 -0
  49. package/dist/api/vault/api.d.ts +261 -0
  50. package/dist/api/vault/api.js +506 -0
  51. package/dist/api/vault/index.d.ts +4 -0
  52. package/dist/api/vault/index.js +4 -0
  53. package/dist/api/websocket/index.d.ts +3 -0
  54. package/dist/api/websocket/index.js +3 -0
  55. package/dist/api/websocket/types.d.ts +41 -0
  56. package/dist/api/websocket/types.js +0 -0
  57. package/dist/api/websocket/utils.d.ts +8 -0
  58. package/dist/api/websocket/utils.js +22 -0
  59. package/dist/api/websocket/websocket.d.ts +5 -0
  60. package/dist/api/websocket/websocket.js +560 -0
  61. package/dist/errors/errors.d.ts +381 -0
  62. package/dist/errors/errors.js +815 -0
  63. package/dist/errors/index.d.ts +1 -0
  64. package/dist/errors/index.js +1 -0
  65. package/dist/index.d.ts +5 -0
  66. package/dist/index.js +5 -0
  67. package/dist/networks/index.d.ts +1 -0
  68. package/dist/networks/index.js +1 -0
  69. package/dist/networks/networks.d.ts +21 -0
  70. package/dist/networks/networks.js +46 -0
  71. package/dist/sdk.d.ts +134 -0
  72. package/dist/sdk.js +294 -0
  73. package/dist/utils/index.d.ts +1 -0
  74. package/dist/utils/index.js +1 -0
  75. package/dist/utils/magnitude.d.ts +26 -0
  76. package/dist/utils/magnitude.js +31 -0
  77. package/package.json +3 -3
@@ -0,0 +1,497 @@
1
+ /**
2
+ * Trading API Implementation
3
+ *
4
+ * Handles trading operations including order placement and management.
5
+ * All operations use JWT authentication and go through the API Gateway.
6
+ *
7
+ * This class provides a complete interface for trading operations on the Monaco protocol,
8
+ * including various order types, order management, and position operations.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const tradingAPI = new TradingAPIImpl(apiUrl);
13
+ * tradingAPI.setAccessToken(jwtToken);
14
+ *
15
+ * // Place a limit order
16
+ * const order = await tradingAPI.placeLimitOrder(
17
+ * "123e4567-e89b-12d3-a456-426614174000", // trading pair UUID
18
+ * "BUY",
19
+ * "1.5",
20
+ * "2000.50"
21
+ * );
22
+ * ```
23
+ */
24
+ import { BatchCreateOrdersSchema, BatchReplaceOrdersSchema, CancelConditionalOrderSchema, CancelOrderSchema, CreateConditionalOrderSchema, GetPaginatedOrdersSchema, ListConditionalOrdersSchema, PlaceLimitOrderSchema, PlaceMarketOrderSchema, ReplaceOrderSchema, validate, } from "@0xmonaco/types";
25
+ import { BaseAPI } from "../base";
26
+ import { perpRoutes } from "../perp";
27
+ function parentTpSlLegToRequest(leg) {
28
+ if (!leg)
29
+ return undefined;
30
+ return {
31
+ trigger_price: leg.triggerPrice,
32
+ order_type: leg.orderType,
33
+ limit_price: leg.limitPrice,
34
+ time_in_force: leg.timeInForce,
35
+ slippage_tolerance_bps: leg.slippageToleranceBps,
36
+ expires_at: leg.expiresAt,
37
+ };
38
+ }
39
+ export class TradingAPIImpl extends BaseAPI {
40
+ /**
41
+ * Places a limit order on the order book.
42
+ *
43
+ * Limit orders are executed only when the market price reaches or improves upon
44
+ * the specified price. They provide price protection but may not execute immediately.
45
+ *
46
+ * @param tradingPairId - The trading pair UUID
47
+ * @param side - The order side ("BUY" or "SELL")
48
+ * @param quantity - The order quantity as string
49
+ * @param price - The limit price as string
50
+ * @param options - Optional parameters for the limit order
51
+ * @param options.tradingMode - Trading mode (e.g., "SPOT")
52
+ * @param options.useMasterBalance - Whether to use master balance for sub-accounts
53
+ * @param options.expirationDate - Optional expiration date for GTC orders (ISO 8601 format)
54
+ * @param options.timeInForce - Time in force ("GTC", "IOC", or "FOK")
55
+ * @returns Promise resolving to CreateOrderResponse with order details
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * // Regular limit order
60
+ * const order = await tradingAPI.placeLimitOrder(
61
+ * "123e4567-e89b-12d3-a456-426614174000",
62
+ * "BUY",
63
+ * "0.5",
64
+ * "35000.00",
65
+ * { tradingMode: "SPOT" }
66
+ * );
67
+ *
68
+ * // GTC order with custom expiration
69
+ * const gtcOrder = await tradingAPI.placeLimitOrder(
70
+ * "123e4567-e89b-12d3-a456-426614174000",
71
+ * "BUY",
72
+ * "0.5",
73
+ * "35000.00",
74
+ * {
75
+ * tradingMode: "SPOT",
76
+ * expirationDate: "2024-12-31T23:59:59Z" // GTC until this date
77
+ * }
78
+ * );
79
+ *
80
+ * // IOC order (execute immediately or cancel)
81
+ * const iocOrder = await tradingAPI.placeLimitOrder(
82
+ * "123e4567-e89b-12d3-a456-426614174000",
83
+ * "BUY",
84
+ * "0.5",
85
+ * "35000.00",
86
+ * { timeInForce: "IOC" }
87
+ * );
88
+ * ```
89
+ */
90
+ async placeLimitOrder(tradingPairId, side, quantity, price, options) {
91
+ // Validate inputs before making API call
92
+ validate(PlaceLimitOrderSchema, {
93
+ tradingPairId,
94
+ side,
95
+ quantity,
96
+ price,
97
+ options,
98
+ });
99
+ const requestBody = {
100
+ trading_pair_id: tradingPairId,
101
+ order_type: "LIMIT",
102
+ side,
103
+ price,
104
+ quantity,
105
+ trading_mode: options?.tradingMode || "SPOT",
106
+ use_master_balance: options?.useMasterBalance,
107
+ expiration_date: options?.expirationDate,
108
+ time_in_force: options?.timeInForce,
109
+ margin_account_id: options?.marginAccountId,
110
+ position_side: options?.positionSide,
111
+ leverage: options?.leverage,
112
+ reduce_only: options?.reduceOnly,
113
+ take_profit: parentTpSlLegToRequest(options?.takeProfit),
114
+ stop_loss: parentTpSlLegToRequest(options?.stopLoss),
115
+ };
116
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.create(), {
117
+ method: "POST",
118
+ body: JSON.stringify(requestBody),
119
+ });
120
+ }
121
+ /**
122
+ * Places a market order for immediate execution.
123
+ *
124
+ * Market orders execute immediately at the current market price. They provide
125
+ * immediate execution but may experience slippage.
126
+ *
127
+ * @param tradingPairId - The trading pair UUID
128
+ * @param side - The order side ("BUY" or "SELL")
129
+ * @param quantity - The order quantity as string
130
+ * @param options - Optional parameters for the market order
131
+ * @param options.tradingMode - Trading mode (e.g., "SPOT")
132
+ * @param options.slippageTolerance - Slippage tolerance as decimal (e.g., 0.01 for 1%, 0 for best price only, undefined for unlimited slippage)
133
+ * @returns Promise resolving to CreateOrderResponse with order details
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * // Market order with 1% slippage tolerance
138
+ * const order1 = await tradingAPI.placeMarketOrder(
139
+ * "123e4567-e89b-12d3-a456-426614174000",
140
+ * "SELL",
141
+ * "0.5",
142
+ * { tradingMode: "SPOT", slippageTolerance: 0.01 } // 1% slippage
143
+ * );
144
+ *
145
+ * // Market order with zero slippage (only execute at best price)
146
+ * const order2 = await tradingAPI.placeMarketOrder(
147
+ * "123e4567-e89b-12d3-a456-426614174000",
148
+ * "BUY",
149
+ * "1.0",
150
+ * { slippageTolerance: 0 } // Only execute at best ask price
151
+ * );
152
+ *
153
+ * // Market order with unlimited slippage
154
+ * const order3 = await tradingAPI.placeMarketOrder(
155
+ * "123e4567-e89b-12d3-a456-426614174000",
156
+ * "BUY",
157
+ * "1.0"
158
+ * // No slippageTolerance specified = unlimited slippage
159
+ * );
160
+ * ```
161
+ */
162
+ async placeMarketOrder(tradingPairId, side, quantity, options) {
163
+ // Validate inputs before making API call
164
+ validate(PlaceMarketOrderSchema, {
165
+ tradingPairId,
166
+ side,
167
+ quantity,
168
+ options,
169
+ });
170
+ const requestBody = {
171
+ trading_pair_id: tradingPairId,
172
+ order_type: "MARKET",
173
+ side,
174
+ slippage_tolerance_bps: options?.slippageTolerance !== undefined ? Math.round(options.slippageTolerance * 10000) : undefined,
175
+ price: null, // Market orders don't need price
176
+ quantity,
177
+ trading_mode: options?.tradingMode || "SPOT",
178
+ margin_account_id: options?.marginAccountId,
179
+ position_side: options?.positionSide,
180
+ leverage: options?.leverage,
181
+ reduce_only: options?.reduceOnly,
182
+ take_profit: parentTpSlLegToRequest(options?.takeProfit),
183
+ stop_loss: parentTpSlLegToRequest(options?.stopLoss),
184
+ };
185
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.create(), {
186
+ method: "POST",
187
+ body: JSON.stringify(requestBody),
188
+ });
189
+ }
190
+ /**
191
+ * Cancels an existing order.
192
+ *
193
+ * Cancels an open order by its ID. The order must be in an open state to be canceled.
194
+ * Canceled orders cannot be recovered.
195
+ *
196
+ * @param orderId - The ID of the order to cancel
197
+ * @returns Promise resolving to CancelOrderResponse with cancellation details
198
+ * @throws {APIError} When API communication fails
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const result = await tradingAPI.cancelOrder("order_123");
203
+ * console.log(`Order canceled: ${result.status}`);
204
+ * ```
205
+ */
206
+ async cancelOrder(orderId) {
207
+ // Validate inputs before making API call
208
+ validate(CancelOrderSchema, { orderId });
209
+ const requestBody = {
210
+ order_id: orderId,
211
+ };
212
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.cancel(), {
213
+ method: "POST",
214
+ body: JSON.stringify(requestBody),
215
+ });
216
+ }
217
+ async createConditionalOrder(params) {
218
+ validate(CreateConditionalOrderSchema, params);
219
+ const requestBody = {
220
+ trading_pair_id: params.tradingPairId,
221
+ margin_account_id: params.marginAccountId,
222
+ condition_type: params.conditionType,
223
+ trigger_price: params.triggerPrice,
224
+ trigger_source: params.triggerSource ?? "MARK_PRICE",
225
+ side: params.side,
226
+ position_side: params.positionSide,
227
+ order_type: params.orderType,
228
+ limit_price: params.limitPrice,
229
+ quantity: params.quantity,
230
+ reduce_only: params.reduceOnly ?? true,
231
+ time_in_force: params.timeInForce,
232
+ slippage_tolerance_bps: params.slippageToleranceBps,
233
+ expires_at: params.expiresAt,
234
+ };
235
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.createConditional(), {
236
+ method: "POST",
237
+ body: JSON.stringify(requestBody),
238
+ });
239
+ }
240
+ async cancelConditionalOrder(conditionalOrderId) {
241
+ validate(CancelConditionalOrderSchema, { conditionalOrderId });
242
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.cancelConditional(conditionalOrderId), {
243
+ method: "DELETE",
244
+ });
245
+ }
246
+ async listConditionalOrders(params) {
247
+ if (params) {
248
+ validate(ListConditionalOrdersSchema, params);
249
+ }
250
+ const { page = 1, page_size = 20, margin_account_id, trading_pair_id, state } = params || {};
251
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.listConditional({
252
+ page,
253
+ page_size: Math.min(Math.max(page_size, 1), 100),
254
+ margin_account_id,
255
+ trading_pair_id,
256
+ state,
257
+ }), { method: "GET" });
258
+ }
259
+ /**
260
+ * Batch cancels specific orders by their IDs.
261
+ *
262
+ * @param orderIds - Array of order IDs to cancel
263
+ * @returns Promise resolving to BatchCancelOrdersResponse with cancellation details
264
+ * @throws {APIError} When API communication fails
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * const result = await tradingAPI.batchCancel(["order_123", "order_456"]);
269
+ * ```
270
+ */
271
+ async batchCancel(orderIds) {
272
+ if (!orderIds || orderIds.length === 0) {
273
+ throw new Error("orderIds is required and must not be empty");
274
+ }
275
+ return this.makeAuthenticatedRequest(perpRoutes.orders.batchCancel(), {
276
+ method: "POST",
277
+ body: JSON.stringify({ order_ids: orderIds }),
278
+ });
279
+ }
280
+ /**
281
+ * Cancels all active orders, optionally filtered by trading pair.
282
+ *
283
+ * @param tradingPairId - Optional trading pair ID to filter cancellation
284
+ * @returns Promise resolving to BatchCancelOrdersResponse with cancellation details
285
+ * @throws {APIError} When API communication fails
286
+ *
287
+ * @example
288
+ * ```typescript
289
+ * // Cancel all active orders globally
290
+ * await tradingAPI.batchCancelAll();
291
+ *
292
+ * // Cancel all orders for a specific trading pair
293
+ * await tradingAPI.batchCancelAll("123e4567-e89b-12d3-a456-426614174000");
294
+ * ```
295
+ */
296
+ async batchCancelAll(tradingPairId) {
297
+ const endpoint = tradingPairId ? perpRoutes.orders.batchCancelAllByPair(tradingPairId) : perpRoutes.orders.batchCancelAll();
298
+ return this.makeAuthenticatedRequest(endpoint, {
299
+ method: "POST",
300
+ });
301
+ }
302
+ async replaceOrder(orderId, newOrder) {
303
+ // Validate inputs before making API call
304
+ validate(ReplaceOrderSchema, { orderId, newOrder });
305
+ const requestBody = {
306
+ use_master_balance: newOrder.useMasterBalance ?? false,
307
+ };
308
+ if (newOrder.price !== undefined) {
309
+ requestBody.price = newOrder.price;
310
+ }
311
+ if (newOrder.quantity !== undefined) {
312
+ requestBody.quantity = newOrder.quantity;
313
+ }
314
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.replace(orderId), {
315
+ method: "PUT",
316
+ body: JSON.stringify(requestBody),
317
+ });
318
+ }
319
+ /**
320
+ * Batch creates multiple orders in a single request.
321
+ *
322
+ * Each order is validated and processed through the matching engine.
323
+ * Failed orders do not prevent other orders from being created.
324
+ *
325
+ * @param orders - Array of order parameters to create
326
+ * @returns Promise resolving to BatchCreateOrdersResponse with individual results
327
+ * @throws {APIError} When API communication fails
328
+ *
329
+ * @example
330
+ * ```typescript
331
+ * const result = await tradingAPI.batchCreate([
332
+ * {
333
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
334
+ * orderType: "LIMIT",
335
+ * side: "BUY",
336
+ * price: "35000.00",
337
+ * quantity: "0.5",
338
+ * },
339
+ * {
340
+ * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
341
+ * orderType: "LIMIT",
342
+ * side: "SELL",
343
+ * price: "36000.00",
344
+ * quantity: "0.3",
345
+ * },
346
+ * ]);
347
+ * ```
348
+ */
349
+ async batchCreate(orders) {
350
+ validate(BatchCreateOrdersSchema, { orders });
351
+ const requestBody = {
352
+ orders: orders.map((order) => ({
353
+ trading_pair_id: order.tradingPairId,
354
+ order_type: order.orderType,
355
+ side: order.side,
356
+ price: order.price,
357
+ quantity: order.quantity,
358
+ trading_mode: order.tradingMode || "SPOT",
359
+ slippage_tolerance_bps: order.slippageTolerance !== undefined ? Math.round(order.slippageTolerance * 10000) : undefined,
360
+ use_master_balance: order.useMasterBalance,
361
+ expiration_date: order.expirationDate,
362
+ time_in_force: order.timeInForce,
363
+ margin_account_id: order.marginAccountId,
364
+ position_side: order.positionSide,
365
+ leverage: order.leverage,
366
+ reduce_only: order.reduceOnly,
367
+ })),
368
+ };
369
+ return this.makeAuthenticatedRequest(perpRoutes.orders.batchCreate(), {
370
+ method: "POST",
371
+ body: JSON.stringify(requestBody),
372
+ });
373
+ }
374
+ /**
375
+ * Batch replaces multiple orders in a single request.
376
+ *
377
+ * Each order is canceled and re-created with new parameters.
378
+ * Failed replacements do not prevent other orders from being replaced.
379
+ *
380
+ * @param orders - Array of order replacement parameters
381
+ * @returns Promise resolving to BatchReplaceOrdersResponse with individual results
382
+ * @throws {APIError} When API communication fails
383
+ *
384
+ * @example
385
+ * ```typescript
386
+ * const result = await tradingAPI.batchReplace([
387
+ * {
388
+ * orderId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
389
+ * price: "35500.00",
390
+ * quantity: "0.7",
391
+ * },
392
+ * {
393
+ * orderId: "7c9e6679-7425-40de-944b-e07fc1f90ae7",
394
+ * price: "36500.00",
395
+ * },
396
+ * ]);
397
+ * ```
398
+ */
399
+ async batchReplace(orders) {
400
+ validate(BatchReplaceOrdersSchema, { orders });
401
+ const requestBody = {
402
+ orders: orders.map((order) => ({
403
+ order_id: order.orderId,
404
+ price: order.price,
405
+ quantity: order.quantity,
406
+ use_master_balance: order.useMasterBalance,
407
+ })),
408
+ };
409
+ return this.makeAuthenticatedRequest(perpRoutes.orders.batchReplace(), {
410
+ method: "POST",
411
+ body: JSON.stringify(requestBody),
412
+ });
413
+ }
414
+ /**
415
+ * Gets paginated orders based on query parameters with automatic pagination.
416
+ *
417
+ * Retrieves orders with optional filtering by status, trading pair, and pagination.
418
+ * Pagination parameters are always included with sensible defaults for consistent API behavior.
419
+ *
420
+ * @param params - Query parameters for filtering orders
421
+ * @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED") (optional)
422
+ * @param params.trading_pair_id - Filter by trading pair UUID (optional)
423
+ * @param params.page - Page number for pagination (defaults to 1, must be > 0)
424
+ * @param params.page_size - Number of orders per page (defaults to 10, max 100, must be > 0)
425
+ * @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
426
+ * @throws {APIError} When API communication fails
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * // Get submitted orders for a specific trading pair with custom pagination
431
+ * const orders = await tradingAPI.getPaginatedOrders({
432
+ * status: "SUBMITTED",
433
+ * trading_pair_id: "456e7890-e12b-12d3-a456-426614174000",
434
+ * page: 1,
435
+ * page_size: 20
436
+ * });
437
+ * console.log(`Found ${orders.total} orders, showing page ${orders.page}`);
438
+ *
439
+ * // Get all orders with default pagination (page=1, page_size=10)
440
+ * const allOrders = await tradingAPI.getPaginatedOrders();
441
+ * ```
442
+ */
443
+ async getPaginatedOrders(params) {
444
+ // Validate inputs before making API call
445
+ if (params) {
446
+ validate(GetPaginatedOrdersSchema, params);
447
+ }
448
+ // Set pagination defaults with destructuring and validation
449
+ const { page = 1, page_size = 10, status, trading_pair_id, trading_mode, margin_account_id } = params || {};
450
+ const validPage = page > 0 ? page : 1;
451
+ const validPageSize = page_size > 0 ? page_size : 10;
452
+ const pageSize = Math.min(validPageSize, 100);
453
+ const searchParams = new URLSearchParams();
454
+ // Always include pagination parameters for consistent API behavior
455
+ searchParams.append("page", validPage.toString());
456
+ searchParams.append("page_size", pageSize.toString());
457
+ if (status) {
458
+ searchParams.append("status", status);
459
+ }
460
+ if (trading_pair_id) {
461
+ searchParams.append("trading_pair_id", trading_pair_id);
462
+ }
463
+ if (trading_mode) {
464
+ searchParams.append("trading_mode", trading_mode);
465
+ }
466
+ if (margin_account_id) {
467
+ searchParams.append("margin_account_id", margin_account_id);
468
+ }
469
+ const endpoint = `/api/v1/orders?${searchParams.toString()}`;
470
+ return await this.makeAuthenticatedRequest(endpoint, {
471
+ method: "GET",
472
+ });
473
+ }
474
+ /**
475
+ * Gets a single order by its ID.
476
+ *
477
+ * Retrieves detailed information about a specific order using its unique identifier.
478
+ * This endpoint provides complete order details including status, quantities, and timestamps.
479
+ *
480
+ * @param orderId - The unique identifier of the order to retrieve
481
+ * @returns Promise resolving to GetOrderResponse with order details
482
+ * @throws {APIError} When API communication fails or order is not found
483
+ *
484
+ * @example
485
+ * ```typescript
486
+ * // Get order details by ID
487
+ * const orderDetails = await tradingAPI.getOrder("order_123");
488
+ * console.log(`Order status: ${orderDetails.order.status}`);
489
+ * console.log(`Remaining quantity: ${orderDetails.order.remaining_quantity}`);
490
+ * ```
491
+ */
492
+ async getOrder(orderId) {
493
+ return await this.makeAuthenticatedRequest(perpRoutes.orders.get(orderId), {
494
+ method: "GET",
495
+ });
496
+ }
497
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Trading API Module
3
+ */
4
+ export { TradingAPIImpl } from "./api";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Trading API Module
3
+ */
4
+ export { TradingAPIImpl } from "./api";