ccxt 4.4.49 → 4.4.53

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 (158) hide show
  1. package/README.md +6 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +65 -2
  5. package/dist/cjs/src/base/Exchange.js +112 -3
  6. package/dist/cjs/src/binance.js +42 -19
  7. package/dist/cjs/src/bitfinex1.js +22 -22
  8. package/dist/cjs/src/blofin.js +6 -2
  9. package/dist/cjs/src/bybit.js +2 -2
  10. package/dist/cjs/src/coinex.js +5 -5
  11. package/dist/cjs/src/coinmetro.js +21 -4
  12. package/dist/cjs/src/defx.js +1 -1
  13. package/dist/cjs/src/deribit.js +23 -4
  14. package/dist/cjs/src/ellipx.js +1 -0
  15. package/dist/cjs/src/gate.js +2 -2
  16. package/dist/cjs/src/hollaex.js +15 -20
  17. package/dist/cjs/src/htx.js +6 -4
  18. package/dist/cjs/src/hyperliquid.js +4 -4
  19. package/dist/cjs/src/krakenfutures.js +1 -1
  20. package/dist/cjs/src/kucoin.js +52 -74
  21. package/dist/cjs/src/kuna.js +1 -1
  22. package/dist/cjs/src/mexc.js +29 -8
  23. package/dist/cjs/src/okcoin.js +13 -5
  24. package/dist/cjs/src/okx.js +1 -1
  25. package/dist/cjs/src/onetrading.js +1 -1
  26. package/dist/cjs/src/paradex.js +2 -2
  27. package/dist/cjs/src/paymium.js +42 -0
  28. package/dist/cjs/src/pro/binance.js +2 -0
  29. package/dist/cjs/src/pro/bitfinex1.js +4 -4
  30. package/dist/cjs/src/pro/bitvavo.js +1 -1
  31. package/dist/cjs/src/pro/blofin.js +9 -1
  32. package/dist/cjs/src/pro/bybit.js +1 -1
  33. package/dist/cjs/src/pro/coincatch.js +2 -2
  34. package/dist/cjs/src/pro/coinex.js +4 -1
  35. package/dist/cjs/src/pro/cryptocom.js +2 -2
  36. package/dist/cjs/src/pro/defx.js +1 -1
  37. package/dist/cjs/src/pro/exmo.js +1 -1
  38. package/dist/cjs/src/pro/gemini.js +1 -1
  39. package/dist/cjs/src/pro/hashkey.js +2 -2
  40. package/dist/cjs/src/pro/htx.js +8 -8
  41. package/dist/cjs/src/pro/hyperliquid.js +2 -2
  42. package/dist/cjs/src/pro/kucoin.js +1 -1
  43. package/dist/cjs/src/pro/okx.js +1 -1
  44. package/dist/cjs/src/pro/oxfun.js +1 -1
  45. package/dist/cjs/src/probit.js +77 -9
  46. package/dist/cjs/src/timex.js +67 -0
  47. package/dist/cjs/src/tokocrypto.js +82 -5
  48. package/dist/cjs/src/tradeogre.js +55 -2
  49. package/dist/cjs/src/vertex.js +65 -2
  50. package/dist/cjs/src/wavesexchange.js +73 -0
  51. package/dist/cjs/src/wazirx.js +59 -3
  52. package/dist/cjs/src/whitebit.js +80 -4
  53. package/dist/cjs/src/xt.js +112 -0
  54. package/dist/cjs/src/yobit.js +56 -0
  55. package/dist/cjs/src/zaif.js +55 -0
  56. package/dist/cjs/src/zonda.js +56 -0
  57. package/examples/README.md +6 -0
  58. package/js/ccxt.d.ts +1 -1
  59. package/js/ccxt.js +1 -1
  60. package/js/src/abstract/binance.d.ts +1 -0
  61. package/js/src/abstract/binancecoinm.d.ts +1 -0
  62. package/js/src/abstract/binanceus.d.ts +1 -0
  63. package/js/src/abstract/binanceusdm.d.ts +1 -0
  64. package/js/src/alpaca.d.ts +35 -0
  65. package/js/src/alpaca.js +65 -2
  66. package/js/src/base/Exchange.d.ts +2 -0
  67. package/js/src/base/Exchange.js +112 -3
  68. package/js/src/binance.d.ts +4 -1
  69. package/js/src/binance.js +42 -19
  70. package/js/src/bitfinex1.d.ts +22 -22
  71. package/js/src/bitfinex1.js +22 -22
  72. package/js/src/blofin.d.ts +1 -1
  73. package/js/src/blofin.js +6 -2
  74. package/js/src/bybit.d.ts +2 -2
  75. package/js/src/bybit.js +2 -2
  76. package/js/src/coinex.js +5 -5
  77. package/js/src/coinmetro.d.ts +1 -1
  78. package/js/src/coinmetro.js +21 -4
  79. package/js/src/defx.d.ts +1 -1
  80. package/js/src/defx.js +1 -1
  81. package/js/src/deribit.d.ts +1 -1
  82. package/js/src/deribit.js +23 -4
  83. package/js/src/ellipx.d.ts +1 -0
  84. package/js/src/ellipx.js +1 -0
  85. package/js/src/gate.d.ts +1 -1
  86. package/js/src/gate.js +2 -2
  87. package/js/src/hollaex.d.ts +2 -1
  88. package/js/src/hollaex.js +15 -20
  89. package/js/src/htx.d.ts +1 -1
  90. package/js/src/htx.js +6 -4
  91. package/js/src/hyperliquid.d.ts +3 -3
  92. package/js/src/hyperliquid.js +4 -4
  93. package/js/src/krakenfutures.d.ts +1 -1
  94. package/js/src/krakenfutures.js +1 -1
  95. package/js/src/kucoin.js +52 -74
  96. package/js/src/kuna.d.ts +1 -1
  97. package/js/src/kuna.js +1 -1
  98. package/js/src/mexc.d.ts +1 -1
  99. package/js/src/mexc.js +29 -8
  100. package/js/src/okcoin.js +13 -5
  101. package/js/src/okx.d.ts +1 -1
  102. package/js/src/okx.js +1 -1
  103. package/js/src/onetrading.d.ts +1 -1
  104. package/js/src/onetrading.js +1 -1
  105. package/js/src/paradex.d.ts +1 -1
  106. package/js/src/paradex.js +2 -2
  107. package/js/src/paymium.js +42 -0
  108. package/js/src/pro/binance.js +2 -0
  109. package/js/src/pro/bitfinex1.d.ts +4 -4
  110. package/js/src/pro/bitfinex1.js +4 -4
  111. package/js/src/pro/bitvavo.d.ts +1 -1
  112. package/js/src/pro/bitvavo.js +1 -1
  113. package/js/src/pro/blofin.d.ts +1 -1
  114. package/js/src/pro/blofin.js +9 -1
  115. package/js/src/pro/bybit.d.ts +1 -1
  116. package/js/src/pro/bybit.js +1 -1
  117. package/js/src/pro/coincatch.d.ts +2 -2
  118. package/js/src/pro/coincatch.js +2 -2
  119. package/js/src/pro/coinex.js +4 -1
  120. package/js/src/pro/cryptocom.d.ts +2 -2
  121. package/js/src/pro/cryptocom.js +2 -2
  122. package/js/src/pro/defx.d.ts +1 -1
  123. package/js/src/pro/defx.js +1 -1
  124. package/js/src/pro/exmo.d.ts +1 -1
  125. package/js/src/pro/exmo.js +1 -1
  126. package/js/src/pro/gemini.d.ts +1 -1
  127. package/js/src/pro/gemini.js +1 -1
  128. package/js/src/pro/hashkey.d.ts +2 -2
  129. package/js/src/pro/hashkey.js +2 -2
  130. package/js/src/pro/htx.d.ts +8 -8
  131. package/js/src/pro/htx.js +8 -8
  132. package/js/src/pro/hyperliquid.d.ts +2 -2
  133. package/js/src/pro/hyperliquid.js +2 -2
  134. package/js/src/pro/kucoin.d.ts +1 -1
  135. package/js/src/pro/kucoin.js +1 -1
  136. package/js/src/pro/okx.d.ts +1 -1
  137. package/js/src/pro/okx.js +1 -1
  138. package/js/src/pro/oxfun.d.ts +1 -1
  139. package/js/src/pro/oxfun.js +1 -1
  140. package/js/src/probit.d.ts +1 -0
  141. package/js/src/probit.js +77 -9
  142. package/js/src/timex.js +67 -0
  143. package/js/src/tokocrypto.d.ts +2 -3
  144. package/js/src/tokocrypto.js +82 -5
  145. package/js/src/tradeogre.d.ts +4 -2
  146. package/js/src/tradeogre.js +55 -2
  147. package/js/src/vertex.js +65 -2
  148. package/js/src/wavesexchange.js +73 -0
  149. package/js/src/wazirx.js +59 -3
  150. package/js/src/whitebit.js +80 -4
  151. package/js/src/xt.js +112 -0
  152. package/js/src/yobit.js +56 -0
  153. package/js/src/zaif.js +55 -0
  154. package/js/src/zonda.d.ts +1 -0
  155. package/js/src/zonda.js +56 -0
  156. package/package.json +2 -2
  157. package/js/src/hitbtc3.d.ts +0 -8
  158. package/js/src/hitbtc3.js +0 -20
