ccxt 4.2.86 → 4.2.87

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 (93) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +671 -130
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/ascendex.js +11 -1
  7. package/dist/cjs/src/binance.js +14 -1
  8. package/dist/cjs/src/bingx.js +37 -1
  9. package/dist/cjs/src/bitfinex.js +3 -0
  10. package/dist/cjs/src/bitfinex2.js +16 -1
  11. package/dist/cjs/src/bitflyer.js +19 -0
  12. package/dist/cjs/src/bitget.js +15 -1
  13. package/dist/cjs/src/bitopro.js +3 -0
  14. package/dist/cjs/src/bitrue.js +13 -7
  15. package/dist/cjs/src/bitvavo.js +3 -0
  16. package/dist/cjs/src/btcmarkets.js +1 -1
  17. package/dist/cjs/src/btcturk.js +2 -1
  18. package/dist/cjs/src/coinex.js +182 -54
  19. package/dist/cjs/src/currencycom.js +1 -1
  20. package/dist/cjs/src/delta.js +3 -1
  21. package/dist/cjs/src/digifinex.js +4 -2
  22. package/dist/cjs/src/exmo.js +11 -12
  23. package/dist/cjs/src/gate.js +5 -2
  24. package/dist/cjs/src/hitbtc.js +26 -2
  25. package/dist/cjs/src/htx.js +2 -2
  26. package/dist/cjs/src/huobijp.js +1 -1
  27. package/dist/cjs/src/hyperliquid.js +249 -12
  28. package/dist/cjs/src/idex.js +1 -1
  29. package/dist/cjs/src/krakenfutures.js +2 -6
  30. package/dist/cjs/src/lbank.js +3 -0
  31. package/dist/cjs/src/oceanex.js +1 -1
  32. package/dist/cjs/src/okx.js +24 -10
  33. package/dist/cjs/src/phemex.js +3 -1
  34. package/dist/cjs/src/pro/kucoin.js +11 -6
  35. package/dist/cjs/src/wazirx.js +1 -1
  36. package/dist/cjs/src/zonda.js +3 -0
  37. package/examples/js/benchmark.js +104 -0
  38. package/examples/ts/benchmark.ts +134 -0
  39. package/js/ccxt.d.ts +1 -1
  40. package/js/ccxt.js +1 -1
  41. package/js/src/ascendex.d.ts +5 -12
  42. package/js/src/ascendex.js +11 -1
  43. package/js/src/base/Exchange.d.ts +4 -4
  44. package/js/src/base/types.d.ts +11 -0
  45. package/js/src/binance.d.ts +4 -11
  46. package/js/src/binance.js +14 -1
  47. package/js/src/bingx.d.ts +5 -2
  48. package/js/src/bingx.js +37 -1
  49. package/js/src/bitfinex.js +3 -0
  50. package/js/src/bitfinex2.d.ts +3 -17
  51. package/js/src/bitfinex2.js +16 -1
  52. package/js/src/bitflyer.d.ts +1 -0
  53. package/js/src/bitflyer.js +20 -1
  54. package/js/src/bitget.d.ts +5 -12
  55. package/js/src/bitget.js +15 -1
  56. package/js/src/bitopro.js +3 -0
  57. package/js/src/bitrue.d.ts +3 -17
  58. package/js/src/bitrue.js +13 -7
  59. package/js/src/bitvavo.js +3 -0
  60. package/js/src/btcmarkets.js +1 -1
  61. package/js/src/btcturk.js +2 -1
  62. package/js/src/coinex.d.ts +4 -11
  63. package/js/src/coinex.js +182 -54
  64. package/js/src/currencycom.js +1 -1
  65. package/js/src/delta.d.ts +5 -37
  66. package/js/src/delta.js +3 -1
  67. package/js/src/digifinex.d.ts +5 -13
  68. package/js/src/digifinex.js +4 -2
  69. package/js/src/exmo.d.ts +5 -37
  70. package/js/src/exmo.js +11 -12
  71. package/js/src/gate.d.ts +5 -33
  72. package/js/src/gate.js +5 -2
  73. package/js/src/hitbtc.d.ts +5 -12
  74. package/js/src/hitbtc.js +26 -2
  75. package/js/src/htx.js +2 -2
  76. package/js/src/huobijp.js +1 -1
  77. package/js/src/hyperliquid.d.ts +7 -4
  78. package/js/src/hyperliquid.js +249 -12
  79. package/js/src/idex.js +1 -1
  80. package/js/src/krakenfutures.js +2 -6
  81. package/js/src/kucoinfutures.d.ts +2 -2
  82. package/js/src/lbank.js +3 -0
  83. package/js/src/mexc.d.ts +3 -3
  84. package/js/src/oceanex.js +1 -1
  85. package/js/src/okx.d.ts +5 -33
  86. package/js/src/okx.js +24 -10
  87. package/js/src/phemex.d.ts +3 -11
  88. package/js/src/phemex.js +3 -1
  89. package/js/src/pro/kucoin.js +11 -6
  90. package/js/src/wazirx.js +1 -1
  91. package/js/src/zonda.js +3 -0
  92. package/package.json +3 -2
  93. package/skip-tests.json +3 -3
@@ -6561,15 +6561,25 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
6561
6561
  });
6562
6562
  }
6563
6563
  parseMarginModification(data, market = undefined) {
6564
+ //
6565
+ // addMargin/reduceMargin
6566
+ //
6567
+ // {
6568
+ // "code": 0
6569
+ // }
6570
+ //
6564
6571
  const errorCode = this.safeString(data, 'code');
6565
6572
  const status = (errorCode === '0') ? 'ok' : 'failed';
6566
6573
  return {
6567
6574
  'info': data,
6575
+ 'symbol': market['symbol'],
6568
6576
  'type': undefined,
6569
6577
  'amount': undefined,
6578
+ 'total': undefined,
6570
6579
  'code': market['quote'],
6571
- 'symbol': market['symbol'],
6572
6580
  'status': status,
6581
+ 'timestamp': undefined,
6582
+ 'datetime': undefined,
6573
6583
  };
6574
6584
  }
6575
6585
  async reduceMargin(symbol, amount, params = {}) {
@@ -29722,6 +29732,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
29722
29732
  });
29723
29733
  }
29724
29734
  parseMarginModification(data, market = undefined) {
29735
+ //
29736
+ // add/reduce margin
29737
+ //
29738
+ // {
29739
+ // "code": 200,
29740
+ // "msg": "Successfully modify position margin.",
29741
+ // "amount": 0.001,
29742
+ // "type": 1
29743
+ // }
29744
+ //
29725
29745
  const rawType = this.safeInteger(data, 'type');
29726
29746
  const resultType = (rawType === 1) ? 'add' : 'reduce';
29727
29747
  const resultAmount = this.safeNumber(data, 'amount');
@@ -29729,11 +29749,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
29729
29749
  const status = (errorCode === '200') ? 'ok' : 'failed';
29730
29750
  return {
29731
29751
  'info': data,
29752
+ 'symbol': market['symbol'],
29732
29753
  'type': resultType,
29733
29754
  'amount': resultAmount,
29755
+ 'total': undefined,
29734
29756
  'code': undefined,
29735
- 'symbol': market['symbol'],
29736
29757
  'status': status,
29758
+ 'timestamp': undefined,
29759
+ 'datetime': undefined,
29737
29760
  };
29738
29761
  }
29739
29762
  async reduceMargin(symbol, amount, params = {}) {
@@ -31374,6 +31397,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31374
31397
  'swap': true,
31375
31398
  'future': false,
31376
31399
  'option': false,
31400
+ 'addMargin': true,
31377
31401
  'cancelAllOrders': true,
31378
31402
  'cancelOrder': true,
31379
31403
  'cancelOrders': true,
@@ -31420,6 +31444,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31420
31444
  'fetchTrades': true,
31421
31445
  'fetchTransfers': true,
31422
31446
  'fetchWithdrawals': true,
31447
+ 'reduceMargin': true,
31423
31448
  'setLeverage': true,
31424
31449
  'setMargin': true,
31425
31450
  'setMarginMode': true,
@@ -34808,6 +34833,18 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34808
34833
  };
