ccxt 4.2.89 → 4.2.91

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 (90) hide show
  1. package/CHANGELOG.md +44 -16
  2. package/README.md +3 -3
  3. package/build.sh +1 -1
  4. package/dist/ccxt.browser.js +1167 -274
  5. package/dist/ccxt.browser.min.js +6 -4
  6. package/dist/cjs/ccxt.js +1 -1
  7. package/dist/cjs/src/ascendex.js +1 -0
  8. package/dist/cjs/src/base/Exchange.js +39 -9
  9. package/dist/cjs/src/base/functions/crypto.js +37 -0
  10. package/dist/cjs/src/base/functions/rsa.js +19 -4
  11. package/dist/cjs/src/binance.js +90 -9
  12. package/dist/cjs/src/bingx.js +101 -1
  13. package/dist/cjs/src/bitfinex2.js +1 -0
  14. package/dist/cjs/src/bitget.js +2 -0
  15. package/dist/cjs/src/bitmex.js +1 -0
  16. package/dist/cjs/src/bitrue.js +1 -0
  17. package/dist/cjs/src/bybit.js +61 -0
  18. package/dist/cjs/src/coinbase.js +51 -25
  19. package/dist/cjs/src/coinbaseinternational.js +1 -0
  20. package/dist/cjs/src/coinex.js +102 -8
  21. package/dist/cjs/src/cryptocom.js +1 -0
  22. package/dist/cjs/src/delta.js +1 -0
  23. package/dist/cjs/src/digifinex.js +1 -0
  24. package/dist/cjs/src/exmo.js +1 -0
  25. package/dist/cjs/src/gate.js +2 -0
  26. package/dist/cjs/src/gemini.js +12 -10
  27. package/dist/cjs/src/hitbtc.js +1 -0
  28. package/dist/cjs/src/htx.js +1 -0
  29. package/dist/cjs/src/hyperliquid.js +1 -0
  30. package/dist/cjs/src/kraken.js +11 -9
  31. package/dist/cjs/src/kucoin.js +1 -0
  32. package/dist/cjs/src/kucoinfutures.js +34 -3
  33. package/dist/cjs/src/mexc.js +1 -0
  34. package/dist/cjs/src/okx.js +187 -38
  35. package/dist/cjs/src/phemex.js +1 -0
  36. package/dist/cjs/src/pro/bitmex.js +39 -18
  37. package/dist/cjs/src/pro/kucoin.js +91 -0
  38. package/dist/cjs/src/pro/kucoinfutures.js +151 -82
  39. package/dist/cjs/src/static_dependencies/noble-curves/p256.js +48 -0
  40. package/dist/cjs/src/woo.js +1 -0
  41. package/js/ccxt.d.ts +1 -1
  42. package/js/ccxt.js +1 -1
  43. package/js/src/abstract/bingx.d.ts +2 -0
  44. package/js/src/abstract/bybit.d.ts +2 -0
  45. package/js/src/ascendex.js +1 -0
  46. package/js/src/base/Exchange.d.ts +5 -0
  47. package/js/src/base/Exchange.js +39 -9
  48. package/js/src/base/functions/crypto.js +37 -0
  49. package/js/src/base/functions/rsa.d.ts +1 -1
  50. package/js/src/base/functions/rsa.js +21 -5
  51. package/js/src/base/types.d.ts +1 -0
  52. package/js/src/binance.d.ts +1 -0
  53. package/js/src/binance.js +90 -9
  54. package/js/src/bingx.d.ts +1 -0
  55. package/js/src/bingx.js +101 -1
  56. package/js/src/bitfinex2.js +1 -0
  57. package/js/src/bitget.js +2 -0
  58. package/js/src/bitmex.js +1 -0
  59. package/js/src/bitrue.js +1 -0
  60. package/js/src/bybit.d.ts +2 -0
  61. package/js/src/bybit.js +61 -0
  62. package/js/src/coinbase.js +51 -25
  63. package/js/src/coinbaseinternational.js +1 -0
  64. package/js/src/coinex.d.ts +2 -0
  65. package/js/src/coinex.js +102 -8
  66. package/js/src/cryptocom.js +1 -0
  67. package/js/src/delta.js +1 -0
  68. package/js/src/digifinex.js +1 -0
  69. package/js/src/exmo.js +1 -0
  70. package/js/src/gate.js +2 -0
  71. package/js/src/gemini.js +12 -10
  72. package/js/src/hitbtc.js +1 -0
  73. package/js/src/htx.js +1 -0
  74. package/js/src/hyperliquid.js +1 -0
  75. package/js/src/kraken.js +11 -9
  76. package/js/src/kucoin.js +1 -0
  77. package/js/src/kucoinfutures.d.ts +2 -9
  78. package/js/src/kucoinfutures.js +34 -3
  79. package/js/src/mexc.js +1 -0
  80. package/js/src/okx.d.ts +1 -0
  81. package/js/src/okx.js +187 -38
  82. package/js/src/phemex.js +1 -0
  83. package/js/src/pro/bitmex.d.ts +1 -0
  84. package/js/src/pro/bitmex.js +39 -18
  85. package/js/src/pro/kucoin.d.ts +4 -0
  86. package/js/src/pro/kucoin.js +91 -0
  87. package/js/src/pro/kucoinfutures.d.ts +9 -5
  88. package/js/src/pro/kucoinfutures.js +151 -82
  89. package/js/src/woo.js +1 -0
  90. package/package.json +1 -1
@@ -6576,6 +6576,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
6576
6576
  'info': data,
6577
6577
  'symbol': market['symbol'],
6578
6578
  'type': undefined,
6579
+ 'marginMode': 'isolated',
6579
6580
  'amount': undefined,
6580
6581
  'total': undefined,
6581
6582
  'code': market['quote'],
@@ -7228,14 +7229,15 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
7228
7229
  /* harmony import */ var _functions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(927);
7229
7230
  /* harmony import */ var _functions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2116);
7230
7231
  /* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6689);
7231
- /* harmony import */ var _Precise_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(2194);
7232
+ /* harmony import */ var _Precise_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(2194);
7232
7233
  /* harmony import */ var _ws_WsClient_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7517);
7233
7234
  /* harmony import */ var _ws_Future_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2367);
7234
7235
  /* harmony import */ var _ws_OrderBook_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7091);
7235
7236
  /* harmony import */ var _functions_crypto_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6890);
7236
- /* harmony import */ var _functions_totp_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(2523);
7237
+ /* harmony import */ var _functions_totp_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(2523);
7237
7238
  /* harmony import */ var _static_dependencies_ethers_index_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(7090);
7238
7239
  /* harmony import */ var _static_dependencies_ethers_hash_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(7843);
7240
+ /* harmony import */ var _static_dependencies_jsencrypt_lib_jsbn_rng_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(2491);
7239
7241
  // ----------------------------------------------------------------------------
7240
7242
  /* eslint-disable */
7241
7243
 
@@ -7254,6 +7256,7 @@ const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sor
7254
7256
 
7255
7257
 
7256
7258
 
7259
+
7257
7260
  // ----------------------------------------------------------------------------
7258
7261
  /**
7259
7262
  * @class Exchange
@@ -7657,6 +7660,7 @@ class Exchange {
7657
7660
  'fetchIndexOHLCV': undefined,
7658
7661
  'fetchIsolatedBorrowRate': undefined,
7659
7662
  'fetchIsolatedBorrowRates': undefined,
7663
+ 'fetchMarginAdjustmentHistory': undefined,
7660
7664
  'fetchIsolatedPositions': undefined,
7661
7665
  'fetchL2OrderBook': true,
7662
7666
  'fetchL3OrderBook': undefined,
@@ -8663,6 +8667,13 @@ class Exchange {
8663
8667
  createSafeDictionary() {
8664
8668
  return {};
8665
8669
  }
8670
+ randomBytes(length) {
8671
+ const rng = new _static_dependencies_jsencrypt_lib_jsbn_rng_js__WEBPACK_IMPORTED_MODULE_10__/* .SecureRandom */ .C();
8672
+ const x = [];
8673
+ x.length = length;
8674
+ rng.nextBytes(x);
8675
+ return Buffer.from(x).toString('hex');
8676
+ }
8666
8677
  /* eslint-enable */
8667
8678
  // ------------------------------------------------------------------------
8668
8679
  // ########################################################################
@@ -9269,6 +9280,20 @@ class Exchange {
9269
9280
  async setMargin(symbol, amount, params = {}) {
9270
9281
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' setMargin() is not supported yet');
9271
9282
  }
9283
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
9284
+ /**
9285
+ * @method
9286
+ * @name exchange#fetchMarginAdjustmentHistory
9287
+ * @description fetches the history of margin added or reduced from contract isolated positions
9288
+ * @param {string} [symbol] unified market symbol
9289
+ * @param {string} [type] "add" or "reduce"
9290
+ * @param {int} [since] timestamp in ms of the earliest change to fetch
9291
+ * @param {int} [limit] the maximum amount of changes to fetch
9292
+ * @param {object} params extra parameters specific to the exchange api endpoint
9293
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9294
+ */
9295
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchMarginAdjustmentHistory() is not supported yet');
9296
+ }
9272
9297
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
9273
9298
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' setMarginMode() is not supported yet');
9274
9299
  }