@@ -4766,7 +4766,7 @@ class bybit extends bybit$1 {
4766
4766
  }
4767
4767
  /**
4768
4768
  * @method
4769
- * @name bybit#fetchOrderClassic
4769
+ * @name bybit#fetchOrder
4770
4770
  * @description *classic accounts only/ spot not supported* fetches information on an order made by the user *classic accounts only*
4771
4771
  * @see https://bybit-exchange.github.io/docs/v5/order/order-list
4772
4772
  * @param {string} id the order id
@@ -4887,7 +4887,7 @@ class bybit extends bybit$1 {
4887
4887
  }
4888
4888
  /**
4889
4889
  * @method
4890
- * @name bybit#fetchOrders
4890
+ * @name bybit#fetchOrdersClassic
4891
4891
  * @description fetches information on multiple orders made by the user *classic accounts only*
4892
4892
  * @see https://bybit-exchange.github.io/docs/v5/order/order-list
4893
4893
  * @param {string} symbol unified market symbol of the market orders were made in
@@ -467,7 +467,7 @@ class coinex extends coinex$1 {
467
467
  'ERC20': 'ERC20',
468
468
  'BRC20': 'BRC20',
469
469
  'SOL': 'SOL',
470
- 'TON': 'SOL',
470
+ 'TON': 'TON',
471
471
  'BSV': 'BSV',
472
472
  'AVAXC': 'AVA_C',
473
473
  'AVAXX': 'AVA',
@@ -3928,7 +3928,7 @@ class coinex extends coinex$1 {
3928
3928
  'currency': this.safeCurrencyCode(undefined, currency),
3929
3929
  'network': undefined,
3930
3930
  'address': address,
3931
- 'tag': tag,
3931
+ 'tag': this.safeString(depositAddress, 'memo', tag),
3932
3932
  };
3933
3933
  }
3934
3934
  /**
@@ -4802,14 +4802,14 @@ class coinex extends coinex$1 {
4802
4802
  this.checkAddress(address);
4803
4803
  await this.loadMarkets();
4804
4804
  const currency = this.currency(code);
4805
- if (tag) {
4806
- address = address + ':' + tag;
4807
- }
4808
4805
  const request = {
4809
4806
  'ccy': currency['id'],
4810
4807
  'to_address': address,
4811
4808
  'amount': this.numberToString(amount), // the actual amount without fees, https://www.coinex.com/fees
4812
4809
  };
4810
+ if (tag !== undefined) {
4811
+ request['memo'] = tag;
4812
+ }
4813
4813
  let networkCode = undefined;
4814
4814
  [networkCode, params] = this.handleNetworkCodeAndParams(params);
4815
4815
  if (networkCode !== undefined) {
@@ -209,7 +209,7 @@ class coinmetro extends coinmetro$1 {
209
209
  // exchange-specific options
210
210
  'options': {
211
211
  'currenciesByIdForParseMarket': undefined,
212
- 'currencyIdsListForParseMarket': undefined,
212
+ 'currencyIdsListForParseMarket': ['QRDO'],
213
213
  },
214
214
  'features': {
215
215
  'spot': {
@@ -398,7 +398,12 @@ class coinmetro extends coinmetro$1 {
398
398
  if (this.safeValue(this.options, 'currenciesByIdForParseMarket') === undefined) {
399
399
  const currenciesById = this.indexBy(result, 'id');
400
400
  this.options['currenciesByIdForParseMarket'] = currenciesById;
401
- this.options['currencyIdsListForParseMarket'] = Object.keys(currenciesById);
401
+ const currentCurrencyIdsList = this.safeList(this.options, 'currencyIdsListForParseMarket', []);
402
+ const currencyIdsList = Object.keys(currenciesById);
403
+ for (let i = 0; i < currencyIdsList.length; i++) {
404
+ currentCurrencyIdsList.push(currencyIdsList[i]);
405
+ }
406
+ this.options['currencyIdsListForParseMarket'] = currentCurrencyIdsList;
402
407
  }
403
408
  return result;
404
409
  }
@@ -499,10 +504,22 @@ class coinmetro extends coinmetro$1 {
499
504
  let baseId = undefined;
500
505
  let quoteId = undefined;
501
506
  const currencyIds = this.safeValue(this.options, 'currencyIdsListForParseMarket', []);
507
+ // Bubble sort by length (longest first)
508
+ const currencyIdsLength = currencyIds.length;
509
+ for (let i = 0; i < currencyIdsLength; i++) {
510
+ for (let j = 0; j < currencyIdsLength - i - 1; j++) {
511
+ const a = currencyIds[j];
512
+ const b = currencyIds[j + 1];
513
+ if (a.length < b.length) {
514
+ currencyIds[j] = b;
515
+ currencyIds[j + 1] = a;
516
+ }
517
+ }
518
+ }
502
519
  for (let i = 0; i < currencyIds.length; i++) {
503
520
  const currencyId = currencyIds[i];
504
521
  const entryIndex = marketId.indexOf(currencyId);
505
- if (entryIndex !== -1) {
522
+ if (entryIndex === 0) {
506
523
  const restId = marketId.replace(currencyId, '');
507
524
  if (this.inArray(restId, currencyIds)) {
508
525
  if (entryIndex === 0) {
@@ -1429,7 +1446,7 @@ class coinmetro extends coinmetro$1 {
1429
1446
  }
1430
1447
  /**
1431
1448
  * @method
1432
- * @name coinmetro#cancelOrder
1449
+ * @name coinmetro#closePosition
1433
1450
  * @description closes an open position
1434
1451
  * @see https://documenter.getpostman.com/view/3653795/SVfWN6KS#47f913fb-8cab-49f4-bc78-d980e6ced316
1435
1452
  * @param {string} symbol not used by coinmetro closePosition ()
@@ -937,7 +937,7 @@ class defx extends defx$1 {
937
937
  }
938
938
  /**
939
939
  * @method
940
- * @name defx#fetchTrades
940
+ * @name defx#fetchMyTrades
941
941
  * @description fetch all trades made by the user
942
942
  * @see https://api-docs.defx.com/#06b5b33c-2fc6-48de-896c-fc316f5871a7
943
943
  * @param {string} symbol unified symbol of the market to fetch trades for
@@ -3161,7 +3161,7 @@ class deribit extends deribit$1 {
3161
3161
  * @param {int} [since] the earliest time in ms to fetch funding rate history for
3162
3162
  * @param {int} [limit] the maximum number of entries to retrieve
3163
3163
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3164
- * @param {int} [params.end_timestamp] fetch funding rate ending at this timestamp
3164
+ * @param {int} [params.until] fetch funding rate ending at this timestamp
3165
3165
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3166
3166
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3167
3167
  */