34809
34834
  return await this.swapV2PrivatePostTradeMarginType(this.extend(request, params));
34810
34835
  }
34836
+ async addMargin(symbol, amount, params = {}) {
34837
+ const request = {
34838
+ 'type': 1,
34839
+ };
34840
+ return await this.setMargin(symbol, amount, this.extend(request, params));
34841
+ }
34842
+ async reduceMargin(symbol, amount, params = {}) {
34843
+ const request = {
34844
+ 'type': 2,
34845
+ };
34846
+ return await this.setMargin(symbol, amount, this.extend(request, params));
34847
+ }
34811
34848
  async setMargin(symbol, amount, params = {}) {
34812
34849
  /**
34813
34850
  * @method
@@ -34842,7 +34879,29 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34842
34879
  // "type": 1
34843
34880
  // }
34844
34881
  //
34845
- return response;
34882
+ return this.parseMarginModification(response, market);
34883
+ }
34884
+ parseMarginModification(data, market = undefined) {
34885
+ //
34886
+ // {
34887
+ // "code": 0,
34888
+ // "msg": "",
34889
+ // "amount": 1,
34890
+ // "type": 1
34891
+ // }
34892
+ //
34893
+ const type = this.safeString(data, 'type');
34894
+ return {
34895
+ 'info': data,
34896
+ 'symbol': this.safeString(market, 'symbol'),
34897
+ 'type': (type === '1') ? 'add' : 'reduce',
34898
+ 'amount': this.safeNumber(data, 'amount'),
34899
+ 'total': this.safeNumber(data, 'margin'),
34900
+ 'code': this.safeString(market, 'settle'),
34901
+ 'status': undefined,
34902
+ 'timestamp': undefined,
34903
+ 'datetime': undefined,
34904
+ };
34846
34905
  }
34847
34906
  async fetchLeverage(symbol, params = {}) {
34848
34907
  /**
@@ -40245,6 +40304,9 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
40245
40304
  if (limit === undefined) {
40246
40305
  limit = 100;
40247
40306
  }
40307
+ else {
40308
+ limit = Math.min(limit, 10000);
40309
+ }
40248
40310
  const market = this.market(symbol);
40249
40311
  const v2id = 't' + market['id'];
40250
40312
  const request = {
@@ -42003,6 +42065,9 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
42003
42065
  if (limit === undefined) {
42004
42066
  limit = 10000;
42005
42067
  }
42068
+ else {
42069
+ limit = Math.min(limit, 10000);
42070
+ }
42006
42071
  let request = {
42007
42072
  'symbol': market['id'],
42008
42073
  'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
@@ -44124,15 +44189,27 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
44124
44189
  return this.parseMarginModification(data, market);
44125
44190
  }
44126
44191
  parseMarginModification(data, market = undefined) {
44192
+ //
44193
+ // setMargin
44194
+ //
44195
+ // [
44196
+ // [
44197
+ // 1
44198
+ // ]
44199
+ // ]
44200
+ //
44127
44201
  const marginStatusRaw = data[0];
44128
44202
  const marginStatus = (marginStatusRaw === 1) ? 'ok' : 'failed';
44129
44203
  return {
44130
44204
  'info': data,
44205
+ 'symbol': market['symbol'],
44131
44206
  'type': undefined,
44132
44207
  'amount': undefined,
44208
+ 'total': undefined,
44133
44209
  'code': undefined,
44134
- 'symbol': market['symbol'],
44135
44210
  'status': marginStatus,
44211
+ 'timestamp': undefined,
44212
+ 'datetime': undefined,
44136
44213
  };
44137
44214
  }
44138
44215
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -44457,6 +44534,11 @@ class bitflyer extends _abstract_bitflyer_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
44457
44534
  },
44458
44535
  },
44459
44536
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__/* .TICK_SIZE */ .sh,
44537
+ 'exceptions': {
44538
+ 'exact': {
44539
+ '-2': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OnMaintenance, // {"status":-2,"error_message":"Under maintenance","data":null}
44540
+ },
44541
+ },
44460
44542
  });
44461
44543
  }
44462
44544
  parseExpiryDate(expiry) {
@@ -45384,6 +45466,20 @@ class bitflyer extends _abstract_bitflyer_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
45384
45466
  }
45385
45467
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
45386
45468
  }
45469
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
45470
+ if (response === undefined) {
45471
+ return undefined; // fallback to the default error handler
45472
+ }
45473
+ const feedback = this.id + ' ' + body;
45474
+ // i.e. {"status":-2,"error_message":"Under maintenance","data":null}
45475
+ const errorMessage = this.safeString(response, 'error_message');
45476
+ const statusCode = this.safeNumber(response, 'status');
45477
+ if (errorMessage !== undefined) {
45478
+ this.throwExactlyMatchedException(this.exceptions['exact'], statusCode, feedback);
45479
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
45480
+ }
45481
+ return undefined;
45482
+ }
45387
45483
  }
45388
45484
 
45389
45485
 
@@ -46618,6 +46714,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46618
46714
  '40768': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.OrderNotFound,
46619
46715
  '41114': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.OnMaintenance,
46620
46716
  '43011': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
46717
+ '43012': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InsufficientFunds,
46621
46718
  '43025': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
46622
46719
  '43115': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.OnMaintenance,
46623
46720
  '45110': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
@@ -52359,15 +52456,28 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
52359
52456
  });
52360
52457
  }
52361
52458
  parseMarginModification(data, market = undefined) {
52459
+ //
52460
+ // addMargin/reduceMargin
52461
+ //
52462
+ // {
52463
+ // "code": "00000",
52464
+ // "msg": "success",
52465
+ // "requestTime": 1700813444618,
52466
+ // "data": ""
52467
+ // }
52468
+ //
52362
52469
  const errorCode = this.safeString(data, 'code');
52363
52470
  const status = (errorCode === '00000') ? 'ok' : 'failed';
52364
52471
  return {
52365
52472
  'info': data,
52473
+ 'symbol': market['symbol'],
52366
52474
  'type': undefined,
52367
52475
  'amount': undefined,
52476
+ 'total': undefined,
52368
52477
  'code': market['settle'],
52369
- 'symbol': market['symbol'],
52370
52478
  'status': status,
52479
+ 'timestamp': undefined,
52480
+ 'datetime': undefined,
52371
52481
  };
52372
52482
  }
