@binance/convert 1.0.0

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/index.mjs ADDED
@@ -0,0 +1,863 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name2 in all)
4
+ __defProp(target, name2, { get: all[name2], enumerable: true });
5
+ };
6
+
7
+ // src/convert.ts
8
+ import { platform, arch } from "os";
9
+ import { ConfigurationRestAPI as ConfigurationRestAPI4, CONVERT_REST_API_PROD_URL } from "@binance/common";
10
+
11
+ // package.json
12
+ var name = "@binance/convert";
13
+ var version = "1.0.0";
14
+
15
+ // src/rest-api/index.ts
16
+ var rest_api_exports = {};
17
+ __export(rest_api_exports, {
18
+ MarketDataApi: () => MarketDataApi,
19
+ RestAPI: () => RestAPI,
20
+ TradeApi: () => TradeApi
21
+ });
22
+
23
+ // src/rest-api/modules/market-data-api.ts
24
+ import {
25
+ sendRequest
26
+ } from "@binance/common";
27
+ var MarketDataApiAxiosParamCreator = function(configuration) {
28
+ return {
29
+ /**
30
+ * Query for all convertible token pairs and the tokens’ respective upper/lower limits
31
+ *
32
+ * User needs to supply either or both of the input parameter
33
+ * If not defined for both fromAsset and toAsset, only partial token pairs will be returned
34
+ *
35
+ * Weight: 3000(IP)
36
+ *
37
+ * @summary List All Convert Pairs
38
+ * @param {string} [fromAsset] User spends coin
39
+ * @param {string} [toAsset] User receives coin
40
+ *
41
+ * @throws {RequiredError}
42
+ */
43
+ listAllConvertPairs: async (fromAsset, toAsset) => {
44
+ const localVarQueryParameter = {};
45
+ if (fromAsset !== void 0 && fromAsset !== null) {
46
+ localVarQueryParameter["fromAsset"] = fromAsset;
47
+ }
48
+ if (toAsset !== void 0 && toAsset !== null) {
49
+ localVarQueryParameter["toAsset"] = toAsset;
50
+ }
51
+ let _timeUnit;
52
+ if ("timeUnit" in configuration)
53
+ _timeUnit = configuration.timeUnit;
54
+ return {
55
+ endpoint: "/sapi/v1/convert/exchangeInfo",
56
+ method: "GET",
57
+ params: localVarQueryParameter,
58
+ timeUnit: _timeUnit
59
+ };
60
+ },
61
+ /**
62
+ * Query for supported asset’s precision information
63
+ *
64
+ * Weight: 100(IP)
65
+ *
66
+ * @summary Query order quantity precision per asset(USER_DATA)
67
+ * @param {number} [recvWindow] The value cannot be greater than 60000
68
+ *
69
+ * @throws {RequiredError}
70
+ */
71
+ queryOrderQuantityPrecisionPerAsset: async (recvWindow) => {
72
+ const localVarQueryParameter = {};
73
+ if (recvWindow !== void 0 && recvWindow !== null) {
74
+ localVarQueryParameter["recvWindow"] = recvWindow;
75
+ }
76
+ let _timeUnit;
77
+ if ("timeUnit" in configuration)
78
+ _timeUnit = configuration.timeUnit;
79
+ return {
80
+ endpoint: "/sapi/v1/convert/assetInfo",
81
+ method: "GET",
82
+ params: localVarQueryParameter,
83
+ timeUnit: _timeUnit
84
+ };
85
+ }
86
+ };
87
+ };
88
+ var MarketDataApi = class {
89
+ constructor(configuration) {
90
+ this.configuration = configuration;
91
+ this.localVarAxiosParamCreator = MarketDataApiAxiosParamCreator(configuration);
92
+ }
93
+ /**
94
+ * Query for all convertible token pairs and the tokens’ respective upper/lower limits
95
+ *
96
+ * User needs to supply either or both of the input parameter
97
+ * If not defined for both fromAsset and toAsset, only partial token pairs will be returned
98
+ *
99
+ * Weight: 3000(IP)
100
+ *
101
+ * @summary List All Convert Pairs
102
+ * @param {ListAllConvertPairsRequest} requestParameters Request parameters.
103
+ * @returns {Promise<RestApiResponse<ListAllConvertPairsResponse>>}
104
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
105
+ * @memberof MarketDataApi
106
+ * @see {@link https://developers.binance.com/docs/convert/market-data/List-All-Convert-Pairs Binance API Documentation}
107
+ */
108
+ async listAllConvertPairs(requestParameters = {}) {
109
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.listAllConvertPairs(
110
+ requestParameters?.fromAsset,
111
+ requestParameters?.toAsset
112
+ );
113
+ return sendRequest(
114
+ this.configuration,
115
+ localVarAxiosArgs.endpoint,
116
+ localVarAxiosArgs.method,
117
+ localVarAxiosArgs.params,
118
+ localVarAxiosArgs?.timeUnit,
119
+ { isSigned: false }
120
+ );
121
+ }
122
+ /**
123
+ * Query for supported asset’s precision information
124
+ *
125
+ * Weight: 100(IP)
126
+ *
127
+ * @summary Query order quantity precision per asset(USER_DATA)
128
+ * @param {QueryOrderQuantityPrecisionPerAssetRequest} requestParameters Request parameters.
129
+ * @returns {Promise<RestApiResponse<QueryOrderQuantityPrecisionPerAssetResponse>>}
130
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
131
+ * @memberof MarketDataApi
132
+ * @see {@link https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset Binance API Documentation}
133
+ */
134
+ async queryOrderQuantityPrecisionPerAsset(requestParameters = {}) {
135
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.queryOrderQuantityPrecisionPerAsset(
136
+ requestParameters?.recvWindow
137
+ );
138
+ return sendRequest(
139
+ this.configuration,
140
+ localVarAxiosArgs.endpoint,
141
+ localVarAxiosArgs.method,
142
+ localVarAxiosArgs.params,
143
+ localVarAxiosArgs?.timeUnit,
144
+ { isSigned: true }
145
+ );
146
+ }
147
+ };
148
+
149
+ // src/rest-api/modules/trade-api.ts
150
+ import {
151
+ assertParamExists,
152
+ sendRequest as sendRequest2
153
+ } from "@binance/common";
154
+ var TradeApiAxiosParamCreator = function(configuration) {
155
+ return {
156
+ /**
157
+ * Accept the offered quote by quote ID.
158
+ *
159
+ * Weight: 500(UID)
160
+ *
161
+ * @summary Accept Quote (TRADE)
162
+ * @param {string} quoteId
163
+ * @param {number} [recvWindow] The value cannot be greater than 60000
164
+ *
165
+ * @throws {RequiredError}
166
+ */
167
+ acceptQuote: async (quoteId, recvWindow) => {
168
+ assertParamExists("acceptQuote", "quoteId", quoteId);
169
+ const localVarQueryParameter = {};
170
+ if (quoteId !== void 0 && quoteId !== null) {
171
+ localVarQueryParameter["quoteId"] = quoteId;
172
+ }
173
+ if (recvWindow !== void 0 && recvWindow !== null) {
174
+ localVarQueryParameter["recvWindow"] = recvWindow;
175
+ }
176
+ let _timeUnit;
177
+ if ("timeUnit" in configuration)
178
+ _timeUnit = configuration.timeUnit;
179
+ return {
180
+ endpoint: "/sapi/v1/convert/acceptQuote",
181
+ method: "POST",
182
+ params: localVarQueryParameter,
183
+ timeUnit: _timeUnit
184
+ };
185
+ },
186
+ /**
187
+ * Enable users to cancel a limit order
188
+ *
189
+ * Weight: 200(UID)
190
+ *
191
+ * @summary Cancel limit order (USER_DATA)
192
+ * @param {number} orderId The orderId from `placeOrder` api
193
+ * @param {number} [recvWindow] The value cannot be greater than 60000
194
+ *
195
+ * @throws {RequiredError}
196
+ */
197
+ cancelLimitOrder: async (orderId, recvWindow) => {
198
+ assertParamExists("cancelLimitOrder", "orderId", orderId);
199
+ const localVarQueryParameter = {};
200
+ if (orderId !== void 0 && orderId !== null) {
201
+ localVarQueryParameter["orderId"] = orderId;
202
+ }
203
+ if (recvWindow !== void 0 && recvWindow !== null) {
204
+ localVarQueryParameter["recvWindow"] = recvWindow;
205
+ }
206
+ let _timeUnit;
207
+ if ("timeUnit" in configuration)
208
+ _timeUnit = configuration.timeUnit;
209
+ return {
210
+ endpoint: "/sapi/v1/convert/limit/cancelOrder",
211
+ method: "POST",
212
+ params: localVarQueryParameter,
213
+ timeUnit: _timeUnit
214
+ };
215
+ },
216
+ /**
217
+ * Get Convert Trade History
218
+ *
219
+ * The max interval between startTime and endTime is 30 days.
220
+ *
221
+ * Weight: 3000
222
+ *
223
+ * @summary Get Convert Trade History(USER_DATA)
224
+ * @param {number} startTime
225
+ * @param {number} endTime
226
+ * @param {number} [limit] Default 100, Max 1000
227
+ * @param {number} [recvWindow] The value cannot be greater than 60000
228
+ *
229
+ * @throws {RequiredError}
230
+ */
231
+ getConvertTradeHistory: async (startTime, endTime, limit, recvWindow) => {
232
+ assertParamExists("getConvertTradeHistory", "startTime", startTime);
233
+ assertParamExists("getConvertTradeHistory", "endTime", endTime);
234
+ const localVarQueryParameter = {};
235
+ if (startTime !== void 0 && startTime !== null) {
236
+ localVarQueryParameter["startTime"] = startTime;
237
+ }
238
+ if (endTime !== void 0 && endTime !== null) {
239
+ localVarQueryParameter["endTime"] = endTime;
240
+ }
241
+ if (limit !== void 0 && limit !== null) {
242
+ localVarQueryParameter["limit"] = limit;
243
+ }
244
+ if (recvWindow !== void 0 && recvWindow !== null) {
245
+ localVarQueryParameter["recvWindow"] = recvWindow;
246
+ }
247
+ let _timeUnit;
248
+ if ("timeUnit" in configuration)
249
+ _timeUnit = configuration.timeUnit;
250
+ return {
251
+ endpoint: "/sapi/v1/convert/tradeFlow",
252
+ method: "GET",
253
+ params: localVarQueryParameter,
254
+ timeUnit: _timeUnit
255
+ };
256
+ },
257
+ /**
258
+ * Query order status by order ID.
259
+ *
260
+ * Weight: 100(UID)
261
+ *
262
+ * @summary Order status(USER_DATA)
263
+ * @param {string} [orderId] Either orderId or quoteId is required
264
+ * @param {string} [quoteId] Either orderId or quoteId is required
265
+ *
266
+ * @throws {RequiredError}
267
+ */
268
+ orderStatus: async (orderId, quoteId) => {
269
+ const localVarQueryParameter = {};
270
+ if (orderId !== void 0 && orderId !== null) {
271
+ localVarQueryParameter["orderId"] = orderId;
272
+ }
273
+ if (quoteId !== void 0 && quoteId !== null) {
274
+ localVarQueryParameter["quoteId"] = quoteId;
275
+ }
276
+ let _timeUnit;
277
+ if ("timeUnit" in configuration)
278
+ _timeUnit = configuration.timeUnit;
279
+ return {
280
+ endpoint: "/sapi/v1/convert/orderStatus",
281
+ method: "GET",
282
+ params: localVarQueryParameter,
283
+ timeUnit: _timeUnit
284
+ };
285
+ },
286
+ /**
287
+ * Enable users to place a limit order
288
+ *
289
+ * `baseAsset` or `quoteAsset` can be determined via `exchangeInfo` endpoint.
290
+ * Limit price is defined from `baseAsset` to `quoteAsset`.
291
+ * Either `baseAmount` or `quoteAmount` is used.
292
+ *
293
+ * Weight: 500(UID)
294
+ *
295
+ * @summary Place limit order (USER_DATA)
296
+ * @param {string} baseAsset base asset (use the response `fromIsBase` from `GET /sapi/v1/convert/exchangeInfo` api to check which one is baseAsset )
297
+ * @param {string} quoteAsset quote asset
298
+ * @param {number} limitPrice Symbol limit price (from baseAsset to quoteAsset)
299
+ * @param {string} side `BUY` or `SELL`
300
+ * @param {string} expiredType 1_D, 3_D, 7_D, 30_D (D means day)
301
+ * @param {number} [baseAmount] Base asset amount. (One of `baseAmount` or `quoteAmount` is required)
302
+ * @param {number} [quoteAmount] Quote asset amount. (One of `baseAmount` or `quoteAmount` is required)
303
+ * @param {string} [walletType] SPOT or FUNDING. Default is SPOT
304
+ * @param {number} [recvWindow] The value cannot be greater than 60000
305
+ *
306
+ * @throws {RequiredError}
307
+ */
308
+ placeLimitOrder: async (baseAsset, quoteAsset, limitPrice, side, expiredType, baseAmount, quoteAmount, walletType, recvWindow) => {
309
+ assertParamExists("placeLimitOrder", "baseAsset", baseAsset);
310
+ assertParamExists("placeLimitOrder", "quoteAsset", quoteAsset);
311
+ assertParamExists("placeLimitOrder", "limitPrice", limitPrice);
312
+ assertParamExists("placeLimitOrder", "side", side);
313
+ assertParamExists("placeLimitOrder", "expiredType", expiredType);
314
+ const localVarQueryParameter = {};
315
+ if (baseAsset !== void 0 && baseAsset !== null) {
316
+ localVarQueryParameter["baseAsset"] = baseAsset;
317
+ }
318
+ if (quoteAsset !== void 0 && quoteAsset !== null) {
319
+ localVarQueryParameter["quoteAsset"] = quoteAsset;
320
+ }
321
+ if (limitPrice !== void 0 && limitPrice !== null) {
322
+ localVarQueryParameter["limitPrice"] = limitPrice;
323
+ }
324
+ if (baseAmount !== void 0 && baseAmount !== null) {
325
+ localVarQueryParameter["baseAmount"] = baseAmount;
326
+ }
327
+ if (quoteAmount !== void 0 && quoteAmount !== null) {
328
+ localVarQueryParameter["quoteAmount"] = quoteAmount;
329
+ }
330
+ if (side !== void 0 && side !== null) {
331
+ localVarQueryParameter["side"] = side;
332
+ }
333
+ if (walletType !== void 0 && walletType !== null) {
334
+ localVarQueryParameter["walletType"] = walletType;
335
+ }
336
+ if (expiredType !== void 0 && expiredType !== null) {
337
+ localVarQueryParameter["expiredType"] = expiredType;
338
+ }
339
+ if (recvWindow !== void 0 && recvWindow !== null) {
340
+ localVarQueryParameter["recvWindow"] = recvWindow;
341
+ }
342
+ let _timeUnit;
343
+ if ("timeUnit" in configuration)
344
+ _timeUnit = configuration.timeUnit;
345
+ return {
346
+ endpoint: "/sapi/v1/convert/limit/placeOrder",
347
+ method: "POST",
348
+ params: localVarQueryParameter,
349
+ timeUnit: _timeUnit
350
+ };
351
+ },
352
+ /**
353
+ * Request a quote for the requested token pairs
354
+ *
355
+ * Weight: 3000(UID)
356
+ *
357
+ * @summary Query limit open orders (USER_DATA)
358
+ * @param {number} [recvWindow] The value cannot be greater than 60000
359
+ *
360
+ * @throws {RequiredError}
361
+ */
362
+ queryLimitOpenOrders: async (recvWindow) => {
363
+ const localVarQueryParameter = {};
364
+ if (recvWindow !== void 0 && recvWindow !== null) {
365
+ localVarQueryParameter["recvWindow"] = recvWindow;
366
+ }
367
+ let _timeUnit;
368
+ if ("timeUnit" in configuration)
369
+ _timeUnit = configuration.timeUnit;
370
+ return {
371
+ endpoint: "/sapi/v1/convert/limit/queryOpenOrders",
372
+ method: "POST",
373
+ params: localVarQueryParameter,
374
+ timeUnit: _timeUnit
375
+ };
376
+ },
377
+ /**
378
+ * Request a quote for the requested token pairs
379
+ *
380
+ * Either fromAmount or toAmount should be sent
381
+ * `quoteId` will be returned only if you have enough funds to convert
382
+ *
383
+ * Weight: 200(UID)
384
+ *
385
+ * @summary Send Quote Request(USER_DATA)
386
+ * @param {string} fromAsset
387
+ * @param {string} toAsset
388
+ * @param {number} [fromAmount] When specified, it is the amount you will be debited after the conversion
389
+ * @param {number} [toAmount] When specified, it is the amount you will be credited after the conversion
390
+ * @param {string} [walletType] SPOT or FUNDING. Default is SPOT
391
+ * @param {string} [validTime] 10s, 30s, 1m, default 10s
392
+ * @param {number} [recvWindow] The value cannot be greater than 60000
393
+ *
394
+ * @throws {RequiredError}
395
+ */
396
+ sendQuoteRequest: async (fromAsset, toAsset, fromAmount, toAmount, walletType, validTime, recvWindow) => {
397
+ assertParamExists("sendQuoteRequest", "fromAsset", fromAsset);
398
+ assertParamExists("sendQuoteRequest", "toAsset", toAsset);
399
+ const localVarQueryParameter = {};
400
+ if (fromAsset !== void 0 && fromAsset !== null) {
401
+ localVarQueryParameter["fromAsset"] = fromAsset;
402
+ }
403
+ if (toAsset !== void 0 && toAsset !== null) {
404
+ localVarQueryParameter["toAsset"] = toAsset;
405
+ }
406
+ if (fromAmount !== void 0 && fromAmount !== null) {
407
+ localVarQueryParameter["fromAmount"] = fromAmount;
408
+ }
409
+ if (toAmount !== void 0 && toAmount !== null) {
410
+ localVarQueryParameter["toAmount"] = toAmount;
411
+ }
412
+ if (walletType !== void 0 && walletType !== null) {
413
+ localVarQueryParameter["walletType"] = walletType;
414
+ }
415
+ if (validTime !== void 0 && validTime !== null) {
416
+ localVarQueryParameter["validTime"] = validTime;
417
+ }
418
+ if (recvWindow !== void 0 && recvWindow !== null) {
419
+ localVarQueryParameter["recvWindow"] = recvWindow;
420
+ }
421
+ let _timeUnit;
422
+ if ("timeUnit" in configuration)
423
+ _timeUnit = configuration.timeUnit;
424
+ return {
425
+ endpoint: "/sapi/v1/convert/getQuote",
426
+ method: "POST",
427
+ params: localVarQueryParameter,
428
+ timeUnit: _timeUnit
429
+ };
430
+ }
431
+ };
432
+ };
433
+ var TradeApi = class {
434
+ constructor(configuration) {
435
+ this.configuration = configuration;
436
+ this.localVarAxiosParamCreator = TradeApiAxiosParamCreator(configuration);
437
+ }
438
+ /**
439
+ * Accept the offered quote by quote ID.
440
+ *
441
+ * Weight: 500(UID)
442
+ *
443
+ * @summary Accept Quote (TRADE)
444
+ * @param {AcceptQuoteRequest} requestParameters Request parameters.
445
+ * @returns {Promise<RestApiResponse<AcceptQuoteResponse>>}
446
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
447
+ * @memberof TradeApi
448
+ * @see {@link https://developers.binance.com/docs/convert/trade/Accept-Quote Binance API Documentation}
449
+ */
450
+ async acceptQuote(requestParameters) {
451
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.acceptQuote(
452
+ requestParameters?.quoteId,
453
+ requestParameters?.recvWindow
454
+ );
455
+ return sendRequest2(
456
+ this.configuration,
457
+ localVarAxiosArgs.endpoint,
458
+ localVarAxiosArgs.method,
459
+ localVarAxiosArgs.params,
460
+ localVarAxiosArgs?.timeUnit,
461
+ { isSigned: true }
462
+ );
463
+ }
464
+ /**
465
+ * Enable users to cancel a limit order
466
+ *
467
+ * Weight: 200(UID)
468
+ *
469
+ * @summary Cancel limit order (USER_DATA)
470
+ * @param {CancelLimitOrderRequest} requestParameters Request parameters.
471
+ * @returns {Promise<RestApiResponse<CancelLimitOrderResponse>>}
472
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
473
+ * @memberof TradeApi
474
+ * @see {@link https://developers.binance.com/docs/convert/trade/Cancel-Order Binance API Documentation}
475
+ */
476
+ async cancelLimitOrder(requestParameters) {
477
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.cancelLimitOrder(
478
+ requestParameters?.orderId,
479
+ requestParameters?.recvWindow
480
+ );
481
+ return sendRequest2(
482
+ this.configuration,
483
+ localVarAxiosArgs.endpoint,
484
+ localVarAxiosArgs.method,
485
+ localVarAxiosArgs.params,
486
+ localVarAxiosArgs?.timeUnit,
487
+ { isSigned: true }
488
+ );
489
+ }
490
+ /**
491
+ * Get Convert Trade History
492
+ *
493
+ * The max interval between startTime and endTime is 30 days.
494
+ *
495
+ * Weight: 3000
496
+ *
497
+ * @summary Get Convert Trade History(USER_DATA)
498
+ * @param {GetConvertTradeHistoryRequest} requestParameters Request parameters.
499
+ * @returns {Promise<RestApiResponse<GetConvertTradeHistoryResponse>>}
500
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
501
+ * @memberof TradeApi
502
+ * @see {@link https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History Binance API Documentation}
503
+ */
504
+ async getConvertTradeHistory(requestParameters) {
505
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.getConvertTradeHistory(
506
+ requestParameters?.startTime,
507
+ requestParameters?.endTime,
508
+ requestParameters?.limit,
509
+ requestParameters?.recvWindow
510
+ );
511
+ return sendRequest2(
512
+ this.configuration,
513
+ localVarAxiosArgs.endpoint,
514
+ localVarAxiosArgs.method,
515
+ localVarAxiosArgs.params,
516
+ localVarAxiosArgs?.timeUnit,
517
+ { isSigned: true }
518
+ );
519
+ }
520
+ /**
521
+ * Query order status by order ID.
522
+ *
523
+ * Weight: 100(UID)
524
+ *
525
+ * @summary Order status(USER_DATA)
526
+ * @param {OrderStatusRequest} requestParameters Request parameters.
527
+ * @returns {Promise<RestApiResponse<OrderStatusResponse>>}
528
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
529
+ * @memberof TradeApi
530
+ * @see {@link https://developers.binance.com/docs/convert/trade/Order-Status Binance API Documentation}
531
+ */
532
+ async orderStatus(requestParameters = {}) {
533
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.orderStatus(
534
+ requestParameters?.orderId,
535
+ requestParameters?.quoteId
536
+ );
537
+ return sendRequest2(
538
+ this.configuration,
539
+ localVarAxiosArgs.endpoint,
540
+ localVarAxiosArgs.method,
541
+ localVarAxiosArgs.params,
542
+ localVarAxiosArgs?.timeUnit,
543
+ { isSigned: true }
544
+ );
545
+ }
546
+ /**
547
+ * Enable users to place a limit order
548
+ *
549
+ * `baseAsset` or `quoteAsset` can be determined via `exchangeInfo` endpoint.
550
+ * Limit price is defined from `baseAsset` to `quoteAsset`.
551
+ * Either `baseAmount` or `quoteAmount` is used.
552
+ *
553
+ * Weight: 500(UID)
554
+ *
555
+ * @summary Place limit order (USER_DATA)
556
+ * @param {PlaceLimitOrderRequest} requestParameters Request parameters.
557
+ * @returns {Promise<RestApiResponse<PlaceLimitOrderResponse>>}
558
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
559
+ * @memberof TradeApi
560
+ * @see {@link https://developers.binance.com/docs/convert/trade/Place-Order Binance API Documentation}
561
+ */
562
+ async placeLimitOrder(requestParameters) {
563
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.placeLimitOrder(
564
+ requestParameters?.baseAsset,
565
+ requestParameters?.quoteAsset,
566
+ requestParameters?.limitPrice,
567
+ requestParameters?.side,
568
+ requestParameters?.expiredType,
569
+ requestParameters?.baseAmount,
570
+ requestParameters?.quoteAmount,
571
+ requestParameters?.walletType,
572
+ requestParameters?.recvWindow
573
+ );
574
+ return sendRequest2(
575
+ this.configuration,
576
+ localVarAxiosArgs.endpoint,
577
+ localVarAxiosArgs.method,
578
+ localVarAxiosArgs.params,
579
+ localVarAxiosArgs?.timeUnit,
580
+ { isSigned: true }
581
+ );
582
+ }
583
+ /**
584
+ * Request a quote for the requested token pairs
585
+ *
586
+ * Weight: 3000(UID)
587
+ *
588
+ * @summary Query limit open orders (USER_DATA)
589
+ * @param {QueryLimitOpenOrdersRequest} requestParameters Request parameters.
590
+ * @returns {Promise<RestApiResponse<QueryLimitOpenOrdersResponse>>}
591
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
592
+ * @memberof TradeApi
593
+ * @see {@link https://developers.binance.com/docs/convert/trade/Query-Order Binance API Documentation}
594
+ */
595
+ async queryLimitOpenOrders(requestParameters = {}) {
596
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.queryLimitOpenOrders(
597
+ requestParameters?.recvWindow
598
+ );
599
+ return sendRequest2(
600
+ this.configuration,
601
+ localVarAxiosArgs.endpoint,
602
+ localVarAxiosArgs.method,
603
+ localVarAxiosArgs.params,
604
+ localVarAxiosArgs?.timeUnit,
605
+ { isSigned: true }
606
+ );
607
+ }
608
+ /**
609
+ * Request a quote for the requested token pairs
610
+ *
611
+ * Either fromAmount or toAmount should be sent
612
+ * `quoteId` will be returned only if you have enough funds to convert
613
+ *
614
+ * Weight: 200(UID)
615
+ *
616
+ * @summary Send Quote Request(USER_DATA)
617
+ * @param {SendQuoteRequestRequest} requestParameters Request parameters.
618
+ * @returns {Promise<RestApiResponse<SendQuoteRequestResponse>>}
619
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
620
+ * @memberof TradeApi
621
+ * @see {@link https://developers.binance.com/docs/convert/trade/Send-quote-request Binance API Documentation}
622
+ */
623
+ async sendQuoteRequest(requestParameters) {
624
+ const localVarAxiosArgs = await this.localVarAxiosParamCreator.sendQuoteRequest(
625
+ requestParameters?.fromAsset,
626
+ requestParameters?.toAsset,
627
+ requestParameters?.fromAmount,
628
+ requestParameters?.toAmount,
629
+ requestParameters?.walletType,
630
+ requestParameters?.validTime,
631
+ requestParameters?.recvWindow
632
+ );
633
+ return sendRequest2(
634
+ this.configuration,
635
+ localVarAxiosArgs.endpoint,
636
+ localVarAxiosArgs.method,
637
+ localVarAxiosArgs.params,
638
+ localVarAxiosArgs?.timeUnit,
639
+ { isSigned: true }
640
+ );
641
+ }
642
+ };
643
+
644
+ // src/rest-api/rest-api.ts
645
+ import { sendRequest as sendRequest3 } from "@binance/common";
646
+ var RestAPI = class {
647
+ constructor(configuration) {
648
+ this.configuration = configuration;
649
+ this.marketDataApi = new MarketDataApi(configuration);
650
+ this.tradeApi = new TradeApi(configuration);
651
+ }
652
+ /**
653
+ * Generic function to send a request.
654
+ * @param endpoint - The API endpoint to call.
655
+ * @param method - HTTP method to use (GET, POST, DELETE, etc.).
656
+ * @param params - Query parameters for the request.
657
+ *
658
+ * @returns A promise resolving to the response data object.
659
+ */
660
+ sendRequest(endpoint, method, params = {}) {
661
+ return sendRequest3(this.configuration, endpoint, method, params, void 0);
662
+ }
663
+ /**
664
+ * Generic function to send a signed request.
665
+ * @param endpoint - The API endpoint to call.
666
+ * @param method - HTTP method to use (GET, POST, DELETE, etc.).
667
+ * @param params - Query parameters for the request.
668
+ *
669
+ * @returns A promise resolving to the response data object.
670
+ */
671
+ sendSignedRequest(endpoint, method, params = {}) {
672
+ return sendRequest3(this.configuration, endpoint, method, params, void 0, {
673
+ isSigned: true
674
+ });
675
+ }
676
+ /**
677
+ * Query for all convertible token pairs and the tokens’ respective upper/lower limits
678
+ *
679
+ * User needs to supply either or both of the input parameter
680
+ * If not defined for both fromAsset and toAsset, only partial token pairs will be returned
681
+ *
682
+ * Weight: 3000(IP)
683
+ *
684
+ * @summary List All Convert Pairs
685
+ * @param {ListAllConvertPairsRequest} requestParameters Request parameters.
686
+ * @returns {Promise<RestApiResponse<ListAllConvertPairsResponse>>}
687
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
688
+ * @see {@link https://developers.binance.com/docs/convert/market-data/List-All-Convert-Pairs Binance API Documentation}
689
+ */
690
+ listAllConvertPairs(requestParameters = {}) {
691
+ return this.marketDataApi.listAllConvertPairs(requestParameters);
692
+ }
693
+ /**
694
+ * Query for supported asset’s precision information
695
+ *
696
+ * Weight: 100(IP)
697
+ *
698
+ * @summary Query order quantity precision per asset(USER_DATA)
699
+ * @param {QueryOrderQuantityPrecisionPerAssetRequest} requestParameters Request parameters.
700
+ * @returns {Promise<RestApiResponse<QueryOrderQuantityPrecisionPerAssetResponse>>}
701
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
702
+ * @see {@link https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset Binance API Documentation}
703
+ */
704
+ queryOrderQuantityPrecisionPerAsset(requestParameters = {}) {
705
+ return this.marketDataApi.queryOrderQuantityPrecisionPerAsset(requestParameters);
706
+ }
707
+ /**
708
+ * Accept the offered quote by quote ID.
709
+ *
710
+ * Weight: 500(UID)
711
+ *
712
+ * @summary Accept Quote (TRADE)
713
+ * @param {AcceptQuoteRequest} requestParameters Request parameters.
714
+ * @returns {Promise<RestApiResponse<AcceptQuoteResponse>>}
715
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
716
+ * @see {@link https://developers.binance.com/docs/convert/trade/Accept-Quote Binance API Documentation}
717
+ */
718
+ acceptQuote(requestParameters) {
719
+ return this.tradeApi.acceptQuote(requestParameters);
720
+ }
721
+ /**
722
+ * Enable users to cancel a limit order
723
+ *
724
+ * Weight: 200(UID)
725
+ *
726
+ * @summary Cancel limit order (USER_DATA)
727
+ * @param {CancelLimitOrderRequest} requestParameters Request parameters.
728
+ * @returns {Promise<RestApiResponse<CancelLimitOrderResponse>>}
729
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
730
+ * @see {@link https://developers.binance.com/docs/convert/trade/Cancel-Order Binance API Documentation}
731
+ */
732
+ cancelLimitOrder(requestParameters) {
733
+ return this.tradeApi.cancelLimitOrder(requestParameters);
734
+ }
735
+ /**
736
+ * Get Convert Trade History
737
+ *
738
+ * The max interval between startTime and endTime is 30 days.
739
+ *
740
+ * Weight: 3000
741
+ *
742
+ * @summary Get Convert Trade History(USER_DATA)
743
+ * @param {GetConvertTradeHistoryRequest} requestParameters Request parameters.
744
+ * @returns {Promise<RestApiResponse<GetConvertTradeHistoryResponse>>}
745
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
746
+ * @see {@link https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History Binance API Documentation}
747
+ */
748
+ getConvertTradeHistory(requestParameters) {
749
+ return this.tradeApi.getConvertTradeHistory(requestParameters);
750
+ }
751
+ /**
752
+ * Query order status by order ID.
753
+ *
754
+ * Weight: 100(UID)
755
+ *
756
+ * @summary Order status(USER_DATA)
757
+ * @param {OrderStatusRequest} requestParameters Request parameters.
758
+ * @returns {Promise<RestApiResponse<OrderStatusResponse>>}
759
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
760
+ * @see {@link https://developers.binance.com/docs/convert/trade/Order-Status Binance API Documentation}
761
+ */
762
+ orderStatus(requestParameters = {}) {
763
+ return this.tradeApi.orderStatus(requestParameters);
764
+ }
765
+ /**
766
+ * Enable users to place a limit order
767
+ *
768
+ * `baseAsset` or `quoteAsset` can be determined via `exchangeInfo` endpoint.
769
+ * Limit price is defined from `baseAsset` to `quoteAsset`.
770
+ * Either `baseAmount` or `quoteAmount` is used.
771
+ *
772
+ * Weight: 500(UID)
773
+ *
774
+ * @summary Place limit order (USER_DATA)
775
+ * @param {PlaceLimitOrderRequest} requestParameters Request parameters.
776
+ * @returns {Promise<RestApiResponse<PlaceLimitOrderResponse>>}
777
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
778
+ * @see {@link https://developers.binance.com/docs/convert/trade/Place-Order Binance API Documentation}
779
+ */
780
+ placeLimitOrder(requestParameters) {
781
+ return this.tradeApi.placeLimitOrder(requestParameters);
782
+ }
783
+ /**
784
+ * Request a quote for the requested token pairs
785
+ *
786
+ * Weight: 3000(UID)
787
+ *
788
+ * @summary Query limit open orders (USER_DATA)
789
+ * @param {QueryLimitOpenOrdersRequest} requestParameters Request parameters.
790
+ * @returns {Promise<RestApiResponse<QueryLimitOpenOrdersResponse>>}
791
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
792
+ * @see {@link https://developers.binance.com/docs/convert/trade/Query-Order Binance API Documentation}
793
+ */
794
+ queryLimitOpenOrders(requestParameters = {}) {
795
+ return this.tradeApi.queryLimitOpenOrders(requestParameters);
796
+ }
797
+ /**
798
+ * Request a quote for the requested token pairs
799
+ *
800
+ * Either fromAmount or toAmount should be sent
801
+ * `quoteId` will be returned only if you have enough funds to convert
802
+ *
803
+ * Weight: 200(UID)
804
+ *
805
+ * @summary Send Quote Request(USER_DATA)
806
+ * @param {SendQuoteRequestRequest} requestParameters Request parameters.
807
+ * @returns {Promise<RestApiResponse<SendQuoteRequestResponse>>}
808
+ * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
809
+ * @see {@link https://developers.binance.com/docs/convert/trade/Send-quote-request Binance API Documentation}
810
+ */
811
+ sendQuoteRequest(requestParameters) {
812
+ return this.tradeApi.sendQuoteRequest(requestParameters);
813
+ }
814
+ };
815
+
816
+ // src/convert.ts
817
+ var Convert = class {
818
+ constructor(config) {
819
+ if (config?.configurationRestAPI) {
820
+ const configRestAPI = new ConfigurationRestAPI4(config.configurationRestAPI);
821
+ configRestAPI.basePath = configRestAPI.basePath || CONVERT_REST_API_PROD_URL;
822
+ configRestAPI.baseOptions = configRestAPI.baseOptions || {};
823
+ configRestAPI.baseOptions.headers = {
824
+ ...configRestAPI.baseOptions.headers || {},
825
+ "User-Agent": `${name}/${version} (Node.js/${process.version}; ${platform()}; ${arch()})`
826
+ };
827
+ this.restAPI = new RestAPI(configRestAPI);
828
+ }
829
+ }
830
+ };
831
+
832
+ // src/index.ts
833
+ import {
834
+ CONVERT_REST_API_PROD_URL as CONVERT_REST_API_PROD_URL2,
835
+ CONVERT_REST_API_TESTNET_URL,
836
+ ConnectorClientError,
837
+ RequiredError,
838
+ UnauthorizedError,
839
+ ForbiddenError,
840
+ TooManyRequestsError,
841
+ RateLimitBanError,
842
+ ServerError,
843
+ NetworkError,
844
+ NotFoundError,
845
+ BadRequestError
846
+ } from "@binance/common";
847
+ export {
848
+ BadRequestError,
849
+ CONVERT_REST_API_PROD_URL2 as CONVERT_REST_API_PROD_URL,
850
+ CONVERT_REST_API_TESTNET_URL,
851
+ ConnectorClientError,
852
+ Convert,
853
+ rest_api_exports as ConvertRestAPI,
854
+ ForbiddenError,
855
+ NetworkError,
856
+ NotFoundError,
857
+ RateLimitBanError,
858
+ RequiredError,
859
+ ServerError,
860
+ TooManyRequestsError,
861
+ UnauthorizedError
862
+ };
863
+ //# sourceMappingURL=index.mjs.map