@@ -3170,19 +3170,38 @@ class deribit extends deribit$1 {
3170
3170
  const market = this.market(symbol);
3171
3171
  let paginate = false;
3172
3172
  [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
3173
+ const maxEntriesPerRequest = 744; // seems exchange returns max 744 items per request
3174
+ const eachItemDuration = '1h';
3173
3175
  if (paginate) {
3174
- return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 720);
3176
+ // fix for: https://github.com/ccxt/ccxt/issues/25040
3177
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, eachItemDuration, this.extend(params, { 'isDeribitPaginationCall': true }), maxEntriesPerRequest);
3175
3178
  }
3176
- const time = this.milliseconds();
3179
+ const duration = this.parseTimeframe(eachItemDuration) * 1000;
3180
+ let time = this.milliseconds();
3177
3181
  const month = 30 * 24 * 60 * 60 * 1000;
3178
3182
  if (since === undefined) {
3179
3183
  since = time - month;
3180
3184
  }
3185
+ else {
3186
+ time = since + month;
3187
+ }
3181
3188
  const request = {
3182
3189
  'instrument_name': market['id'],
3183
3190
  'start_timestamp': since - 1,
3184
- 'end_timestamp': time,
3185
3191
  };
3192
+ const until = this.safeInteger2(params, 'until', 'end_timestamp');
3193
+ if (until !== undefined) {
3194
+ params = this.omit(params, ['until']);
3195
+ request['end_timestamp'] = until;
3196
+ }
3197
+ else {
3198
+ request['end_timestamp'] = time;
3199
+ }
3200
+ if ('isDeribitPaginationCall' in params) {
3201
+ params = this.omit(params, 'isDeribitPaginationCall');
3202
+ const maxUntil = this.sum(since, limit * duration);
3203
+ request['end_timestamp'] = Math.min(request['end_timestamp'], maxUntil);
3204
+ }
3186
3205
  const response = await this.publicGetGetFundingRateHistory(this.extend(request, params));