52373
52483
  async reduceMargin(symbol, amount, params = {}) {
@@ -63252,6 +63362,9 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
63252
63362
  if (limit === undefined) {
63253
63363
  limit = 500;
63254
63364
  }
63365
+ else {
63366
+ limit = Math.min(limit, 75000); // supports slightly more than 75k candles atm, but limit here to avoid errors
63367
+ }
63255
63368
  const timeframeInSeconds = this.parseTimeframe(timeframe);
63256
63369
  let alignedSince = undefined;
63257
63370
  if (since === undefined) {
@@ -65600,9 +65713,6 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
65600
65713
  'interval': this.safeString(timeframesFuture, timeframe, '1min'),
65601
65714
  };
65602
65715
  if (limit !== undefined) {
65603
- if (limit > 300) {
65604
- limit = 300;
65605
- }
65606
65716
  request['limit'] = limit;
65607
65717
  }
65608
65718
  if (market['linear']) {
@@ -65621,9 +65731,6 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
65621
65731
  'scale': this.safeString(timeframesSpot, timeframe, '1m'),
65622
65732
  };
65623
65733
  if (limit !== undefined) {
65624
- if (limit > 1440) {
65625
- limit = 1440;
65626
- }
65627
65734
  request['limit'] = limit;
65628
65735
  }
65629
65736
  if (since !== undefined) {
@@ -67295,13 +67402,25 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
67295
67402
  return response;
67296
67403
  }
67297
67404
  parseMarginModification(data, market = undefined) {
67405
+ //
67406
+ // setMargin
67407
+ //
67408
+ // {
67409
+ // "code": 0,
67410
+ // "msg": "success"
67411
+ // "data": null
67412
+ // }
67413
+ //
67298
67414
  return {
67299
67415
  'info': data,
67416
+ 'symbol': market['symbol'],
67300
67417
  'type': undefined,
67301
67418
  'amount': undefined,
67419
+ 'total': undefined,
67302
67420
  'code': undefined,
67303
- 'symbol': market['symbol'],
67304
67421
  'status': undefined,
67422
+ 'timestamp': undefined,
67423
+ 'datetime': undefined,
67305
67424
  };
67306
67425
  }
67307
67426
  async setMargin(symbol, amount, params = {}) {
@@ -74872,6 +74991,9 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
74872
74991
  if (limit === undefined) {
74873
74992
  limit = 1440;
74874
74993
  }
74994
+ else {
74995
+ limit = Math.min(limit, 1440);
74996
+ }
74875
74997
  request['end'] = this.sum(since, limit * duration * 1000);
74876
74998
  }
74877
74999
  [request, params] = this.handleUntilOption('end', request, params);
@@ -82034,7 +82156,7 @@ class btcmarkets extends _abstract_btcmarkets_js__WEBPACK_IMPORTED_MODULE_0__/*
82034
82156
  request['from'] = this.iso8601(since);
82035
82157
  }
82036
82158
  if (limit !== undefined) {
82037
- request['limit'] = limit; // default is 10, max 200
82159
+ request['limit'] = Math.min(limit, 200); // default is 10, max 200
82038
82160
  }
82039
82161
  const response = await this.publicGetMarketsMarketIdCandles(this.extend(request, params));
82040
82162
  //
@@ -83363,6 +83485,7 @@ class btcturk extends _abstract_btcturk_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
83363
83485
  limit = 100; // default value
83364
83486
  }
83365
83487
  if (limit !== undefined) {
83488
+ limit = Math.min(limit, 11000); // max 11000 candles diapason can be covered
83366
83489
  if (timeframe === '1y') { // difficult with leap years
83367
83490
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' fetchOHLCV () does not accept a limit parameter when timeframe == "1y"');
83368
83491
  }
@@ -83373,7 +83496,7 @@ class btcturk extends _abstract_btcturk_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
83373
83496
  request['to'] = Math.min(request['to'], to);
83374
83497
  }
83375
83498
  else {
83376
- request['from'] = this.parseToInt(until / 1000) - limitSeconds;
83499
+ request['from'] = this.parseToInt(0 / 1000) - limitSeconds;
83377
83500
  }
83378
83501
  }
83379
83502
  const response = await this.graphGetKlinesHistory(this.extend(request, params));
@@ -103667,19 +103790,22 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
103667
103790
  * @method
103668
103791
  * @name coinex#fetchTime
103669
103792
  * @description fetches the current integer timestamp in milliseconds from the exchange server
103670
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http005_system_time
103793
+ * @see https://docs.coinex.com/api/v2/common/http/time
103671
103794
  * @param {object} [params] extra parameters specific to the exchange API endpoint
103672
103795
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
103673
103796
  */
103674
- const response = await this.v1PerpetualPublicGetTime(params);
103797
+ const response = await this.v2PublicGetTime(params);
103675
103798
  //
103676
103799
  // {
103677
- // "code": "0",
103678
- // "data": "1653261274414",
103800
+ // "code": 0,
103801
+ // "data": {
103802
+ // "timestamp": 1711699867777
103803
+ // },
103679
103804
  // "message": "OK"
103680
103805
  // }
103681
103806
  //
103682
- return this.safeInteger(response, 'data');
103807
+ const data = this.safeDict(response, 'data', {});
103808
+ return this.safeInteger(data, 'timestamp');
103683
103809
  }