@@ -9290,7 +9315,7 @@ class Exchange {
9290
9315
  parseToInt(number) {
9291
9316
  // Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
9292
9317
  // using a number as parameter which is not valid in ts
9293
- const stringifiedNumber = number.toString();
9318
+ const stringifiedNumber = this.numberToString(number);
9294
9319
  const convertedNumber = parseFloat(stringifiedNumber);
9295
9320
  return parseInt(convertedNumber);
9296
9321
  }
@@ -9336,18 +9361,18 @@ class Exchange {
9336
9361
  const amount = this.safeString(entry, 'amount');
9337
9362
  if (amount !== undefined) {
9338
9363
  if (before === undefined && after !== undefined) {
9339
- before = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringSub(after, amount);
9364
+ before = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringSub(after, amount);
9340
9365
  }
9341
9366
  else if (before !== undefined && after === undefined) {
9342
- after = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAdd(before, amount);
9367
+ after = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAdd(before, amount);
9343
9368
  }
9344
9369
  }
9345
9370
  if (before !== undefined && after !== undefined) {
9346
9371
  if (direction === undefined) {
9347
- if (_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringGt(before, after)) {
9372
+ if (_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringGt(before, after)) {
9348
9373
  direction = 'out';
9349
9374
  }
9350
- if (_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringGt(after, before)) {
9375
+ if (_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringGt(after, before)) {
9351
9376
  direction = 'in';
9352
9377
  }
9353
9378
  }
@@ -9599,13 +9624,13 @@ class Exchange {
9599
9624
  let used = this.safeString(balance[code], 'used');
9600
9625
  const debt = this.safeString(balance[code], 'debt');
9601
9626
  if ((total === undefined) && (free !== undefined) && (used !== undefined)) {
9602
- total = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAdd(free, used);
9627
+ total = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAdd(free, used);
9603
9628
  }
9604
9629
  if ((free === undefined) && (total !== undefined) && (used !== undefined)) {
9605
- free = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringSub(total, used);
9630
+ free = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringSub(total, used);
9606
9631
  }
9607
9632
  if ((used === undefined) && (total !== undefined) && (free !== undefined)) {
9608
- used = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringSub(total, free);
9633
+ used = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringSub(total, free);
9609
9634
  }
9610
9635
  balance[code]['free'] = this.parseNumber(free);
9611
9636
  balance[code]['used'] = this.parseNumber(used);
@@ -9693,11 +9718,11 @@ class Exchange {
9693
9718
  const trade = trades[i];
9694
9719
  const tradeAmount = this.safeString(trade, 'amount');
9695
9720
  if (parseFilled && (tradeAmount !== undefined)) {
9696
- filled = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAdd(filled, tradeAmount);
9721
+ filled = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAdd(filled, tradeAmount);
9697
9722
  }
9698
9723
  const tradeCost = this.safeString(trade, 'cost');
9699
9724
  if (parseCost && (tradeCost !== undefined)) {
9700
- cost = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAdd(cost, tradeCost);
9725
+ cost = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAdd(cost, tradeCost);
9701
9726
  }
9702
9727
  if (parseSymbol) {
9703
9728
  symbol = this.safeString(trade, 'symbol');
@@ -9758,7 +9783,7 @@ class Exchange {
9758
9783
  if (amount === undefined) {
9759
9784
  // ensure amount = filled + remaining
9760
9785
  if (filled !== undefined && remaining !== undefined) {
9761
- amount = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAdd(filled, remaining);
9786
+ amount = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAdd(filled, remaining);
9762
9787
  }
9763
9788
  else if (status === 'closed') {
9764
9789
  amount = filled;
@@ -9766,7 +9791,7 @@ class Exchange {
9766
9791
  }
9767
9792
  if (filled === undefined) {
9768
9793
  if (amount !== undefined && remaining !== undefined) {
9769
- filled = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringSub(amount, remaining);
9794
+ filled = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringSub(amount, remaining);
9770
9795
  }
9771
9796
  else if (status === 'closed' && amount !== undefined) {
9772
9797
  filled = amount;
@@ -9774,7 +9799,7 @@ class Exchange {
9774
9799
  }
9775
9800
  if (remaining === undefined) {
9776
9801
  if (amount !== undefined && filled !== undefined) {
9777
- remaining = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringSub(amount, filled);
9802
+ remaining = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringSub(amount, filled);
9778
9803
  }
9779
9804
  else if (status === 'closed') {
9780
9805
  remaining = '0';
@@ -9789,13 +9814,13 @@ class Exchange {
9789
9814
  // linear
9790
9815
  // price = cost / (filled * contract size)
9791
9816
  if (average === undefined) {
9792
- if ((filled !== undefined) && (cost !== undefined) && _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringGt(filled, '0')) {
9793
- const filledTimesContractSize = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(filled, contractSize);
9817
+ if ((filled !== undefined) && (cost !== undefined) && _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringGt(filled, '0')) {
9818
+ const filledTimesContractSize = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(filled, contractSize);
9794
9819
  if (inverse) {
9795
- average = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv(filledTimesContractSize, cost);
9820
+ average = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv(filledTimesContractSize, cost);
9796
9821
  }
9797
9822
  else {
9798
- average = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv(cost, filledTimesContractSize);
9823
+ average = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv(cost, filledTimesContractSize);
9799
9824
  }
9800
9825
  }
9801
9826
  }
@@ -9815,17 +9840,17 @@ class Exchange {
9815
9840
  multiplyPrice = average;
9816
9841
  }
9817
9842
  // contract trading
9818
- const filledTimesContractSize = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(filled, contractSize);
9843
+ const filledTimesContractSize = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(filled, contractSize);
9819
9844
  if (inverse) {
9820
- cost = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv(filledTimesContractSize, multiplyPrice);
9845
+ cost = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv(filledTimesContractSize, multiplyPrice);
9821
9846
  }
9822
9847
  else {
9823
- cost = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(filledTimesContractSize, multiplyPrice);
9848
+ cost = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(filledTimesContractSize, multiplyPrice);
9824
9849
  }
9825
9850
  }
9826
9851
  // support for market orders
9827
9852
  const orderType = this.safeValue(order, 'type');
9828
- const emptyPrice = (price === undefined) || _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringEquals(price, '0');
9853
+ const emptyPrice = (price === undefined) || _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringEquals(price, '0');
9829
9854
  if (emptyPrice && (orderType === 'market')) {
9830
9855
  price = average;
9831
9856
  }
@@ -9976,7 +10001,7 @@ class Exchange {
9976
10001
  let key = undefined;
9977
10002
  if (useQuote) {
9978
10003
  const priceString = this.numberToString(price);
9979
- cost = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(cost, priceString);
10004
+ cost = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(cost, priceString);
9980
10005
  key = 'quote';
9981
10006
  }
9982
10007
  else {
@@ -9991,7 +10016,7 @@ class Exchange {
9991
10016
  takerOrMaker = 'taker';
9992
10017
  }
9993
10018
  const rate = this.safeString(market, takerOrMaker);
9994
- cost = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(cost, rate);
10019
+ cost = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(cost, rate);
9995
10020
  return {
9996
10021
  'type': takerOrMaker,
9997
10022
  'currency': market[key],
@@ -10006,10 +10031,10 @@ class Exchange {
10006
10031
  let baseValue = this.safeString(liquidation, 'baseValue');
10007
10032
  let quoteValue = this.safeString(liquidation, 'quoteValue');
10008
10033
  if ((baseValue === undefined) && (contracts !== undefined) && (contractSize !== undefined) && (price !== undefined)) {
10009
- baseValue = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(contracts, contractSize);
10034
+ baseValue = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(contracts, contractSize);
10010
10035
  }
10011
10036
  if ((quoteValue === undefined) && (baseValue !== undefined) && (price !== undefined)) {
10012
- quoteValue = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(baseValue, price);
10037
+ quoteValue = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(baseValue, price);
10013
10038
  }
10014
10039
  liquidation['contracts'] = this.parseNumber(contracts);
10015
10040
  liquidation['contractSize'] = this.parseNumber(contractSize);
@@ -10029,11 +10054,11 @@ class Exchange {
10029
10054
  if (contractSize !== undefined) {
10030
10055
  const inverse = this.safeBool(market, 'inverse', false);
10031
10056
  if (inverse) {
10032
- multiplyPrice = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv('1', price);
10057
+ multiplyPrice = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv('1', price);
10033
10058
  }
10034
- multiplyPrice = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(multiplyPrice, contractSize);
10059
+ multiplyPrice = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(multiplyPrice, contractSize);
10035
10060
  }
10036
- cost = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(multiplyPrice, amount);
10061
+ cost = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(multiplyPrice, amount);
10037
10062
  }
10038
10063
  const parseFee = this.safeValue(trade, 'fee') === undefined;
10039
10064
  const parseFees = this.safeValue(trade, 'fees') === undefined;
@@ -10143,7 +10168,7 @@ class Exchange {
10143
10168
  if (feeCurrencyCode !== undefined) {
10144
10169
  const rate = this.safeString(fee, 'rate');
10145
10170
  const cost = this.safeValue(fee, 'cost');
10146
- if (_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringEq(cost, '0')) {
10171
+ if (_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringEq(cost, '0')) {
10147
10172
  // omit zero cost fees
10148
10173
  continue;
10149
10174
  }
@@ -10152,7 +10177,7 @@ class Exchange {
10152
10177
  }
10153
10178
  const rateKey = (rate === undefined) ? '' : rate;
10154
10179
  if (rateKey in reduced[feeCurrencyCode]) {
10155
- reduced[feeCurrencyCode][rateKey]['cost'] = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAdd(reduced[feeCurrencyCode][rateKey]['cost'], cost);
10180
+ reduced[feeCurrencyCode][rateKey]['cost'] = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAdd(reduced[feeCurrencyCode][rateKey]['cost'], cost);
10156
10181
  }
10157
10182
  else {
10158
10183
  reduced[feeCurrencyCode][rateKey] = {
@@ -10184,7 +10209,7 @@ class Exchange {
10184
10209
  const baseVolume = this.safeString(ticker, 'baseVolume');
10185
10210
  const quoteVolume = this.safeString(ticker, 'quoteVolume');
10186
10211
  if (vwap === undefined) {
10187
- vwap = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv(this.omitZero(quoteVolume), baseVolume);
10212
+ vwap = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv(this.omitZero(quoteVolume), baseVolume);
10188
10213
  }
10189
10214
  if ((last !== undefined) && (close === undefined)) {
10190
10215
  close = last;
@@ -10194,20 +10219,20 @@ class Exchange {
10194
10219
  }
10195
10220
  if ((last !== undefined) && (open !== undefined)) {
10196
10221
  if (change === undefined) {
10197
- change = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringSub(last, open);
10222
+ change = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringSub(last, open);
10198
10223
  }
10199
10224
  if (average === undefined) {
10200
- average = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv(_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAdd(last, open), '2');
10225
+ average = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv(_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAdd(last, open), '2');
10201
10226
  }
10202
10227
  }
10203
- if ((percentage === undefined) && (change !== undefined) && (open !== undefined) && _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringGt(open, '0')) {
10204
- percentage = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv(change, open), '100');
10228
+ if ((percentage === undefined) && (change !== undefined) && (open !== undefined) && _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringGt(open, '0')) {
10229
+ percentage = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv(change, open), '100');
10205
10230
  }
10206
10231
  if ((change === undefined) && (percentage !== undefined) && (open !== undefined)) {
10207
- change = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv(_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(percentage, open), '100');
10232
+ change = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv(_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(percentage, open), '100');
10208
10233
  }
10209
10234
  if ((open === undefined) && (last !== undefined) && (change !== undefined)) {
10210
- open = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringSub(last, change);
10235
+ open = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringSub(last, change);
10211
10236
  }
10212
10237
  // timestamp and symbol operations don't belong in safeTicker
10213
10238
  // they should be done in the derived classes
@@ -10677,7 +10702,7 @@ class Exchange {
10677
10702
  const percentage = this.safeValue(position, 'percentage');
10678
10703
  if ((percentage === undefined) && (unrealizedPnlString !== undefined) && (initialMarginString !== undefined)) {
10679
10704
  // as it was done in all implementations ( aax, btcex, bybit, deribit, ftx, gate, kucoinfutures, phemex )
10680
- const percentageString = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringMul(_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringDiv(unrealizedPnlString, initialMarginString, 4), '100');
10705
+ const percentageString = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringMul(_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringDiv(unrealizedPnlString, initialMarginString, 4), '100');
10681
10706
  position['percentage'] = this.parseNumber(percentageString);
10682
10707
  }
10683
10708
  // if contractSize is undefined get from market
@@ -11085,7 +11110,7 @@ class Exchange {
11085
11110
  }
11086
11111
  oath() {
11087
11112
  if (this.twofa !== undefined) {
11088
- return (0,_functions_totp_js__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .Z)(this.twofa);
11113
+ return (0,_functions_totp_js__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .Z)(this.twofa);
11089
11114
  }
11090
11115
  else {
11091
11116
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError(this.id + ' exchange.twofa has not been set for 2FA Two-Factor Authentication');
@@ -11783,13 +11808,6 @@ class Exchange {
11783
11808
  if (!this.substituteCommonCurrencyCodes) {
11784
11809
  return code;
11785
11810
  }
11786
- // if the provided code already exists as a value in commonCurrencies dict, then we should not again transform it
11787
- // more details at: https://github.com/ccxt/ccxt/issues/21112#issuecomment-2031293691
11788
- const commonCurrencies = Object.values(this.commonCurrencies);
11789
- const exists = this.inArray(code, commonCurrencies);
11790
- if (exists) {
11791
- return code;
11792
- }
11793
11811
  return this.safeString(this.commonCurrencies, code, code);
11794
11812
  }
11795
11813
  currency(code) {
@@ -11956,11 +11974,11 @@ class Exchange {
11956
11974
  if (precision === undefined) {
11957
11975
  return undefined;
11958
11976
  }
11959
- if (_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringGe(precision, '0')) {
11977
+ if (_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringGe(precision, '0')) {
11960
11978
  return this.parsePrecision(precision);
11961
11979
  }
11962
11980
  else {
11963
- const positivePrecisionString = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAbs(precision);
11981
+ const positivePrecisionString = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAbs(precision);
11964
11982
  const positivePrecision = parseInt(positivePrecisionString);
11965
11983
  let parsedPrecision = '1';
11966
11984
  for (let i = 0; i < positivePrecision - 1; i++) {
@@ -12440,7 +12458,6 @@ class Exchange {
12440
12458
  * @returns {object} objects with withdraw and deposit fees, indexed by currency codes
12441
12459
  */
12442
12460
  const depositWithdrawFees = {};
12443
- codes = this.marketCodes(codes);
12444
12461
  const isArray = Array.isArray(response);
12445
12462
  let responseKeys = response;
12446
12463
  if (!isArray) {
@@ -13032,6 +13049,21 @@ class Exchange {
13032
13049
  const reconstructedDate = day + month + year;
13033
13050
  return reconstructedDate;
13034
13051
  }
13052
+ parseMarginModification(data, market = undefined) {
13053
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseMarginModification() is not supported yet');
13054
+ }
13055
+ parseMarginModifications(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
13056
+ const marginModifications = [];
13057
+ for (let i = 0; i < response.length; i++) {
13058
+ const info = response[i];
13059
+ const marketId = this.safeString(info, symbolKey);
13060
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
13061
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
13062
+ marginModifications.push(this.parseMarginModification(info, market));
13063
+ }
13064
+ }
13065
+ return marginModifications;
13066
+ }
13035
13067
  }
13036
13068
 
13037
13069
 
@@ -13795,19 +13827,29 @@ __webpack_require__.r(__webpack_exports__);
13795
13827
  /* harmony export */ kn: () => (/* binding */ crc32),
13796
13828
  /* harmony export */ vp: () => (/* binding */ hash)
13797
13829
  /* harmony export */ });
13798
- /* harmony import */ var _static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(138);
13830
+ /* harmony import */ var _static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(138);
13799
13831
  /* harmony import */ var _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9651);
13800
- /* harmony import */ var _static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9285);
13832
+ /* harmony import */ var _static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9285);
13833
+ /* harmony import */ var _static_dependencies_jsencrypt_lib_asn1js_asn1_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1728);
13834
+ /* harmony import */ var _static_dependencies_noble_curves_secp256k1_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1339);
13835
+ /* harmony import */ var _static_dependencies_noble_curves_p256_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2572);
13801
13836
  /* ------------------------------------------------------------------------ */
13802
13837
 
13803
13838
 
13804
13839
 
13840
+
13841
+
13842
+
13805
13843
  /* ------------------------------------------------------------------------ */
13806
13844
  const encoders = {
13807
13845
  binary: x => x,
13808
13846
  hex: _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base16 */ .YU.encode,
13809
13847
  base64: _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base64 */ .US.encode,
13810
13848
  };
13849
+ const supportedCurve = {
13850
+ '1.3.132.0.10': _static_dependencies_noble_curves_secp256k1_js__WEBPACK_IMPORTED_MODULE_1__/* .secp256k1 */ .kA,
13851
+ '1.2.840.10045.3.1.7': _static_dependencies_noble_curves_p256_js__WEBPACK_IMPORTED_MODULE_2__/* .P256 */ .lA,
13852
+ };
13811
13853
  /* ............................................. */
13812
13854
  const hash = (request, hash, digest = 'hex') => {
13813
13855
  const binary = hash(request);
@@ -13815,7 +13857,7 @@ const hash = (request, hash, digest = 'hex') => {
13815
13857
  };
13816
13858
  /* ............................................. */
13817
13859
  const hmac = (request, secret, hash, digest = 'hex') => {
13818
- const binary = (0,_static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_1__/* .hmac */ .b)(hash, secret, request);
13860
+ const binary = (0,_static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_3__/* .hmac */ .b)(hash, secret, request);
13819
13861
  return encoders[digest](binary);
13820
13862
  };
13821
13863
  /* ............................................. */
@@ -13823,6 +13865,36 @@ function ecdsa(request, secret, curve, prehash = null) {
13823
13865
  if (prehash) {
13824
13866
  request = hash(request, prehash, 'hex');
13825
13867
  }
13868
+ if (typeof secret === 'string' && secret.length > 64) {
13869
+ // decode pem key
13870
+ if (secret.startsWith('-----BEGIN EC PRIVATE KEY-----')) {
13871
+ const der = _static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_4__/* .Base64 */ .D.unarmor(secret);
13872
+ let asn1 = _static_dependencies_jsencrypt_lib_asn1js_asn1_js__WEBPACK_IMPORTED_MODULE_5__/* .ASN1 */ .lj.decode(der);
13873
+ if (asn1.sub.length === 4) {
13874
+ // ECPrivateKey ::= SEQUENCE {
13875
+ // version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
13876
+ // privateKey OCTET STRING,
13877
+ // parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
13878
+ // publicKey [1] BIT STRING OPTIONAL
13879
+ // }
13880
+ if (typeof asn1.sub[2].sub !== null && asn1.sub[2].sub.length > 0) {
13881
+ const oid = asn1.sub[2].sub[0].content(undefined);
13882
+ if (supportedCurve[oid] === undefined)
13883
+ throw new Error('Unsupported curve');
13884
+ curve = supportedCurve[oid];
13885
+ }
13886
+ secret = asn1.sub[1].getHexStringValue();
13887
+ }
13888
+ else {
13889
+ // maybe return false
13890
+ throw new Error('Unsupported key format');
13891
+ }
13892
+ }
13893
+ else {
13894
+ // maybe return false
13895
+ throw new Error('Unsupported key format');
13896
+ }
13897
+ }
13826
13898
  const signature = curve.sign(request, secret);
13827
13899
  return {
13828
13900
  'r': signature.r.toString(16),
@@ -13838,7 +13910,7 @@ function axolotl(request, secret, curve) {
13838
13910
  function eddsa(request, secret, curve) {
13839
13911
  // secret is the base64 pem encoded key
13840
13912
  // we get the last 32 bytes
13841
- const privateKey = new Uint8Array(_static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_2__/* .Base64 */ .D.unarmor(secret).slice(16));
13913
+ const privateKey = new Uint8Array(_static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_4__/* .Base64 */ .D.unarmor(secret).slice(16));
13842
13914
  const signature = curve.sign(request, privateKey);
13843
13915
  return _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base64 */ .US.encode(signature);
13844
13916
  }
@@ -14578,6 +14650,9 @@ const isNode = !(isBrowser || isWebWorker);
14578
14650
  /* harmony import */ var _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9651);
14579
14651
  /* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1237);
14580
14652
  /* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6890);
14653
+ /* harmony import */ var _static_dependencies_noble_curves_p256_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2572);
14654
+
14655
+
14581
14656
 
14582
14657
 
14583
14658
 
@@ -14589,9 +14664,17 @@ function rsa(request, secret, hash) {
14589
14664
  const name = (hash.create()).constructor.name.toLowerCase();
14590
14665
  return RSA.sign(request, digester, name);
14591
14666
  }
14592
- function jwt(request, secret, hash, isRSA = false) {
14593
- const alg = (isRSA ? 'RS' : 'HS') + (hash.outputLen * 8);
14594
- const encodedHeader = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .stringToBase64 */ .Ne)(JSON.stringify({ 'alg': alg, 'typ': 'JWT' })));
14667
+ function jwt(request, secret, hash, isRSA = false, opts = {}) {
14668
+ let alg = (isRSA ? 'RS' : 'HS') + (hash.outputLen * 8);
14669
+ if (opts['alg']) {
14670
+ alg = opts['alg'].toUpperCase();
14671
+ }
14672
+ const header = Object.assign({ 'alg': alg, 'typ': 'JWT' }, opts);
14673
+ if (header['iat'] !== undefined) {
14674
+ request['iat'] = header['iat'];
14675
+ delete header['iat'];
14676
+ }
14677
+ const encodedHeader = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .stringToBase64 */ .Ne)(JSON.stringify(header)));
14595
14678
  const encodedData = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .stringToBase64 */ .Ne)(JSON.stringify(request)));
14596
14679
  const token = [encodedHeader, encodedData].join('.');
14597
14680
  const algoType = alg.slice(0, 2);
@@ -14599,9 +14682,15 @@ function jwt(request, secret, hash, isRSA = false) {
14599
14682
  if (algoType === 'HS') {
14600
14683
  signature = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)((0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__/* .hmac */ .bD)(token, secret, hash, 'base64'));
14601
14684
  }
14602
- else if (algoType === 'RS') {
14685
+ else if (isRSA || algoType === 'RS') {
14603
14686
  signature = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)(rsa(token, _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_1__/* .utf8 */ .KA.encode(secret), hash));
14604
14687
  }
14688
+ else if (algoType === 'ES') {
14689
+ const signedHash = (0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__/* .ecdsa */ .bu)(token, _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_1__/* .utf8 */ .KA.encode(secret), _static_dependencies_noble_curves_p256_js__WEBPACK_IMPORTED_MODULE_4__/* .P256 */ .lA, hash);
14690
+ const r = (signedHash.r.length === 64) ? signedHash.r : '0' + signedHash.r;
14691
+ const s = (signedHash.s.length === 64) ? signedHash.s : '0' + signedHash.s;
14692
+ signature = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .binaryToBase64 */ .bA)((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .base16ToBinary */ .aj)(r + s)));
14693
+ }
14605
14694
  return [token, signature].join('.');
14606
14695
  }
14607
14696
 
@@ -18652,6 +18741,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18652
18741
  'fetchLeverages': true,
18653
18742
  'fetchLeverageTiers': true,
18654
18743
  'fetchLiquidations': false,
18744
+ 'fetchMarginAdjustmentHistory': true,
18655
18745
  'fetchMarginMode': 'emulated',
18656
18746
  'fetchMarginModes': true,
18657
18747
  'fetchMarketLeverageTiers': 'emulated',
@@ -29782,21 +29872,37 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
29782
29872
  // "type": 1
29783
29873
  // }
29784
29874
  //
29875
+ // fetchMarginAdjustmentHistory
29876
+ //
29877
+ // {
29878
+ // symbol: "XRPUSDT",
29879
+ // type: "1",
29880
+ // deltaType: "TRADE",
29881
+ // amount: "2.57148240",
29882
+ // asset: "USDT",
29883
+ // time: "1711046271555",
29884
+ // positionSide: "BOTH",
29885
+ // clientTranId: ""
29886
+ // }
29887
+ //
29785
29888
  const rawType = this.safeInteger(data, 'type');
29786
- const resultType = (rawType === 1) ? 'add' : 'reduce';
29787
- const resultAmount = this.safeNumber(data, 'amount');
29788
29889
  const errorCode = this.safeString(data, 'code');
29789
- const status = (errorCode === '200') ? 'ok' : 'failed';
29890
+ const marketId = this.safeString(data, 'symbol');
29891
+ const timestamp = this.safeInteger(data, 'time');
29892
+ market = this.safeMarket(marketId, market, undefined, 'swap');
29893
+ const noErrorCode = errorCode === undefined;
29894
+ const success = errorCode === '200';
29790
29895
  return {
29791
29896
  'info': data,
29792
29897
  'symbol': market['symbol'],
29793
- 'type': resultType,
29794
- 'amount': resultAmount,
29898
+ 'type': (rawType === 1) ? 'add' : 'reduce',
29899
+ 'marginMode': 'isolated',
29900
+ 'amount': this.safeNumber(data, 'amount'),
29901
+ 'code': this.safeString(data, 'asset'),
29795
29902
  'total': undefined,
29796
- 'code': undefined,
29797
- 'status': status,
29798
- 'timestamp': undefined,
29799
- 'datetime': undefined,
29903
+ 'status': (success || noErrorCode) ? 'ok' : 'failed',
29904
+ 'timestamp': timestamp,
29905
+ 'datetime': this.iso8601(timestamp),
29800
29906
  };
29801
29907
  }
29802
29908
  async reduceMargin(symbol, amount, params = {}) {
@@ -31059,6 +31165,70 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
31059
31165
  'quoteVolume': undefined,
31060
31166
  };
31061
31167
  }
31168
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
31169
+ /**
31170
+ * @method
31171
+ * @description fetches the history of margin added or reduced from contract isolated positions
31172
+ * @see https://binance-docs.github.io/apidocs/futures/en/#get-position-margin-change-history-trade
31173
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#get-position-margin-change-history-trade
31174
+ * @param {string} symbol unified market symbol
31175
+ * @param {string} [type] "add" or "reduce"
31176
+ * @param {int} [since] timestamp in ms of the earliest change to fetch
31177
+ * @param {int} [limit] the maximum amount of changes to fetch
31178
+ * @param {object} params extra parameters specific to the exchange api endpoint
31179
+ * @param {int} [params.until] timestamp in ms of the latest change to fetch
31180
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
31181
+ */
31182
+ await this.loadMarkets();
31183
+ if (symbol === undefined) {
31184
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory () requires a symbol argument');
31185
+ }
31186
+ const market = this.market(symbol);
31187
+ const until = this.safeInteger(params, 'until');
31188
+ params = this.omit(params, 'until');
31189
+ const request = {
31190
+ 'symbol': market['id'],
31191
+ };
31192
+ if (type !== undefined) {
31193
+ request['type'] = (type === 'add') ? 1 : 2;
31194
+ }
31195
+ if (since !== undefined) {
31196
+ request['startTime'] = since;
31197
+ }
31198
+ if (limit !== undefined) {
31199
+ request['limit'] = limit;
31200
+ }
31201
+ if (until !== undefined) {
31202
+ request['endTime'] = until;
31203
+ }
31204
+ let response = undefined;
31205
+ if (market['linear']) {
31206
+ response = await this.fapiPrivateGetPositionMarginHistory(this.extend(request, params));
31207
+ }
31208
+ else if (market['inverse']) {
31209
+ response = await this.dapiPrivateGetPositionMarginHistory(this.extend(request, params));
31210
+ }
31211
+ else {
31212
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + 'fetchMarginAdjustmentHistory () is not supported for markets of type ' + market['type']);
31213
+ }
31214
+ //
31215
+ // [
31216
+ // {
31217
+ // symbol: "XRPUSDT",
31218
+ // type: "1",
31219
+ // deltaType: "TRADE",
31220
+ // amount: "2.57148240",
31221
+ // asset: "USDT",
31222
+ // time: "1711046271555",
31223
+ // positionSide: "BOTH",
31224
+ // clientTranId: ""
31225
+ // }
31226
+ // ...
31227
+ // ]
31228
+ //
31229
+ const modifications = this.parseMarginModifications(response);
31230
+ return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
31231
+ }
31062
31232
  }
31063
31233
 
31064
31234
 
@@ -31467,6 +31637,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31467
31637
  'fetchFundingRates': true,
31468
31638
  'fetchLeverage': true,
31469
31639
  'fetchLiquidations': false,
31640
+ 'fetchMarginAdjustmentHistory': false,
31470
31641
  'fetchMarginMode': true,
31471
31642
  'fetchMarkets': true,
31472
31643
  'fetchMarkOHLCV': true,
@@ -31476,6 +31647,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31476
31647
  'fetchOpenOrders': true,
31477
31648
  'fetchOrder': true,
31478
31649
  'fetchOrderBook': true,
31650
+ 'fetchOrders': true,
31479
31651
  'fetchPositionMode': true,
31480
31652
  'fetchPositions': true,
31481
31653
  'fetchTicker': true,
@@ -31587,6 +31759,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31587
31759
  'positionSide/dual': 1,
31588
31760
  'market/markPriceKlines': 1,
31589
31761
  'trade/batchCancelReplace': 1,
31762
+ 'trade/fullOrder': 1,
31590
31763
  },
31591
31764
  'post': {
31592
31765
  'trade/cancelReplace': 1,
@@ -31734,6 +31907,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31734
31907
  'post': {
31735
31908
  'swap/trace/closeTrackOrder': 1,
31736
31909
  'swap/trace/setTPSL': 1,
31910
+ 'spot/trader/sellOrder': 1,
31737
31911
  },
31738
31912
  },
31739
31913
  },
@@ -34164,7 +34338,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34164
34338
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
34165
34339
  */
34166
34340
  if (symbol === undefined) {
34167
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
34341
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
34168
34342
  }
34169
34343
  await this.loadMarkets();
34170
34344
  const market = this.market(symbol);
@@ -34235,6 +34409,101 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34235
34409
  const first = this.safeDict(data, 'order', data);
34236
34410
  return this.parseOrder(first, market);
34237
34411
  }
34412
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
34413
+ /**
34414
+ * @method
34415
+ * @name bingx#fetchOrders
34416
+ * @description fetches information on multiple orders made by the user
34417
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#User's%20All%20Orders
34418
+ * @param {string} symbol unified market symbol of the market orders were made in
34419
+ * @param {int} [since] the earliest time in ms to fetch orders for
34420
+ * @param {int} [limit] the maximum number of order structures to retrieve
34421
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
34422
+ * @param {int} [params.until] the latest time in ms to fetch entries for
34423
+ * @param {int} [params.orderId] Only return subsequent orders, and return the latest order by default
34424
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
34425
+ */
34426
+ await this.loadMarkets();
34427
+ const request = {};
34428
+ let market = undefined;
34429
+ if (symbol !== undefined) {
34430
+ market = this.market(symbol);
34431
+ request['symbol'] = market['id'];
34432
+ }
34433
+ let type = undefined;
34434
+ [type, params] = this.handleMarketTypeAndParams('fetchOrders', market, params);
34435
+ if (type !== 'swap') {
34436
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrders() is only supported for swap markets');
34437
+ }
34438
+ if (limit !== undefined) {
34439
+ request['limit'] = limit;
34440
+ }
34441
+ if (since !== undefined) {
34442
+ request['startTime'] = since;
34443
+ }
34444
+ const until = this.safeInteger2(params, 'until', 'till'); // unified in milliseconds
34445
+ const endTime = this.safeInteger(params, 'endTime', until); // exchange-specific in milliseconds
34446
+ params = this.omit(params, ['endTime', 'till', 'until']);
34447
+ if (endTime !== undefined) {
34448
+ request['endTime'] = endTime;
34449
+ }
34450
+ const response = await this.swapV1PrivateGetTradeFullOrder(this.extend(request, params));
34451
+ //
34452
+ // {
34453
+ // "code": 0,
34454
+ // "msg": "",
34455
+ // "data": {
34456
+ // "orders": [
34457
+ // {
34458
+ // "symbol": "PYTH-USDT",
34459
+ // "orderId": 1736007506620112100,
34460
+ // "side": "SELL",
34461
+ // "positionSide": "SHORT",
34462
+ // "type": "LIMIT",
34463
+ // "origQty": "33",
34464
+ // "price": "0.3916",
34465
+ // "executedQty": "33",
34466
+ // "avgPrice": "0.3916",
34467
+ // "cumQuote": "13",
34468
+ // "stopPrice": "",
34469
+ // "profit": "0.0000",
34470
+ // "commission": "-0.002585",
34471
+ // "status": "FILLED",
34472
+ // "time": 1702731418000,
34473
+ // "updateTime": 1702731470000,
34474
+ // "clientOrderId": "",
34475
+ // "leverage": "15X",
34476
+ // "takeProfit": {
34477
+ // "type": "TAKE_PROFIT",
34478
+ // "quantity": 0,
34479
+ // "stopPrice": 0,
34480
+ // "price": 0,
34481
+ // "workingType": ""
34482
+ // },
34483
+ // "stopLoss": {
34484
+ // "type": "STOP",
34485
+ // "quantity": 0,
34486
+ // "stopPrice": 0,
34487
+ // "price": 0,
34488
+ // "workingType": ""
34489
+ // },
34490
+ // "advanceAttr": 0,
34491
+ // "positionID": 0,
34492
+ // "takeProfitEntrustPrice": 0,
34493
+ // "stopLossEntrustPrice": 0,
34494
+ // "orderType": "",
34495
+ // "workingType": "MARK_PRICE",
34496
+ // "stopGuaranteed": false,
34497
+ // "triggerOrderId": 1736012449498123500
34498
+ // }
34499
+ // ]
34500
+ // }
34501
+ // }
34502
+ //
34503
+ const data = this.safeDict(response, 'data', {});
34504
+ const orders = this.safeList(data, 'orders', []);
34505
+ return this.parseOrders(orders, market, since, limit);
34506
+ }
34238
34507
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
34239
34508
  /**
34240
34509
  * @method
@@ -34935,6 +35204,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34935
35204
  'info': data,
34936
35205
  'symbol': this.safeString(market, 'symbol'),
34937
35206
  'type': (type === '1') ? 'add' : 'reduce',
35207
+ 'marginMode': 'isolated',
34938
35208
  'amount': this.safeNumber(data, 'amount'),
34939
35209
  'total': this.safeNumber(data, 'margin'),
34940
35210
  'code': this.safeString(market, 'settle'),
@@ -44244,6 +44514,7 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
44244
44514
  'info': data,
44245
44515
  'symbol': market['symbol'],
44246
44516
  'type': undefined,
44517
+ 'marginMode': 'isolated',
44247
44518
  'amount': undefined,
44248
44519
  'total': undefined,
44249
44520
  'code': undefined,
@@ -45621,6 +45892,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45621
45892
  'fetchLeverage': true,
45622
45893
  'fetchLeverageTiers': false,
45623
45894
  'fetchLiquidations': false,
45895
+ 'fetchMarginAdjustmentHistory': false,
45624
45896
  'fetchMarginMode': true,
45625
45897
  'fetchMarketLeverageTiers': true,
45626
45898
  'fetchMarkets': true,
@@ -52521,6 +52793,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
52521
52793
  'info': data,
52522
52794
  'symbol': market['symbol'],
52523
52795
  'type': undefined,
52796
+ 'marginMode': 'isolated',
52524
52797
  'amount': undefined,
52525
52798
  'total': undefined,
52526
52799
  'code': market['settle'],
@@ -59780,6 +60053,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
59780
60053
  'fetchLeverages': true,
59781
60054
  'fetchLeverageTiers': false,
59782
60055
  'fetchLiquidations': true,
60056
+ 'fetchMarginAdjustmentHistory': false,
59783
60057
  'fetchMarketLeverageTiers': false,
59784
60058
  'fetchMarkets': true,
59785
60059
  'fetchMarkOHLCV': false,
@@ -67466,6 +67740,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
67466
67740
  'info': data,
67467
67741
  'symbol': market['symbol'],
67468
67742
  'type': undefined,
67743
+ 'marginMode': 'isolated',
67469
67744
  'amount': undefined,
67470
67745
  'total': undefined,
67471
67746
  'code': undefined,
@@ -83974,6 +84249,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
83974
84249
  'fetchLedger': true,
83975
84250
  'fetchLeverage': true,
83976
84251
  'fetchLeverageTiers': true,
84252
+ 'fetchMarginAdjustmentHistory': false,
83977
84253
  'fetchMarketLeverageTiers': true,
83978
84254
  'fetchMarkets': true,
83979
84255
  'fetchMarkOHLCV': true,
@@ -84044,6 +84320,13 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84044
84320
  'public': 'https://api.{hostname}',
84045
84321
  'private': 'https://api.{hostname}',
84046
84322
  },
84323
+ 'demotrading': {
84324
+ 'spot': 'https://api-demo.{hostname}',
84325
+ 'futures': 'https://api-demo.{hostname}',
84326
+ 'v2': 'https://api-demo.{hostname}',
84327
+ 'public': 'https://api-demo.{hostname}',
84328
+ 'private': 'https://api-demo.{hostname}',
84329
+ },
84047
84330
  'www': 'https://www.bybit.com',
84048
84331
  'doc': [
84049
84332
  'https://bybit-exchange.github.io/docs/inverse/',
@@ -84232,6 +84515,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84232
84515
  'v5/user/get-member-type': 5,
84233
84516
  'v5/user/aff-customer-info': 5,
84234
84517
  'v5/user/del-submember': 5,
84518
+ 'v5/user/submembers': 5,
84235
84519
  // spot leverage token
84236
84520
  'v5/spot-lever-token/order-record': 1,
84237
84521
  // spot margin trade
@@ -84392,6 +84676,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84392
84676
  'v5/lending/redeem-cancel': 5,
84393
84677
  'v5/account/set-collateral-switch': 5,
84394
84678
  'v5/account/set-collateral-switch-batch': 5,
84679
+ // demo trading
84680
+ 'v5/account/demo-apply-money': 5,
84395
84681
  },
84396
84682
  },
84397
84683
  },
@@ -84858,6 +85144,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84858
85144
  },
84859
85145
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_2__/* .TICK_SIZE */ .sh,
84860
85146
  'options': {
85147
+ 'sandboxMode': false,
85148
+ 'enableDemoTrading': false,
84861
85149
  'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
84862
85150
  'createOrder': {
84863
85151
  'method': 'privatePostV5OrderCreate', // 'privatePostV5PositionTradingStop'
@@ -84941,6 +85229,39 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84941
85229
  },
84942
85230
  });
84943
85231
  }
85232
+ setSandboxMode(enable) {
85233
+ /**
85234
+ * @method
85235
+ * @name bybit#setSandboxMode
85236
+ * @description enables or disables sandbox mode
85237
+ * @param {boolean} [enable] true if demo trading should be enabled, false otherwise
85238
+ */
85239
+ super.setSandboxMode(enable);
85240
+ this.options['sandboxMode'] = enable;
85241
+ }
85242
+ enableDemoTrading(enable) {
85243
+ /**
85244
+ * @method
85245
+ * @name bybit#enableDemoTrading
85246
+ * @description enables or disables demo trading mode
85247
+ * @see https://bybit-exchange.github.io/docs/v5/demo
85248
+ * @param {boolean} [enable] true if demo trading should be enabled, false otherwise
85249
+ */
85250
+ if (this.options['sandboxMode']) {
85251
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' demo trading does not support in sandbox environment');
85252
+ }
85253
+ // enable demo trading in bybit, see: https://bybit-exchange.github.io/docs/v5/demo
85254
+ if (enable) {
85255
+ this.urls['apiBackupDemoTrading'] = this.urls['api'];
85256
+ this.urls['api'] = this.urls['demotrading'];
85257
+ }
85258
+ else if ('apiBackupDemoTrading' in this.urls) {
85259
+ this.urls['api'] = this.urls['apiBackupDemoTrading'];
85260
+ const newUrls = this.omit(this.urls, 'apiBackupDemoTrading');
85261
+ this.urls = newUrls;
85262
+ }
85263
+ this.options['enableDemoTrading'] = enable;
85264
+ }
84944
85265
  nonce() {
84945
85266
  return this.milliseconds() - this.options['timeDifference'];
84946
85267
  }
@@ -84957,12 +85278,24 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84957
85278
  return data;
84958
85279
  }
84959
85280
  async isUnifiedEnabled(params = {}) {
85281
+ /**
85282
+ * @method
85283
+ * @name bybit#isUnifiedEnabled
85284
+ * @description returns [enableUnifiedMargin, enableUnifiedAccount] so the user can check if unified account is enabled
85285
+ */
84960
85286
  // The API key of user id must own one of permissions will be allowed to call following API endpoints.
84961
85287
  // SUB UID: "Account Transfer"
84962
85288
  // MASTER UID: "Account Transfer", "Subaccount Transfer", "Withdrawal"
84963
85289
  const enableUnifiedMargin = this.safeValue(this.options, 'enableUnifiedMargin');
84964
85290
  const enableUnifiedAccount = this.safeValue(this.options, 'enableUnifiedAccount');
84965
85291
  if (enableUnifiedMargin === undefined || enableUnifiedAccount === undefined) {
85292
+ if (this.options['enableDemoTrading']) {
85293
+ // info endpoint is not available in demo trading
85294
+ // so we're assuming UTA is enabled
85295
+ this.options['enableUnifiedMargin'] = false;
85296
+ this.options['enableUnifiedAccount'] = true;
85297
+ return [this.options['enableUnifiedMargin'], this.options['enableUnifiedAccount']];
85298
+ }
84966
85299
  const response = await this.privateGetV5UserQueryApi(params);
84967
85300
  //
84968
85301
  // {
@@ -85132,6 +85465,9 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
85132
85465
  if (!this.checkRequiredCredentials(false)) {
85133
85466
  return undefined;
85134
85467
  }
85468
+ if (this.options['enableDemoTrading']) {
85469
+ return undefined;
85470
+ }
85135
85471
  const response = await this.privateGetV5AssetCoinQueryInfo(params);
85136
85472
  //
85137
85473
  // {
@@ -94092,13 +94428,15 @@ class cex extends _abstract_cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
94092
94428
  /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
94093
94429
  /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2194);
94094
94430
  /* harmony import */ var _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9292);
94095
- /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1372);
94431
+ /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1372);
94432
+ /* harmony import */ var _base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5981);
94096
94433
  // ----------------------------------------------------------------------------
94097
94434
 
94098
94435
 
94099
94436
 
94100
94437
 
94101
94438
 
94439
+
94102
94440
  // ----------------------------------------------------------------------------
94103
94441
  /**
94104
94442
  * @class coinbase
@@ -94419,6 +94757,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
94419
94757
  'CGLD': 'CELO',
94420
94758
  },
94421
94759
  'options': {
94760
+ 'brokerId': 'ccxt',
94422
94761
  'stablePairs': ['BUSD-USD', 'CBETH-ETH', 'DAI-USD', 'GUSD-USD', 'GYEN-USD', 'PAX-USD', 'PAX-USDT', 'USDC-EUR', 'USDC-GBP', 'USDT-EUR', 'USDT-GBP', 'USDT-USD', 'USDT-USDC', 'WBTC-BTC'],
94423
94762
  'fetchCurrencies': {
94424
94763
  'expires': 5000,
@@ -96429,8 +96768,9 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96429
96768
  */
96430
96769
  await this.loadMarkets();
96431
96770
  const market = this.market(symbol);
96771
+ const id = this.safeString(this.options, 'brokerId', 'ccxt');
96432
96772
  let request = {
96433
- 'client_order_id': this.uuid(),
96773
+ 'client_order_id': id + '-' + this.uuid(),
96434
96774
  'product_id': market['id'],
96435
96775
  'side': side.toUpperCase(),
96436
96776
  };
@@ -97875,31 +98215,16 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
97875
98215
  const url = this.urls['api']['rest'] + fullPath;
97876
98216
  if (signed) {
97877
98217
  const authorization = this.safeString(this.headers, 'Authorization');
98218
+ let authorizationString = undefined;
97878
98219
  if (authorization !== undefined) {
97879
- headers = {
97880
- 'Authorization': authorization,
97881
- 'Content-Type': 'application/json',
97882
- };
97883
- if (method !== 'GET') {
97884
- if (Object.keys(query).length) {
97885
- body = this.json(query);
97886
- }
97887
- }
98220
+ authorizationString = authorization;
97888
98221
  }
97889
98222
  else if (this.token && !this.checkRequiredCredentials(false)) {
97890
- headers = {
97891
- 'Authorization': 'Bearer ' + this.token,
97892
- 'Content-Type': 'application/json',
97893
- };
97894
- if (method !== 'GET') {
97895
- if (Object.keys(query).length) {
97896
- body = this.json(query);
97897
- }
97898
- }
98223
+ authorizationString = 'Bearer ' + this.token;
97899
98224
  }
97900
98225
  else {
97901
98226
  this.checkRequiredCredentials();
97902
- const timestampString = this.seconds().toString();
98227
+ const seconds = this.seconds();
97903
98228
  let payload = '';
97904
98229
  if (method !== 'GET') {
97905
98230
  if (Object.keys(query).length) {
@@ -97918,14 +98243,52 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
97918
98243
  // https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#example-request
97919
98244
  // v2: 'GET' require payload in the signature
97920
98245
  // https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-key-authentication
97921
- const auth = timestampString + method + savedPath + payload;
97922
- const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J);
98246
+ const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
98247
+ if (isCloudAPiKey) {
98248
+ if (this.apiKey.startsWith('-----BEGIN')) {
98249
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
98250
+ }
98251
+ // it may not work for v2
98252
+ let uri = method + ' ' + url.replace('https://', '');
98253
+ const quesPos = uri.indexOf('?');
98254
+ if (quesPos >= 0) {
98255
+ uri = uri.slice(0, quesPos);
98256
+ }
98257
+ const nonce = this.randomBytes(16);
98258
+ const request = {
98259
+ 'aud': ['retail_rest_api_proxy'],
98260
+ 'iss': 'coinbase-cloud',
98261
+ 'nbf': seconds,
98262
+ 'exp': seconds + 120,
98263
+ 'sub': this.apiKey,
98264
+ 'uri': uri,
98265
+ 'iat': seconds,
98266
+ };
98267
+ const token = (0,_base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__/* .jwt */ .F)(request, this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J, false, { 'kid': this.apiKey, 'nonce': nonce, 'alg': 'ES256' });
98268
+ authorizationString = 'Bearer ' + token;
98269
+ }
98270
+ else {
98271
+ const timestampString = this.seconds().toString();
98272
+ const auth = timestampString + method + savedPath + payload;
98273
+ const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J);
98274
+ headers = {
98275
+ 'CB-ACCESS-KEY': this.apiKey,
98276
+ 'CB-ACCESS-SIGN': signature,
98277
+ 'CB-ACCESS-TIMESTAMP': timestampString,
98278
+ 'Content-Type': 'application/json',
98279
+ };
98280
+ }
98281
+ }
98282
+ if (authorizationString !== undefined) {
97923
98283
  headers = {
97924
- 'CB-ACCESS-KEY': this.apiKey,
97925
- 'CB-ACCESS-SIGN': signature,
97926
- 'CB-ACCESS-TIMESTAMP': timestampString,
98284
+ 'Authorization': authorizationString,
97927
98285
  'Content-Type': 'application/json',
97928
98286
  };
98287
+ if (method !== 'GET') {
98288
+ if (Object.keys(query).length) {
98289
+ body = this.json(query);
98290
+ }
98291
+ }
97929
98292
  }
97930
98293
  }
97931
98294
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
@@ -98068,6 +98431,7 @@ class coinbaseinternational extends _abstract_coinbaseinternational_js__WEBPACK_
98068
98431
  'fetchLedger': false,
98069
98432
  'fetchLeverage': false,
98070
98433
  'fetchLeverageTiers': false,
98434
+ 'fetchMarginAdjustmentHistory': false,
98071
98435
  'fetchMarginMode': false,
98072
98436
  'fetchMarkets': true,
98073
98437
  'fetchMarkOHLCV': false,
@@ -102844,6 +103208,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
102844
103208
  'fetchLeverage': 'emulated',
102845
103209
  'fetchLeverages': true,
102846
103210
  'fetchLeverageTiers': true,
103211
+ 'fetchMarginAdjustmentHistory': true,
102847
103212
  'fetchMarketLeverageTiers': 'emulated',
102848
103213
  'fetchMarkets': true,
102849
103214
  'fetchMarkOHLCV': false,
@@ -107003,11 +107368,10 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
107003
107368
  // "message":"OK"
107004
107369
  // }
107005
107370
  //
107371
+ const data = this.safeDict(response, 'data');
107006
107372
  const status = this.safeString(response, 'message');
107007
- const type = (addOrReduce === 1) ? 'add' : 'reduce';
107008
- return this.extend(this.parseMarginModification(response, market), {
107373
+ return this.extend(this.parseMarginModification(data, market), {
107009
107374
  'amount': this.parseNumber(amount),
107010
- 'type': type,
107011
107375
  'status': status,
107012
107376
  });
107013
107377
  }
@@ -107067,13 +107431,34 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
107067
107431
  // "user_id": 3620173
107068
107432
  // }
107069
107433
  //
107070
- const timestamp = this.safeIntegerProduct(data, 'update_time', 1000);
107434
+ // fetchMarginAdjustmentHistory
107435
+ //
107436
+ // {
107437
+ // bkr_price: '0',
107438
+ // leverage: '3',
107439
+ // liq_price: '0',
107440
+ // margin_amount: '5.33236666666666666666',
107441
+ // margin_change: '3',
107442
+ // market: 'XRPUSDT',
107443
+ // position_amount: '11',
107444
+ // position_id: '297155652',
107445
+ // position_type: '2',
107446
+ // settle_price: '0.6361',
107447
+ // time: '1711050906.382891',
107448
+ // type: '1',
107449
+ // user_id: '3685860'
107450
+ // }
107451
+ //
107452
+ const marketId = this.safeString(data, 'market');
107453
+ const type = this.safeString(data, 'type');
107454
+ const timestamp = this.safeIntegerProduct2(data, 'time', 'update_time', 1000);
107071
107455
  return {
107072
107456
  'info': data,
107073
- 'symbol': this.safeSymbol(undefined, market),
107074
- 'type': undefined,
107075
- 'amount': this.safeNumber(data, 'margin_amount'),
107076
- 'total': undefined,
107457
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
107458
+ 'type': (type === '1') ? 'add' : 'reduce',
107459
+ 'marginMode': 'isolated',
107460
+ 'amount': this.safeNumber(data, 'margin_change'),
107461
+ 'total': this.safeNumber(data, 'position_amount'),
107077
107462
  'code': market['quote'],
107078
107463
  'status': undefined,
107079
107464
  'timestamp': timestamp,
@@ -107724,6 +108109,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
107724
108109
  const currencyId = this.safeString(transfer, 'asset');
107725
108110
  const currencyCode = this.safeCurrencyCode(currencyId, currency);
107726
108111
  return {
108112
+ 'info': transfer,
107727
108113
  'id': this.safeInteger(transfer, 'id'),
107728
108114
  'timestamp': timestamp,
107729
108115
  'datetime': this.iso8601(timestamp),
@@ -108556,6 +108942,78 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
108556
108942
  }
108557
108943
  return undefined;
108558
108944
  }
108945
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
108946
+ /**
108947
+ * @method
108948
+ * @name coinex#fetchMarginAdjustmentHistory
108949
+ * @description fetches the history of margin added or reduced from contract isolated positions
108950
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http046_position_margin_history
108951
+ * @param {string} [symbol] unified market symbol
108952
+ * @param {string} [type] not used by coinex fetchMarginAdjustmentHistory
108953
+ * @param {int} [since] timestamp in ms of the earliest change to fetch
108954
+ * @param {int} [limit] the maximum amount of changes to fetch, default=100, max=100
108955
+ * @param {object} params extra parameters specific to the exchange api endpoint
108956
+ * @param {int} [params.until] timestamp in ms of the latest change to fetch
108957
+ *
108958
+ * EXCHANGE SPECIFIC PARAMETERS
108959
+ * @param {int} [params.offset] offset
108960
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
108961
+ */
108962
+ await this.loadMarkets();
108963
+ const until = this.safeInteger(params, 'until');
108964
+ params = this.omit(params, 'until');
108965
+ if (limit === undefined) {
108966
+ limit = 100;
108967
+ }
108968
+ const request = {
108969
+ 'market': '',
108970
+ 'position_id': 0,
108971
+ 'offset': 0,
108972
+ 'limit': limit,
108973
+ };
108974
+ if (symbol !== undefined) {
108975
+ const market = this.market(symbol);
108976
+ request['market'] = market['id'];
108977
+ }
108978
+ if (since !== undefined) {
108979
+ request['start_time'] = since;
108980
+ }
108981
+ if (until !== undefined) {
108982
+ request['end_time'] = until;
108983
+ }
108984
+ const response = await this.v1PerpetualPrivateGetPositionMarginHistory(this.extend(request, params));
108985
+ //
108986
+ // {
108987
+ // code: '0',
108988
+ // data: {
108989
+ // limit: '100',
108990
+ // offset: '0',
108991
+ // records: [
108992
+ // {
108993
+ // bkr_price: '0',
108994
+ // leverage: '3',
108995
+ // liq_price: '0',
108996
+ // margin_amount: '5.33236666666666666666',
108997
+ // margin_change: '3',
108998
+ // market: 'XRPUSDT',
108999
+ // position_amount: '11',
109000
+ // position_id: '297155652',
109001
+ // position_type: '2',
109002
+ // settle_price: '0.6361',
109003
+ // time: '1711050906.382891',
109004
+ // type: '1',
109005
+ // user_id: '3685860'
109006
+ // }
109007
+ // ]
109008
+ // },
109009
+ // message: 'OK'
109010
+ // }
109011
+ //
109012
+ const data = this.safeDict(response, 'data', {});
109013
+ const records = this.safeList(data, 'records', []);
109014
+ const modifications = this.parseMarginModifications(records, undefined, 'market', 'swap');
109015
+ return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
109016
+ }
108559
109017
  }
108560
109018
 
108561
109019
 
@@ -117759,6 +118217,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117759
118217
  'fetchLedger': true,
117760
118218
  'fetchLeverage': false,
117761
118219
  'fetchLeverageTiers': false,
118220
+ 'fetchMarginAdjustmentHistory': false,
117762
118221
  'fetchMarginMode': false,
117763
118222
  'fetchMarketLeverageTiers': false,
117764
118223
  'fetchMarkets': true,
@@ -125432,6 +125891,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
125432
125891
  'info': data,
125433
125892
  'symbol': market['symbol'],
125434
125893
  'type': undefined,
125894
+ 'marginMode': 'isolated',
125435
125895
  'amount': undefined,
125436
125896
  'total': this.safeNumber(data, 'margin'),
125437
125897
  'code': undefined,
@@ -134072,6 +134532,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
134072
134532
  'info': data,
134073
134533
  'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
134074
134534
  'type': (rawType === 1) ? 'add' : 'reduce',
134535
+ 'marginMode': 'isolated',
134075
134536
  'amount': this.safeNumber(data, 'amount'),
134076
134537
  'total': undefined,
134077
134538
  'code': market['settle'],
@@ -134528,6 +134989,7 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
134528
134989
  'info': data,
134529
134990
  'symbol': this.safeSymbol(undefined, market),
134530
134991
  'type': undefined,
134992
+ 'marginMode': 'isolated',
134531
134993
  'amount': undefined,
134532
134994
  'total': undefined,
134533
134995
  'code': this.safeValue(market, 'quote'),
@@ -137100,6 +137562,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
137100
137562
  'fetchLeverages': true,
137101
137563
  'fetchLeverageTiers': true,
137102
137564
  'fetchLiquidations': true,
137565
+ 'fetchMarginAdjustmentHistory': false,
137103
137566
  'fetchMarginMode': false,
137104
137567
  'fetchMarketLeverageTiers': true,
137105
137568
  'fetchMarkets': true,
@@ -143099,6 +143562,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
143099
143562
  'info': data,
143100
143563
  'symbol': market['symbol'],
143101
143564
  'type': undefined,
143565
+ 'marginMode': 'isolated',
143102
143566
  'amount': undefined,
143103
143567
  'total': total,
143104
143568
  'code': this.safeValue(market, 'quote'),
@@ -144528,6 +144992,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
144528
144992
  // https://github.com/ccxt/ccxt/issues/7874
144529
144993
  // https://github.com/ccxt/ccxt/issues/7894
144530
144994
  'web': 'https://docs.gemini.com',
144995
+ 'webExchange': 'https://exchange.gemini.com',
144531
144996
  },
144532
144997
  'fees': [
144533
144998
  'https://gemini.com/api-fee-schedule',
@@ -144863,7 +145328,8 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
144863
145328
  // '<td>0.01 USD', // quote currency price increment
144864
145329
  // '</tr>'
144865
145330
  // ]
144866
- const marketId = cells[0].replace('<td>', '');
145331
+ let marketId = cells[0].replace('<td>', '');
145332
+ marketId = marketId.replace('*', '');
144867
145333
  // const base = this.safeCurrencyCode (baseId);
144868
145334
  const minAmountString = cells[1].replace('<td>', '');
144869
145335
  const minAmountParts = minAmountString.split(' ');
@@ -145065,7 +145531,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
145065
145531
  let quoteId = undefined;
145066
145532
  let settleId = undefined;
145067
145533
  let tickSize = undefined;
145068
- let increment = undefined;
145534
+ let amountPrecision = undefined;
145069
145535
  let minSize = undefined;
145070
145536
  let status = undefined;
145071
145537
  let swap = false;
@@ -145076,9 +145542,9 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
145076
145542
  const isArray = (Array.isArray(response));
145077
145543
  if (!isString && !isArray) {
145078
145544
  marketId = this.safeStringLower(response, 'symbol');
145545
+ amountPrecision = this.safeNumber(response, 'tick_size'); // right, exchange has an imperfect naming and this turns out to be an amount-precision
145546
+ tickSize = this.safeNumber(response, 'quote_increment'); // this is tick-size actually
145079
145547
  minSize = this.safeNumber(response, 'min_order_size');
145080
- tickSize = this.safeNumber(response, 'tick_size');
145081
- increment = this.safeNumber(response, 'quote_increment');
145082
145548
  status = this.parseMarketActive(this.safeString(response, 'status'));
145083
145549
  baseId = this.safeString(response, 'base_currency');
145084
145550
  quoteId = this.safeString(response, 'quote_currency');
@@ -145091,9 +145557,9 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
145091
145557
  }
145092
145558
  else {
145093
145559
  marketId = this.safeStringLower(response, 0);
145094
- minSize = this.safeNumber(response, 3);
145095
- tickSize = this.parseNumber(this.parsePrecision(this.safeString(response, 1)));
145096
- increment = this.parseNumber(this.parsePrecision(this.safeString(response, 2)));
145560
+ tickSize = this.parseNumber(this.parsePrecision(this.safeString(response, 1))); // priceTickDecimalPlaces
145561
+ amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(response, 2))); // quantityTickDecimalPlaces
145562
+ minSize = this.safeNumber(response, 3); // quantityMinimum
145097
145563
  }
145098
145564
  const marketIdUpper = marketId.toUpperCase();
145099
145565
  const isPerp = (marketIdUpper.indexOf('PERP') >= 0);
@@ -145148,8 +145614,8 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
145148
145614
  'strike': undefined,
145149
145615
  'optionType': undefined,
145150
145616
  'precision': {
145151
- 'price': increment,
145152
- 'amount': tickSize,
145617
+ 'price': tickSize,
145618
+ 'amount': amountPrecision,
145153
145619
  },
145154
145620
  'limits': {
145155
145621
  'leverage': {
@@ -146223,7 +146689,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
146223
146689
  if (apiKey.indexOf('account') < 0) {
146224
146690
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError(this.id + ' sign() requires an account-key, master-keys are not-supported');
146225
146691
  }
146226
- const nonce = this.nonce();
146692
+ const nonce = this.nonce().toString();
146227
146693
  const request = this.extend({
146228
146694
  'request': url,
146229
146695
  'nonce': nonce,
@@ -149667,6 +150133,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
149667
150133
  'info': data,
149668
150134
  'symbol': market['symbol'],
149669
150135
  'type': undefined,
150136
+ 'marginMode': 'isolated',
149670
150137
  'amount': undefined,
149671
150138
  'total': undefined,
149672
150139
  'code': this.safeString(currencyInfo, 'code'),
@@ -152081,6 +152548,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
152081
152548
  'fetchLeverage': false,
152082
152549
  'fetchLeverageTiers': true,
152083
152550
  'fetchLiquidations': true,
152551
+ 'fetchMarginAdjustmentHistory': false,
152084
152552
  'fetchMarketLeverageTiers': true,
152085
152553
  'fetchMarkets': true,
152086
152554
  'fetchMarkOHLCV': true,
@@ -165280,6 +165748,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
165280
165748
  'info': data,
165281
165749
  'symbol': this.safeSymbol(undefined, market),
165282
165750
  'type': undefined,
165751
+ 'marginMode': 'isolated',
165283
165752
  'amount': undefined,
165284
165753
  'total': undefined,
165285
165754
  'code': this.safeString(market, 'settle'),
@@ -170073,10 +170542,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
170073
170542
  if (currencyId !== undefined) {
170074
170543
  if (currencyId.length > 3) {
170075
170544
  if ((currencyId.indexOf('X') === 0) || (currencyId.indexOf('Z') === 0)) {
170076
- if (currencyId.indexOf('.') > 0) {
170077
- return super.safeCurrency(currencyId, currency);
170078
- }
170079
- else {
170545
+ if (!(currencyId.indexOf('.') > 0)) {
170080
170546
  currencyId = currencyId.slice(1);
170081
170547
  }
170082
170548
  }
@@ -170125,8 +170591,13 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
170125
170591
  // {
170126
170592
  // "error": [],
170127
170593
  // "result": {
170128
- // "ADA": { "aclass": "currency", "altname": "ADA", "decimals": 8, "display_decimals": 6 },
170129
- // "BCH": { "aclass": "currency", "altname": "BCH", "decimals": 10, "display_decimals": 5 },
170594
+ // "BCH": {
170595
+ // "aclass": "currency",
170596
+ // "altname": "BCH",
170597
+ // "decimals": 10,
170598
+ // "display_decimals": 5
170599
+ // "status": "enabled",
170600
+ // },
170130
170601
  // ...
170131
170602
  // },
170132
170603
  // }
@@ -170141,15 +170612,15 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
170141
170612
  // see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
170142
170613
  // to add support for multiple withdrawal/deposit methods and
170143
170614
  // differentiated fees for each particular method
170144
- const code = this.safeCurrencyCode(this.safeString(currency, 'altname'));
170615
+ const code = this.safeCurrencyCode(id);
170145
170616
  const precision = this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals')));
170146
170617
  // assumes all currencies are active except those listed above
170147
- const active = !this.inArray(code, this.options['inactiveCurrencies']);
170618
+ const active = this.safeString(currency, 'status') === 'enabled';
170148
170619
  result[code] = {
170149
170620
  'id': id,
170150
170621
  'code': code,
170151
170622
  'info': currency,
170152
- 'name': code,
170623
+ 'name': this.safeString(currency, 'altname'),
170153
170624
  'active': active,
170154
170625
  'deposit': undefined,
170155
170626
  'withdraw': undefined,
@@ -175208,6 +175679,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
175208
175679
  'fetchL3OrderBook': true,
175209
175680
  'fetchLedger': true,
175210
175681
  'fetchLeverageTiers': false,
175682
+ 'fetchMarginAdjustmentHistory': false,
175211
175683
  'fetchMarginMode': false,
175212
175684
  'fetchMarketLeverageTiers': false,
175213
175685
  'fetchMarkets': true,
@@ -179976,6 +180448,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
179976
180448
  'fetchL3OrderBook': true,
179977
180449
  'fetchLedger': true,
179978
180450
  'fetchLeverageTiers': false,
180451
+ 'fetchMarginAdjustmentHistory': false,
179979
180452
  'fetchMarginMode': false,
179980
180453
  'fetchMarketLeverageTiers': true,
179981
180454
  'fetchMarkets': true,
@@ -181522,14 +181995,18 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
181522
181995
  const crossMode = this.safeValue(info, 'crossMode');
181523
181996
  const mode = crossMode ? 'cross' : 'isolated';
181524
181997
  const marketId = this.safeString(market, 'symbol');
181998
+ const timestamp = this.safeInteger(info, 'currentTimestamp');
181525
181999
  return {
181526
182000
  'info': info,
181527
- 'direction': undefined,
181528
- 'mode': mode,
182001
+ 'symbol': this.safeSymbol(marketId, market),
182002
+ 'type': undefined,
182003
+ 'marginMode': mode,
181529
182004
  'amount': undefined,
182005
+ 'total': undefined,
181530
182006
  'code': this.safeCurrencyCode(currencyId),
181531
- 'symbol': this.safeSymbol(marketId, market),
181532
182007
  'status': undefined,
182008
+ 'timestamp': timestamp,
182009
+ 'datetime': this.iso8601(timestamp),
181533
182010
  };
181534
182011
  }
181535
182012
  async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -181670,6 +182147,32 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
181670
182147
  }
181671
182148
  return await this.fetchOrdersByStatus('done', symbol, since, limit, params);
181672
182149
  }
182150
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
182151
+ /**
182152
+ * @method
182153
+ * @name kucoinfutures#fetchOpenOrders
182154
+ * @description fetches information on multiple open orders made by the user
182155
+ * @see https://docs.kucoin.com/futures/#get-order-list
182156
+ * @see https://docs.kucoin.com/futures/#get-untriggered-stop-order-list
182157
+ * @param {string} symbol unified market symbol of the market orders were made in
182158
+ * @param {int} [since] the earliest time in ms to fetch orders for
182159
+ * @param {int} [limit] the maximum number of order structures to retrieve
182160
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
182161
+ * @param {int} [params.till] end time in ms
182162
+ * @param {string} [params.side] buy or sell
182163
+ * @param {string} [params.type] limit, or market
182164
+ * @param {boolean} [params.trigger] set to true to retrieve untriggered stop orders
182165
+ * @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)
182166
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
182167
+ */
182168
+ await this.loadMarkets();
182169
+ let paginate = false;
182170
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
182171
+ if (paginate) {
182172
+ return await this.fetchPaginatedCallDynamic('fetchOpenOrders', symbol, since, limit, params);
182173
+ }
182174
+ return await this.fetchOrdersByStatus('open', symbol, since, limit, params);
182175
+ }
181673
182176
  async fetchOrder(id = undefined, symbol = undefined, params = {}) {
181674
182177
  /**
181675
182178
  * @method
@@ -192656,6 +193159,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
192656
193159
  'fetchLeverage': true,
192657
193160
  'fetchLeverages': false,
192658
193161
  'fetchLeverageTiers': true,
193162
+ 'fetchMarginAdjustmentHistory': false,
192659
193163
  'fetchMarginMode': false,
192660
193164
  'fetchMarketLeverageTiers': undefined,
192661
193165
  'fetchMarkets': true,
@@ -206484,6 +206988,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
206484
206988
  'fetchLedgerEntry': undefined,
206485
206989
  'fetchLeverage': true,
206486
206990
  'fetchLeverageTiers': false,
206991
+ 'fetchMarginAdjustmentHistory': true,
206487
206992
  'fetchMarketLeverageTiers': true,
206488
206993
  'fetchMarkets': true,
206489
206994
  'fetchMarkOHLCV': true,
@@ -207618,7 +208123,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
207618
208123
  // ]
207619
208124
  // }
207620
208125
  //
207621
- const data = this.safeValue(response, 'data', []);
208126
+ const data = this.safeList(response, 'data', []);
207622
208127
  const dataLength = data.length;
207623
208128
  const update = {
207624
208129
  'updated': undefined,
@@ -207666,8 +208171,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
207666
208171
  // "msg": ""
207667
208172
  // }
207668
208173
  //
207669
- const data = this.safeValue(response, 'data', []);
207670
- const first = this.safeValue(data, 0, {});
208174
+ const data = this.safeList(response, 'data', []);
208175
+ const first = this.safeDict(data, 0, {});
207671
208176
  return this.safeInteger(first, 'ts');
207672
208177
  }
207673
208178
  async fetchAccounts(params = {}) {
@@ -207699,7 +208204,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
207699
208204
  // "msg": ""
207700
208205
  // }
207701
208206
  //
207702
- const data = this.safeValue(response, 'data', []);
208207
+ const data = this.safeList(response, 'data', []);
207703
208208
  const result = [];
207704
208209
  for (let i = 0; i < data.length; i++) {
207705
208210
  const account = data[i];
@@ -207724,7 +208229,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
207724
208229
  * @param {object} [params] extra parameters specific to the exchange API endpoint
207725
208230
  * @returns {object[]} an array of objects representing market data
207726
208231
  */
207727
- const types = this.safeValue(this.options, 'fetchMarkets');
208232
+ const types = this.safeList(this.options, 'fetchMarkets', []);
207728
208233
  let promises = [];
207729
208234
  let result = [];
207730
208235
  for (let i = 0; i < types.length; i++) {
@@ -207828,7 +208333,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
207828
208333
  }
207829
208334
  }
207830
208335
  const tickSize = this.safeString(market, 'tickSz');
207831
- const fees = this.safeValue2(this.fees, type, 'trading', {});
208336
+ const fees = this.safeDict2(this.fees, type, 'trading', {});
207832
208337
  let maxLeverage = this.safeString(market, 'lever', '1');
207833
208338
  maxLeverage = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMax(maxLeverage, '1');
207834
208339
  const maxSpotCost = this.safeNumber(market, 'maxMktSz');
@@ -207887,7 +208392,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
207887
208392
  'instType': this.convertToInstrumentType(type),
207888
208393
  };
207889
208394
  if (type === 'option') {
207890
- const optionsUnderlying = this.safeValue(this.options, 'defaultUnderlying', ['BTC-USD', 'ETH-USD']);
208395
+ const optionsUnderlying = this.safeList(this.options, 'defaultUnderlying', ['BTC-USD', 'ETH-USD']);
207891
208396
  const promises = [];
207892
208397
  for (let i = 0; i < optionsUnderlying.length; i++) {
207893
208398
  const underlying = optionsUnderlying[i];
@@ -207897,8 +208402,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
207897
208402
  const promisesResult = await Promise.all(promises);
207898
208403
  let markets = [];
207899
208404
  for (let i = 0; i < promisesResult.length; i++) {
207900
- const res = this.safeValue(promisesResult, i, {});
207901
- const options = this.safeValue(res, 'data', []);
208405
+ const res = this.safeDict(promisesResult, i, {});
208406
+ const options = this.safeList(res, 'data', []);
207902
208407
  markets = this.arrayConcat(markets, options);
207903
208408
  }
207904
208409
  return this.parseMarkets(markets);
@@ -207937,7 +208442,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
207937
208442
  // "msg": ""
207938
208443
  // }
207939
208444
  //
207940
- const dataResponse = this.safeValue(response, 'data', []);
208445
+ const dataResponse = this.safeList(response, 'data', []);
207941
208446
  return this.parseMarkets(dataResponse);
207942
208447
  }
207943
208448
  safeNetwork(networkId) {
@@ -208014,7 +208519,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208014
208519
  // "msg": ""
208015
208520
  // }
208016
208521
  //
208017
- const data = this.safeValue(response, 'data', []);
208522
+ const data = this.safeList(response, 'data', []);
208018
208523
  const result = {};
208019
208524
  const dataByCurrencyId = this.groupBy(data, 'ccy');
208020
208525
  const currencyIds = Object.keys(dataByCurrencyId);
@@ -208030,11 +208535,11 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208030
208535
  let maxPrecision = undefined;
208031
208536
  for (let j = 0; j < chains.length; j++) {
208032
208537
  const chain = chains[j];
208033
- const canDeposit = this.safeValue(chain, 'canDep');
208538
+ const canDeposit = this.safeBool(chain, 'canDep');
208034
208539
  depositEnabled = (canDeposit) ? canDeposit : depositEnabled;
208035
- const canWithdraw = this.safeValue(chain, 'canWd');
208540
+ const canWithdraw = this.safeBool(chain, 'canWd');
208036
208541
  withdrawEnabled = (canWithdraw) ? canWithdraw : withdrawEnabled;
208037
- const canInternal = this.safeValue(chain, 'canInternal');
208542
+ const canInternal = this.safeBool(chain, 'canInternal');
208038
208543
  const active = (canDeposit && canWithdraw && canInternal) ? true : false;
208039
208544
  currencyActive = (active) ? active : currencyActive;
208040
208545
  const networkId = this.safeString(chain, 'chain');
@@ -208067,7 +208572,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208067
208572
  };
208068
208573
  }
208069
208574
  }
208070
- const firstChain = this.safeValue(chains, 0);
208575
+ const firstChain = this.safeDict(chains, 0, {});
208071
208576
  result[code] = {
208072
208577
  'info': undefined,
208073
208578
  'code': code,
@@ -208143,8 +208648,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208143
208648
  // ]
208144
208649
  // }
208145
208650
  //
208146
- const data = this.safeValue(response, 'data', []);
208147
- const first = this.safeValue(data, 0, {});
208651
+ const data = this.safeList(response, 'data', []);
208652
+ const first = this.safeDict(data, 0, {});
208148
208653
  const timestamp = this.safeInteger(first, 'ts');
208149
208654
  return this.parseOrderBook(first, symbol, timestamp);
208150
208655
  }
@@ -208245,7 +208750,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208245
208750
  // ]
208246
208751
  // }
208247
208752
  //
208248
- const data = this.safeValue(response, 'data', []);
208753
+ const data = this.safeList(response, 'data', []);
208249
208754
  const first = this.safeDict(data, 0, {});
208250
208755
  return this.parseTicker(first, market);
208251
208756
  }
@@ -208268,7 +208773,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208268
208773
  'instType': this.convertToInstrumentType(marketType),
208269
208774
  };
208270
208775
  if (marketType === 'option') {
208271
- const defaultUnderlying = this.safeValue(this.options, 'defaultUnderlying', 'BTC-USD');
208776
+ const defaultUnderlying = this.safeString(this.options, 'defaultUnderlying', 'BTC-USD');
208272
208777
  const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
208273
208778
  if (currencyId === undefined) {
208274
208779
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
@@ -208534,7 +209039,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208534
209039
  }
208535
209040
  const price = this.safeString(params, 'price');
208536
209041
  params = this.omit(params, 'price');
208537
- const options = this.safeValue(this.options, 'fetchOHLCV', {});
209042
+ const options = this.safeDict(this.options, 'fetchOHLCV', {});
208538
209043
  const timezone = this.safeString(options, 'timezone', 'UTC');
208539
209044
  if (limit === undefined) {
208540
209045
  limit = 100; // default 100, max 100
@@ -208667,7 +209172,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208667
209172
  // }
208668
209173
  //
208669
209174
  const rates = [];
208670
- const data = this.safeValue(response, 'data', []);
209175
+ const data = this.safeList(response, 'data', []);
208671
209176
  for (let i = 0; i < data.length; i++) {
208672
209177
  const rate = data[i];
208673
209178
  const timestamp = this.safeInteger(rate, 'fundingTime');
@@ -208692,10 +209197,10 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208692
209197
  }
208693
209198
  parseTradingBalance(response) {
208694
209199
  const result = { 'info': response };
208695
- const data = this.safeValue(response, 'data', []);
208696
- const first = this.safeValue(data, 0, {});
209200
+ const data = this.safeList(response, 'data', []);
209201
+ const first = this.safeDict(data, 0, {});
208697
209202
  const timestamp = this.safeInteger(first, 'uTime');
208698
- const details = this.safeValue(first, 'details', []);
209203
+ const details = this.safeList(first, 'details', []);
208699
209204
  for (let i = 0; i < details.length; i++) {
208700
209205
  const balance = details[i];
208701
209206
  const currencyId = this.safeString(balance, 'ccy');
@@ -208720,7 +209225,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208720
209225
  }
208721
209226
  parseFundingBalance(response) {
208722
209227
  const result = { 'info': response };
208723
- const data = this.safeValue(response, 'data', []);
209228
+ const data = this.safeList(response, 'data', []);
208724
209229
  for (let i = 0; i < data.length; i++) {
208725
209230
  const balance = data[i];
208726
209231
  const currencyId = this.safeString(balance, 'ccy');
@@ -208804,8 +209309,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
208804
209309
  // "msg": ""
208805
209310
  // }
208806
209311
  //
208807
- const data = this.safeValue(response, 'data', []);
208808
- const first = this.safeValue(data, 0, {});
209312
+ const data = this.safeList(response, 'data', []);
209313
+ const first = this.safeDict(data, 0, {});
208809
209314
  return this.parseTradingFee(first, market);
208810
209315
  }
208811
209316
  async fetchBalance(params = {}) {
@@ -209293,8 +209798,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
209293
209798
  else {
209294
209799
  response = await this.privatePostTradeBatchOrders(request);
209295
209800
  }
209296
- const data = this.safeValue(response, 'data', []);
209297
- const first = this.safeValue(data, 0);
209801
+ const data = this.safeList(response, 'data', []);
209802
+ const first = this.safeDict(data, 0, {});
209298
209803
  const order = this.parseOrder(first, market);
209299
209804
  order['type'] = type;
209300
209805
  order['side'] = side;
@@ -210805,7 +211310,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
210805
211310
  // ]
210806
211311
  // }
210807
211312
  //
210808
- const data = this.safeValue(response, 'data', []);
211313
+ const data = this.safeList(response, 'data', []);
210809
211314
  return this.parseLedger(data, currency, since, limit);
210810
211315
  }
210811
211316
  parseLedgerEntryType(type) {
@@ -212863,9 +213368,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212863
213368
  // }
212864
213369
  //
212865
213370
  const data = this.safeList(response, 'data', []);
213371
+ const entry = this.safeDict(data, 0, {});
212866
213372
  const errorCode = this.safeString(response, 'code');
212867
- const item = this.safeDict(data, 0, {});
212868
- return this.extend(this.parseMarginModification(item, market), {
213373
+ return this.extend(this.parseMarginModification(entry, market), {
212869
213374
  'status': (errorCode === '0') ? 'ok' : 'failed',
212870
213375
  });
212871
213376
  }
@@ -212880,22 +213385,68 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212880
213385
  // "type": "reduce"
212881
213386
  // }
212882
213387
  //
212883
- const amountRaw = this.safeNumber(data, 'amt');
213388
+ // fetchMarginAdjustmentHistory
213389
+ //
213390
+ // {
213391
+ // bal: '67621.4325135010619812',
213392
+ // balChg: '-10.0000000000000000',
213393
+ // billId: '691293628710342659',
213394
+ // ccy: 'USDT',
213395
+ // clOrdId: '',
213396
+ // execType: '',
213397
+ // fee: '0',
213398
+ // fillFwdPx: '',
213399
+ // fillIdxPx: '',
213400
+ // fillMarkPx: '',
213401
+ // fillMarkVol: '',
213402
+ // fillPxUsd: '',
213403
+ // fillPxVol: '',
213404
+ // fillTime: '1711089244850',
213405
+ // from: '',
213406
+ // instId: 'XRP-USDT-SWAP',
213407
+ // instType: 'SWAP',
213408
+ // interest: '0',
213409
+ // mgnMode: 'isolated',
213410
+ // notes: '',
213411
+ // ordId: '',
213412
+ // pnl: '0',
213413
+ // posBal: '73.12',
213414
+ // posBalChg: '10.00',
213415
+ // px: '',
213416
+ // subType: '160',
213417
+ // sz: '10',
213418
+ // tag: '',
213419
+ // to: '',
213420
+ // tradeId: '0',
213421
+ // ts: '1711089244699',
213422
+ // type: '6'
213423
+ // }
213424
+ //
213425
+ const amountRaw = this.safeString2(data, 'amt', 'posBalChg');
212884
213426
  const typeRaw = this.safeString(data, 'type');
212885
- const type = (typeRaw === 'reduce') ? 'reduce' : 'add';
213427
+ let type = undefined;
213428
+ if (typeRaw === '6') {
213429
+ type = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringGt(amountRaw, '0') ? 'add' : 'reduce';
213430
+ }
213431
+ else {
213432
+ type = typeRaw;
213433
+ }
213434
+ const amount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(amountRaw);
212886
213435
  const marketId = this.safeString(data, 'instId');
212887
213436
  const responseMarket = this.safeMarket(marketId, market);
212888
213437
  const code = responseMarket['inverse'] ? responseMarket['base'] : responseMarket['quote'];
213438
+ const timestamp = this.safeInteger(data, 'ts');
212889
213439
  return {
212890
213440
  'info': data,
212891
213441
  'symbol': responseMarket['symbol'],
212892
213442
  'type': type,
212893
- 'amount': amountRaw,
212894
- 'total': undefined,
213443
+ 'marginMode': 'isolated',
213444
+ 'amount': this.parseNumber(amount),
212895
213445
  'code': code,
213446
+ 'total': undefined,
212896
213447
  'status': undefined,
212897
- 'timestamp': undefined,
212898
- 'datetime': undefined,
213448
+ 'timestamp': timestamp,
213449
+ 'datetime': this.iso8601(timestamp),
212899
213450
  };
212900
213451
  }
212901
213452
  async reduceMargin(symbol, amount, params = {}) {
@@ -213997,6 +214548,108 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213997
214548
  }
213998
214549
  return undefined;
213999
214550
  }
214551
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
214552
+ /**
214553
+ * @method
214554
+ * @name okx#fetchMarginAdjustmentHistory
214555
+ * @description fetches the history of margin added or reduced from contract isolated positions
214556
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-7-days
214557
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months
214558
+ * @param {string} [symbol] not used by okx fetchMarginAdjustmentHistory
214559
+ * @param {string} [type] "add" or "reduce"
214560
+ * @param {object} params extra parameters specific to the exchange api endpoint
214561
+ * @param {boolean} [params.auto] true if fetching auto margin increases
214562
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
214563
+ */
214564
+ await this.loadMarkets();
214565
+ const auto = this.safeBool(params, 'auto');
214566
+ if (type === undefined) {
214567
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory () requires a type argument');
214568
+ }
214569
+ const isAdd = type === 'add';
214570
+ let subType = isAdd ? '160' : '161';
214571
+ if (auto) {
214572
+ if (isAdd) {
214573
+ subType = '162';
214574
+ }
214575
+ else {
214576
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' cannot fetch margin adjustments for type ' + type);
214577
+ }
214578
+ }
214579
+ const request = {
214580
+ 'subType': subType,
214581
+ 'mgnMode': 'isolated',
214582
+ };
214583
+ const until = this.safeInteger(params, 'until');
214584
+ params = this.omit(params, 'until');
214585
+ if (since !== undefined) {
214586
+ request['startTime'] = since;
214587
+ }
214588
+ if (limit !== undefined) {
214589
+ request['limit'] = limit;
214590
+ }
214591
+ if (until !== undefined) {
214592
+ request['endTime'] = until;
214593
+ }
214594
+ let response = undefined;
214595
+ const now = this.milliseconds();
214596
+ const oneWeekAgo = now - 604800000;
214597
+ const threeMonthsAgo = now - 7776000000;
214598
+ if ((since === undefined) || (since > oneWeekAgo)) {
214599
+ response = await this.privateGetAccountBills(this.extend(request, params));
214600
+ }
214601
+ else if (since > threeMonthsAgo) {
214602
+ response = await this.privateGetAccountBillsArchive(this.extend(request, params));
214603
+ }
214604
+ else {
214605
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' fetchMarginAdjustmentHistory () cannot fetch margin adjustments older than 3 months');
214606
+ }
214607
+ //
214608
+ // {
214609
+ // code: '0',
214610
+ // data: [
214611
+ // {
214612
+ // bal: '67621.4325135010619812',
214613
+ // balChg: '-10.0000000000000000',
214614
+ // billId: '691293628710342659',
214615
+ // ccy: 'USDT',
214616
+ // clOrdId: '',
214617
+ // execType: '',
214618
+ // fee: '0',
214619
+ // fillFwdPx: '',
214620
+ // fillIdxPx: '',
214621
+ // fillMarkPx: '',
214622
+ // fillMarkVol: '',
214623
+ // fillPxUsd: '',
214624
+ // fillPxVol: '',
214625
+ // fillTime: '1711089244850',
214626
+ // from: '',
214627
+ // instId: 'XRP-USDT-SWAP',
214628
+ // instType: 'SWAP',
214629
+ // interest: '0',
214630
+ // mgnMode: 'isolated',
214631
+ // notes: '',
214632
+ // ordId: '',
214633
+ // pnl: '0',
214634
+ // posBal: '73.12',
214635
+ // posBalChg: '10.00',
214636
+ // px: '',
214637
+ // subType: '160',
214638
+ // sz: '10',
214639
+ // tag: '',
214640
+ // to: '',
214641
+ // tradeId: '0',
214642
+ // ts: '1711089244699',
214643
+ // type: '6'
214644
+ // }
214645
+ // ],
214646
+ // msg: ''
214647
+ // }
214648
+ //
214649
+ const data = this.safeList(response, 'data');
214650
+ const modifications = this.parseMarginModifications(data);
214651
+ return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
214652
+ }
214000
214653
  }
214001
214654
 
214002
214655
 
@@ -221945,6 +222598,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
221945
222598
  'info': data,
221946
222599
  'symbol': this.safeSymbol(undefined, market),
221947
222600
  'type': 'set',
222601
+ 'marginMode': 'isolated',
221948
222602
  'amount': undefined,
221949
222603
  'total': undefined,
221950
222604
  'code': market[codeCurrency],
@@ -239119,8 +239773,8 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
239119
239773
  for (let i = 0; i < marketIds.length; i++) {
239120
239774
  const marketId = marketIds[i];
239121
239775
  const market = this.safeMarket(marketId);
239122
- const messageHash = table + ':' + marketId;
239123
239776
  const symbol = market['symbol'];
239777
+ const messageHash = table + ':' + symbol;
239124
239778
  const trades = this.parseTrades(dataByMarketIds[marketId], market);
239125
239779
  let stored = this.safeValue(this.trades, symbol);
239126
239780
  if (stored === undefined) {
@@ -239145,23 +239799,7 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
239145
239799
  * @param {object} [params] extra parameters specific to the exchange API endpoint
239146
239800
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
239147
239801
  */
239148
- await this.loadMarkets();
239149
- const market = this.market(symbol);
239150
- symbol = market['symbol'];
239151
- const table = 'trade';
239152
- const messageHash = table + ':' + market['id'];
239153
- const url = this.urls['api']['ws'];
239154
- const request = {
239155
- 'op': 'subscribe',
239156
- 'args': [
239157
- messageHash,
239158
- ],
239159
- };
239160
- const trades = await this.watch(url, messageHash, this.extend(request, params), messageHash);
239161
- if (this.newUpdates) {
239162
- limit = trades.getLimit(symbol, limit);
239163
- }
239164
- return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
239802
+ return await this.watchTradesForSymbols([symbol], since, limit, params);
239165
239803
  }
239166
239804
  async authenticate(params = {}) {
239167
239805
  const url = this.urls['api']['ws'];
@@ -239794,6 +240432,43 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
239794
240432
  const orderbook = await this.watchMultiple(url, messageHashes, this.deepExtend(request, params), topics);
239795
240433
  return orderbook.limit();
239796
240434
  }
240435
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
240436
+ /**
240437
+ * @method
240438
+ * @name bitmex#watchTradesForSymbols
240439
+ * @description get the list of most recent trades for a list of symbols
240440
+ * @param {string[]} symbols unified symbol of the market to fetch trades for
240441
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
240442
+ * @param {int} [limit] the maximum amount of trades to fetch
240443
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
240444
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
240445
+ */
240446
+ await this.loadMarkets();
240447
+ symbols = this.marketSymbols(symbols, undefined, false);
240448
+ const table = 'trade';
240449
+ const topics = [];
240450
+ const messageHashes = [];
240451
+ for (let i = 0; i < symbols.length; i++) {
240452
+ const symbol = symbols[i];
240453
+ const market = this.market(symbol);
240454
+ const topic = table + ':' + market['id'];
240455
+ topics.push(topic);
240456
+ const messageHash = table + ':' + symbol;
240457
+ messageHashes.push(messageHash);
240458
+ }
240459
+ const url = this.urls['api']['ws'];
240460
+ const request = {
240461
+ 'op': 'subscribe',
240462
+ 'args': topics,
240463
+ };
240464
+ const trades = await this.watchMultiple(url, messageHashes, this.deepExtend(request, params), topics);
240465
+ if (this.newUpdates) {
240466
+ const first = this.safeValue(trades, 0);
240467
+ const tradeSymbol = this.safeString(first, 'symbol');
240468
+ limit = trades.getLimit(tradeSymbol, limit);
240469
+ }
240470
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
240471
+ }
239797
240472
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
239798
240473
  /**
239799
240474
  * @method
@@ -266207,8 +266882,8 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
266207
266882
  /* harmony export */ Z: () => (/* binding */ kucoin)
266208
266883
  /* harmony export */ });
266209
266884
  /* harmony import */ var _kucoin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3583);