3187
3206
  //
3188
3207
  // {
@@ -1707,6 +1707,7 @@ class ellipx extends ellipx$1 {
1707
1707
  }
1708
1708
  /**
1709
1709
  * @method
1710
+ * @name ellipx#withdraw
1710
1711
  * @description Make a withdrawal request
1711
1712
  * @see https://docs.google.com/document/d/1ZXzTQYffKE_EglTaKptxGQERRnunuLHEMmar7VC9syM/edit?tab=t.0#heading=h.zegupoa8g4t9
1712
1713
  * @param {string} code Currency code
@@ -1821,7 +1821,7 @@ class gate extends gate$1 {
1821
1821
  const active = listed && tradeEnabled && withdrawEnabled && depositEnabled;
1822
1822
  if (this.safeValue(result, code) === undefined) {
1823
1823
  result[code] = {
1824
- 'id': code.toLowerCase(),
1824
+ 'id': currency,
1825
1825
  'code': code,
1826
1826
  'info': undefined,
1827
1827
  'name': undefined,
@@ -6453,7 +6453,7 @@ class gate extends gate$1 {
6453
6453
  }
6454
6454
  /**
6455
6455
  * @method
6456
- * @name gate#borrowMargin
6456
+ * @name gate#borrowIsolatedMargin
6457
6457
  * @description create a loan to borrow margin
6458
6458
  * @see https://www.gate.io/docs/developers/apiv4/en/#marginuni
6459
6459
  * @param {string} symbol unified market symbol, required for isolated margin
@@ -828,13 +828,14 @@ class hollaex extends hollaex$1 {
828
828
  /**
829
829
  * @method
830
830
  * @name hollaex#fetchOHLCV
831
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
831
+ * @description hollaex has large gaps between candles, so it's recommended to specify since
832
832
  * @see https://apidocs.hollaex.com/#chart
833
833
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
834
834
  * @param {string} timeframe the length of time each candle represents
835
835
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
836
836
  * @param {int} [limit] the maximum amount of candles to fetch
837
837
  * @param {object} [params] extra parameters specific to the exchange API endpoint
838
+ * @param {int} [params.until] timestamp in ms of the latest candle to fetch
838
839
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
839
840
  */