103684
103810
  async fetchOrderBook(symbol, limit = 20, params = {}) {
103685
103811
  /**
@@ -103939,7 +104065,8 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
103939
104065
  * @method
103940
104066
  * @name coinex#fetchTradingFee
103941
104067
  * @description fetch the trading fees for a market
103942
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market003_single_market_info
104068
+ * @see https://docs.coinex.com/api/v2/spot/market/http/list-market
104069
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market
103943
104070
  * @param {string} symbol unified market symbol
103944
104071
  * @param {object} [params] extra parameters specific to the exchange API endpoint
103945
104072
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
@@ -103949,67 +104076,132 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
103949
104076
  const request = {
103950
104077
  'market': market['id'],
103951
104078
  };
103952
- const response = await this.v1PublicGetMarketDetail(this.extend(request, params));
103953
- //
103954
- // {
103955
- // "code": 0,
103956
- // "data": {
103957
- // "name": "BTCUSDC",
103958
- // "min_amount": "0.0005",
103959
- // "maker_fee_rate": "0.002",
103960
- // "taker_fee_rate": "0.002",
103961
- // "pricing_name": "USDC",
103962
- // "pricing_decimal": 2,
103963
- // "trading_name": "BTC",
103964
- // "trading_decimal": 8
103965
- // },
103966
- // "message": "OK"
103967
- // }
103968
- //
103969
- const data = this.safeValue(response, 'data', {});
103970
- return this.parseTradingFee(data, market);
104079
+ let response = undefined;
104080
+ if (market['spot']) {
104081
+ response = await this.v2PublicGetSpotMarket(this.extend(request, params));
104082
+ //
104083
+ // {
104084
+ // "code": 0,
104085
+ // "data": [
104086
+ // {
104087
+ // "base_ccy": "BTC",
104088
+ // "base_ccy_precision": 8,
104089
+ // "is_amm_available": false,
104090
+ // "is_margin_available": true,
104091
+ // "maker_fee_rate": "0.002",
104092
+ // "market": "BTCUSDT",
104093
+ // "min_amount": "0.0001",
104094
+ // "quote_ccy": "USDT",
104095
+ // "quote_ccy_precision": 2,
104096
+ // "taker_fee_rate": "0.002"
104097
+ // }
104098
+ // ],
104099
+ // "message": "OK"
104100
+ // }
104101
+ //
104102
+ }
104103
+ else {
104104
+ response = await this.v2PublicGetFuturesMarket(this.extend(request, params));
104105
+ //
104106
+ // {
104107
+ // "code": 0,
104108
+ // "data": [
104109
+ // {
104110
+ // "base_ccy": "BTC",
104111
+ // "base_ccy_precision": 8,
104112
+ // "contract_type": "linear",
104113
+ // "leverage": ["1","2","3","5","8","10","15","20","30","50","100"],
104114
+ // "maker_fee_rate": "0",
104115
+ // "market": "BTCUSDT",
104116
+ // "min_amount": "0.0001",
104117
+ // "open_interest_volume": "185.7498",
104118
+ // "quote_ccy": "USDT",
104119
+ // "quote_ccy_precision": 2,
104120
+ // "taker_fee_rate": "0"
104121
+ // }
104122
+ // ],
104123
+ // "message": "OK"
104124
+ // }
104125
+ //
104126
+ }
104127
+ const data = this.safeList(response, 'data', []);
104128
+ const result = this.safeDict(data, 0, {});
104129
+ return this.parseTradingFee(result, market);
103971
104130
  }
103972
104131
  async fetchTradingFees(params = {}) {
103973
104132
  /**
103974
104133
  * @method
103975
104134
  * @name coinex#fetchTradingFees
103976
104135
  * @description fetch the trading fees for multiple markets
103977
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market002_all_market_info
104136
+ * @see https://docs.coinex.com/api/v2/spot/market/http/list-market
104137
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market
103978
104138
  * @param {object} [params] extra parameters specific to the exchange API endpoint
103979
104139
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
103980
104140
  */
103981
104141
  await this.loadMarkets();
103982
- const response = await this.v1PublicGetMarketInfo(params);
103983
- //
103984
- // {
103985
- // "code": 0,
103986
- // "data": {
103987
- // "WAVESBTC": {
103988
- // "name": "WAVESBTC",
103989
- // "min_amount": "1",
103990
- // "maker_fee_rate": "0.001",
103991
- // "taker_fee_rate": "0.001",
103992
- // "pricing_name": "BTC",
103993
- // "pricing_decimal": 8,
103994
- // "trading_name": "WAVES",
103995
- // "trading_decimal": 8
103996
- // }
103997
- // ...
103998
- // }
103999
- // }
104000
- //
104001
- const data = this.safeValue(response, 'data', {});
104142
+ let type = undefined;
104143
+ [type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
104144
+ let response = undefined;
104145
+ if (type === 'swap') {
104146
+ response = await this.v2PublicGetFuturesMarket(params);
104147
+ //
104148
+ // {
104149
+ // "code": 0,
104150
+ // "data": [
104151
+ // {
104152
+ // "base_ccy": "BTC",
104153
+ // "base_ccy_precision": 8,
104154
+ // "contract_type": "linear",
104155
+ // "leverage": ["1","2","3","5","8","10","15","20","30","50","100"],
104156
+ // "maker_fee_rate": "0",
104157
+ // "market": "BTCUSDT",
104158
+ // "min_amount": "0.0001",
104159
+ // "open_interest_volume": "185.7498",
104160
+ // "quote_ccy": "USDT",
104161
+ // "quote_ccy_precision": 2,
104162
+ // "taker_fee_rate": "0"
104163
+ // }
104164
+ // ],
104165
+ // "message": "OK"
104166
+ // }
104167
+ //
104168
+ }
104169
+ else {
104170
+ response = await this.v2PublicGetSpotMarket(params);
104171
+ //
104172
+ // {
104173
+ // "code": 0,
104174
+ // "data": [
104175
+ // {
104176
+ // "base_ccy": "BTC",
104177
+ // "base_ccy_precision": 8,
104178
+ // "is_amm_available": false,
104179
+ // "is_margin_available": true,
104180
+ // "maker_fee_rate": "0.002",
104181
+ // "market": "BTCUSDT",
104182
+ // "min_amount": "0.0001",
104183
+ // "quote_ccy": "USDT",
104184
+ // "quote_ccy_precision": 2,
104185
+ // "taker_fee_rate": "0.002"
104186
+ // },
104187
+ // ],
104188
+ // "message": "OK"
104189
+ // }
104190
+ //
104191
+ }
104192
+ const data = this.safeList(response, 'data', []);
104002
104193
  const result = {};
104003
- for (let i = 0; i < this.symbols.length; i++) {
104004
- const symbol = this.symbols[i];
104005
- const market = this.market(symbol);
104006
- const fee = this.safeValue(data, market['id'], {});
104007
- result[symbol] = this.parseTradingFee(fee, market);
104194
+ for (let i = 0; i < data.length; i++) {
104195
+ const entry = data[i];
104196
+ const marketId = this.safeString(entry, 'market');
104197
+ const market = this.safeMarket(marketId, undefined, undefined, type);
104198
+ const symbol = market['symbol'];
104199
+ result[symbol] = this.parseTradingFee(entry, market);
104008
104200
  }
104009
104201
  return result;
104010
104202
  }
104011
104203
  parseTradingFee(fee, market = undefined) {
104012
- const marketId = this.safeValue(fee, 'name');
104204
+ const marketId = this.safeValue(fee, 'market');
104013
104205
  const symbol = this.safeSymbol(marketId, market);
104014
104206
  return {
104015
104207
  'info': fee,
@@ -106781,13 +106973,72 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
106781
106973
  });
106782
106974
  }
106783
106975
  parseMarginModification(data, market = undefined) {
106976
+ //
106977
+ // addMargin/reduceMargin
106978
+ //
106979
+ // {
106980
+ // "adl_sort": 1,
106981
+ // "adl_sort_val": "0.00004320",
106982
+ // "amount": "0.0005",
106983
+ // "amount_max": "0.0005",
106984
+ // "amount_max_margin": "6.57352000000000000000",
106985
+ // "bkr_price": "16294.08000000000000011090",
106986
+ // "bkr_price_imply": "0.00000000000000000000",
106987
+ // "close_left": "0.0005",
106988
+ // "create_time": 1651202571.320778,
106989
+ // "deal_all": "19.72000000000000000000",
106990
+ // "deal_asset_fee": "0.00000000000000000000",
106991
+ // "fee_asset": "",
106992
+ // "finish_type": 1,
106993
+ // "first_price": "39441.12",
106994
+ // "insurance": "0.00000000000000000000",
106995
+ // "latest_price": "39441.12",
106996
+ // "leverage": "3",
106997
+ // "liq_amount": "0.00000000000000000000",
106998
+ // "liq_order_price": "0",
106999
+ // "liq_order_time": 0,
107000
+ // "liq_price": "16491.28560000000000011090",
107001
+ // "liq_price_imply": "0.00000000000000000000",
107002
+ // "liq_profit": "0.00000000000000000000",
107003
+ // "liq_time": 0,
107004
+ // "mainten_margin": "0.005",
107005
+ // "mainten_margin_amount": "0.09860280000000000000",
107006
+ // "maker_fee": "0.00000000000000000000",
107007
+ // "margin_amount": "11.57352000000000000000",
107008
+ // "market": "BTCUSDT",
107009
+ // "open_margin": "0.58687582908396110455",
107010
+ // "open_margin_imply": "0.00000000000000000000",
107011
+ // "open_price": "39441.12000000000000000000",
107012
+ // "open_val": "19.72056000000000000000",
107013
+ // "open_val_max": "19.72056000000000000000",
107014
+ // "position_id": 65171206,
107015
+ // "profit_clearing": "-0.00986028000000000000",
107016
+ // "profit_real": "-0.00986028000000000000",
107017
+ // "profit_unreal": "0.00",
107018
+ // "side": 2,
107019
+ // "stop_loss_price": "0.00000000000000000000",
107020
+ // "stop_loss_type": 0,
107021
+ // "sys": 0,
107022
+ // "take_profit_price": "0.00000000000000000000",
107023
+ // "take_profit_type": 0,
107024
+ // "taker_fee": "0.00000000000000000000",
107025
+ // "total": 3464,
107026
+ // "type": 1,
107027
+ // "update_time": 1651202638.911212,
107028
+ // "user_id": 3620173
107029
+ // }
107030
+ //
107031
+ const timestamp = this.safeIntegerProduct(data, 'update_time', 1000);
106784
107032
  return {
106785
107033
  'info': data,
107034
+ 'symbol': this.safeSymbol(undefined, market),
106786
107035
  'type': undefined,
106787
- 'amount': undefined,
107036
+ 'amount': this.safeNumber(data, 'margin_amount'),
107037
+ 'total': undefined,
106788
107038
  'code': market['quote'],
106789
- 'symbol': this.safeSymbol(undefined, market),
106790
107039
  'status': undefined,
107040
+ 'timestamp': timestamp,
107041
+ 'datetime': this.iso8601(timestamp),
106791
107042
  };
106792
107043
  }
106793
107044
  async addMargin(symbol, amount, params = {}) {
@@ -121403,7 +121654,7 @@ class currencycom extends _abstract_currencycom_js__WEBPACK_IMPORTED_MODULE_0__/
121403
121654
  request['startTime'] = since;
121404
121655
  }
121405
121656
  if (limit !== undefined) {
121406
- request['limit'] = limit; // default 500, max 1000
121657
+ request['limit'] = Math.min(limit, 1000); // default 500, max 1000
121407
121658
  }
121408
121659
  const response = await this.publicGetV2Klines(this.extend(request, params));
121409
121660
  //
@@ -125138,12 +125389,14 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
125138
125389
  market = this.safeMarket(marketId, market);
125139
125390
  return {
125140
125391
  'info': data,
125392
+ 'symbol': market['symbol'],
125141
125393
  'type': undefined,
125142
125394
  'amount': undefined,
125143
125395
  'total': this.safeNumber(data, 'margin'),
125144
125396
  'code': undefined,
125145
- 'symbol': market['symbol'],
125146
125397
  'status': undefined,
125398
+ 'timestamp': undefined,
125399
+ 'datetime': undefined,
125147
125400
  };
125148
125401
  }