266210
- /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
266211
- /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3020);
266885
+ /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
266886
+ /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3020);
266212
266887
  // ---------------------------------------------------------------------------
266213
266888
 
266214
266889
 
@@ -266226,6 +266901,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266226
266901
  'cancelOrderWs': false,
266227
266902
  'cancelOrdersWs': false,
266228
266903
  'cancelAllOrdersWs': false,
266904
+ 'watchBidsAsks': true,
266229
266905
  'watchOrderBook': true,
266230
266906
  'watchOrders': true,
266231
266907
  'watchMyTrades': true,
@@ -266493,6 +267169,92 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266493
267169
  }
266494
267170
  }
266495
267171
  }
267172
+ async watchBidsAsks(symbols = undefined, params = {}) {
267173
+ /**
267174
+ * @method
267175
+ * @name kucoin#watchBidsAsks
267176
+ * @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level1-bbo-market-data
267177
+ * @description watches best bid & ask for symbols
267178
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
267179
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
267180
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
267181
+ */
267182
+ const ticker = await this.watchMultiHelper('watchBidsAsks', '/spotMarket/level1:', symbols, params);
267183
+ if (this.newUpdates) {
267184
+ const tickers = {};
267185
+ tickers[ticker['symbol']] = ticker;
267186
+ return tickers;
267187
+ }
267188
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
267189
+ }
267190
+ async watchMultiHelper(methodName, channelName, symbols = undefined, params = {}) {
267191
+ await this.loadMarkets();
267192
+ symbols = this.marketSymbols(symbols, undefined, false, true, false);
267193
+ const length = symbols.length;
267194
+ if (length > 100) {
267195
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' ' + methodName + '() accepts a maximum of 100 symbols');
267196
+ }
267197
+ const messageHashes = [];
267198
+ for (let i = 0; i < symbols.length; i++) {
267199
+ const symbol = symbols[i];
267200
+ const market = this.market(symbol);
267201
+ messageHashes.push('bidask@' + market['symbol']);
267202
+ }
267203
+ const url = await this.negotiate(false);
267204
+ const marketIds = this.marketIds(symbols);
267205
+ const joined = marketIds.join(',');
267206
+ const requestId = this.requestId().toString();
267207
+ const request = {
267208
+ 'id': requestId,
267209
+ 'type': 'subscribe',
267210
+ 'topic': channelName + joined,
267211
+ 'response': true,
267212
+ };
267213
+ const message = this.extend(request, params);
267214
+ return await this.watchMultiple(url, messageHashes, message, messageHashes);
267215
+ }
267216
+ handleBidAsk(client, message) {
267217
+ //
267218
+ // arrives one symbol dict
267219
+ //
267220
+ // {
267221
+ // topic: '/spotMarket/level1:ETH-USDT',
267222
+ // type: 'message',
267223
+ // data: {
267224
+ // asks: [ '3347.42', '2.0778387' ],
267225
+ // bids: [ '3347.41', '6.0411697' ],
267226
+ // timestamp: 1712231142085
267227
+ // },
267228
+ // subject: 'level1'
267229
+ // }
267230
+ //
267231
+ const parsedTicker = this.parseWsBidAsk(message);
267232
+ const symbol = parsedTicker['symbol'];
267233
+ this.bidsasks[symbol] = parsedTicker;
267234
+ const messageHash = 'bidask@' + symbol;
267235
+ client.resolve(parsedTicker, messageHash);
267236
+ }
267237
+ parseWsBidAsk(ticker, market = undefined) {
267238
+ const topic = this.safeString(ticker, 'topic');
267239
+ const parts = topic.split(':');
267240
+ const marketId = parts[1];
267241
+ market = this.safeMarket(marketId, market);
267242
+ const symbol = this.safeString(market, 'symbol');
267243
+ const data = this.safeDict(ticker, 'data', {});
267244
+ const ask = this.safeList(data, 'asks', []);
267245
+ const bid = this.safeList(data, 'bids', []);
267246
+ const timestamp = this.safeInteger(data, 'timestamp');
267247
+ return this.safeTicker({
267248
+ 'symbol': symbol,
267249
+ 'timestamp': timestamp,
267250
+ 'datetime': this.iso8601(timestamp),
267251
+ 'ask': this.safeNumber(ask, 0),
267252
+ 'askVolume': this.safeNumber(ask, 1),
267253
+ 'bid': this.safeNumber(bid, 0),
267254
+ 'bidVolume': this.safeNumber(bid, 1),
267255
+ 'info': ticker,
267256
+ }, market);
267257
+ }
266496
267258
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
266497
267259
  /**
266498
267260
  * @method
@@ -266554,7 +267316,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266554
267316
  let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
266555
267317
  if (stored === undefined) {
266556
267318
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
266557
- stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCacheByTimestamp */ .Py(limit);
267319
+ stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
266558
267320
  this.ohlcvs[symbol][timeframe] = stored;