840
841
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
@@ -844,27 +845,20 @@ class hollaex extends hollaex$1 {
844
845
  'symbol': market['id'],
845
846
  'resolution': this.safeString(this.timeframes, timeframe, timeframe),
846
847
  };
847
- const duration = this.parseTimeframe(timeframe);
848
- if (since === undefined) {
849
- if (limit === undefined) {
850
- limit = 1000; // they have no defaults and can actually provide tens of thousands of bars in one request, but we should cap "default" at generous amount
851
- }
852
- const end = this.seconds();
853
- const start = end - duration * limit;
854
- request['to'] = end;
855
- request['from'] = start;
848
+ const until = this.safeInteger(params, 'until');
849
+ let end = this.seconds();
850
+ if (until !== undefined) {
851
+ end = this.parseToInt(until / 1000);
852
+ }
853
+ const defaultSpan = 2592000; // 30 days
854
+ if (since !== undefined) {
855
+ request['from'] = this.parseToInt(since / 1000);
856
856
  }
857
857
  else {
858
- if (limit === undefined) {
859
- request['from'] = this.parseToInt(since / 1000);
860
- request['to'] = this.seconds();
861
- }
862
- else {
863
- const start = this.parseToInt(since / 1000);
864
- request['from'] = start;
865
- request['to'] = this.sum(start, duration * limit);
866
- }
858
+ request['from'] = end - defaultSpan;
867
859
  }
860
+ request['to'] = end;
861
+ params = this.omit(params, 'until');
868
862
  const response = await this.publicGetChart(this.extend(request, params));
869
863
  //
870
864
  // [
@@ -1956,6 +1950,7 @@ class hollaex extends hollaex$1 {
1956
1950
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1957
1951
  }
1958
1952
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1953
+ // { "message": "Invalid token" }
1959
1954
  if (response === undefined) {
1960
1955
  return undefined;
1961
1956
  }
@@ -1963,7 +1958,7 @@ class hollaex extends hollaex$1 {
1963
1958
  //
1964
1959
  // { "message": "Invalid token" }
1965
1960
  //
1966
- // different errors return the same code eg:
1961
+ // different errors return the same code eg
1967
1962
  //
1968
1963
  // { "message":"Error 1001 - Order rejected. Order could not be submitted as this order was set to a post only order." }
1969
1964
  //
@@ -9,7 +9,7 @@ var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
9
9
  // ----------------------------------------------------------------------------
10
10
  // ---------------------------------------------------------------------------
11
11
  /**
12
- * @class huobi
12
+ * @class htx
13
13
  * @augments Exchange
14
14
  */
15
15
  class htx extends htx$1 {
@@ -7557,11 +7557,13 @@ class htx extends htx$1 {
7557
7557
  'AccessKeyId': this.apiKey,
7558
7558
  'Timestamp': timestamp,
7559
7559
  };
7560
+ // sorting needs such flow exactly, before urlencoding (more at: https://github.com/ccxt/ccxt/issues/24930 )
7561
+ request = this.keysort(request);
7560
7562
  if (method !== 'POST') {
7561
- request = this.extend(request, query);
7563
+ const sortedQuery = this.keysort(query);
7564
+ request = this.extend(request, sortedQuery);
7562
7565
  }
7563
- request = this.keysort(request);
7564
- let auth = this.urlencode(request);
7566
+ let auth = this.urlencode(request).replace('%2c', '%2C'); // in c# it manually needs to be uppercased
7565
7567
  // unfortunately, PHP demands double quotes for the escaped newline symbol
7566
7568
  const payload = [method, hostname, url, auth].join("\n"); // eslint-disable-line quotes
7567
7569
  const signature = this.hmac(this.encode(payload), this.encode(this.secret), sha256.sha256, 'base64');
@@ -397,7 +397,7 @@ class hyperliquid extends hyperliquid$1 {
397
397
  }
398
398
  /**
399
399
  * @method
400
- * @name hyperliquid#fetchMarkets
400
+ * @name hyperliquid#fetchSwapMarkets
401
401
  * @description retrieves data on all swap markets for hyperliquid
402
402
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
403
403
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -452,7 +452,7 @@ class hyperliquid extends hyperliquid$1 {
452
452
  }
453
453
  /**
454
454
  * @method
455
- * @name calculatePricePrecision
455
+ * @name hyperliquid#calculatePricePrecision
456
456
  * @description Helper function to calculate the Hyperliquid DECIMAL_PLACES price precision
457
457
  * @param {float} price the price to use in the calculation
458
458
  * @param {int} amountPrecision the amountPrecision to use in the calculation
@@ -501,7 +501,7 @@ class hyperliquid extends hyperliquid$1 {
501
501
  }
502
502
  /**
503
503
  * @method
504
- * @name hyperliquid#fetchMarkets
504
+ * @name hyperliquid#fetchSpotMarkets
505
505
  * @description retrieves data on all spot markets for hyperliquid
506
506
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
507
507
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1399,7 +1399,7 @@ class hyperliquid extends hyperliquid$1 {
1399
1399
  createOrdersRequest(orders, params = {}) {
1400
1400
  /**
1401
1401
  * @method
1402
- * @name hyperliquid#createOrders
1402
+ * @name hyperliquid#createOrdersRequest
1403
1403
  * @description create a list of trade orders
1404
1404
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
1405
1405
  * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
@@ -699,7 +699,7 @@ class krakenfutures extends krakenfutures$1 {
699
699
  }
700
700
  /**
701
701
  * @method
702
- * @name kraken#fetchOHLCV
702
+ * @name krakenfutures#fetchOHLCV
703
703
  * @see https://docs.futures.kraken.com/#http-api-charts-candles
704
704
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
705
705
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
@@ -1341,8 +1341,7 @@ class kucoin extends kucoin$1 {
1341
1341
  * @returns {object} an associative dictionary of currencies
1342
1342
  */
1343
1343
  async fetchCurrencies(params = {}) {
1344
- const promises = [];
1345
- promises.push(this.publicGetCurrencies(params));
1344
+ const response = await this.publicGetCurrencies(params);
1346
1345
  //
1347
1346
  // {
1348
1347
  // "code":"200000",
@@ -1368,92 +1367,40 @@ class kucoin extends kucoin$1 {
1368
1367
  // "isDepositEnabled":false,
1369
1368
  // "confirms":12,
1370
1369
  // "preConfirms":12,
1370
+ // "withdrawPrecision": 8,
1371
+ // "maxWithdraw": null,
1372
+ // "maxDeposit": null,
1373
+ // "needTag": false,
1371
1374
  // "contractAddress":"0xa6446d655a0c34bc4f05042ee88170d056cbaf45",
1372
1375
  // "depositFeeRate": "0.001", // present for some currencies/networks
1373
1376
  // }
1374
1377
  // ]
1375
1378
  // },
1376
- // }
1377
- //
1378
- promises.push(this.fetchWebEndpoint('fetchCurrencies', 'webExchangeGetCurrencyCurrencyChainInfo', true));
1379
- //
1380
- // {
1381
- // "success": true,
1382
- // "code": "200",
1383
- // "msg": "success",
1384
- // "retry": false,
1385
- // "data": [
1386
- // {
1387
- // "status": "enabled",
1388
- // "currency": "BTC",
1389
- // "isChainEnabled": "true",
1390
- // "chain": "btc",
1391
- // "chainName": "BTC",
1392
- // "chainFullName": "Bitcoin",
1393
- // "walletPrecision": "8",
1394
- // "isDepositEnabled": "true",
1395
- // "depositMinSize": "0.00005",
1396
- // "confirmationCount": "2",
1397
- // "isWithdrawEnabled": "true",
1398
- // "withdrawMinSize": "0.001",
1399
- // "withdrawMinFee": "0.0005",
1400
- // "withdrawFeeRate": "0",
1401
- // "depositDisabledTip": "Wallet Maintenance",
1402
- // "preDepositTipEnabled": "true",
1403
- // "preDepositTip": "Do not transfer from ETH network directly",
1404
- // "withdrawDisabledTip": "",
1405
- // "preWithdrawTipEnabled": "false",
1406
- // "preWithdrawTip": "",
1407
- // "orgAddress": "",
1408
- // "userAddressName": "Memo",
1409
- // },
1410
1379
  // ]
1411
1380
  // }
1412
1381
  //
1413
- const responses = await Promise.all(promises);
1414
- const currenciesResponse = this.safeDict(responses, 0, {});
1415
- const currenciesData = this.safeList(currenciesResponse, 'data', []);
1416
- const additionalResponse = this.safeDict(responses, 1, {});
1417
- const additionalData = this.safeList(additionalResponse, 'data', []);
1418
- const additionalDataGrouped = this.groupBy(additionalData, 'currency');
1382
+ const currenciesData = this.safeList(response, 'data', []);
1419
1383
  const result = {};
1420
1384
  for (let i = 0; i < currenciesData.length; i++) {
1421
1385
  const entry = currenciesData[i];
1422
1386
  const id = this.safeString(entry, 'currency');
1423
1387
  const name = this.safeString(entry, 'fullName');
1424
1388
  const code = this.safeCurrencyCode(id);
1425
- let isWithdrawEnabled = undefined;
1426
- let isDepositEnabled = undefined;
1427
1389
  const networks = {};
1428
1390
  const chains = this.safeList(entry, 'chains', []);
1429
- const extraChainsData = this.indexBy(this.safeList(additionalDataGrouped, id, []), 'chain');
1430
1391
  const rawPrecision = this.safeString(entry, 'precision');
1431
1392
  const precision = this.parseNumber(this.parsePrecision(rawPrecision));
1432
1393
  const chainsLength = chains.length;
1433
1394
  if (!chainsLength) {
1434
- // https://t.me/KuCoin_API/173118
1435
- isWithdrawEnabled = false;
1436
- isDepositEnabled = false;
1395
+ // one buggy coin, which doesn't contain info https://t.me/KuCoin_API/173118
1396
+ continue;
1437
1397
  }
1438
1398
  for (let j = 0; j < chainsLength; j++) {
1439
1399
  const chain = chains[j];
1440
1400
  const chainId = this.safeString(chain, 'chainId');
1441
1401
  const networkCode = this.networkIdToCode(chainId, code);
1442
1402
  const chainWithdrawEnabled = this.safeBool(chain, 'isWithdrawEnabled', false);
1443
- if (isWithdrawEnabled === undefined) {
1444
- isWithdrawEnabled = chainWithdrawEnabled;
1445
- }
1446
- else {
1447
- isWithdrawEnabled = isWithdrawEnabled || chainWithdrawEnabled;
1448
- }
1449
1403
  const chainDepositEnabled = this.safeBool(chain, 'isDepositEnabled', false);
1450
- if (isDepositEnabled === undefined) {
1451
- isDepositEnabled = chainDepositEnabled;
1452
- }
1453
- else {
1454
- isDepositEnabled = isDepositEnabled || chainDepositEnabled;
1455
- }
1456
- const chainExtraData = this.safeDict(extraChainsData, chainId, {});
1457
1404
  networks[networkCode] = {
1458
1405
  'info': chain,
1459
1406
  'id': chainId,
@@ -1463,35 +1410,35 @@ class kucoin extends kucoin$1 {
1463
1410
  'fee': this.safeNumber(chain, 'withdrawalMinFee'),
1464
1411
  'deposit': chainDepositEnabled,
1465
1412
  'withdraw': chainWithdrawEnabled,
1466
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(chainExtraData, 'walletPrecision'))),
1413
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'withdrawPrecision'))),
1467
1414
  'limits': {
1468
1415
  'withdraw': {
1469
1416
  'min': this.safeNumber(chain, 'withdrawalMinSize'),
1470
- 'max': undefined,
1417
+ 'max': this.safeNumber(chain, 'maxWithdraw'),
1471
1418
  },
1472
1419
  'deposit': {
1473
1420
  'min': this.safeNumber(chain, 'depositMinSize'),
1474
- 'max': undefined,
1421
+ 'max': this.safeNumber(chain, 'maxDeposit'),
1475
1422
  },
1476
1423
  },
1477
1424
  };
1478
1425
  }
1479
1426
  // kucoin has determined 'fiat' currencies with below logic
1480
1427
  const isFiat = (rawPrecision === '2') && (chainsLength === 0);
1481
- result[code] = {
1428
+ result[code] = this.safeCurrencyStructure({
1482
1429
  'id': id,
1483
1430
  'name': name,
1484
1431
  'code': code,
1485
1432
  'type': isFiat ? 'fiat' : 'crypto',
1486
1433
  'precision': precision,
1487
1434
  'info': entry,
1488
- 'active': (isDepositEnabled || isWithdrawEnabled),
1489
- 'deposit': isDepositEnabled,
1490
- 'withdraw': isWithdrawEnabled,
1491
- 'fee': undefined,
1492
- 'limits': this.limits,
1493
1435
  'networks': networks,
1494
- };
1436
+ 'deposit': undefined,
1437
+ 'withdraw': undefined,
1438
+ 'active': undefined,
1439
+ 'fee': undefined,
1440
+ 'limits': undefined,
1441
+ });
1495
1442
  }
1496
1443
  return result;
1497
1444
  }