125149
125402
  async fetchOpenInterest(symbol, params = {}) {
@@ -131121,7 +131374,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
131121
131374
  request['instrument_id'] = market['id'];
131122
131375
  request['granularity'] = timeframe;
131123
131376
  if (limit !== undefined) {
131124
- request['limit'] = limit;
131377
+ request['limit'] = Math.min(limit, 100);
131125
131378
  }
131126
131379
  response = await this.publicSwapGetPublicCandles(this.extend(request, params));
131127
131380
  }
@@ -133774,12 +134027,14 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
133774
134027
  const rawType = this.safeInteger(data, 'type');
133775
134028
  return {
133776
134029
  'info': data,
134030
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
133777
134031
  'type': (rawType === 1) ? 'add' : 'reduce',
133778
134032
  'amount': this.safeNumber(data, 'amount'),
133779
134033
  'total': undefined,
133780
134034
  'code': market['settle'],
133781
- 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
133782
134035
  'status': undefined,
134036
+ 'timestamp': undefined,
134037
+ 'datetime': undefined,
133783
134038
  };
133784
134039
  }
133785
134040
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -134228,12 +134483,14 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
134228
134483
  //
134229
134484
  return {
134230
134485
  'info': data,
134486
+ 'symbol': this.safeSymbol(undefined, market),
134231
134487
  'type': undefined,
134232
134488
  'amount': undefined,
134233
- 'code': this.safeValue(market, 'quote'),
134234
- 'symbol': this.safeSymbol(undefined, market),
134235
134489
  'total': undefined,
134490
+ 'code': this.safeValue(market, 'quote'),
134236
134491
  'status': 'ok',
134492
+ 'timestamp': undefined,
134493
+ 'datetime': undefined,
134237
134494
  };
134238
134495
  }
134239
134496
  async reduceMargin(symbol, amount, params = {}) {
@@ -134826,16 +135083,15 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
134826
135083
  'symbol': market['id'],
134827
135084
  'resolution': this.safeString(this.timeframes, timeframe, timeframe),
134828
135085
  };
134829
- const options = this.safeValue(this.options, 'fetchOHLCV');
134830
- const maxLimit = this.safeInteger(options, 'maxLimit', 3000);
135086
+ const maxLimit = 3000;
134831
135087
  const duration = this.parseTimeframe(timeframe);
134832
135088
  const now = this.milliseconds();
134833
135089
  if (since === undefined) {
134834
135090
  if (limit === undefined) {
134835
135091
  limit = 1000; // cap default at generous amount
134836
135092
  }
134837
- if (limit > maxLimit) {
134838
- limit = maxLimit; // avoid exception
135093
+ else {
135094
+ limit = Math.min(limit, maxLimit);
134839
135095
  }
134840
135096
  request['from'] = this.parseToInt(now / 1000) - limit * duration - 1;
134841
135097
  request['to'] = this.parseToInt(now / 1000);
@@ -134843,15 +135099,13 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
134843
135099
  else {
134844
135100
  request['from'] = this.parseToInt(since / 1000) - 1;
134845
135101
  if (limit === undefined) {
134846
- request['to'] = this.parseToInt(now / 1000);
135102
+ limit = maxLimit;
134847
135103
  }
134848
135104
  else {
134849
- if (limit > maxLimit) {
134850
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOHLCV() will serve ' + maxLimit.toString() + ' candles at most');
134851
- }
134852
- const to = this.sum(since, limit * duration * 1000);
134853
- request['to'] = this.parseToInt(to / 1000);
135105
+ limit = Math.min(limit, maxLimit);
134854
135106
  }
135107
+ const to = this.sum(since, limit * duration * 1000);
135108
+ request['to'] = this.parseToInt(to / 1000);
134855
135109
  }
134856
135110
  const response = await this.publicGetCandlesHistory(this.extend(request, params));
134857
135111
  //
@@ -142798,11 +143052,14 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
142798
143052
  const total = this.safeNumber(data, 'margin');
142799
143053
  return {
142800
143054
  'info': data,
142801
- 'amount': undefined,
142802
- 'code': this.safeValue(market, 'quote'),
142803
143055
  'symbol': market['symbol'],
143056
+ 'type': undefined,
143057
+ 'amount': undefined,
142804
143058
  'total': total,
143059
+ 'code': this.safeValue(market, 'quote'),
142805
143060
  'status': 'ok',
143061
+ 'timestamp': undefined,
143062
+ 'datetime': undefined,
142806
143063
  };
142807
143064
  }
142808
143065
  async reduceMargin(symbol, amount, params = {}) {
@@ -147778,7 +148035,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
147778
148035
  }
147779
148036
  [request, params] = this.handleUntilOption('till', request, params);
147780
148037
  if (limit !== undefined) {
147781
- request['limit'] = limit;
148038
+ request['limit'] = Math.min(limit, 1000);
147782
148039
  }
147783
148040
  const price = this.safeString(params, 'price');
147784
148041
  params = this.omit(params, 'price');
@@ -149336,15 +149593,39 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
149336
149593
  });
149337
149594
  }
149338
149595
  parseMarginModification(data, market = undefined) {
149596
+ //
149597
+ // addMargin/reduceMargin
149598
+ //
149599
+ // {
149600
+ // "symbol": "BTCUSDT_PERP",
149601
+ // "type": "isolated",
149602
+ // "leverage": "8.00",
149603
+ // "created_at": "2022-03-30T23:34:27.161Z",
149604
+ // "updated_at": "2022-03-30T23:34:27.161Z",
149605
+ // "currencies": [
149606
+ // {
149607
+ // "code": "USDT",
149608
+ // "margin_balance": "7.000000000000",
149609
+ // "reserved_orders": "0",
149610
+ // "reserved_positions": "0"
149611
+ // }
149612
+ // ],
149613
+ // "positions": null
149614
+ // }
149615
+ //
149339
149616
  const currencies = this.safeValue(data, 'currencies', []);
149340
149617
  const currencyInfo = this.safeValue(currencies, 0);
149618
+ const datetime = this.safeString(data, 'updated_at');
149341
149619
  return {
149342
149620
  'info': data,
149621
+ 'symbol': market['symbol'],
149343
149622
  'type': undefined,
149344
149623
  'amount': undefined,
149624
+ 'total': undefined,
149345
149625
  'code': this.safeString(currencyInfo, 'code'),
149346
- 'symbol': market['symbol'],
149347
149626
  'status': undefined,
149627
+ 'timestamp': this.parse8601(datetime),
149628
+ 'datetime': datetime,
149348
149629
  };
149349
149630
  }