266559
267321
  }
266560
267322
  const ohlcv = this.parseOHLCV(candles, market);
@@ -266587,7 +267349,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266587
267349
  */
266588
267350
  const symbolsLength = symbols.length;
266589
267351
  if (symbolsLength === 0) {
266590
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
267352
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
266591
267353
  }
266592
267354
  await this.loadMarkets();
266593
267355
  symbols = this.marketSymbols(symbols);
@@ -266637,7 +267399,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266637
267399
  let trades = this.safeValue(this.trades, symbol);
266638
267400
  if (trades === undefined) {
266639
267401
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
266640
- trades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCache */ .ZL(limit);
267402
+ trades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCache */ .ZL(limit);
266641
267403
  this.trades[symbol] = trades;
266642
267404
  }
266643
267405
  trades.append(trade);
@@ -266692,11 +267454,11 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266692
267454
  */
266693
267455
  const symbolsLength = symbols.length;
266694
267456
  if (symbolsLength === 0) {
266695
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols');
267457
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols');
266696
267458
  }
266697
267459
  if (limit !== undefined) {
266698
267460
  if ((limit !== 20) && (limit !== 100) && (limit !== 50) && (limit !== 5)) {
266699
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + " watchOrderBook 'limit' argument must be undefined, 5, 20, 50 or 100");
267461
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + " watchOrderBook 'limit' argument must be undefined, 5, 20, 50 or 100");
266700
267462
  }
