@0xmonaco/core 0.7.6 → 0.7.7

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/package.json +3 -3
  2. package/dist/api/applications/api.d.ts +0 -43
  3. package/dist/api/applications/api.js +0 -54
  4. package/dist/api/applications/index.d.ts +0 -4
  5. package/dist/api/applications/index.js +0 -4
  6. package/dist/api/auth/api.d.ts +0 -206
  7. package/dist/api/auth/api.js +0 -305
  8. package/dist/api/auth/index.d.ts +0 -4
  9. package/dist/api/auth/index.js +0 -4
  10. package/dist/api/base.d.ts +0 -123
  11. package/dist/api/base.js +0 -286
  12. package/dist/api/fees/api.d.ts +0 -72
  13. package/dist/api/fees/api.js +0 -90
  14. package/dist/api/fees/index.d.ts +0 -6
  15. package/dist/api/fees/index.js +0 -6
  16. package/dist/api/index.d.ts +0 -18
  17. package/dist/api/index.js +0 -18
  18. package/dist/api/margin-accounts/api.d.ts +0 -12
  19. package/dist/api/margin-accounts/api.js +0 -69
  20. package/dist/api/margin-accounts/index.d.ts +0 -1
  21. package/dist/api/margin-accounts/index.js +0 -1
  22. package/dist/api/market/api.d.ts +0 -20
  23. package/dist/api/market/api.js +0 -97
  24. package/dist/api/market/index.d.ts +0 -1
  25. package/dist/api/market/index.js +0 -1
  26. package/dist/api/orderbook/api.d.ts +0 -15
  27. package/dist/api/orderbook/api.js +0 -37
  28. package/dist/api/orderbook/index.d.ts +0 -1
  29. package/dist/api/orderbook/index.js +0 -1
  30. package/dist/api/perp/index.d.ts +0 -1
  31. package/dist/api/perp/index.js +0 -1
  32. package/dist/api/perp/routes.d.ts +0 -133
  33. package/dist/api/perp/routes.js +0 -85
  34. package/dist/api/positions/api.d.ts +0 -12
  35. package/dist/api/positions/api.js +0 -88
  36. package/dist/api/positions/index.d.ts +0 -1
  37. package/dist/api/positions/index.js +0 -1
  38. package/dist/api/profile/api.d.ts +0 -191
  39. package/dist/api/profile/api.js +0 -259
  40. package/dist/api/profile/index.d.ts +0 -6
  41. package/dist/api/profile/index.js +0 -6
  42. package/dist/api/trades/api.d.ts +0 -44
  43. package/dist/api/trades/api.js +0 -42
  44. package/dist/api/trades/index.d.ts +0 -1
  45. package/dist/api/trades/index.js +0 -1
  46. package/dist/api/trading/api.d.ts +0 -297
  47. package/dist/api/trading/api.js +0 -481
  48. package/dist/api/trading/index.d.ts +0 -4
  49. package/dist/api/trading/index.js +0 -4
  50. package/dist/api/vault/api.d.ts +0 -261
  51. package/dist/api/vault/api.js +0 -506
  52. package/dist/api/vault/index.d.ts +0 -4
  53. package/dist/api/vault/index.js +0 -4
  54. package/dist/api/websocket/index.d.ts +0 -3
  55. package/dist/api/websocket/index.js +0 -3
  56. package/dist/api/websocket/types.d.ts +0 -41
  57. package/dist/api/websocket/types.js +0 -0
  58. package/dist/api/websocket/utils.d.ts +0 -8
  59. package/dist/api/websocket/utils.js +0 -22
  60. package/dist/api/websocket/websocket.d.ts +0 -5
  61. package/dist/api/websocket/websocket.js +0 -556
  62. package/dist/errors/errors.d.ts +0 -381
  63. package/dist/errors/errors.js +0 -815
  64. package/dist/errors/index.d.ts +0 -1
  65. package/dist/errors/index.js +0 -1
  66. package/dist/index.d.ts +0 -5
  67. package/dist/index.js +0 -5
  68. package/dist/networks/index.d.ts +0 -1
  69. package/dist/networks/index.js +0 -1
  70. package/dist/networks/networks.d.ts +0 -21
  71. package/dist/networks/networks.js +0 -46
  72. package/dist/sdk.d.ts +0 -134
  73. package/dist/sdk.js +0 -294
  74. package/dist/utils/index.d.ts +0 -1
  75. package/dist/utils/index.js +0 -1
  76. package/dist/utils/magnitude.d.ts +0 -26
  77. package/dist/utils/magnitude.js +0 -31