149350
149631
  async reduceMargin(symbol, amount, params = {}) {
@@ -154631,7 +154912,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
154631
154912
  const untilSeconds = (until !== undefined) ? this.parseToInt(until / 1000) : undefined;
154632
154913
  if (market['contract']) {
154633
154914
  if (limit !== undefined) {
154634
- request['size'] = limit; // when using limit: from & to are ignored
154915
+ request['size'] = Math.min(limit, 2000); // when using limit: from & to are ignored
154635
154916
  // https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
154636
154917
  }
154637
154918
  else {
@@ -154723,7 +155004,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
154723
155004
  [useHistorical, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', true);
154724
155005
  if (!useHistorical) {
154725
155006
  if (limit !== undefined) {
154726
- request['size'] = Math.min(2000, limit); // max 2000
155007
+ request['size'] = Math.min(limit, 2000); // max 2000
154727
155008
  }
154728
155009
  response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
154729
155010
  }
@@ -161835,7 +162116,7 @@ class huobijp extends _abstract_huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
161835
162116
  'period': this.safeString(this.timeframes, timeframe, timeframe),
161836
162117
  };
161837
162118
  if (limit !== undefined) {
161838
- request['size'] = limit;
162119
+ request['size'] = Math.min(limit, 2000);
161839
162120
  }
161840
162121
  const response = await this.marketGetHistoryKline(this.extend(request, params));
161841
162122
  //
@@ -162839,7 +163120,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162839
163120
  'pro': true,
162840
163121
  'has': {
162841
163122
  'CORS': undefined,
162842
- 'spot': false,
163123
+ 'spot': true,
162843
163124
  'margin': false,
162844
163125
  'swap': true,
162845
163126
  'future': true,
@@ -162972,6 +163253,10 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162972
163253
  'taker': this.parseNumber('0.00035'),
162973
163254
  'maker': this.parseNumber('0.0001'),
162974
163255
  },
163256
+ 'spot': {
163257
+ 'taker': this.parseNumber('0.00035'),
163258
+ 'maker': this.parseNumber('0.0001'),
163259
+ },
162975
163260
  },
162976
163261
  'requiredCredentials': {
162977
163262
  'apiKey': false,
@@ -162997,6 +163282,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162997
163282
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_2__/* .TICK_SIZE */ .sh,
162998
163283
  'commonCurrencies': {},
162999
163284
  'options': {
163285
+ 'defaultType': 'swap',
163000
163286
  'sandboxMode': false,
163001
163287
  'defaultSlippage': 0.05,
163002
163288
  'zeroAddress': '0x0000000000000000000000000000000000000000',
@@ -163067,6 +163353,24 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163067
163353
  * @param {object} [params] extra parameters specific to the exchange API endpoint
163068
163354
  * @returns {object[]} an array of objects representing market data
163069
163355
  */
163356
+ const rawPromises = [
163357
+ this.fetchSwapMarkets(params),
163358
+ this.fetchSpotMarkets(params),
163359
+ ];
163360
+ const promises = await Promise.all(rawPromises);
163361
+ const swapMarkets = promises[0];
163362
+ const spotMarkets = promises[1];
163363
+ return this.arrayConcat(swapMarkets, spotMarkets);
163364
+ }
163365
+ async fetchSwapMarkets(params = {}) {
163366
+ /**
163367
+ * @method
163368
+ * @name hyperliquid#fetchMarkets
163369
+ * @description retrieves data on all swap markets for hyperliquid
163370
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
163371
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
163372
+ * @returns {object[]} an array of objects representing market data
163373
+ */
163070
163374
  const request = {
163071
163375
  'type': 'metaAndAssetCtxs',
163072
163376
  };
@@ -163112,6 +163416,132 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163112
163416
  }
163113
163417
  return this.parseMarkets(result);
163114
163418
  }
163419
+ async fetchSpotMarkets(params = {}) {
163420
+ /**
163421
+ * @method
163422
+ * @name hyperliquid#fetchMarkets
163423
+ * @description retrieves data on all spot markets for hyperliquid
163424
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
163425
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
163426
+ * @returns {object[]} an array of objects representing market data
163427
+ */
163428
+ const request = {
163429
+ 'type': 'spotMetaAndAssetCtxs',
163430
+ };
163431
+ const response = await this.publicPostInfo(this.extend(request, params));
163432
+ //
163433
+ // [
163434
+ // {
163435
+ // 'tokens': [
163436
+ // {
163437
+ // 'name': 'USDC',
163438
+ // 'szDecimals': '8',
163439
+ // 'weiDecimals': '8',
163440
+ // },
163441
+ // {
163442
+ // 'name': 'PURR',
163443
+ // 'szDecimals': '0',
163444
+ // 'weiDecimals': '5',
163445
+ // },
163446
+ // ],
163447
+ // 'universe': [
163448
+ // {
163449
+ // 'name': 'PURR/USDC',
163450
+ // 'tokens': [
163451
+ // 1,
163452
+ // 0,
163453
+ // ],
163454
+ // },
163455
+ // ],
163456
+ // },
163457
+ // [
163458
+ // {
163459
+ // 'dayNtlVlm': '264250385.14640012',
163460
+ // 'markPx': '0.018314',
163461
+ // 'midPx': '0.0182235',
163462
+ // 'prevDayPx': '0.017427',
163463
+ // },
163464
+ // ],
163465
+ // ];
163466
+ //
163467
+ const first = this.safeDict(response, 0, {});
163468
+ const meta = this.safeList(first, 'universe', []);
163469
+ const tokens = this.safeList(first, 'tokens', []);
163470
+ const markets = [];
163471
+ for (let i = 0; i < meta.length; i++) {
163472
+ const market = this.safeDict(meta, i, {});
163473
+ const marketName = this.safeString(market, 'name');
163474
+ const marketParts = marketName.split('/');
163475
+ const baseName = this.safeString(marketParts, 0);
163476
+ const quoteId = this.safeString(marketParts, 1);
163477
+ const base = this.safeCurrencyCode(baseName);
163478
+ const quote = this.safeCurrencyCode(quoteId);
163479
+ const symbol = base + '/' + quote;
163480
+ const fees = this.safeDict(this.fees, 'spot', {});
163481
+ const taker = this.safeNumber(fees, 'taker');
163482
+ const maker = this.safeNumber(fees, 'maker');
163483
+ const tokensPos = this.safeList(market, 'tokens', []);
163484
+ const baseTokenPos = this.safeInteger(tokensPos, 0);
163485
+ const quoteTokenPos = this.safeInteger(tokensPos, 1);
163486
+ const baseTokenInfo = this.safeDict(tokens, baseTokenPos, {});
163487
+ const quoteTokenInfo = this.safeDict(tokens, quoteTokenPos, {});
163488
+ const baseDecimals = this.safeString(baseTokenInfo, 'szDecimals');
163489
+ const quoteDecimals = this.safeInteger(quoteTokenInfo, 'szDecimals');
163490
+ const baseId = this.numberToString(i + 10000);
163491
+ markets.push(this.safeMarketStructure({
163492
+ 'id': baseId,
163493
+ 'symbol': symbol,
163494
+ 'base': base,
163495
+ 'quote': quote,
163496
+ 'settle': undefined,
163497
+ 'baseId': baseId,
163498
+ 'quoteId': quoteId,
163499
+ 'settleId': undefined,
163500
+ 'type': 'spot',
163501
+ 'spot': true,
163502
+ 'margin': undefined,
163503
+ 'swap': false,
163504
+ 'future': false,
163505
+ 'option': false,
163506
+ 'active': true,
163507
+ 'contract': false,
163508
+ 'linear': true,
163509
+ 'inverse': false,
163510
+ 'taker': taker,
163511
+ 'maker': maker,
163512
+ 'contractSize': undefined,
163513
+ 'expiry': undefined,
163514
+ 'expiryDatetime': undefined,
163515
+ 'strike': undefined,
163516
+ 'optionType': undefined,
163517
+ 'precision': {
163518
+ 'amount': this.parseNumber(this.parsePrecision(baseDecimals)),
163519
+ 'price': quoteDecimals, // significant digits
163520
+ },
163521
+ 'limits': {
163522
+ 'leverage': {
163523
+ 'min': undefined,
163524
+ 'max': undefined,
163525
+ },
163526
+ 'amount': {
163527
+ 'min': undefined,
163528
+ 'max': undefined,
163529
+ },
163530
+ 'price': {
163531
+ 'min': undefined,
163532
+ 'max': undefined,
163533
+ },
163534
+ 'cost': {
163535
+ 'min': undefined,
163536
+ 'max': undefined,
163537
+ },
163538
+ },
163539
+ 'created': undefined,
163540
+ 'info': market,
163541
+ }));
163542
+ }
163543
+ return markets;
163544
+ }
163115
163545
  parseMarket(market) {
163116
163546
  //
163117
163547
  // {
@@ -163210,12 +163640,17 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163210
163640
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
163211
163641
  * @param {object} [params] extra parameters specific to the exchange API endpoint
163212
163642
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
163643
+ * @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap
163213
163644
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
163214
163645
  */
163215
163646
  let userAddress = undefined;
163216
163647
  [userAddress, params] = this.handlePublicAddress('fetchBalance', params);
163648
+ let type = undefined;
163649
+ [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
163650
+ const isSpot = (type === 'spot');
163651
+ const reqType = (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState';
163217
163652
  const request = {
163218
- 'type': 'clearinghouseState',
163653
+ 'type': reqType,
163219
163654
  'user': userAddress,
163220
163655
  };
163221
163656
  const response = await this.publicPostInfo(this.extend(request, params));
@@ -163238,7 +163673,37 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163238
163673
  // "time": "1704261007014",
163239
163674
  // "withdrawable": "100.0"
163240
163675
  // }
163676
+ // spot
163241
163677
  //
163678
+ // {
163679
+ // "balances":[
163680
+ // {
163681
+ // "coin":"USDC",
163682
+ // "hold":"0.0",
163683
+ // "total":"1481.844"
163684
+ // },
163685
+ // {
163686
+ // "coin":"PURR",
163687
+ // "hold":"0.0",
163688
+ // "total":"999.65004"
163689
+ // }
163690
+ // }
163691
+ //
163692
+ const balances = this.safeList(response, 'balances');
163693
+ if (balances !== undefined) {
163694
+ const spotBalances = { 'info': response };
163695
+ for (let i = 0; i < balances.length; i++) {
163696
+ const balance = balances[i];
163697
+ const code = this.safeCurrencyCode(this.safeString(balance, 'coin'));
163698
+ const account = this.account();
163699
+ const total = this.safeString(balance, 'total');
163700
+ const free = this.safeString(balance, 'hold');
163701
+ account['total'] = total;
163702
+ account['free'] = free;
163703
+ spotBalances[code] = account;
163704
+ }
163705
+ return this.safeBalance(spotBalances);
163706
+ }
163242
163707
  const data = this.safeDict(response, 'marginSummary', {});
163243
163708
  const result = {
163244
163709
  'info': response,
@@ -163764,6 +164229,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163764
164229
  * @param {string} symbol unified symbol of the market the order was made in
163765
164230
  * @param {object} [params] extra parameters specific to the exchange API endpoint
163766
164231
  * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
164232
+ * @param {string} [params.vaultAddress] the vault address for order
163767
164233
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
163768
164234
  */
163769
164235
  return await this.cancelOrders([id], symbol, params);
@@ -163779,6 +164245,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163779
164245
  * @param {string} [symbol] unified market symbol
163780
164246
  * @param {object} [params] extra parameters specific to the exchange API endpoint
163781
164247
  * @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
164248
+ * @param {string} [params.vaultAddress] the vault address
163782
164249
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
163783
164250
  */
163784
164251
  this.checkRequiredCredentials();
@@ -164261,7 +164728,12 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
164261
164728
  const coin = this.safeString(entry, 'coin');
164262
164729
  let marketId = undefined;
164263
164730
  if (coin !== undefined) {
164264
- marketId = coin + '/USDC:USDC';
164731
+ if (coin.indexOf('/') > -1) {
164732
+ marketId = coin;
164733
+ }
164734
+ else {
164735
+ marketId = coin + '/USDC:USDC';
164736
+ }
164265
164737
  }
164266
164738
  if (this.safeString(entry, 'id') === undefined) {
164267
164739
  market = this.safeMarket(marketId, undefined);
@@ -164745,10 +165217,27 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
164745
165217
  // 'status': 'ok'
164746
165218
  // }
164747
165219
  //
164748
- return response;
164749
- // return this.extend (this.parseMarginModification (response, market), {
164750
- // 'code': code,
164751
- // });
165220
+ return this.extend(this.parseMarginModification(response, market), {
165221
+ 'code': this.safeString(response, 'status'),
165222
+ });
165223
+ }
165224
+ parseMarginModification(data, market = undefined) {
165225
+ //
165226
+ // {
165227
+ // 'type': 'default'
165228
+ // }
165229
+ //
165230
+ return {
165231
+ 'info': data,
165232
+ 'symbol': this.safeSymbol(undefined, market),
165233
+ 'type': undefined,
165234
+ 'amount': undefined,
165235
+ 'total': undefined,
165236
+ 'code': this.safeString(market, 'settle'),
165237
+ 'status': undefined,
165238
+ 'timestamp': undefined,
165239
+ 'datetime': undefined,
165240
+ };
164752
165241
  }
164753
165242
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
164754
165243
  /**
@@ -164758,13 +165247,44 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
164758
165247
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#l1-usdc-transfer
164759
165248
  * @param {string} code unified currency code
164760
165249
  * @param {float} amount amount to transfer
164761
- * @param {string} fromAccount account to transfer from
164762
- * @param {string} toAccount account to transfer to
165250
+ * @param {string} fromAccount account to transfer from *spot, swap*
165251
+ * @param {string} toAccount account to transfer to *swap, spot or address*
164763
165252
  * @param {object} [params] extra parameters specific to the exchange API endpoint
165253
+ * @param {string} [params.vaultAddress] the vault address for order
164764
165254
  * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
164765
165255
  */
164766
165256
  this.checkRequiredCredentials();
164767
165257
  await this.loadMarkets();
165258
+ const isSandboxMode = this.safeBool(this.options, 'sandboxMode');
165259
+ const nonce = this.milliseconds();
165260
+ if (this.inArray(fromAccount, ['spot', 'swap', 'perp'])) {
165261
+ // handle swap <> spot account transfer
165262
+ if (!this.inArray(toAccount, ['spot', 'swap', 'perp'])) {
165263
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + 'transfer() only support spot <> swap transfer');
165264
+ }
165265
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
165266
+ params = this.omit(params, 'vaultAddress');
165267
+ const toPerp = (toAccount === 'perp') || (toAccount === 'swap');
165268
+ const action = {
165269
+ 'type': 'spotUser',
165270
+ 'classTransfer': {
165271
+ 'usdc': amount,
165272
+ 'toPerp': toPerp,
165273
+ },
165274
+ };
165275
+ const signature = this.signL1Action(action, nonce, vaultAddress);
165276
+ const innerRequest = {
165277
+ 'action': this.extend(action, params),
165278
+ 'nonce': nonce,
165279
+ 'signature': signature,
165280
+ };
165281
+ if (vaultAddress !== undefined) {
165282
+ innerRequest['vaultAddress'] = vaultAddress;
165283
+ }
165284
+ const transferResponse = await this.privatePostExchange(innerRequest);
165285
+ return transferResponse;
165286
+ }
165287
+ // handle sub-account/different account transfer
164768
165288
  this.checkAddress(toAccount);
164769
165289
  if (code !== undefined) {
164770
165290
  code = code.toUpperCase();
@@ -164772,11 +165292,9 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
164772
165292
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + 'withdraw() only support USDC');
164773
165293
  }
164774
165294
  }
164775
- const isSandboxMode = this.safeBool(this.options, 'sandboxMode');
164776
- const nonce = this.milliseconds();
164777
165295
  const payload = {
164778
165296
  'destination': toAccount,
164779
- 'amount': amount.toString(),
165297
+ 'amount': this.numberToString(amount),
164780
165298
  'time': nonce,
164781
165299
  };
164782
165300
  const sig = this.buildTransferSig(payload);
@@ -165381,7 +165899,7 @@ class idex extends _abstract_idex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
165381
165899
  request['start'] = since;
165382
165900
  }
165383
165901
  if (limit !== undefined) {
165384
- request['limit'] = limit;
165902
+ request['limit'] = Math.min(limit, 1000);
165385
165903
  }
165386
165904
  const response = await this.publicGetCandles(this.extend(request, params));
165387
165905
  if (Array.isArray(response)) {
@@ -172505,17 +173023,13 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
172505
173023
  if (limit === undefined) {
172506
173024
  limit = 5000;
172507
173025
  }
172508
- else if (limit > 5000) {
172509
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' fetchOHLCV() limit cannot exceed 5000');
172510
- }
173026
+ limit = Math.min(limit, 5000);
172511
173027
  const toTimestamp = this.sum(request['from'], limit * duration - 1);
172512
173028
  const currentTimestamp = this.seconds();
172513
173029
  request['to'] = Math.min(toTimestamp, currentTimestamp);
172514
173030
  }
172515
173031
  else if (limit !== undefined) {
172516
- if (limit > 5000) {
172517
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' fetchOHLCV() limit cannot exceed 5000');
172518
- }
173032
+ limit = Math.min(limit, 5000);
172519
173033
  const duration = this.parseTimeframe(timeframe);
172520
173034
  request['to'] = this.seconds();
172521
173035
  request['from'] = this.parseToInt(request['to'] - (duration * limit));
@@ -186723,6 +187237,9 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
186723
187237
  if (limit === undefined) {
186724
187238
  limit = 100;
186725
187239
  }
187240
+ else {
187241
+ limit = Math.min(limit, 2000);
187242
+ }
186726
187243
  if (since === undefined) {
186727
187244
  const duration = this.parseTimeframe(timeframe);
186728
187245
  since = this.milliseconds() - duration * 1000 * limit;
@@ -202411,7 +202928,7 @@ class oceanex extends _abstract_oceanex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
202411
202928
  request['timestamp'] = since;
202412
202929
  }
202413
202930
  if (limit !== undefined) {
202414
- request['limit'] = limit;
202931
+ request['limit'] = Math.min(limit, 10000);
202415
202932
  }
202416
202933
  const response = await this.publicPostK(this.extend(request, params));
202417
202934
  const ohlcvs = this.safeList(response, 'data', []);
@@ -212210,26 +212727,40 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212210
212727
  // "msg": ""
212211
212728
  // }
212212
212729
  //
212213
- return this.parseMarginModification(response, market);
212730
+ const data = this.safeList(response, 'data', []);
212731
+ const errorCode = this.safeString(response, 'code');
212732
+ const item = this.safeDict(data, 0, {});
212733
+ return this.extend(this.parseMarginModification(item, market), {
212734
+ 'status': (errorCode === '0') ? 'ok' : 'failed',
212735
+ });
212214
212736
  }