266701
267463
  }
266702
267464
  await this.loadMarkets();
@@ -266884,6 +267646,9 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
266884
267646
  // }
266885
267647
  //
266886
267648
  const id = this.safeString(message, 'id');
267649
+ if (!(id in client.subscriptions)) {
267650
+ return;
267651
+ }
266887
267652
  const subscriptionHash = this.safeString(client.subscriptions, id);
266888
267653
  const subscription = this.safeValue(client.subscriptions, subscriptionHash);
266889
267654
  delete client.subscriptions[id];
@@ -267053,8 +267818,8 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
267053
267818
  const isTriggerOrder = (triggerPrice !== undefined);
267054
267819
  if (this.orders === undefined) {
267055
267820
  const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
267056
- this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCacheBySymbolById */ .hl(limit);
267057
- this.triggerOrders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCacheBySymbolById */ .hl(limit);
267821
+ this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
267822
+ this.triggerOrders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
267058
267823
  }
267059
267824
  const cachedOrders = isTriggerOrder ? this.triggerOrders : this.orders;
267060
267825
  const orders = this.safeValue(cachedOrders.hashmap, symbol, {});
@@ -267102,7 +267867,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
267102
267867
  handleMyTrade(client, message) {
267103
267868
  if (this.myTrades === undefined) {
267104
267869
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
267105
- this.myTrades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCacheBySymbolById */ .hl(limit);
267870
+ this.myTrades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
267106
267871
  }
267107
267872
  const data = this.safeDict(message, 'data');
267108
267873
  const parsed = this.parseWsTrade(data);
@@ -267257,6 +268022,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
267257
268022
  }
