@0xmonaco/core 0.8.14 → 0.8.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/applications/api.js +4 -4
- package/dist/api/auth/api.d.ts +1 -1
- package/dist/api/auth/api.js +10 -10
- package/dist/api/base.d.ts +2 -2
- package/dist/api/base.js +2 -2
- package/dist/api/delegated-agents/api.js +12 -12
- package/dist/api/faucet/api.d.ts +1 -1
- package/dist/api/faucet/api.js +1 -1
- package/dist/api/fees/api.d.ts +13 -13
- package/dist/api/fees/api.js +18 -18
- package/dist/api/margin-accounts/api.js +23 -23
- package/dist/api/market/api.js +16 -16
- package/dist/api/orderbook/api.js +13 -13
- package/dist/api/perp/routes.d.ts +57 -53
- package/dist/api/perp/routes.js +1 -0
- package/dist/api/positions/api.js +19 -19
- package/dist/api/profile/api.d.ts +23 -23
- package/dist/api/profile/api.js +46 -46
- package/dist/api/sub-accounts/api.d.ts +2 -2
- package/dist/api/sub-accounts/api.js +2 -2
- package/dist/api/trades/api.d.ts +11 -11
- package/dist/api/trades/api.js +10 -10
- package/dist/api/trading/api.d.ts +6 -6
- package/dist/api/trading/api.js +69 -69
- package/dist/api/vault/api.js +4 -4
- package/dist/api/whitelist/api.d.ts +2 -2
- package/dist/api/whitelist/api.js +2 -2
- package/dist/api/withdrawals/api.d.ts +3 -2
- package/dist/api/withdrawals/api.js +7 -2
- package/dist/coverage.d.ts +1 -0
- package/dist/coverage.js +1 -0
- package/dist/sdk.js +3 -3
- package/package.json +3 -3
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
|
-
* const {
|
|
13
|
-
* await sdk.subAccounts.createLimit({
|
|
12
|
+
* const { subAccounts } = await sdk.subAccounts.list();
|
|
13
|
+
* await sdk.subAccounts.createLimit({ subAccountId, assetId, maxAmount: "1000.00" });
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
import { BaseAPI } from "../base";
|
package/dist/api/trades/api.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import type { TradeEvent } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
/**
|
|
4
|
-
* Raw trade event from the API (
|
|
4
|
+
* Raw trade event from the API (camelCase wire shape).
|
|
5
5
|
*/
|
|
6
6
|
interface RawTradeEvent {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
eventType: string;
|
|
8
|
+
tradingPairId: string;
|
|
9
|
+
tradingMode: string;
|
|
10
10
|
data: {
|
|
11
|
-
|
|
11
|
+
tradeId: string;
|
|
12
12
|
price: string;
|
|
13
13
|
quantity: string;
|
|
14
14
|
/** Raw (integer) quantity; present on single-trade lookups, ignored when mapping */
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
quantityRaw?: string;
|
|
16
|
+
makerSide: string;
|
|
17
17
|
/** Absent when the trade has no recorded execution time */
|
|
18
|
-
|
|
18
|
+
executedAt?: string;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Convert a raw trade event
|
|
22
|
+
* Convert a raw wire trade event to an ergonomic TradeEvent.
|
|
23
23
|
*/
|
|
24
24
|
export declare function parseRawTradeEvent(raw: RawTradeEvent): TradeEvent;
|
|
25
25
|
/**
|
|
@@ -29,7 +29,7 @@ export interface GetTradesOptions {
|
|
|
29
29
|
/** Page number (starts from 1, default: 1) */
|
|
30
30
|
page?: number;
|
|
31
31
|
/** Maximum number of records to return (default: 25, max: 100) */
|
|
32
|
-
|
|
32
|
+
pageSize?: number;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Trades API for fetching historical trade data
|
|
@@ -40,7 +40,7 @@ export declare class TradesAPIImpl extends BaseAPI {
|
|
|
40
40
|
*
|
|
41
41
|
* @param tradingPairId - The trading pair UUID
|
|
42
42
|
* @param options - Pagination options
|
|
43
|
-
* @returns Array of TradeEvent records sorted by
|
|
43
|
+
* @returns Array of TradeEvent records sorted by executedAt descending (newest first)
|
|
44
44
|
*/
|
|
45
45
|
getTrades(tradingPairId: string, options?: GetTradesOptions): Promise<TradeEvent[]>;
|
|
46
46
|
/**
|
package/dist/api/trades/api.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { BaseAPI } from "../base";
|
|
2
2
|
import { perpRoutes } from "../perp";
|
|
3
3
|
/**
|
|
4
|
-
* Convert a raw trade event
|
|
4
|
+
* Convert a raw wire trade event to an ergonomic TradeEvent.
|
|
5
5
|
*/
|
|
6
6
|
export function parseRawTradeEvent(raw) {
|
|
7
7
|
return {
|
|
8
8
|
eventType: "trade",
|
|
9
|
-
tradingPairId: raw.
|
|
10
|
-
tradingMode: raw.
|
|
9
|
+
tradingPairId: raw.tradingPairId,
|
|
10
|
+
tradingMode: raw.tradingMode.toUpperCase(),
|
|
11
11
|
data: {
|
|
12
|
-
tradeId: raw.data.
|
|
12
|
+
tradeId: raw.data.tradeId,
|
|
13
13
|
price: raw.data.price,
|
|
14
14
|
quantity: raw.data.quantity,
|
|
15
|
-
makerSide: raw.data.
|
|
16
|
-
executedAt: raw.data.
|
|
15
|
+
makerSide: raw.data.makerSide.toUpperCase(),
|
|
16
|
+
executedAt: raw.data.executedAt ?? "",
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
}
|
|
@@ -26,17 +26,17 @@ export class TradesAPIImpl extends BaseAPI {
|
|
|
26
26
|
*
|
|
27
27
|
* @param tradingPairId - The trading pair UUID
|
|
28
28
|
* @param options - Pagination options
|
|
29
|
-
* @returns Array of TradeEvent records sorted by
|
|
29
|
+
* @returns Array of TradeEvent records sorted by executedAt descending (newest first)
|
|
30
30
|
*/
|
|
31
31
|
async getTrades(tradingPairId, options = {}) {
|
|
32
32
|
const { page = 1 } = options;
|
|
33
|
-
// Ensure
|
|
34
|
-
const
|
|
33
|
+
// Ensure pageSize is a positive number between 1 and 100, defaulting to 25
|
|
34
|
+
const pageSize = options.pageSize != null && options.pageSize > 0 ? Math.min(options.pageSize, 100) : 25;
|
|
35
35
|
const params = new URLSearchParams();
|
|
36
36
|
if (page > 1) {
|
|
37
37
|
params.set("page", String(page));
|
|
38
38
|
}
|
|
39
|
-
params.set("
|
|
39
|
+
params.set("pageSize", String(pageSize));
|
|
40
40
|
const response = await this.makePublicRequest(`/api/v1/trades/${encodeURIComponent(tradingPairId)}?${params.toString()}`);
|
|
41
41
|
return response.trades.map(parseRawTradeEvent);
|
|
42
42
|
}
|
|
@@ -262,9 +262,9 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
262
262
|
*
|
|
263
263
|
* @param params - Query parameters for filtering orders
|
|
264
264
|
* @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED") (optional)
|
|
265
|
-
* @param params.
|
|
265
|
+
* @param params.tradingPairId - Filter by trading pair UUID (optional)
|
|
266
266
|
* @param params.page - Page number for pagination (defaults to 1, must be > 0)
|
|
267
|
-
* @param params.
|
|
267
|
+
* @param params.pageSize - Number of orders per page (defaults to 10, max 100, must be > 0)
|
|
268
268
|
* @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
|
|
269
269
|
* @throws {APIError} When API communication fails
|
|
270
270
|
*
|
|
@@ -273,13 +273,13 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
273
273
|
* // Get submitted orders for a specific trading pair with custom pagination
|
|
274
274
|
* const orders = await tradingAPI.getPaginatedOrders({
|
|
275
275
|
* status: "SUBMITTED",
|
|
276
|
-
*
|
|
276
|
+
* tradingPairId: "456e7890-e12b-12d3-a456-426614174000",
|
|
277
277
|
* page: 1,
|
|
278
|
-
*
|
|
278
|
+
* pageSize: 20
|
|
279
279
|
* });
|
|
280
280
|
* console.log(`Found ${orders.total} orders, showing page ${orders.page}`);
|
|
281
281
|
*
|
|
282
|
-
* // Get all orders with default pagination (page=1,
|
|
282
|
+
* // Get all orders with default pagination (page=1, pageSize=10)
|
|
283
283
|
* const allOrders = await tradingAPI.getPaginatedOrders();
|
|
284
284
|
* ```
|
|
285
285
|
*/
|
|
@@ -299,7 +299,7 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
299
299
|
* // Get order details by ID
|
|
300
300
|
* const orderDetails = await tradingAPI.getOrder("order_123");
|
|
301
301
|
* console.log(`Order status: ${orderDetails.order.status}`);
|
|
302
|
-
* console.log(`Remaining quantity: ${orderDetails.order.
|
|
302
|
+
* console.log(`Remaining quantity: ${orderDetails.order.remainingQuantity}`);
|
|
303
303
|
* ```
|
|
304
304
|
*/
|
|
305
305
|
getOrder(orderId: string): Promise<GetOrderResponse>;
|
package/dist/api/trading/api.js
CHANGED
|
@@ -28,12 +28,12 @@ function parentTpSlLegToRequest(leg) {
|
|
|
28
28
|
if (!leg)
|
|
29
29
|
return undefined;
|
|
30
30
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
triggerPrice: leg.triggerPrice,
|
|
32
|
+
orderType: leg.orderType,
|
|
33
|
+
limitPrice: leg.limitPrice,
|
|
34
|
+
timeInForce: leg.timeInForce,
|
|
35
|
+
slippageToleranceBps: leg.slippageToleranceBps,
|
|
36
|
+
expiresAt: leg.expiresAt,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
export class TradingAPIImpl extends BaseAPI {
|
|
@@ -97,24 +97,24 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
97
97
|
options,
|
|
98
98
|
});
|
|
99
99
|
const requestBody = {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
tradingPairId: tradingPairId,
|
|
101
|
+
orderType: "LIMIT",
|
|
102
102
|
side,
|
|
103
103
|
price,
|
|
104
104
|
quantity,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
tradingMode: options?.tradingMode || "SPOT",
|
|
106
|
+
useMasterBalance: options?.useMasterBalance,
|
|
107
|
+
expirationDate: options?.expirationDate,
|
|
108
|
+
timeInForce: options?.timeInForce,
|
|
109
|
+
marginAccountId: options?.marginAccountId,
|
|
110
|
+
riskBucketId: options?.riskBucketId,
|
|
111
|
+
riskBucketCollateral: options?.riskBucketCollateral,
|
|
112
|
+
strategyKey: options?.strategyKey,
|
|
113
|
+
positionSide: options?.positionSide,
|
|
114
114
|
leverage: options?.leverage,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
reduceOnly: options?.reduceOnly,
|
|
116
|
+
takeProfit: parentTpSlLegToRequest(options?.takeProfit),
|
|
117
|
+
stopLoss: parentTpSlLegToRequest(options?.stopLoss),
|
|
118
118
|
};
|
|
119
119
|
return await this.makeAuthenticatedRequest(perpRoutes.orders.create(), {
|
|
120
120
|
method: "POST",
|
|
@@ -171,22 +171,22 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
171
171
|
options,
|
|
172
172
|
});
|
|
173
173
|
const requestBody = {
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
tradingPairId: tradingPairId,
|
|
175
|
+
orderType: "MARKET",
|
|
176
176
|
side,
|
|
177
|
-
|
|
177
|
+
slippageToleranceBps: options?.slippageTolerance !== undefined ? Math.round(options.slippageTolerance * 10000) : undefined,
|
|
178
178
|
price: null, // Market orders don't need price
|
|
179
179
|
quantity,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
tradingMode: options?.tradingMode || "SPOT",
|
|
181
|
+
marginAccountId: options?.marginAccountId,
|
|
182
|
+
riskBucketId: options?.riskBucketId,
|
|
183
|
+
riskBucketCollateral: options?.riskBucketCollateral,
|
|
184
|
+
strategyKey: options?.strategyKey,
|
|
185
|
+
positionSide: options?.positionSide,
|
|
186
186
|
leverage: options?.leverage,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
reduceOnly: options?.reduceOnly,
|
|
188
|
+
takeProfit: parentTpSlLegToRequest(options?.takeProfit),
|
|
189
|
+
stopLoss: parentTpSlLegToRequest(options?.stopLoss),
|
|
190
190
|
};
|
|
191
191
|
return await this.makeAuthenticatedRequest(perpRoutes.orders.create(), {
|
|
192
192
|
method: "POST",
|
|
@@ -213,7 +213,7 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
213
213
|
// Validate inputs before making API call
|
|
214
214
|
validate(CancelOrderSchema, { orderId });
|
|
215
215
|
const requestBody = {
|
|
216
|
-
|
|
216
|
+
orderId: orderId,
|
|
217
217
|
};
|
|
218
218
|
return await this.makeAuthenticatedRequest(perpRoutes.orders.cancel(), {
|
|
219
219
|
method: "POST",
|
|
@@ -230,12 +230,12 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
230
230
|
if (params) {
|
|
231
231
|
validate(ListConditionalOrdersSchema, params);
|
|
232
232
|
}
|
|
233
|
-
const { page = 1,
|
|
233
|
+
const { page = 1, pageSize = 20, marginAccountId, tradingPairId, state } = params || {};
|
|
234
234
|
return await this.makeAuthenticatedRequest(perpRoutes.orders.listConditional({
|
|
235
235
|
page,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
pageSize: Math.min(Math.max(pageSize, 1), 100),
|
|
237
|
+
marginAccountId,
|
|
238
|
+
tradingPairId,
|
|
239
239
|
state,
|
|
240
240
|
}), { method: "GET" });
|
|
241
241
|
}
|
|
@@ -257,7 +257,7 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
257
257
|
}
|
|
258
258
|
return this.makeAuthenticatedRequest(perpRoutes.orders.batchCancel(), {
|
|
259
259
|
method: "POST",
|
|
260
|
-
body: JSON.stringify({
|
|
260
|
+
body: JSON.stringify({ orderIds: orderIds }),
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
263
|
/**
|
|
@@ -286,7 +286,7 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
286
286
|
// Validate inputs before making API call
|
|
287
287
|
validate(ReplaceOrderSchema, { orderId, newOrder });
|
|
288
288
|
const requestBody = {
|
|
289
|
-
|
|
289
|
+
useMasterBalance: newOrder.useMasterBalance ?? false,
|
|
290
290
|
};
|
|
291
291
|
if (newOrder.price !== undefined) {
|
|
292
292
|
requestBody.price = newOrder.price;
|
|
@@ -333,23 +333,23 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
333
333
|
validate(BatchCreateOrdersSchema, { orders });
|
|
334
334
|
const requestBody = {
|
|
335
335
|
orders: orders.map((order) => ({
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
tradingPairId: order.tradingPairId,
|
|
337
|
+
orderType: order.orderType,
|
|
338
338
|
side: order.side,
|
|
339
339
|
price: order.price,
|
|
340
340
|
quantity: order.quantity,
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
341
|
+
tradingMode: order.tradingMode || "SPOT",
|
|
342
|
+
slippageToleranceBps: order.slippageTolerance !== undefined ? Math.round(order.slippageTolerance * 10000) : undefined,
|
|
343
|
+
useMasterBalance: order.useMasterBalance,
|
|
344
|
+
expirationDate: order.expirationDate,
|
|
345
|
+
timeInForce: order.timeInForce,
|
|
346
|
+
marginAccountId: order.marginAccountId,
|
|
347
|
+
riskBucketId: order.riskBucketId,
|
|
348
|
+
riskBucketCollateral: order.riskBucketCollateral,
|
|
349
|
+
strategyKey: order.strategyKey,
|
|
350
|
+
positionSide: order.positionSide,
|
|
351
351
|
leverage: order.leverage,
|
|
352
|
-
|
|
352
|
+
reduceOnly: order.reduceOnly,
|
|
353
353
|
})),
|
|
354
354
|
};
|
|
355
355
|
return this.makeAuthenticatedRequest(perpRoutes.orders.batchCreate(), {
|
|
@@ -386,10 +386,10 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
386
386
|
validate(BatchReplaceOrdersSchema, { orders });
|
|
387
387
|
const requestBody = {
|
|
388
388
|
orders: orders.map((order) => ({
|
|
389
|
-
|
|
389
|
+
orderId: order.orderId,
|
|
390
390
|
price: order.price,
|
|
391
391
|
quantity: order.quantity,
|
|
392
|
-
|
|
392
|
+
useMasterBalance: order.useMasterBalance,
|
|
393
393
|
})),
|
|
394
394
|
};
|
|
395
395
|
return this.makeAuthenticatedRequest(perpRoutes.orders.batchReplace(), {
|
|
@@ -405,9 +405,9 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
405
405
|
*
|
|
406
406
|
* @param params - Query parameters for filtering orders
|
|
407
407
|
* @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED") (optional)
|
|
408
|
-
* @param params.
|
|
408
|
+
* @param params.tradingPairId - Filter by trading pair UUID (optional)
|
|
409
409
|
* @param params.page - Page number for pagination (defaults to 1, must be > 0)
|
|
410
|
-
* @param params.
|
|
410
|
+
* @param params.pageSize - Number of orders per page (defaults to 10, max 100, must be > 0)
|
|
411
411
|
* @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
|
|
412
412
|
* @throws {APIError} When API communication fails
|
|
413
413
|
*
|
|
@@ -416,13 +416,13 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
416
416
|
* // Get submitted orders for a specific trading pair with custom pagination
|
|
417
417
|
* const orders = await tradingAPI.getPaginatedOrders({
|
|
418
418
|
* status: "SUBMITTED",
|
|
419
|
-
*
|
|
419
|
+
* tradingPairId: "456e7890-e12b-12d3-a456-426614174000",
|
|
420
420
|
* page: 1,
|
|
421
|
-
*
|
|
421
|
+
* pageSize: 20
|
|
422
422
|
* });
|
|
423
423
|
* console.log(`Found ${orders.total} orders, showing page ${orders.page}`);
|
|
424
424
|
*
|
|
425
|
-
* // Get all orders with default pagination (page=1,
|
|
425
|
+
* // Get all orders with default pagination (page=1, pageSize=10)
|
|
426
426
|
* const allOrders = await tradingAPI.getPaginatedOrders();
|
|
427
427
|
* ```
|
|
428
428
|
*/
|
|
@@ -432,25 +432,25 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
432
432
|
validate(GetPaginatedOrdersSchema, params);
|
|
433
433
|
}
|
|
434
434
|
// Set pagination defaults with destructuring and validation
|
|
435
|
-
const { page = 1,
|
|
435
|
+
const { page = 1, pageSize: requestedPageSize = 10, status, tradingPairId, tradingMode, marginAccountId } = params || {};
|
|
436
436
|
const validPage = page > 0 ? page : 1;
|
|
437
|
-
const validPageSize =
|
|
437
|
+
const validPageSize = requestedPageSize > 0 ? requestedPageSize : 10;
|
|
438
438
|
const pageSize = Math.min(validPageSize, 100);
|
|
439
439
|
const searchParams = new URLSearchParams();
|
|
440
440
|
// Always include pagination parameters for consistent API behavior
|
|
441
441
|
searchParams.append("page", validPage.toString());
|
|
442
|
-
searchParams.append("
|
|
442
|
+
searchParams.append("pageSize", pageSize.toString());
|
|
443
443
|
if (status) {
|
|
444
444
|
searchParams.append("status", status);
|
|
445
445
|
}
|
|
446
|
-
if (
|
|
447
|
-
searchParams.append("
|
|
446
|
+
if (tradingPairId) {
|
|
447
|
+
searchParams.append("tradingPairId", tradingPairId);
|
|
448
448
|
}
|
|
449
|
-
if (
|
|
450
|
-
searchParams.append("
|
|
449
|
+
if (tradingMode) {
|
|
450
|
+
searchParams.append("tradingMode", tradingMode);
|
|
451
451
|
}
|
|
452
|
-
if (
|
|
453
|
-
searchParams.append("
|
|
452
|
+
if (marginAccountId) {
|
|
453
|
+
searchParams.append("marginAccountId", marginAccountId);
|
|
454
454
|
}
|
|
455
455
|
const endpoint = `/api/v1/orders?${searchParams.toString()}`;
|
|
456
456
|
return await this.makeAuthenticatedRequest(endpoint, {
|
|
@@ -472,7 +472,7 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
472
472
|
* // Get order details by ID
|
|
473
473
|
* const orderDetails = await tradingAPI.getOrder("order_123");
|
|
474
474
|
* console.log(`Order status: ${orderDetails.order.status}`);
|
|
475
|
-
* console.log(`Remaining quantity: ${orderDetails.order.
|
|
475
|
+
* console.log(`Remaining quantity: ${orderDetails.order.remainingQuantity}`);
|
|
476
476
|
* ```
|
|
477
477
|
*/
|
|
478
478
|
async getOrder(orderId) {
|
package/dist/api/vault/api.js
CHANGED
|
@@ -338,7 +338,7 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
338
338
|
const deadline = Date.now() + timeoutMs;
|
|
339
339
|
for (;;) {
|
|
340
340
|
try {
|
|
341
|
-
const {
|
|
341
|
+
const { vaultAddress, calldata } = await this.makePublicRequest(`/api/v1/withdrawals/${withdrawalIndex}`);
|
|
342
342
|
// Ready: non-empty calldata. (Defensively treat an empty/`0x` body as
|
|
343
343
|
// not-ready too, though the gateway returns an error in that case.)
|
|
344
344
|
if (calldata && calldata !== "0x") {
|
|
@@ -428,13 +428,13 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
428
428
|
const source = typeof sourceOrRetry === "string" ? sourceOrRetry : "spot";
|
|
429
429
|
const retryOptions = typeof sourceOrRetry === "string" ? retry : sourceOrRetry;
|
|
430
430
|
validate(WithdrawSchema, { assetId, amount, destination, autoWait, source });
|
|
431
|
-
// 1. Gateway allocates the
|
|
431
|
+
// 1. Gateway allocates the withdrawalIndex and debits the balance. No
|
|
432
432
|
// executable calldata yet — it needs the merkle proof, available only once
|
|
433
433
|
// the withdrawal root is confirmed on-chain.
|
|
434
|
-
const {
|
|
434
|
+
const { withdrawalIndex } = await this.makeAuthenticatedRequest("/api/v1/withdrawals", {
|
|
435
435
|
method: "POST",
|
|
436
436
|
body: JSON.stringify({
|
|
437
|
-
|
|
437
|
+
assetId: assetId,
|
|
438
438
|
amount: amount.toString(),
|
|
439
439
|
destination,
|
|
440
440
|
source,
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* const { message,
|
|
12
|
-
*
|
|
11
|
+
* const { message, userId } = await sdk.whitelist.submit({
|
|
12
|
+
* walletAddress: "0x...",
|
|
13
13
|
* email: "user@example.com",
|
|
14
14
|
* });
|
|
15
15
|
* ```
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* const { message,
|
|
12
|
-
*
|
|
11
|
+
* const { message, userId } = await sdk.whitelist.submit({
|
|
12
|
+
* walletAddress: "0x...",
|
|
13
13
|
* email: "user@example.com",
|
|
14
14
|
* });
|
|
15
15
|
* ```
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { InitiateWithdrawalRequest, WithdrawalResponse, WithdrawalsAPI } from "@0xmonaco/types";
|
|
1
|
+
import type { InitiateWithdrawalRequest, ListPendingWithdrawalsParams, ListPendingWithdrawalsResponse, WithdrawalResponse, WithdrawalsAPI } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
/**
|
|
4
4
|
* Low-level withdrawals client.
|
|
5
5
|
*
|
|
6
6
|
* `initiateWithdrawal` debits the caller's balance via the matching engine and
|
|
7
|
-
* allocates a `
|
|
7
|
+
* allocates a `withdrawalIndex` (its `calldata` is empty — the proof is not
|
|
8
8
|
* available until the withdrawal root is confirmed on-chain). `getWithdrawal`
|
|
9
9
|
* returns the `executeWithdrawal` calldata once that proof is ready, and throws
|
|
10
10
|
* an `APIError` (404 not-persisted-yet / 409 not-confirmed-yet) while it is not.
|
|
@@ -14,4 +14,5 @@ import { BaseAPI } from "../base";
|
|
|
14
14
|
export declare class WithdrawalsAPIImpl extends BaseAPI implements WithdrawalsAPI {
|
|
15
15
|
initiateWithdrawal(request: InitiateWithdrawalRequest): Promise<WithdrawalResponse>;
|
|
16
16
|
getWithdrawal(withdrawalIndex: number): Promise<WithdrawalResponse>;
|
|
17
|
+
listPendingWithdrawals(params?: ListPendingWithdrawalsParams): Promise<ListPendingWithdrawalsResponse>;
|
|
17
18
|
}
|
|
@@ -4,7 +4,7 @@ import { perpRoutes } from "../perp";
|
|
|
4
4
|
* Low-level withdrawals client.
|
|
5
5
|
*
|
|
6
6
|
* `initiateWithdrawal` debits the caller's balance via the matching engine and
|
|
7
|
-
* allocates a `
|
|
7
|
+
* allocates a `withdrawalIndex` (its `calldata` is empty — the proof is not
|
|
8
8
|
* available until the withdrawal root is confirmed on-chain). `getWithdrawal`
|
|
9
9
|
* returns the `executeWithdrawal` calldata once that proof is ready, and throws
|
|
10
10
|
* an `APIError` (404 not-persisted-yet / 409 not-confirmed-yet) while it is not.
|
|
@@ -16,7 +16,7 @@ export class WithdrawalsAPIImpl extends BaseAPI {
|
|
|
16
16
|
return this.makeAuthenticatedRequest(perpRoutes.withdrawals.initiate(), {
|
|
17
17
|
method: "POST",
|
|
18
18
|
body: JSON.stringify({
|
|
19
|
-
|
|
19
|
+
assetId: request.assetId,
|
|
20
20
|
amount: request.amount,
|
|
21
21
|
destination: request.destination,
|
|
22
22
|
source: request.source ?? "spot",
|
|
@@ -27,4 +27,9 @@ export class WithdrawalsAPIImpl extends BaseAPI {
|
|
|
27
27
|
// Public lookup — no auth required.
|
|
28
28
|
return this.makePublicRequest(perpRoutes.withdrawals.byIndex(withdrawalIndex));
|
|
29
29
|
}
|
|
30
|
+
async listPendingWithdrawals(params) {
|
|
31
|
+
// The gateway serves camelCase (the REST wire format), which matches the
|
|
32
|
+
// public surface, so the response is returned directly with no remapping.
|
|
33
|
+
return this.makeAuthenticatedRequest(perpRoutes.withdrawals.list({ page: params?.page, pageSize: params?.pageSize }));
|
|
34
|
+
}
|
|
30
35
|
}
|
package/dist/coverage.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare const COVERED: {
|
|
|
51
51
|
get_user_trades: string;
|
|
52
52
|
get_withdrawal: string;
|
|
53
53
|
initiate_withdrawal: string;
|
|
54
|
+
list_pending_withdrawals: string;
|
|
54
55
|
list_application_balances: string;
|
|
55
56
|
list_application_movements: string;
|
|
56
57
|
list_application_orders: string;
|
package/dist/coverage.js
CHANGED
|
@@ -51,6 +51,7 @@ export const COVERED = {
|
|
|
51
51
|
get_user_trades: "getUserTrades",
|
|
52
52
|
get_withdrawal: "getWithdrawal",
|
|
53
53
|
initiate_withdrawal: "initiateWithdrawal",
|
|
54
|
+
list_pending_withdrawals: "listPendingWithdrawals",
|
|
54
55
|
list_application_balances: "listApplicationBalances",
|
|
55
56
|
list_application_movements: "listApplicationMovements",
|
|
56
57
|
list_application_orders: "listApplicationOrders",
|
package/dist/sdk.js
CHANGED
|
@@ -242,10 +242,10 @@ export class MonacoSDKImpl {
|
|
|
242
242
|
this.authState = {
|
|
243
243
|
sessionPublicKey: session.publicKey,
|
|
244
244
|
sessionPrivateKey: session.privateKey,
|
|
245
|
-
expiresAt: delegatedSession.
|
|
245
|
+
expiresAt: delegatedSession.expiresAt,
|
|
246
246
|
user: {
|
|
247
|
-
id: delegatedSession.
|
|
248
|
-
address: delegatedSession.
|
|
247
|
+
id: delegatedSession.ownerUserId,
|
|
248
|
+
address: delegatedSession.agentAddress,
|
|
249
249
|
},
|
|
250
250
|
};
|
|
251
251
|
this.propagateSession(this.sessionFromAuthState(this.authState));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"viem": "^2.45.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@0xmonaco/contracts": "0.8.
|
|
27
|
-
"@0xmonaco/types": "0.8.
|
|
26
|
+
"@0xmonaco/contracts": "0.8.15",
|
|
27
|
+
"@0xmonaco/types": "0.8.15",
|
|
28
28
|
"@noble/curves": "^1.9.1",
|
|
29
29
|
"@noble/hashes": "^1.8.0",
|
|
30
30
|
"http-status-codes": "^2.3.0"
|