212215
212737
  parseMarginModification(data, market = undefined) {
212216
- const innerData = this.safeValue(data, 'data', []);
212217
- const entry = this.safeValue(innerData, 0, {});
212218
- const errorCode = this.safeString(data, 'code');
212219
- const status = (errorCode === '0') ? 'ok' : 'failed';
212220
- const amountRaw = this.safeNumber(entry, 'amt');
212221
- const typeRaw = this.safeString(entry, 'type');
212738
+ //
212739
+ // addMargin/reduceMargin
212740
+ //
212741
+ // {
212742
+ // "amt": "0.01",
212743
+ // "instId": "ETH-USD-SWAP",
212744
+ // "posSide": "net",
212745
+ // "type": "reduce"
212746
+ // }
212747
+ //
212748
+ const amountRaw = this.safeNumber(data, 'amt');
212749
+ const typeRaw = this.safeString(data, 'type');
212222
212750
  const type = (typeRaw === 'reduce') ? 'reduce' : 'add';
212223
- const marketId = this.safeString(entry, 'instId');
212751
+ const marketId = this.safeString(data, 'instId');
212224
212752
  const responseMarket = this.safeMarket(marketId, market);
212225
212753
  const code = responseMarket['inverse'] ? responseMarket['base'] : responseMarket['quote'];
212226
212754
  return {
212227
212755
  'info': data,
212756
+ 'symbol': responseMarket['symbol'],
212228
212757
  'type': type,
212229
212758
  'amount': amountRaw,
212759
+ 'total': undefined,
212230
212760
  'code': code,
212231
- 'symbol': responseMarket['symbol'],
212232
- 'status': status,
212761
+ 'status': undefined,
212762
+ 'timestamp': undefined,
212763
+ 'datetime': undefined,
212233
212764
  };
212234
212765
  }