267258
268023
  const subject = this.safeString(message, 'subject');
267259
268024
  const methods = {
268025
+ 'level1': this.handleBidAsk,
267260
268026
  'level2': this.handleOrderBook,
267261
268027
  'trade.l2update': this.handleOrderBook,
267262
268028
  'trade.ticker': this.handleTicker,
@@ -267346,6 +268112,8 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267346
268112
  'has': {
267347
268113
  'ws': true,
267348
268114
  'watchTicker': true,
268115
+ 'watchTickers': true,
268116
+ 'watchBidsAsks': true,
267349
268117
  'watchTrades': true,
267350
268118
  'watchOrderBook': true,
267351
268119
  'watchOrders': true,
@@ -267375,9 +268143,6 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267375
268143
  'snapshotDelay': 20,
267376
268144
  'snapshotMaxRetries': 3,
267377
268145
  },
267378
- 'watchTicker': {
267379
- 'name': 'contractMarket/tickerV2', // market/ticker
267380
- },
267381
268146
  'watchPosition': {
267382
268147
  'fetchPositionSnapshot': true,
267383
268148
  'awaitPositionSnapshot': true, // whether to wait for the position snapshot before providing updates
@@ -267480,7 +268245,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267480
268245
  }
267481
268246
  return await this.watch(url, messageHash, message, subscriptionHash, subscription);
267482
268247
  }