@@ -1,297 +0,0 @@
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 type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, OrderSide, PositionSide, ReplaceOrderResponse, TimeInForce, TradingAPI, TradingMode } from "@0xmonaco/types";
25
- import { BaseAPI } from "../base";
26
- export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
27
- /**
28
- * Places a limit order on the order book.
29
- *
30
- * Limit orders are executed only when the market price reaches or improves upon
31
- * the specified price. They provide price protection but may not execute immediately.
32
- *
33
- * @param tradingPairId - The trading pair UUID
34
- * @param side - The order side ("BUY" or "SELL")
35
- * @param quantity - The order quantity as string
36
- * @param price - The limit price as string
37
- * @param options - Optional parameters for the limit order
38
- * @param options.tradingMode - Trading mode (e.g., "SPOT")
39
- * @param options.useMasterBalance - Whether to use master balance for sub-accounts
40
- * @param options.expirationDate - Optional expiration date for GTC orders (ISO 8601 format)
41
- * @param options.timeInForce - Time in force ("GTC", "IOC", or "FOK")
42
- * @returns Promise resolving to CreateOrderResponse with order details
43
- *
44
- * @example
45
- * ```typescript
46
- * // Regular limit order
47
- * const order = await tradingAPI.placeLimitOrder(
48
- * "123e4567-e89b-12d3-a456-426614174000",
49
- * "BUY",
50
- * "0.5",
51
- * "35000.00",
52
- * { tradingMode: "SPOT" }
53
- * );
54
- *
55
- * // GTC order with custom expiration
56
- * const gtcOrder = await tradingAPI.placeLimitOrder(
57
- * "123e4567-e89b-12d3-a456-426614174000",
58
- * "BUY",
59
- * "0.5",
60
- * "35000.00",
61
- * {
62
- * tradingMode: "SPOT",
63
- * expirationDate: "2024-12-31T23:59:59Z" // GTC until this date
64
- * }
65
- * );
66
- *
67
- * // IOC order (execute immediately or cancel)
68
- * const iocOrder = await tradingAPI.placeLimitOrder(
69
- * "123e4567-e89b-12d3-a456-426614174000",
70
- * "BUY",
71
- * "0.5",
72
- * "35000.00",
73
- * { timeInForce: "IOC" }
74
- * );
75
- * ```
76
- */
77
- placeLimitOrder(tradingPairId: string, side: OrderSide, quantity: string, price: string, options?: {
78
- tradingMode?: TradingMode;
79
- useMasterBalance?: boolean;
80
- expirationDate?: string;
81
- timeInForce?: TimeInForce;
82
- marginAccountId?: string;
83
- positionSide?: PositionSide;
84
- leverage?: string;
85
- reduceOnly?: boolean;
86
- }): Promise<CreateOrderResponse>;
87
- /**
88
- * Places a market order for immediate execution.
89
- *
90
- * Market orders execute immediately at the current market price. They provide
91
- * immediate execution but may experience slippage.
92
- *
93
- * @param tradingPairId - The trading pair UUID
94
- * @param side - The order side ("BUY" or "SELL")
95
- * @param quantity - The order quantity as string
96
- * @param options - Optional parameters for the market order
97
- * @param options.tradingMode - Trading mode (e.g., "SPOT")
98
- * @param options.slippageTolerance - Slippage tolerance as decimal (e.g., 0.01 for 1%, 0 for best price only, undefined for unlimited slippage)
99
- * @returns Promise resolving to CreateOrderResponse with order details
100
- *
101
- * @example
102
- * ```typescript
103
- * // Market order with 1% slippage tolerance
104
- * const order1 = await tradingAPI.placeMarketOrder(
105
- * "123e4567-e89b-12d3-a456-426614174000",
106
- * "SELL",
107
- * "0.5",
108
- * { tradingMode: "SPOT", slippageTolerance: 0.01 } // 1% slippage
109
- * );
110
- *
111
- * // Market order with zero slippage (only execute at best price)
112
- * const order2 = await tradingAPI.placeMarketOrder(
113
- * "123e4567-e89b-12d3-a456-426614174000",
114
- * "BUY",
115
- * "1.0",
116
- * { slippageTolerance: 0 } // Only execute at best ask price
117
- * );
118
- *
119
- * // Market order with unlimited slippage
120
- * const order3 = await tradingAPI.placeMarketOrder(
121
- * "123e4567-e89b-12d3-a456-426614174000",
122
- * "BUY",
123
- * "1.0"
124
- * // No slippageTolerance specified = unlimited slippage
125
- * );
126
- * ```
127
- */
128
- placeMarketOrder(tradingPairId: string, side: OrderSide, quantity: string, options?: {
129
- tradingMode?: TradingMode;
130
- slippageTolerance?: number;
131
- marginAccountId?: string;
132
- positionSide?: PositionSide;
133
- leverage?: string;
134
- reduceOnly?: boolean;
135
- }): Promise<CreateOrderResponse>;
136
- /**
137
- * Cancels an existing order.
138
- *
139
- * Cancels an open order by its ID. The order must be in an open state to be canceled.
140
- * Canceled orders cannot be recovered.
141
- *
142
- * @param orderId - The ID of the order to cancel
143
- * @returns Promise resolving to CancelOrderResponse with cancellation details
144
- * @throws {APIError} When API communication fails
145
- *
146
- * @example
147
- * ```typescript
148
- * const result = await tradingAPI.cancelOrder("order_123");
149
- * console.log(`Order canceled: ${result.status}`);
150
- * ```
151
- */
152
- cancelOrder(orderId: string): Promise<CancelOrderResponse>;
153
- createConditionalOrder(params: CreateConditionalOrderParams): Promise<CreateConditionalOrderResponse>;
154
- cancelConditionalOrder(conditionalOrderId: string): Promise<CancelConditionalOrderResponse>;
155
- listConditionalOrders(params?: ListConditionalOrdersParams): Promise<ListConditionalOrdersResponse>;
156
- /**
157
- * Batch cancels specific orders by their IDs.
158
- *
159
- * @param orderIds - Array of order IDs to cancel
160
- * @returns Promise resolving to BatchCancelOrdersResponse with cancellation details
161
- * @throws {APIError} When API communication fails
162
- *
163
- * @example
164
- * ```typescript
165
- * const result = await tradingAPI.batchCancel(["order_123", "order_456"]);
166
- * ```
167
- */
168
- batchCancel(orderIds: string[]): Promise<BatchCancelOrdersResponse>;
169
- /**
170
- * Cancels all active orders, optionally filtered by trading pair.
171
- *
172
- * @param tradingPairId - Optional trading pair ID to filter cancellation
173
- * @returns Promise resolving to BatchCancelOrdersResponse with cancellation details
174
- * @throws {APIError} When API communication fails
175
- *
176
- * @example
177
- * ```typescript
178
- * // Cancel all active orders globally
179
- * await tradingAPI.batchCancelAll();
180
- *
181
- * // Cancel all orders for a specific trading pair
182
- * await tradingAPI.batchCancelAll("123e4567-e89b-12d3-a456-426614174000");
183
- * ```
184
- */
185
- batchCancelAll(tradingPairId?: string): Promise<BatchCancelOrdersResponse>;
186
- replaceOrder(orderId: string, newOrder: {
187
- price?: string;
188
- quantity?: string;
189
- useMasterBalance?: boolean;
190
- }): Promise<ReplaceOrderResponse>;
191
- /**
192
- * Batch creates multiple orders in a single request.
193
- *
194
- * Each order is validated and processed through the matching engine.
195
- * Failed orders do not prevent other orders from being created.
196
- *
197
- * @param orders - Array of order parameters to create
198
- * @returns Promise resolving to BatchCreateOrdersResponse with individual results
199
- * @throws {APIError} When API communication fails
200
- *
201
- * @example
202
- * ```typescript
203
- * const result = await tradingAPI.batchCreate([
204
- * {
205
- * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
206
- * orderType: "LIMIT",
207
- * side: "BUY",
208
- * price: "35000.00",
209
- * quantity: "0.5",
210
- * },
211
- * {
212
- * tradingPairId: "123e4567-e89b-12d3-a456-426614174000",
213
- * orderType: "LIMIT",
214
- * side: "SELL",
215
- * price: "36000.00",
216
- * quantity: "0.3",
217
- * },
218
- * ]);
219
- * ```
220
- */
221
- batchCreate(orders: BatchCreateOrderParams[]): Promise<BatchCreateOrdersResponse>;
222
- /**
223
- * Batch replaces multiple orders in a single request.
224
- *
225
- * Each order is canceled and re-created with new parameters.
226
- * Failed replacements do not prevent other orders from being replaced.
227
- *
228
- * @param orders - Array of order replacement parameters
229
- * @returns Promise resolving to BatchReplaceOrdersResponse with individual results
230
- * @throws {APIError} When API communication fails
231
- *
232
- * @example
233
- * ```typescript
234
- * const result = await tradingAPI.batchReplace([
235
- * {
236
- * orderId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
237
- * price: "35500.00",
238
- * quantity: "0.7",
239
- * },
240
- * {
241
- * orderId: "7c9e6679-7425-40de-944b-e07fc1f90ae7",
242
- * price: "36500.00",
243
- * },
244
- * ]);
245
- * ```
246
- */
247
- batchReplace(orders: BatchReplaceOrderParams[]): Promise<BatchReplaceOrdersResponse>;
248
- /**
249
- * Gets paginated orders based on query parameters with automatic pagination.
250
- *
251
- * Retrieves orders with optional filtering by status, trading pair, and pagination.
252
- * Pagination parameters are always included with sensible defaults for consistent API behavior.
253
- *
254
- * @param params - Query parameters for filtering orders
255
- * @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED") (optional)
256
- * @param params.trading_pair_id - Filter by trading pair UUID (optional)
257
- * @param params.page - Page number for pagination (defaults to 1, must be > 0)
258
- * @param params.page_size - Number of orders per page (defaults to 10, max 100, must be > 0)
259
- * @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
260
- * @throws {APIError} When API communication fails
261
- *
262
- * @example
263
- * ```typescript
264
- * // Get submitted orders for a specific trading pair with custom pagination
265
- * const orders = await tradingAPI.getPaginatedOrders({
266
- * status: "SUBMITTED",
267
- * trading_pair_id: "456e7890-e12b-12d3-a456-426614174000",
268
- * page: 1,
269
- * page_size: 20
270
- * });
271
- * console.log(`Found ${orders.total} orders, showing page ${orders.page}`);
272
- *
273
- * // Get all orders with default pagination (page=1, page_size=10)
274
- * const allOrders = await tradingAPI.getPaginatedOrders();
275
- * ```
276
- */
277
- getPaginatedOrders(params?: GetPaginatedOrdersParams): Promise<GetPaginatedOrdersResponse>;
278
- /**
279
- * Gets a single order by its ID.
280
- *
281
- * Retrieves detailed information about a specific order using its unique identifier.
282
- * This endpoint provides complete order details including status, quantities, and timestamps.
283
- *
284
- * @param orderId - The unique identifier of the order to retrieve
285
- * @returns Promise resolving to GetOrderResponse with order details
286
- * @throws {APIError} When API communication fails or order is not found
287
- *
288
- * @example
289
- * ```typescript
290
- * // Get order details by ID
291
- * const orderDetails = await tradingAPI.getOrder("order_123");
292
- * console.log(`Order status: ${orderDetails.order.status}`);
293
- * console.log(`Remaining quantity: ${orderDetails.order.remaining_quantity}`);
294
- * ```
295
- */
296
- getOrder(orderId: string): Promise<GetOrderResponse>;
297
- }