@@ -1635,6 +1582,37 @@ class kucoin extends kucoin$1 {
1635
1582
  // "chain": "ERC20"
1636
1583
  // }
1637
1584
  //
1585
+ if ('chains' in fee) {
1586
+ // if data obtained through `currencies` endpoint
1587
+ const resultNew = {
1588
+ 'info': fee,
1589
+ 'withdraw': {
1590
+ 'fee': undefined,
1591
+ 'percentage': false,
1592
+ },
1593
+ 'deposit': {
1594
+ 'fee': undefined,
1595
+ 'percentage': undefined,
1596
+ },
1597
+ 'networks': {},
1598
+ };
1599
+ const chains = this.safeList(fee, 'chains', []);
1600
+ for (let i = 0; i < chains.length; i++) {
1601
+ const chain = chains[i];
1602
+ const networkCodeNew = this.networkIdToCode(this.safeString(chain, 'chainId'), this.safeString(currency, 'code'));
1603
+ resultNew['networks'][networkCodeNew] = {
1604
+ 'withdraw': {
1605
+ 'fee': this.safeNumber(chain, 'withdrawMinFee'),
1606
+ 'percentage': false,
1607
+ },
1608
+ 'deposit': {
1609
+ 'fee': undefined,
1610
+ 'percentage': undefined,
1611
+ },
1612
+ };
1613
+ }
1614
+ return resultNew;
1615
+ }
1638
1616
  const minWithdrawFee = this.safeNumber(fee, 'withdrawMinFee');
1639
1617
  const result = {
1640
1618
  'info': fee,
@@ -3237,15 +3215,15 @@ class kucoin extends kucoin$1 {
3237
3215
  market = this.market(symbol);
3238
3216
  request['symbol'] = market['id'];
3239
3217
  }
3240
- if (limit !== undefined) {
3241
- request['pageSize'] = limit;
3242
- }
3243
3218
  const method = this.options['fetchMyTradesMethod'];
3244
3219
  let parseResponseData = false;
3245
3220
  let response = undefined;
3246
3221
  [request, params] = this.handleUntilOption('endAt', request, params);
3247
3222
  if (hf) {
3248
3223
  // does not return trades earlier than 2019-02-18T00:00:00Z
3224
+ if (limit !== undefined) {
3225
+ request['limit'] = limit;
3226
+ }
3249
3227
  if (since !== undefined) {
3250
3228
  // only returns trades up to one week after the since param
3251
3229
  request['startAt'] = since;
@@ -1079,7 +1079,7 @@ class kuna extends kuna$1 {
1079
1079
  }
1080
1080
  /**
1081
1081
  * @method
1082
- * @name kuna#cancelOrder
1082
+ * @name kuna#cancelOrders
1083
1083
  * @description cancels an open order
1084
1084
  * @param {string} ids order ids
1085
1085
  * @param {string} symbol not used by kuna cancelOrder
@@ -1381,6 +1381,7 @@ class mexc extends mexc$1 {
1381
1381
  const quote = this.safeCurrencyCode(quoteId);
1382
1382
  const settle = this.safeCurrencyCode(settleId);
1383
1383
  const state = this.safeString(market, 'state');
1384
+ const isLinear = quote === settle;
1384
1385
  result.push({
1385
1386
  'id': id,
1386
1387
  'symbol': base + '/' + quote + ':' + settle,
@@ -1398,8 +1399,8 @@ class mexc extends mexc$1 {
1398
1399
  'option': false,
1399
1400
  'active': (state === '0'),
1400
1401
  'contract': true,
1401
- 'linear': true,
1402
- 'inverse': false,
1402
+ 'linear': isLinear,
1403
+ 'inverse': !isLinear,
1403
1404
  'taker': this.safeNumber(market, 'takerFeeRate'),
1404
1405
  'maker': this.safeNumber(market, 'makerFeeRate'),
1405
1406
  'contractSize': this.safeNumber(market, 'contractSize'),
@@ -2295,7 +2296,7 @@ class mexc extends mexc$1 {
2295
2296
  * @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
2296
2297
  * @param {bool} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
2297
2298
  * @param {bool} [params.hedged] *swap only* true for hedged mode, false for one way mode, default is false
2298
- *
2299
+ * @param {string} [params.timeInForce] 'IOC' or 'FOK', default is 'GTC'
2299
2300
  * EXCHANGE SPECIFIC PARAMETERS
2300
2301
  * @param {int} [params.leverage] *contract only* leverage is necessary on isolated margin
2301
2302
  * @param {long} [params.positionId] *contract only* it is recommended to fill in this parameter when closing a position
@@ -2364,6 +2365,16 @@ class mexc extends mexc$1 {
2364
2365
  if (postOnly) {
2365
2366
  request['type'] = 'LIMIT_MAKER';
2366
2367
  }
2368
+ const tif = this.safeString(params, 'timeInForce');
2369
+ if (tif !== undefined) {
2370
+ params = this.omit(params, 'timeInForce');
2371
+ if (tif === 'IOC') {
2372
+ request['type'] = 'IMMEDIATE_OR_CANCEL';
2373
+ }
2374
+ else if (tif === 'FOK') {
2375
+ request['type'] = 'FILL_OR_KILL';
2376
+ }
2377
+ }
2367
2378
  return this.extend(request, params);
2368
2379
  }
2369
2380
  /**
@@ -5989,13 +6000,23 @@ class mexc extends mexc$1 {
5989
6000
  else {
5990
6001
  url = this.urls['api'][section][access] + '/api/' + this.version + '/' + path;
5991
6002
  }
5992
- let paramsEncoded = '';
6003
+ let urlParams = params;
5993
6004
  if (access === 'private') {
5994
- params['timestamp'] = this.nonce();
5995
- params['recvWindow'] = this.safeInteger(this.options, 'recvWindow', 5000);
6005
+ if (section === 'broker' && ((method === 'POST') || (method === 'PUT') || (method === 'DELETE'))) {
6006
+ urlParams = {
6007
+ 'timestamp': this.nonce(),
6008
+ 'recvWindow': this.safeInteger(this.options, 'recvWindow', 5000),
6009
+ };
6010
+ body = this.json(params);
6011
+ }
6012
+ else {
6013
+ urlParams['timestamp'] = this.nonce();
6014
+ urlParams['recvWindow'] = this.safeInteger(this.options, 'recvWindow', 5000);
6015
+ }
5996
6016
  }
5997
- if (Object.keys(params).length) {
5998
- paramsEncoded = this.urlencode(params);
6017
+ let paramsEncoded = '';
6018
+ if (Object.keys(urlParams).length) {
6019
+ paramsEncoded = this.urlencode(urlParams);
5999
6020
  url += '?' + paramsEncoded;
6000
6021
  }
6001
6022
  if (access === 'private') {