267483
- async subscribeMultiple(url, messageHashes, topic, subscriptionHashes, subscription, params = {}) {
268248
+ async subscribeMultiple(url, messageHashes, topic, subscriptionHashes, subscriptionArgs, params = {}) {
267484
268249
  const requestId = this.requestId().toString();
267485
268250
  const request = {
267486
268251
  'id': requestId,
@@ -267488,24 +268253,14 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267488
268253
  'topic': topic,
267489
268254
  'response': true,
267490
268255
  };
267491
- const message = this.extend(request, params);
267492
- const subscriptionRequest = {
267493
- 'id': requestId,
267494
- };
267495
- if (subscription === undefined) {
267496
- subscription = subscriptionRequest;
267497
- }
267498
- else {
267499
- subscription = this.extend(subscriptionRequest, subscription);
267500
- }
267501
- return await this.watchMultiple(url, messageHashes, message, subscriptionHashes, subscription);
268256
+ return await this.watchMultiple(url, messageHashes, this.extend(request, params), subscriptionHashes, subscriptionArgs);
267502
268257
  }
267503
268258
  async watchTicker(symbol, params = {}) {
267504
268259
  /**
267505
268260
  * @method
267506
268261
  * @name kucoinfutures#watchTicker
267507
268262
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
267508
- * @see https://docs.kucoin.com/futures/#get-real-time-symbol-ticker-v2
268263
+ * @see https://www.kucoin.com/docs/websocket/futures-trading/public-channels/get-ticker
267509
268264
  * @param {string} symbol unified symbol of the market to fetch the ticker for
267510
268265
  * @param {object} [params] extra parameters specific to the exchange API endpoint
267511
268266
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -267513,30 +268268,48 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267513
268268
  await this.loadMarkets();
267514
268269
  const market = this.market(symbol);
267515
268270
  symbol = market['symbol'];
267516
- const url = await this.negotiate(false);
267517
- const options = this.safeValue(this.options, 'watchTicker', {});
267518
- const channel = this.safeString(options, 'name', 'contractMarket/tickerV2');
267519
- const topic = '/' + channel + ':' + market['id'];
267520
- const messageHash = 'ticker:' + symbol;
267521
- return await this.subscribe(url, messageHash, topic, undefined, params);
268271
+ params['callerMethodName'] = 'watchTicker';
268272
+ const tickers = await this.watchTickers([symbol], params);
268273
+ return tickers[symbol];
268274
+ }
268275
+ async watchTickers(symbols = undefined, params = {}) {
268276
+ /**
268277
+ * @method
268278
+ * @name kucoinfutures#watchTickers
268279
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
268280
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
268281
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
268282
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
268283
+ */
268284
+ await this.loadMarkets();
268285
+ const ticker = await this.watchMultiRequest('watchTickers', '/contractMarket/ticker:', symbols, params);
268286
+ if (this.newUpdates) {
268287
+ const tickers = {};
268288
+ tickers[ticker['symbol']] = ticker;
268289
+ return tickers;
268290
+ }
268291
+ return this.filterByArray(this.tickers, 'symbol', symbols);
267522
268292
  }
267523
268293
  handleTicker(client, message) {
267524
268294
  //
267525
- // market/tickerV2
268295
+ // ticker (v1)
267526
268296
  //
267527
268297
  // {
267528
- // "type": "message",
267529
- // "topic": "/contractMarket/tickerV2:ADAUSDTM",
267530
- // "subject": "tickerV2",
267531
- // "data": {
267532
- // "symbol": "ADAUSDTM",
267533
- // "sequence": 1668007800439,
267534
- // "bestBidSize": 178,
267535
- // "bestBidPrice": "0.35959",
267536
- // "bestAskPrice": "0.35981",
267537
- // "ts": "1668141430037124460",
267538
- // "bestAskSize": 134
267539
- // }
268298
+ // "subject": "ticker",
268299
+ // "topic": "/contractMarket/ticker:XBTUSDM",
268300
+ // "data": {
268301
+ // "symbol": "XBTUSDM", //Market of the symbol
268302
+ // "sequence": 45, //Sequence number which is used to judge the continuity of the pushed messages
268303
+ // "side": "sell", //Transaction side of the last traded taker order
268304
+ // "price": "3600.0", //Filled price
268305
+ // "size": 16, //Filled quantity
268306
+ // "tradeId": "5c9dcf4170744d6f5a3d32fb", //Order ID
268307
+ // "bestBidSize": 795, //Best bid size
268308
+ // "bestBidPrice": "3200.0", //Best bid
268309
+ // "bestAskPrice": "3600.0", //Best ask size
268310
+ // "bestAskSize": 284, //Best ask
268311
+ // "ts": 1553846081210004941 //Filled time - nanosecond
268312
+ // }
267540
268313
  // }
267541
268314
  //
267542
268315
  const data = this.safeValue(message, 'data', {});
@@ -267544,9 +268317,95 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267544
268317
  const market = this.safeMarket(marketId, undefined, '-');
267545
268318
  const ticker = this.parseTicker(data, market);
267546
268319
  this.tickers[market['symbol']] = ticker;
267547
- const messageHash = 'ticker:' + market['symbol'];
267548
- client.resolve(ticker, messageHash);
267549
- return message;
268320
+ client.resolve(ticker, this.getMessageHash('ticker', market['symbol']));
268321
+ }
268322
+ async watchBidsAsks(symbols = undefined, params = {}) {
268323
+ /**
268324
+ * @method
268325
+ * @name kucoinfutures#watchBidsAsks
268326
+ * @see https://www.kucoin.com/docs/websocket/futures-trading/public-channels/get-ticker-v2
268327
+ * @description watches best bid & ask for symbols
268328
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
268329
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
268330
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
268331
+ */
268332
+ const ticker = await this.watchMultiRequest('watchBidsAsks', '/contractMarket/tickerV2:', symbols, params);
268333
+ if (this.newUpdates) {
268334
+ const tickers = {};
268335
+ tickers[ticker['symbol']] = ticker;
268336
+ return tickers;
268337
+ }
268338
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
268339
+ }
268340
+ async watchMultiRequest(methodName, channelName, symbols = undefined, params = {}) {
268341
+ await this.loadMarkets();
268342
+ [methodName, params] = this.handleParamString(params, 'callerMethodName', methodName);
268343
+ const isBidsAsks = (methodName === 'watchBidsAsks');
268344
+ symbols = this.marketSymbols(symbols, undefined, false, true, false);
268345
+ const length = symbols.length;
268346
+ if (length > 100) {
268347
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' ' + methodName + '() accepts a maximum of 100 symbols');
268348
+ }
268349
+ const messageHashes = [];
268350
+ for (let i = 0; i < symbols.length; i++) {
268351
+ const symbol = symbols[i];
268352
+ const market = this.market(symbol);
268353
+ const prefix = isBidsAsks ? 'bidask' : 'ticker';
268354
+ messageHashes.push(this.getMessageHash(prefix, market['symbol']));
268355
+ }
268356
+ const url = await this.negotiate(false);
268357
+ const marketIds = this.marketIds(symbols);
268358
+ const joined = marketIds.join(',');
268359
+ const requestId = this.requestId().toString();
268360
+ const request = {
268361
+ 'id': requestId,
268362
+ 'type': 'subscribe',
268363
+ 'topic': channelName + joined,
268364
+ 'response': true,
268365
+ };
268366
+ const subscription = {
268367
+ 'id': requestId,
268368
+ };
268369
+ return await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscription);
268370
+ }
268371
+ handleBidAsk(client, message) {
268372
+ //
268373
+ // arrives one symbol dict
268374
+ //
268375
+ // {
268376
+ // "subject": "tickerV2",
268377
+ // "topic": "/contractMarket/tickerV2:XBTUSDM",
268378
+ // "data": {
268379
+ // "symbol": "XBTUSDM", //Market of the symbol
268380
+ // "bestBidSize": 795, // Best bid size
268381
+ // "bestBidPrice": 3200.0, // Best bid
268382
+ // "bestAskPrice": 3600.0, // Best ask
268383
+ // "bestAskSize": 284, // Best ask size
268384
+ // "ts": 1553846081210004941 // Filled time - nanosecond
268385
+ // }
268386
+ // }
268387
+ //
268388
+ const parsedTicker = this.parseWsBidAsk(message);
268389
+ const symbol = parsedTicker['symbol'];
268390
+ this.bidsasks[symbol] = parsedTicker;
268391
+ client.resolve(parsedTicker, this.getMessageHash('bidask', symbol));
268392
+ }
268393
+ parseWsBidAsk(ticker, market = undefined) {
268394
+ const data = this.safeDict(ticker, 'data', {});
268395
+ const marketId = this.safeString(data, 'symbol');
268396
+ market = this.safeMarket(marketId, market);
268397
+ const symbol = this.safeString(market, 'symbol');
268398
+ const timestamp = this.safeIntegerProduct(data, 'ts', 0.000001);
268399
+ return this.safeTicker({
268400
+ 'symbol': symbol,
268401
+ 'timestamp': timestamp,
268402
+ 'datetime': this.iso8601(timestamp),
268403
+ 'ask': this.safeNumber(data, 'bestAskPrice'),
268404
+ 'askVolume': this.safeNumber(data, 'bestAskSize'),
268405
+ 'bid': this.safeNumber(data, 'bestBidPrice'),
268406
+ 'bidVolume': this.safeNumber(data, 'bestBidSize'),
268407
+ 'info': ticker,
268408
+ }, market);
267550
268409
  }