212235
212766
  async reduceMargin(symbol, amount, params = {}) {
@@ -221277,12 +221808,14 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
221277
221808
  const codeCurrency = inverse ? 'base' : 'quote';
221278
221809
  return {
221279
221810
  'info': data,
221811
+ 'symbol': this.safeSymbol(undefined, market),
221280
221812
  'type': 'set',
221281
221813
  'amount': undefined,
221282
221814
  'total': undefined,
221283
221815
  'code': market[codeCurrency],
221284
- 'symbol': this.safeSymbol(undefined, market),
221285
221816
  'status': this.parseMarginStatus(this.safeString(data, 'code')),
221817
+ 'timestamp': undefined,
221818
+ 'datetime': undefined,
221286
221819
  };
221287
221820
  }
221288
221821
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -266108,17 +266641,22 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266108
266641
  const marketId = this.safeString(data, 'symbol', topicSymbol);
266109
266642
  const symbol = this.safeSymbol(marketId, undefined, '-');
266110
266643
  const messageHash = 'orderbook:' + symbol;
266111
- let orderbook = this.safeDict(this.orderbooks, symbol);
266644
+ // let orderbook = this.safeDict (this.orderbooks, symbol);
266112
266645
  if (subject === 'level2') {
266113
- if (orderbook === undefined) {
266114
- orderbook = this.orderBook();
266646
+ if (!(symbol in this.orderbooks)) {
266647
+ this.orderbooks[symbol] = this.orderBook();
266115
266648
  }
266116
266649
  else {
266650
+ const orderbook = this.orderbooks[symbol];
266117
266651
  orderbook.reset();
266118
266652
  }
266119
- orderbook['symbol'] = symbol;
266653
+ this.orderbooks[symbol]['symbol'] = symbol;
266120
266654
  }
266121
266655
  else {
266656
+ if (!(symbol in this.orderbooks)) {
266657
+ this.orderbooks[symbol] = this.orderBook();
266658
+ }
266659
+ const orderbook = this.orderbooks[symbol];
266122
266660
  const nonce = this.safeInteger(orderbook, 'nonce');
266123
266661
  const deltaEnd = this.safeInteger2(data, 'sequenceEnd', 'timestamp');
266124
266662
  if (nonce === undefined) {
@@ -266144,8 +266682,8 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266144
266682
  return;
266145
266683
  }
266146
266684
  }
266147
- this.handleDelta(orderbook, data);
266148
- client.resolve(orderbook, messageHash);
266685
+ this.handleDelta(this.orderbooks[symbol], data);
266686
+ client.resolve(this.orderbooks[symbol], messageHash);
266149
266687
  }
266150
266688
  getCacheIndex(orderbook, cache) {
266151
266689
  const firstDelta = this.safeValue(cache, 0);
@@ -307543,7 +308081,7 @@ class wazirx extends _abstract_wazirx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
307543
308081
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
307544
308082
  };
307545
308083
  if (limit !== undefined) {
307546
- request['limit'] = limit;
308084
+ request['limit'] = Math.min(limit, 2000);
307547
308085
  }
307548
308086
  const until = this.safeInteger(params, 'until');
307549
308087
  params = this.omit(params, ['until']);
@@ -317144,6 +317682,9 @@ class zonda extends _abstract_zonda_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
317144
317682
  if (limit === undefined) {
317145
317683
  limit = 100;
317146
317684
  }
317685
+ else {
317686
+ limit = Math.min(limit, 11000); // supports up to 11k candles diapason
317687
+ }
317147
317688
  const duration = this.parseTimeframe(timeframe);
317148
317689
  const timerange = limit * duration * 1000;
317149
317690
  if (since === undefined) {
@@ -323967,7 +324508,7 @@ SOFTWARE.
323967
324508
 
323968
324509
  //-----------------------------------------------------------------------------
323969
324510
  // this is updated by vss.js when building
323970
- const version = '4.2.86';
324511
+ const version = '4.2.87';
323971
324512
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
323972
324513
  //-----------------------------------------------------------------------------
323973
324514