267551
268410
  async watchPosition(symbol = undefined, params = {}) {
267552
268411
  /**
@@ -267765,7 +268624,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267765
268624
  messageHashes.push('trades:' + symbol);
267766
268625
  subscriptionHashes.push('/contractMarket/execution:' + marketId);
267767
268626
  }
267768
- const trades = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, params);
268627
+ const trades = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, undefined, params);
267769
268628
  if (this.newUpdates) {
267770
268629
  const first = this.safeValue(trades, 0);
267771
268630
  const tradeSymbol = this.safeString(first, 'symbol');
@@ -267851,9 +268710,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267851
268710
  const marketIds = this.marketIds(symbols);
267852
268711
  const url = await this.negotiate(false);
267853
268712
  const topic = '/contractMarket/level2:' + marketIds.join(',');
267854
- const subscription = {
267855
- 'method': this.handleOrderBookSubscription,
267856
- 'symbols': symbols,
268713
+ const subscriptionArgs = {
267857
268714
  'limit': limit,
267858
268715
  };
267859
268716
  const subscriptionHashes = [];
@@ -267864,7 +268721,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267864
268721
  messageHashes.push('orderbook:' + symbol);
267865
268722
  subscriptionHashes.push('/contractMarket/level2:' + marketId);
267866
268723
  }
267867
- const orderbook = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, subscription, params);
268724
+ const orderbook = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, subscriptionArgs, params);
267868
268725
  return orderbook.limit();
267869
268726
  }
267870
268727
  handleDelta(orderbook, delta) {
@@ -267915,11 +268772,13 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267915
268772
  const marketId = this.safeString(topicParts, 1);
267916
268773
  const symbol = this.safeSymbol(marketId, undefined, '-');
267917
268774
  const messageHash = 'orderbook:' + symbol;
267918
- const storedOrderBook = this.safeValue(this.orderbooks, symbol);
267919
- const nonce = this.safeInteger(storedOrderBook, 'nonce');
267920
- if (storedOrderBook === undefined) {
267921
- return; // this shouldn't be needed, but for some reason sometimes this runs before handleOrderBookSubscription in c#
268775
+ if (!(symbol in this.orderbooks)) {
268776
+ const subscriptionArgs = this.safeDict(client.subscriptions, topic, {});
268777
+ const limit = this.safeInteger(subscriptionArgs, 'limit');
268778
+ this.orderbooks[symbol] = this.orderBook({}, limit);
267922
268779
  }
268780
+ const storedOrderBook = this.orderbooks[symbol];
268781
+ const nonce = this.safeInteger(storedOrderBook, 'nonce');
267923
268782
  const deltaEnd = this.safeInteger(data, 'sequence');
267924
268783
  if (nonce === undefined) {
267925
268784
  const cacheLength = storedOrderBook.cache.length;
@@ -267965,39 +268824,6 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
267965
268824
  }
267966
268825
  return cache.length;
267967
268826
  }
267968
- handleOrderBookSubscription(client, message, subscription) {
267969
- const limit = this.safeInteger(subscription, 'limit');
267970
- const symbols = this.safeValue(subscription, 'symbols');
267971
- if (symbols === undefined) {
267972
- const symbol = this.safeString(subscription, 'symbol');
267973
- this.orderbooks[symbol] = this.orderBook({}, limit);
267974
- }
267975
- else {
267976
- for (let i = 0; i < symbols.length; i++) {
267977
- const symbol = symbols[i];
267978
- this.orderbooks[symbol] = this.orderBook({}, limit);
267979
- }
267980
- }
267981
- // moved snapshot initialization to handleOrderBook to fix
267982
- // https://github.com/ccxt/ccxt/issues/6820
267983
- // the general idea is to fetch the snapshot after the first delta
267984
- // but not before, because otherwise we cannot synchronize the feed
267985
- }
267986
- handleSubscriptionStatus(client, message) {
267987
- //
267988
- // {
267989
- // "id": "1578090438322",
267990
- // "type": "ack"
267991
- // }
267992
- //
267993
- const id = this.safeString(message, 'id');
267994
- const subscriptionsById = this.indexBy(client.subscriptions, 'id');
267995
- const subscription = this.safeValue(subscriptionsById, id, {});
267996
- const method = this.safeValue(subscription, 'method');
267997
- if (method !== undefined) {
267998
- method.call(this, client, message, subscription);
267999
- }
268000
- }
268001
268827
  handleSystemStatus(client, message) {
268002
268828
  //
268003
268829
  // todo: answer the question whether handleSystemStatus should be renamed
@@ -268256,7 +269082,8 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
268256
269082
  const subject = this.safeString(message, 'subject');
268257
269083
  const methods = {
268258
269084
  'level2': this.handleOrderBook,
268259
- 'tickerV2': this.handleTicker,
269085
+ 'ticker': this.handleTicker,
269086
+ 'tickerV2': this.handleBidAsk,
268260
269087
  'availableBalance.change': this.handleBalance,
268261
269088
  'match': this.handleTrade,
268262
269089
  'orderChange': this.handleOrder,
@@ -268270,6 +269097,15 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
268270
269097
  method.call(this, client, message);
268271
269098
  }
268272
269099
  }
269100
+ getMessageHash(elementName, symbol = undefined) {
269101
+ // elementName can be 'ticker', 'bidask', ...
269102
+ if (symbol !== undefined) {
269103
+ return elementName + '@' + symbol;
269104
+ }
269105
+ else {
269106
+ return elementName + 's@all';
269107
+ }
269108
+ }
268273
269109
  ping(client) {
268274
269110
  // kucoin does not support built-in ws protocol-level ping-pong
268275
269111
  // instead it requires a custom json-based text ping-pong
@@ -268309,7 +269145,6 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
268309
269145
  const methods = {
268310
269146
  // 'heartbeat': this.handleHeartbeat,
268311
269147
  'welcome': this.handleSystemStatus,
268312
- 'ack': this.handleSubscriptionStatus,
268313
269148
  'message': this.handleSubject,
268314
269149
  'pong': this.handlePong,
268315
269150
  'error': this.handleErrorMessage,
@@ -296285,6 +297120,63 @@ const hash_to_ristretto255 = (msg, options) => {
296285
297120
  };
296286
297121
 
296287
297122
 
297123
+ /***/ }),
297124
+
297125
+ /***/ 2572:
297126
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
297127
+
297128
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
297129
+ /* harmony export */ lA: () => (/* binding */ P256)
297130
+ /* harmony export */ });
297131
+ /* unused harmony exports secp256r1, hashToCurve, encodeToCurve */
297132
+ /* harmony import */ var _shortw_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(77);
297133
+ /* harmony import */ var _noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1372);
297134
+ /* harmony import */ var _abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(111);
297135
+ /* harmony import */ var _abstract_weierstrass_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9270);
297136
+ /* harmony import */ var _abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4945);
297137
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
297138
+
297139
+
297140
+
297141
+
297142
+
297143
+ // NIST secp256r1 aka P256
297144
+ // https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256
297145
+ // Field over which we'll do calculations; 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n
297146
+ const Fp = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.Fp)(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff'));
297147
+ const CURVE_A = Fp.create(BigInt('-3'));
297148
+ const CURVE_B = BigInt('0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b');
297149
+ const mapSWU = (0,_abstract_weierstrass_js__WEBPACK_IMPORTED_MODULE_1__/* .mapToCurveSimpleSWU */ .L4)(Fp, {
297150
+ A: CURVE_A,
297151
+ B: CURVE_B,
297152
+ Z: Fp.create(BigInt('-10')),
297153
+ });
297154
+ const P256 = (0,_shortw_utils_js__WEBPACK_IMPORTED_MODULE_2__/* .createCurve */ ._)({
297155
+ // Params: a, b
297156
+ a: CURVE_A,
297157
+ b: CURVE_B,
297158
+ Fp,
297159
+ // Curve order, total count of valid points in the field
297160
+ n: BigInt('0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551'),
297161
+ // Base point (x, y) aka generator point
297162
+ Gx: BigInt('0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'),
297163
+ Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'),
297164
+ h: BigInt(1),
297165
+ lowS: false,
297166
+ }, _noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__/* .sha256 */ .J);
297167
+ const secp256r1 = P256;
297168
+ const { hashToCurve, encodeToCurve } = _abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__/* .createHasher */ .V1(secp256r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
297169
+ DST: 'P256_XMD:SHA-256_SSWU_RO_',
297170
+ encodeDST: 'P256_XMD:SHA-256_SSWU_NU_',
297171
+ p: Fp.ORDER,
297172
+ m: 1,
297173
+ k: 128,
297174
+ expand: 'xmd',
297175
+ hash: _noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__/* .sha256 */ .J,
297176
+ });
297177
+
297178
+
297179
+
296288
297180
  /***/ }),
296289
297181
 
296290
297182
  /***/ 1339:
@@ -311563,6 +312455,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
311563
312455
  'fetchIndexOHLCV': false,
311564
312456
  'fetchLedger': true,
311565
312457
  'fetchLeverage': true,
312458
+ 'fetchMarginAdjustmentHistory': false,
311566
312459
  'fetchMarginMode': false,
311567
312460
  'fetchMarkets': true,
311568
312461
  'fetchMarkOHLCV': false,
@@ -324652,7 +325545,7 @@ SOFTWARE.
324652
325545
 
324653
325546
  //-----------------------------------------------------------------------------
324654
325547
  // this is updated by vss.js when building
324655
- const version = '4.2.89';
325548
+ const version = '4.2.91';
324656
325549
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
324657
325550
  //-----------------------------------------------------------------------------
324658
325551