ccxt 4.2.89 → 4.2.90

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 (78) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +829 -114
  4. package/dist/ccxt.browser.min.js +6 -4
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/ascendex.js +1 -0
  7. package/dist/cjs/src/base/Exchange.js +38 -0
  8. package/dist/cjs/src/base/functions/crypto.js +37 -0
  9. package/dist/cjs/src/base/functions/rsa.js +19 -4
  10. package/dist/cjs/src/binance.js +90 -9
  11. package/dist/cjs/src/bingx.js +101 -1
  12. package/dist/cjs/src/bitfinex2.js +1 -0
  13. package/dist/cjs/src/bitget.js +2 -0
  14. package/dist/cjs/src/bitmex.js +1 -0
  15. package/dist/cjs/src/bitrue.js +1 -0
  16. package/dist/cjs/src/bybit.js +61 -0
  17. package/dist/cjs/src/coinbase.js +48 -24
  18. package/dist/cjs/src/coinbaseinternational.js +1 -0
  19. package/dist/cjs/src/coinex.js +102 -8
  20. package/dist/cjs/src/cryptocom.js +1 -0
  21. package/dist/cjs/src/delta.js +1 -0
  22. package/dist/cjs/src/digifinex.js +1 -0
  23. package/dist/cjs/src/exmo.js +1 -0
  24. package/dist/cjs/src/gate.js +2 -0
  25. package/dist/cjs/src/gemini.js +10 -9
  26. package/dist/cjs/src/hitbtc.js +1 -0
  27. package/dist/cjs/src/htx.js +1 -0
  28. package/dist/cjs/src/hyperliquid.js +1 -0
  29. package/dist/cjs/src/kucoin.js +1 -0
  30. package/dist/cjs/src/kucoinfutures.js +34 -3
  31. package/dist/cjs/src/mexc.js +1 -0
  32. package/dist/cjs/src/okx.js +157 -8
  33. package/dist/cjs/src/phemex.js +1 -0
  34. package/dist/cjs/src/static_dependencies/noble-curves/p256.js +48 -0
  35. package/dist/cjs/src/woo.js +1 -0
  36. package/js/ccxt.d.ts +1 -1
  37. package/js/ccxt.js +1 -1
  38. package/js/src/abstract/bingx.d.ts +2 -0
  39. package/js/src/abstract/bybit.d.ts +2 -0
  40. package/js/src/ascendex.js +1 -0
  41. package/js/src/base/Exchange.d.ts +5 -0
  42. package/js/src/base/Exchange.js +38 -0
  43. package/js/src/base/functions/crypto.js +37 -0
  44. package/js/src/base/functions/rsa.d.ts +1 -1
  45. package/js/src/base/functions/rsa.js +21 -5
  46. package/js/src/base/types.d.ts +1 -0
  47. package/js/src/binance.d.ts +1 -0
  48. package/js/src/binance.js +90 -9
  49. package/js/src/bingx.d.ts +1 -0
  50. package/js/src/bingx.js +101 -1
  51. package/js/src/bitfinex2.js +1 -0
  52. package/js/src/bitget.js +2 -0
  53. package/js/src/bitmex.js +1 -0
  54. package/js/src/bitrue.js +1 -0
  55. package/js/src/bybit.d.ts +2 -0
  56. package/js/src/bybit.js +61 -0
  57. package/js/src/coinbase.js +48 -24
  58. package/js/src/coinbaseinternational.js +1 -0
  59. package/js/src/coinex.d.ts +2 -0
  60. package/js/src/coinex.js +102 -8
  61. package/js/src/cryptocom.js +1 -0
  62. package/js/src/delta.js +1 -0
  63. package/js/src/digifinex.js +1 -0
  64. package/js/src/exmo.js +1 -0
  65. package/js/src/gate.js +2 -0
  66. package/js/src/gemini.js +10 -9
  67. package/js/src/hitbtc.js +1 -0
  68. package/js/src/htx.js +1 -0
  69. package/js/src/hyperliquid.js +1 -0
  70. package/js/src/kucoin.js +1 -0
  71. package/js/src/kucoinfutures.d.ts +2 -9
  72. package/js/src/kucoinfutures.js +34 -3
  73. package/js/src/mexc.js +1 -0
  74. package/js/src/okx.d.ts +1 -0
  75. package/js/src/okx.js +157 -8
  76. package/js/src/phemex.js +1 -0
  77. package/js/src/woo.js +1 -0
  78. 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
  }
@@ -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');
@@ -11956,11 +11981,11 @@ class Exchange {
11956
11981
  if (precision === undefined) {
11957
11982
  return undefined;
11958
11983
  }
11959
- if (_Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringGe(precision, '0')) {
11984
+ if (_Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringGe(precision, '0')) {
11960
11985
  return this.parsePrecision(precision);
11961
11986
  }
11962
11987
  else {
11963
- const positivePrecisionString = _Precise_js__WEBPACK_IMPORTED_MODULE_10__/* .Precise */ .O.stringAbs(precision);
11988
+ const positivePrecisionString = _Precise_js__WEBPACK_IMPORTED_MODULE_11__/* .Precise */ .O.stringAbs(precision);
11964
11989
  const positivePrecision = parseInt(positivePrecisionString);
11965
11990
  let parsedPrecision = '1';
11966
11991
  for (let i = 0; i < positivePrecision - 1; i++) {
@@ -13032,6 +13057,21 @@ class Exchange {
13032
13057
  const reconstructedDate = day + month + year;
13033
13058
  return reconstructedDate;
13034
13059
  }
13060
+ parseMarginModification(data, market = undefined) {
13061
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseMarginModification() is not supported yet');
13062
+ }
13063
+ parseMarginModifications(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
13064
+ const marginModifications = [];
13065
+ for (let i = 0; i < response.length; i++) {
13066
+ const info = response[i];
13067
+ const marketId = this.safeString(info, symbolKey);
13068
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
13069
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
13070
+ marginModifications.push(this.parseMarginModification(info, market));
13071
+ }
13072
+ }
13073
+ return marginModifications;
13074
+ }
13035
13075
  }
13036
13076
 
13037
13077
 
@@ -13795,19 +13835,29 @@ __webpack_require__.r(__webpack_exports__);
13795
13835
  /* harmony export */ kn: () => (/* binding */ crc32),
13796
13836
  /* harmony export */ vp: () => (/* binding */ hash)
13797
13837
  /* harmony export */ });
13798
- /* harmony import */ var _static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(138);
13838
+ /* harmony import */ var _static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(138);
13799
13839
  /* 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);
13840
+ /* harmony import */ var _static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9285);
13841
+ /* harmony import */ var _static_dependencies_jsencrypt_lib_asn1js_asn1_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1728);
13842
+ /* harmony import */ var _static_dependencies_noble_curves_secp256k1_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1339);
13843
+ /* harmony import */ var _static_dependencies_noble_curves_p256_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2572);
13801
13844
  /* ------------------------------------------------------------------------ */
13802
13845
 
13803
13846
 
13804
13847
 
13848
+
13849
+
13850
+
13805
13851
  /* ------------------------------------------------------------------------ */
13806
13852
  const encoders = {
13807
13853
  binary: x => x,
13808
13854
  hex: _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base16 */ .YU.encode,
13809
13855
  base64: _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base64 */ .US.encode,
13810
13856
  };
13857
+ const supportedCurve = {
13858
+ '1.3.132.0.10': _static_dependencies_noble_curves_secp256k1_js__WEBPACK_IMPORTED_MODULE_1__/* .secp256k1 */ .kA,
13859
+ '1.2.840.10045.3.1.7': _static_dependencies_noble_curves_p256_js__WEBPACK_IMPORTED_MODULE_2__/* .P256 */ .lA,
13860
+ };
13811
13861
  /* ............................................. */
13812
13862
  const hash = (request, hash, digest = 'hex') => {
13813
13863
  const binary = hash(request);
@@ -13815,7 +13865,7 @@ const hash = (request, hash, digest = 'hex') => {
13815
13865
  };
13816
13866
  /* ............................................. */
13817
13867
  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);
13868
+ const binary = (0,_static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_3__/* .hmac */ .b)(hash, secret, request);
13819
13869
  return encoders[digest](binary);
13820
13870
  };
13821
13871
  /* ............................................. */
@@ -13823,6 +13873,36 @@ function ecdsa(request, secret, curve, prehash = null) {
13823
13873
  if (prehash) {
13824
13874
  request = hash(request, prehash, 'hex');
13825
13875
  }
13876
+ if (typeof secret === 'string' && secret.length > 64) {
13877
+ // decode pem key
13878
+ if (secret.startsWith('-----BEGIN EC PRIVATE KEY-----')) {
13879
+ const der = _static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_4__/* .Base64 */ .D.unarmor(secret);
13880
+ let asn1 = _static_dependencies_jsencrypt_lib_asn1js_asn1_js__WEBPACK_IMPORTED_MODULE_5__/* .ASN1 */ .lj.decode(der);
13881
+ if (asn1.sub.length === 4) {
13882
+ // ECPrivateKey ::= SEQUENCE {
13883
+ // version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
13884
+ // privateKey OCTET STRING,
13885
+ // parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
13886
+ // publicKey [1] BIT STRING OPTIONAL
13887
+ // }
13888
+ if (typeof asn1.sub[2].sub !== null && asn1.sub[2].sub.length > 0) {
13889
+ const oid = asn1.sub[2].sub[0].content(undefined);
13890
+ if (supportedCurve[oid] === undefined)
13891
+ throw new Error('Unsupported curve');
13892
+ curve = supportedCurve[oid];
13893
+ }
13894
+ secret = asn1.sub[1].getHexStringValue();
13895
+ }
13896
+ else {
13897
+ // maybe return false
13898
+ throw new Error('Unsupported key format');
13899
+ }
13900
+ }
13901
+ else {
13902
+ // maybe return false
13903
+ throw new Error('Unsupported key format');
13904
+ }
13905
+ }
13826
13906
  const signature = curve.sign(request, secret);
13827
13907
  return {
13828
13908
  'r': signature.r.toString(16),
@@ -13838,7 +13918,7 @@ function axolotl(request, secret, curve) {
13838
13918
  function eddsa(request, secret, curve) {
13839
13919
  // secret is the base64 pem encoded key
13840
13920
  // 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));
13921
+ const privateKey = new Uint8Array(_static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_4__/* .Base64 */ .D.unarmor(secret).slice(16));
13842
13922
  const signature = curve.sign(request, privateKey);
13843
13923
  return _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base64 */ .US.encode(signature);
13844
13924
  }
@@ -14578,6 +14658,9 @@ const isNode = !(isBrowser || isWebWorker);
14578
14658
  /* harmony import */ var _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9651);
14579
14659
  /* harmony import */ var _encode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1237);
14580
14660
  /* harmony import */ var _crypto_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6890);
14661
+ /* harmony import */ var _static_dependencies_noble_curves_p256_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2572);
14662
+
14663
+
14581
14664
 
14582
14665
 
14583
14666
 
@@ -14589,9 +14672,17 @@ function rsa(request, secret, hash) {
14589
14672
  const name = (hash.create()).constructor.name.toLowerCase();
14590
14673
  return RSA.sign(request, digester, name);
14591
14674
  }
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' })));
14675
+ function jwt(request, secret, hash, isRSA = false, opts = {}) {
14676
+ let alg = (isRSA ? 'RS' : 'HS') + (hash.outputLen * 8);
14677
+ if (opts['alg']) {
14678
+ alg = opts['alg'].toUpperCase();
14679
+ }
14680
+ const header = Object.assign({ 'alg': alg, 'typ': 'JWT' }, opts);
14681
+ if (header['iat'] !== undefined) {
14682
+ request['iat'] = header['iat'];
14683
+ delete header['iat'];
14684
+ }
14685
+ const encodedHeader = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .stringToBase64 */ .Ne)(JSON.stringify(header)));
14595
14686
  const encodedData = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)((0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .stringToBase64 */ .Ne)(JSON.stringify(request)));
14596
14687
  const token = [encodedHeader, encodedData].join('.');
14597
14688
  const algoType = alg.slice(0, 2);
@@ -14599,9 +14690,15 @@ function jwt(request, secret, hash, isRSA = false) {
14599
14690
  if (algoType === 'HS') {
14600
14691
  signature = (0,_encode_js__WEBPACK_IMPORTED_MODULE_2__/* .urlencodeBase64 */ .xr)((0,_crypto_js__WEBPACK_IMPORTED_MODULE_3__/* .hmac */ .bD)(token, secret, hash, 'base64'));
14601
14692
  }
14602
- else if (algoType === 'RS') {
14693
+ else if (isRSA || algoType === 'RS') {
14603
14694
  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
14695
  }
14696
+ else if (algoType === 'ES') {
14697
+ 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);
14698
+ const r = (signedHash.r.length === 64) ? signedHash.r : '0' + signedHash.r;
14699
+ const s = (signedHash.s.length === 64) ? signedHash.s : '0' + signedHash.s;
14700
+ 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)));
14701
+ }
14605
14702
  return [token, signature].join('.');
14606
14703
  }
14607
14704
 
@@ -18652,6 +18749,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18652
18749
  'fetchLeverages': true,
18653
18750
  'fetchLeverageTiers': true,
18654
18751
  'fetchLiquidations': false,
18752
+ 'fetchMarginAdjustmentHistory': true,
18655
18753
  'fetchMarginMode': 'emulated',
18656
18754
  'fetchMarginModes': true,
18657
18755
  'fetchMarketLeverageTiers': 'emulated',
@@ -29782,21 +29880,37 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
29782
29880
  // "type": 1
29783
29881
  // }
29784
29882
  //
29883
+ // fetchMarginAdjustmentHistory
29884
+ //
29885
+ // {
29886
+ // symbol: "XRPUSDT",
29887
+ // type: "1",
29888
+ // deltaType: "TRADE",
29889
+ // amount: "2.57148240",
29890
+ // asset: "USDT",
29891
+ // time: "1711046271555",
29892
+ // positionSide: "BOTH",
29893
+ // clientTranId: ""
29894
+ // }
29895
+ //
29785
29896
  const rawType = this.safeInteger(data, 'type');
29786
- const resultType = (rawType === 1) ? 'add' : 'reduce';
29787
- const resultAmount = this.safeNumber(data, 'amount');
29788
29897
  const errorCode = this.safeString(data, 'code');
29789
- const status = (errorCode === '200') ? 'ok' : 'failed';
29898
+ const marketId = this.safeString(data, 'symbol');
29899
+ const timestamp = this.safeInteger(data, 'time');
29900
+ market = this.safeMarket(marketId, market, undefined, 'swap');
29901
+ const noErrorCode = errorCode === undefined;
29902
+ const success = errorCode === '200';
29790
29903
  return {
29791
29904
  'info': data,
29792
29905
  'symbol': market['symbol'],
29793
- 'type': resultType,
29794
- 'amount': resultAmount,
29906
+ 'type': (rawType === 1) ? 'add' : 'reduce',
29907
+ 'marginMode': 'isolated',
29908
+ 'amount': this.safeNumber(data, 'amount'),
29909
+ 'code': this.safeString(data, 'asset'),
29795
29910
  'total': undefined,
29796
- 'code': undefined,
29797
- 'status': status,
29798
- 'timestamp': undefined,
29799
- 'datetime': undefined,
29911
+ 'status': (success || noErrorCode) ? 'ok' : 'failed',
29912
+ 'timestamp': timestamp,
29913
+ 'datetime': this.iso8601(timestamp),
29800
29914
  };
29801
29915
  }
29802
29916
  async reduceMargin(symbol, amount, params = {}) {
@@ -31059,6 +31173,70 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
31059
31173
  'quoteVolume': undefined,
31060
31174
  };
31061
31175
  }
31176
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
31177
+ /**
31178
+ * @method
31179
+ * @description fetches the history of margin added or reduced from contract isolated positions
31180
+ * @see https://binance-docs.github.io/apidocs/futures/en/#get-position-margin-change-history-trade
31181
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#get-position-margin-change-history-trade
31182
+ * @param {string} symbol unified market symbol
31183
+ * @param {string} [type] "add" or "reduce"
31184
+ * @param {int} [since] timestamp in ms of the earliest change to fetch
31185
+ * @param {int} [limit] the maximum amount of changes to fetch
31186
+ * @param {object} params extra parameters specific to the exchange api endpoint
31187
+ * @param {int} [params.until] timestamp in ms of the latest change to fetch
31188
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
31189
+ */
31190
+ await this.loadMarkets();
31191
+ if (symbol === undefined) {
31192
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory () requires a symbol argument');
31193
+ }
31194
+ const market = this.market(symbol);
31195
+ const until = this.safeInteger(params, 'until');
31196
+ params = this.omit(params, 'until');
31197
+ const request = {
31198
+ 'symbol': market['id'],
31199
+ };
31200
+ if (type !== undefined) {
31201
+ request['type'] = (type === 'add') ? 1 : 2;
31202
+ }
31203
+ if (since !== undefined) {
31204
+ request['startTime'] = since;
31205
+ }
31206
+ if (limit !== undefined) {
31207
+ request['limit'] = limit;
31208
+ }
31209
+ if (until !== undefined) {
31210
+ request['endTime'] = until;
31211
+ }
31212
+ let response = undefined;
31213
+ if (market['linear']) {
31214
+ response = await this.fapiPrivateGetPositionMarginHistory(this.extend(request, params));
31215
+ }
31216
+ else if (market['inverse']) {
31217
+ response = await this.dapiPrivateGetPositionMarginHistory(this.extend(request, params));
31218
+ }
31219
+ else {
31220
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + 'fetchMarginAdjustmentHistory () is not supported for markets of type ' + market['type']);
31221
+ }
31222
+ //
31223
+ // [
31224
+ // {
31225
+ // symbol: "XRPUSDT",
31226
+ // type: "1",
31227
+ // deltaType: "TRADE",
31228
+ // amount: "2.57148240",
31229
+ // asset: "USDT",
31230
+ // time: "1711046271555",
31231
+ // positionSide: "BOTH",
31232
+ // clientTranId: ""
31233
+ // }
31234
+ // ...
31235
+ // ]
31236
+ //
31237
+ const modifications = this.parseMarginModifications(response);
31238
+ return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
31239
+ }
31062
31240
  }
31063
31241
 
31064
31242
 
@@ -31467,6 +31645,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31467
31645
  'fetchFundingRates': true,
31468
31646
  'fetchLeverage': true,
31469
31647
  'fetchLiquidations': false,
31648
+ 'fetchMarginAdjustmentHistory': false,
31470
31649
  'fetchMarginMode': true,
31471
31650
  'fetchMarkets': true,
31472
31651
  'fetchMarkOHLCV': true,
@@ -31476,6 +31655,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31476
31655
  'fetchOpenOrders': true,
31477
31656
  'fetchOrder': true,
31478
31657
  'fetchOrderBook': true,
31658
+ 'fetchOrders': true,
31479
31659
  'fetchPositionMode': true,
31480
31660
  'fetchPositions': true,
31481
31661
  'fetchTicker': true,
@@ -31587,6 +31767,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31587
31767
  'positionSide/dual': 1,
31588
31768
  'market/markPriceKlines': 1,
31589
31769
  'trade/batchCancelReplace': 1,
31770
+ 'trade/fullOrder': 1,
31590
31771
  },
31591
31772
  'post': {
31592
31773
  'trade/cancelReplace': 1,
@@ -31734,6 +31915,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31734
31915
  'post': {
31735
31916
  'swap/trace/closeTrackOrder': 1,
31736
31917
  'swap/trace/setTPSL': 1,
31918
+ 'spot/trader/sellOrder': 1,
31737
31919
  },
31738
31920
  },
31739
31921
  },
@@ -34164,7 +34346,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34164
34346
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
34165
34347
  */
34166
34348
  if (symbol === undefined) {
34167
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
34349
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
34168
34350
  }
34169
34351
  await this.loadMarkets();
34170
34352
  const market = this.market(symbol);
@@ -34235,6 +34417,101 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34235
34417
  const first = this.safeDict(data, 'order', data);
34236
34418
  return this.parseOrder(first, market);
34237
34419
  }
34420
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
34421
+ /**
34422
+ * @method
34423
+ * @name bingx#fetchOrders
34424
+ * @description fetches information on multiple orders made by the user
34425
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#User's%20All%20Orders
34426
+ * @param {string} symbol unified market symbol of the market orders were made in
34427
+ * @param {int} [since] the earliest time in ms to fetch orders for
34428
+ * @param {int} [limit] the maximum number of order structures to retrieve
34429
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
34430
+ * @param {int} [params.until] the latest time in ms to fetch entries for
34431
+ * @param {int} [params.orderId] Only return subsequent orders, and return the latest order by default
34432
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
34433
+ */
34434
+ await this.loadMarkets();
34435
+ const request = {};
34436
+ let market = undefined;
34437
+ if (symbol !== undefined) {
34438
+ market = this.market(symbol);
34439
+ request['symbol'] = market['id'];
34440
+ }
34441
+ let type = undefined;
34442
+ [type, params] = this.handleMarketTypeAndParams('fetchOrders', market, params);
34443
+ if (type !== 'swap') {
34444
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrders() is only supported for swap markets');
34445
+ }
34446
+ if (limit !== undefined) {
34447
+ request['limit'] = limit;
34448
+ }
34449
+ if (since !== undefined) {
34450
+ request['startTime'] = since;
34451
+ }
34452
+ const until = this.safeInteger2(params, 'until', 'till'); // unified in milliseconds
34453
+ const endTime = this.safeInteger(params, 'endTime', until); // exchange-specific in milliseconds
34454
+ params = this.omit(params, ['endTime', 'till', 'until']);
34455
+ if (endTime !== undefined) {
34456
+ request['endTime'] = endTime;
34457
+ }
34458
+ const response = await this.swapV1PrivateGetTradeFullOrder(this.extend(request, params));
34459
+ //
34460
+ // {
34461
+ // "code": 0,
34462
+ // "msg": "",
34463
+ // "data": {
34464
+ // "orders": [
34465
+ // {
34466
+ // "symbol": "PYTH-USDT",
34467
+ // "orderId": 1736007506620112100,
34468
+ // "side": "SELL",
34469
+ // "positionSide": "SHORT",
34470
+ // "type": "LIMIT",
34471
+ // "origQty": "33",
34472
+ // "price": "0.3916",
34473
+ // "executedQty": "33",
34474
+ // "avgPrice": "0.3916",
34475
+ // "cumQuote": "13",
34476
+ // "stopPrice": "",
34477
+ // "profit": "0.0000",
34478
+ // "commission": "-0.002585",
34479
+ // "status": "FILLED",
34480
+ // "time": 1702731418000,
34481
+ // "updateTime": 1702731470000,
34482
+ // "clientOrderId": "",
34483
+ // "leverage": "15X",
34484
+ // "takeProfit": {
34485
+ // "type": "TAKE_PROFIT",
34486
+ // "quantity": 0,
34487
+ // "stopPrice": 0,
34488
+ // "price": 0,
34489
+ // "workingType": ""
34490
+ // },
34491
+ // "stopLoss": {
34492
+ // "type": "STOP",
34493
+ // "quantity": 0,
34494
+ // "stopPrice": 0,
34495
+ // "price": 0,
34496
+ // "workingType": ""
34497
+ // },
34498
+ // "advanceAttr": 0,
34499
+ // "positionID": 0,
34500
+ // "takeProfitEntrustPrice": 0,
34501
+ // "stopLossEntrustPrice": 0,
34502
+ // "orderType": "",
34503
+ // "workingType": "MARK_PRICE",
34504
+ // "stopGuaranteed": false,
34505
+ // "triggerOrderId": 1736012449498123500
34506
+ // }
34507
+ // ]
34508
+ // }
34509
+ // }
34510
+ //
34511
+ const data = this.safeDict(response, 'data', {});
34512
+ const orders = this.safeList(data, 'orders', []);
34513
+ return this.parseOrders(orders, market, since, limit);
34514
+ }
34238
34515
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
34239
34516
  /**
34240
34517
  * @method
@@ -34935,6 +35212,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34935
35212
  'info': data,
34936
35213
  'symbol': this.safeString(market, 'symbol'),
34937
35214
  'type': (type === '1') ? 'add' : 'reduce',
35215
+ 'marginMode': 'isolated',
34938
35216
  'amount': this.safeNumber(data, 'amount'),
34939
35217
  'total': this.safeNumber(data, 'margin'),
34940
35218
  'code': this.safeString(market, 'settle'),
@@ -44244,6 +44522,7 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
44244
44522
  'info': data,
44245
44523
  'symbol': market['symbol'],
44246
44524
  'type': undefined,
44525
+ 'marginMode': 'isolated',
44247
44526
  'amount': undefined,
44248
44527
  'total': undefined,
44249
44528
  'code': undefined,
@@ -45621,6 +45900,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45621
45900
  'fetchLeverage': true,
45622
45901
  'fetchLeverageTiers': false,
45623
45902
  'fetchLiquidations': false,
45903
+ 'fetchMarginAdjustmentHistory': false,
45624
45904
  'fetchMarginMode': true,
45625
45905
  'fetchMarketLeverageTiers': true,
45626
45906
  'fetchMarkets': true,
@@ -52521,6 +52801,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
52521
52801
  'info': data,
52522
52802
  'symbol': market['symbol'],
52523
52803
  'type': undefined,
52804
+ 'marginMode': 'isolated',
52524
52805
  'amount': undefined,
52525
52806
  'total': undefined,
52526
52807
  'code': market['settle'],
@@ -59780,6 +60061,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
59780
60061
  'fetchLeverages': true,
59781
60062
  'fetchLeverageTiers': false,
59782
60063
  'fetchLiquidations': true,
60064
+ 'fetchMarginAdjustmentHistory': false,
59783
60065
  'fetchMarketLeverageTiers': false,
59784
60066
  'fetchMarkets': true,
59785
60067
  'fetchMarkOHLCV': false,
@@ -67466,6 +67748,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
67466
67748
  'info': data,
67467
67749
  'symbol': market['symbol'],
67468
67750
  'type': undefined,
67751
+ 'marginMode': 'isolated',
67469
67752
  'amount': undefined,
67470
67753
  'total': undefined,
67471
67754
  'code': undefined,
@@ -83974,6 +84257,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
83974
84257
  'fetchLedger': true,
83975
84258
  'fetchLeverage': true,
83976
84259
  'fetchLeverageTiers': true,
84260
+ 'fetchMarginAdjustmentHistory': false,
83977
84261
  'fetchMarketLeverageTiers': true,
83978
84262
  'fetchMarkets': true,
83979
84263
  'fetchMarkOHLCV': true,
@@ -84044,6 +84328,13 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84044
84328
  'public': 'https://api.{hostname}',
84045
84329
  'private': 'https://api.{hostname}',
84046
84330
  },
84331
+ 'demotrading': {
84332
+ 'spot': 'https://api-demo.{hostname}',
84333
+ 'futures': 'https://api-demo.{hostname}',
84334
+ 'v2': 'https://api-demo.{hostname}',
84335
+ 'public': 'https://api-demo.{hostname}',
84336
+ 'private': 'https://api-demo.{hostname}',
84337
+ },
84047
84338
  'www': 'https://www.bybit.com',
84048
84339
  'doc': [
84049
84340
  'https://bybit-exchange.github.io/docs/inverse/',
@@ -84232,6 +84523,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84232
84523
  'v5/user/get-member-type': 5,
84233
84524
  'v5/user/aff-customer-info': 5,
84234
84525
  'v5/user/del-submember': 5,
84526
+ 'v5/user/submembers': 5,
84235
84527
  // spot leverage token
84236
84528
  'v5/spot-lever-token/order-record': 1,
84237
84529
  // spot margin trade
@@ -84392,6 +84684,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84392
84684
  'v5/lending/redeem-cancel': 5,
84393
84685
  'v5/account/set-collateral-switch': 5,
84394
84686
  'v5/account/set-collateral-switch-batch': 5,
84687
+ // demo trading
84688
+ 'v5/account/demo-apply-money': 5,
84395
84689
  },
84396
84690
  },
84397
84691
  },
@@ -84858,6 +85152,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84858
85152
  },
84859
85153
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_2__/* .TICK_SIZE */ .sh,
84860
85154
  'options': {
85155
+ 'sandboxMode': false,
85156
+ 'enableDemoTrading': false,
84861
85157
  'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
84862
85158
  'createOrder': {
84863
85159
  'method': 'privatePostV5OrderCreate', // 'privatePostV5PositionTradingStop'
@@ -84941,6 +85237,39 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84941
85237
  },
84942
85238
  });
84943
85239
  }
85240
+ setSandboxMode(enable) {
85241
+ /**
85242
+ * @method
85243
+ * @name bybit#setSandboxMode
85244
+ * @description enables or disables sandbox mode
85245
+ * @param {boolean} [enable] true if demo trading should be enabled, false otherwise
85246
+ */
85247
+ super.setSandboxMode(enable);
85248
+ this.options['sandboxMode'] = enable;
85249
+ }
85250
+ enableDemoTrading(enable) {
85251
+ /**
85252
+ * @method
85253
+ * @name bybit#enableDemoTrading
85254
+ * @description enables or disables demo trading mode
85255
+ * @see https://bybit-exchange.github.io/docs/v5/demo
85256
+ * @param {boolean} [enable] true if demo trading should be enabled, false otherwise
85257
+ */
85258
+ if (this.options['sandboxMode']) {
85259
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' demo trading does not support in sandbox environment');
85260
+ }
85261
+ // enable demo trading in bybit, see: https://bybit-exchange.github.io/docs/v5/demo
85262
+ if (enable) {
85263
+ this.urls['apiBackupDemoTrading'] = this.urls['api'];
85264
+ this.urls['api'] = this.urls['demotrading'];
85265
+ }
85266
+ else if ('apiBackupDemoTrading' in this.urls) {
85267
+ this.urls['api'] = this.urls['apiBackupDemoTrading'];
85268
+ const newUrls = this.omit(this.urls, 'apiBackupDemoTrading');
85269
+ this.urls = newUrls;
85270
+ }
85271
+ this.options['enableDemoTrading'] = enable;
85272
+ }
84944
85273
  nonce() {
84945
85274
  return this.milliseconds() - this.options['timeDifference'];
84946
85275
  }
@@ -84957,12 +85286,24 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
84957
85286
  return data;
84958
85287
  }
84959
85288
  async isUnifiedEnabled(params = {}) {
85289
+ /**
85290
+ * @method
85291
+ * @name bybit#isUnifiedEnabled
85292
+ * @description returns [enableUnifiedMargin, enableUnifiedAccount] so the user can check if unified account is enabled
85293
+ */
84960
85294
  // The API key of user id must own one of permissions will be allowed to call following API endpoints.
84961
85295
  // SUB UID: "Account Transfer"
84962
85296
  // MASTER UID: "Account Transfer", "Subaccount Transfer", "Withdrawal"
84963
85297
  const enableUnifiedMargin = this.safeValue(this.options, 'enableUnifiedMargin');
84964
85298
  const enableUnifiedAccount = this.safeValue(this.options, 'enableUnifiedAccount');
84965
85299
  if (enableUnifiedMargin === undefined || enableUnifiedAccount === undefined) {
85300
+ if (this.options['enableDemoTrading']) {
85301
+ // info endpoint is not available in demo trading
85302
+ // so we're assuming UTA is enabled
85303
+ this.options['enableUnifiedMargin'] = false;
85304
+ this.options['enableUnifiedAccount'] = true;
85305
+ return [this.options['enableUnifiedMargin'], this.options['enableUnifiedAccount']];
85306
+ }
84966
85307
  const response = await this.privateGetV5UserQueryApi(params);
84967
85308
  //
84968
85309
  // {
@@ -85132,6 +85473,9 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
85132
85473
  if (!this.checkRequiredCredentials(false)) {
85133
85474
  return undefined;
85134
85475
  }
85476
+ if (this.options['enableDemoTrading']) {
85477
+ return undefined;
85478
+ }
85135
85479
  const response = await this.privateGetV5AssetCoinQueryInfo(params);
85136
85480
  //
85137
85481
  // {
@@ -94092,13 +94436,15 @@ class cex extends _abstract_cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
94092
94436
  /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
94093
94437
  /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2194);
94094
94438
  /* 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);
94439
+ /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1372);
94440
+ /* harmony import */ var _base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5981);
94096
94441
  // ----------------------------------------------------------------------------
94097
94442
 
94098
94443
 
94099
94444
 
94100
94445
 
94101
94446
 
94447
+
94102
94448
  // ----------------------------------------------------------------------------
94103
94449
  /**
94104
94450
  * @class coinbase
@@ -97875,31 +98221,16 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
97875
98221
  const url = this.urls['api']['rest'] + fullPath;
97876
98222
  if (signed) {
97877
98223
  const authorization = this.safeString(this.headers, 'Authorization');
98224
+ let authorizationString = undefined;
97878
98225
  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
- }
98226
+ authorizationString = authorization;
97888
98227
  }
97889
98228
  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
- }
98229
+ authorizationString = 'Bearer ' + this.token;
97899
98230
  }
97900
98231
  else {
97901
98232
  this.checkRequiredCredentials();
97902
- const timestampString = this.seconds().toString();
98233
+ const seconds = this.seconds();
97903
98234
  let payload = '';
97904
98235
  if (method !== 'GET') {
97905
98236
  if (Object.keys(query).length) {
@@ -97918,14 +98249,52 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
97918
98249
  // https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#example-request
97919
98250
  // v2: 'GET' require payload in the signature
97920
98251
  // 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);
98252
+ const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
98253
+ if (isCloudAPiKey) {
98254
+ if (this.apiKey.startsWith('-----BEGIN')) {
98255
+ 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');
98256
+ }
98257
+ // it may not work for v2
98258
+ let uri = method + ' ' + url.replace('https://', '');
98259
+ const quesPos = uri.indexOf('?');
98260
+ if (quesPos >= 0) {
98261
+ uri = uri.slice(0, quesPos);
98262
+ }
98263
+ const nonce = this.randomBytes(16);
98264
+ const request = {
98265
+ 'aud': ['retail_rest_api_proxy'],
98266
+ 'iss': 'coinbase-cloud',
98267
+ 'nbf': seconds,
98268
+ 'exp': seconds + 120,
98269
+ 'sub': this.apiKey,
98270
+ 'uri': uri,
98271
+ 'iat': seconds,
98272
+ };
98273
+ 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' });
98274
+ authorizationString = 'Bearer ' + token;
98275
+ }
98276
+ else {
98277
+ const timestampString = this.seconds().toString();
98278
+ const auth = timestampString + method + savedPath + payload;
98279
+ const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J);
98280
+ headers = {
98281
+ 'CB-ACCESS-KEY': this.apiKey,
98282
+ 'CB-ACCESS-SIGN': signature,
98283
+ 'CB-ACCESS-TIMESTAMP': timestampString,
98284
+ 'Content-Type': 'application/json',
98285
+ };
98286
+ }
98287
+ }
98288
+ if (authorizationString !== undefined) {
97923
98289
  headers = {
97924
- 'CB-ACCESS-KEY': this.apiKey,
97925
- 'CB-ACCESS-SIGN': signature,
97926
- 'CB-ACCESS-TIMESTAMP': timestampString,
98290
+ 'Authorization': authorizationString,
97927
98291
  'Content-Type': 'application/json',
97928
98292
  };
98293
+ if (method !== 'GET') {
98294
+ if (Object.keys(query).length) {
98295
+ body = this.json(query);
98296
+ }
98297
+ }
97929
98298
  }
97930
98299
  }
97931
98300
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
@@ -98068,6 +98437,7 @@ class coinbaseinternational extends _abstract_coinbaseinternational_js__WEBPACK_
98068
98437
  'fetchLedger': false,
98069
98438
  'fetchLeverage': false,
98070
98439
  'fetchLeverageTiers': false,
98440
+ 'fetchMarginAdjustmentHistory': false,
98071
98441
  'fetchMarginMode': false,
98072
98442
  'fetchMarkets': true,
98073
98443
  'fetchMarkOHLCV': false,
@@ -102844,6 +103214,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
102844
103214
  'fetchLeverage': 'emulated',
102845
103215
  'fetchLeverages': true,
102846
103216
  'fetchLeverageTiers': true,
103217
+ 'fetchMarginAdjustmentHistory': true,
102847
103218
  'fetchMarketLeverageTiers': 'emulated',
102848
103219
  'fetchMarkets': true,
102849
103220
  'fetchMarkOHLCV': false,
@@ -107003,11 +107374,10 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
107003
107374
  // "message":"OK"
107004
107375
  // }
107005
107376
  //
107377
+ const data = this.safeDict(response, 'data');
107006
107378
  const status = this.safeString(response, 'message');
107007
- const type = (addOrReduce === 1) ? 'add' : 'reduce';
107008
- return this.extend(this.parseMarginModification(response, market), {
107379
+ return this.extend(this.parseMarginModification(data, market), {
107009
107380
  'amount': this.parseNumber(amount),
107010
- 'type': type,
107011
107381
  'status': status,
107012
107382
  });
107013
107383
  }
@@ -107067,13 +107437,34 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
107067
107437
  // "user_id": 3620173
107068
107438
  // }
107069
107439
  //
107070
- const timestamp = this.safeIntegerProduct(data, 'update_time', 1000);
107440
+ // fetchMarginAdjustmentHistory
107441
+ //
107442
+ // {
107443
+ // bkr_price: '0',
107444
+ // leverage: '3',
107445
+ // liq_price: '0',
107446
+ // margin_amount: '5.33236666666666666666',
107447
+ // margin_change: '3',
107448
+ // market: 'XRPUSDT',
107449
+ // position_amount: '11',
107450
+ // position_id: '297155652',
107451
+ // position_type: '2',
107452
+ // settle_price: '0.6361',
107453
+ // time: '1711050906.382891',
107454
+ // type: '1',
107455
+ // user_id: '3685860'
107456
+ // }
107457
+ //
107458
+ const marketId = this.safeString(data, 'market');
107459
+ const type = this.safeString(data, 'type');
107460
+ const timestamp = this.safeIntegerProduct2(data, 'time', 'update_time', 1000);
107071
107461
  return {
107072
107462
  'info': data,
107073
- 'symbol': this.safeSymbol(undefined, market),
107074
- 'type': undefined,
107075
- 'amount': this.safeNumber(data, 'margin_amount'),
107076
- 'total': undefined,
107463
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
107464
+ 'type': (type === '1') ? 'add' : 'reduce',
107465
+ 'marginMode': 'isolated',
107466
+ 'amount': this.safeNumber(data, 'margin_change'),
107467
+ 'total': this.safeNumber(data, 'position_amount'),
107077
107468
  'code': market['quote'],
107078
107469
  'status': undefined,
107079
107470
  'timestamp': timestamp,
@@ -107724,6 +108115,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
107724
108115
  const currencyId = this.safeString(transfer, 'asset');
107725
108116
  const currencyCode = this.safeCurrencyCode(currencyId, currency);
107726
108117
  return {
108118
+ 'info': transfer,
107727
108119
  'id': this.safeInteger(transfer, 'id'),
107728
108120
  'timestamp': timestamp,
107729
108121
  'datetime': this.iso8601(timestamp),
@@ -108556,6 +108948,78 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
108556
108948
  }
108557
108949
  return undefined;
108558
108950
  }
108951
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
108952
+ /**
108953
+ * @method
108954
+ * @name coinex#fetchMarginAdjustmentHistory
108955
+ * @description fetches the history of margin added or reduced from contract isolated positions
108956
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http046_position_margin_history
108957
+ * @param {string} [symbol] unified market symbol
108958
+ * @param {string} [type] not used by coinex fetchMarginAdjustmentHistory
108959
+ * @param {int} [since] timestamp in ms of the earliest change to fetch
108960
+ * @param {int} [limit] the maximum amount of changes to fetch, default=100, max=100
108961
+ * @param {object} params extra parameters specific to the exchange api endpoint
108962
+ * @param {int} [params.until] timestamp in ms of the latest change to fetch
108963
+ *
108964
+ * EXCHANGE SPECIFIC PARAMETERS
108965
+ * @param {int} [params.offset] offset
108966
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
108967
+ */
108968
+ await this.loadMarkets();
108969
+ const until = this.safeInteger(params, 'until');
108970
+ params = this.omit(params, 'until');
108971
+ if (limit === undefined) {
108972
+ limit = 100;
108973
+ }
108974
+ const request = {
108975
+ 'market': '',
108976
+ 'position_id': 0,
108977
+ 'offset': 0,
108978
+ 'limit': limit,
108979
+ };
108980
+ if (symbol !== undefined) {
108981
+ const market = this.market(symbol);
108982
+ request['market'] = market['id'];
108983
+ }
108984
+ if (since !== undefined) {
108985
+ request['start_time'] = since;
108986
+ }
108987
+ if (until !== undefined) {
108988
+ request['end_time'] = until;
108989
+ }
108990
+ const response = await this.v1PerpetualPrivateGetPositionMarginHistory(this.extend(request, params));
108991
+ //
108992
+ // {
108993
+ // code: '0',
108994
+ // data: {
108995
+ // limit: '100',
108996
+ // offset: '0',
108997
+ // records: [
108998
+ // {
108999
+ // bkr_price: '0',
109000
+ // leverage: '3',
109001
+ // liq_price: '0',
109002
+ // margin_amount: '5.33236666666666666666',
109003
+ // margin_change: '3',
109004
+ // market: 'XRPUSDT',
109005
+ // position_amount: '11',
109006
+ // position_id: '297155652',
109007
+ // position_type: '2',
109008
+ // settle_price: '0.6361',
109009
+ // time: '1711050906.382891',
109010
+ // type: '1',
109011
+ // user_id: '3685860'
109012
+ // }
109013
+ // ]
109014
+ // },
109015
+ // message: 'OK'
109016
+ // }
109017
+ //
109018
+ const data = this.safeDict(response, 'data', {});
109019
+ const records = this.safeList(data, 'records', []);
109020
+ const modifications = this.parseMarginModifications(records, undefined, 'market', 'swap');
109021
+ return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
109022
+ }
108559
109023
  }
108560
109024
 
108561
109025
 
@@ -117759,6 +118223,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117759
118223
  'fetchLedger': true,
117760
118224
  'fetchLeverage': false,
117761
118225
  'fetchLeverageTiers': false,
118226
+ 'fetchMarginAdjustmentHistory': false,
117762
118227
  'fetchMarginMode': false,
117763
118228
  'fetchMarketLeverageTiers': false,
117764
118229
  'fetchMarkets': true,
@@ -125432,6 +125897,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
125432
125897
  'info': data,
125433
125898
  'symbol': market['symbol'],
125434
125899
  'type': undefined,
125900
+ 'marginMode': 'isolated',
125435
125901
  'amount': undefined,
125436
125902
  'total': this.safeNumber(data, 'margin'),
125437
125903
  'code': undefined,
@@ -134072,6 +134538,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
134072
134538
  'info': data,
134073
134539
  'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
134074
134540
  'type': (rawType === 1) ? 'add' : 'reduce',
134541
+ 'marginMode': 'isolated',
134075
134542
  'amount': this.safeNumber(data, 'amount'),
134076
134543
  'total': undefined,
134077
134544
  'code': market['settle'],
@@ -134528,6 +134995,7 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
134528
134995
  'info': data,
134529
134996
  'symbol': this.safeSymbol(undefined, market),
134530
134997
  'type': undefined,
134998
+ 'marginMode': 'isolated',
134531
134999
  'amount': undefined,
134532
135000
  'total': undefined,
134533
135001
  'code': this.safeValue(market, 'quote'),
@@ -137100,6 +137568,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
137100
137568
  'fetchLeverages': true,
137101
137569
  'fetchLeverageTiers': true,
137102
137570
  'fetchLiquidations': true,
137571
+ 'fetchMarginAdjustmentHistory': false,
137103
137572
  'fetchMarginMode': false,
137104
137573
  'fetchMarketLeverageTiers': true,
137105
137574
  'fetchMarkets': true,
@@ -143099,6 +143568,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
143099
143568
  'info': data,
143100
143569
  'symbol': market['symbol'],
143101
143570
  'type': undefined,
143571
+ 'marginMode': 'isolated',
143102
143572
  'amount': undefined,
143103
143573
  'total': total,
143104
143574
  'code': this.safeValue(market, 'quote'),
@@ -144528,6 +144998,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
144528
144998
  // https://github.com/ccxt/ccxt/issues/7874
144529
144999
  // https://github.com/ccxt/ccxt/issues/7894
144530
145000
  'web': 'https://docs.gemini.com',
145001
+ 'webExchange': 'https://exchange.gemini.com',
144531
145002
  },
144532
145003
  'fees': [
144533
145004
  'https://gemini.com/api-fee-schedule',
@@ -145065,7 +145536,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
145065
145536
  let quoteId = undefined;
145066
145537
  let settleId = undefined;
145067
145538
  let tickSize = undefined;
145068
- let increment = undefined;
145539
+ let amountPrecision = undefined;
145069
145540
  let minSize = undefined;
145070
145541
  let status = undefined;
145071
145542
  let swap = false;
@@ -145076,9 +145547,9 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
145076
145547
  const isArray = (Array.isArray(response));
145077
145548
  if (!isString && !isArray) {
145078
145549
  marketId = this.safeStringLower(response, 'symbol');
145550
+ amountPrecision = this.safeNumber(response, 'tick_size'); // right, exchange has an imperfect naming and this turns out to be an amount-precision
145551
+ tickSize = this.safeNumber(response, 'quote_increment'); // this is tick-size actually
145079
145552
  minSize = this.safeNumber(response, 'min_order_size');
145080
- tickSize = this.safeNumber(response, 'tick_size');
145081
- increment = this.safeNumber(response, 'quote_increment');
145082
145553
  status = this.parseMarketActive(this.safeString(response, 'status'));
145083
145554
  baseId = this.safeString(response, 'base_currency');
145084
145555
  quoteId = this.safeString(response, 'quote_currency');
@@ -145091,9 +145562,9 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
145091
145562
  }
145092
145563
  else {
145093
145564
  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)));
145565
+ tickSize = this.parseNumber(this.parsePrecision(this.safeString(response, 1))); // priceTickDecimalPlaces
145566
+ amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(response, 2))); // quantityTickDecimalPlaces
145567
+ minSize = this.safeNumber(response, 3); // quantityMinimum
145097
145568
  }
145098
145569
  const marketIdUpper = marketId.toUpperCase();
145099
145570
  const isPerp = (marketIdUpper.indexOf('PERP') >= 0);
@@ -145148,8 +145619,8 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
145148
145619
  'strike': undefined,
145149
145620
  'optionType': undefined,
145150
145621
  'precision': {
145151
- 'price': increment,
145152
- 'amount': tickSize,
145622
+ 'price': tickSize,
145623
+ 'amount': amountPrecision,
145153
145624
  },
145154
145625
  'limits': {
145155
145626
  'leverage': {
@@ -146223,7 +146694,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
146223
146694
  if (apiKey.indexOf('account') < 0) {
146224
146695
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError(this.id + ' sign() requires an account-key, master-keys are not-supported');
146225
146696
  }
146226
- const nonce = this.nonce();
146697
+ const nonce = this.nonce().toString();
146227
146698
  const request = this.extend({
146228
146699
  'request': url,
146229
146700
  'nonce': nonce,
@@ -149667,6 +150138,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
149667
150138
  'info': data,
149668
150139
  'symbol': market['symbol'],
149669
150140
  'type': undefined,
150141
+ 'marginMode': 'isolated',
149670
150142
  'amount': undefined,
149671
150143
  'total': undefined,
149672
150144
  'code': this.safeString(currencyInfo, 'code'),
@@ -152081,6 +152553,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
152081
152553
  'fetchLeverage': false,
152082
152554
  'fetchLeverageTiers': true,
152083
152555
  'fetchLiquidations': true,
152556
+ 'fetchMarginAdjustmentHistory': false,
152084
152557
  'fetchMarketLeverageTiers': true,
152085
152558
  'fetchMarkets': true,
152086
152559
  'fetchMarkOHLCV': true,
@@ -165280,6 +165753,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
165280
165753
  'info': data,
165281
165754
  'symbol': this.safeSymbol(undefined, market),
165282
165755
  'type': undefined,
165756
+ 'marginMode': 'isolated',
165283
165757
  'amount': undefined,
165284
165758
  'total': undefined,
165285
165759
  'code': this.safeString(market, 'settle'),
@@ -175208,6 +175682,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
175208
175682
  'fetchL3OrderBook': true,
175209
175683
  'fetchLedger': true,
175210
175684
  'fetchLeverageTiers': false,
175685
+ 'fetchMarginAdjustmentHistory': false,
175211
175686
  'fetchMarginMode': false,
175212
175687
  'fetchMarketLeverageTiers': false,
175213
175688
  'fetchMarkets': true,
@@ -179976,6 +180451,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
179976
180451
  'fetchL3OrderBook': true,
179977
180452
  'fetchLedger': true,
179978
180453
  'fetchLeverageTiers': false,
180454
+ 'fetchMarginAdjustmentHistory': false,
179979
180455
  'fetchMarginMode': false,
179980
180456
  'fetchMarketLeverageTiers': true,
179981
180457
  'fetchMarkets': true,
@@ -181522,14 +181998,18 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
181522
181998
  const crossMode = this.safeValue(info, 'crossMode');
181523
181999
  const mode = crossMode ? 'cross' : 'isolated';
181524
182000
  const marketId = this.safeString(market, 'symbol');
182001
+ const timestamp = this.safeInteger(info, 'currentTimestamp');
181525
182002
  return {
181526
182003
  'info': info,
181527
- 'direction': undefined,
181528
- 'mode': mode,
182004
+ 'symbol': this.safeSymbol(marketId, market),
182005
+ 'type': undefined,
182006
+ 'marginMode': mode,
181529
182007
  'amount': undefined,
182008
+ 'total': undefined,
181530
182009
  'code': this.safeCurrencyCode(currencyId),
181531
- 'symbol': this.safeSymbol(marketId, market),
181532
182010
  'status': undefined,
182011
+ 'timestamp': timestamp,
182012
+ 'datetime': this.iso8601(timestamp),
181533
182013
  };
181534
182014
  }
181535
182015
  async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -181670,6 +182150,32 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
181670
182150
  }
181671
182151
  return await this.fetchOrdersByStatus('done', symbol, since, limit, params);
181672
182152
  }
182153
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
182154
+ /**
182155
+ * @method
182156
+ * @name kucoinfutures#fetchOpenOrders
182157
+ * @description fetches information on multiple open orders made by the user
182158
+ * @see https://docs.kucoin.com/futures/#get-order-list
182159
+ * @see https://docs.kucoin.com/futures/#get-untriggered-stop-order-list
182160
+ * @param {string} symbol unified market symbol of the market orders were made in
182161
+ * @param {int} [since] the earliest time in ms to fetch orders for
182162
+ * @param {int} [limit] the maximum number of order structures to retrieve
182163
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
182164
+ * @param {int} [params.till] end time in ms
182165
+ * @param {string} [params.side] buy or sell
182166
+ * @param {string} [params.type] limit, or market
182167
+ * @param {boolean} [params.trigger] set to true to retrieve untriggered stop orders
182168
+ * @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)
182169
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
182170
+ */
182171
+ await this.loadMarkets();
182172
+ let paginate = false;
182173
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
182174
+ if (paginate) {
182175
+ return await this.fetchPaginatedCallDynamic('fetchOpenOrders', symbol, since, limit, params);
182176
+ }
182177
+ return await this.fetchOrdersByStatus('open', symbol, since, limit, params);
182178
+ }
181673
182179
  async fetchOrder(id = undefined, symbol = undefined, params = {}) {
181674
182180
  /**
181675
182181
  * @method
@@ -192656,6 +193162,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
192656
193162
  'fetchLeverage': true,
192657
193163
  'fetchLeverages': false,
192658
193164
  'fetchLeverageTiers': true,
193165
+ 'fetchMarginAdjustmentHistory': false,
192659
193166
  'fetchMarginMode': false,
192660
193167
  'fetchMarketLeverageTiers': undefined,
192661
193168
  'fetchMarkets': true,
@@ -206484,6 +206991,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
206484
206991
  'fetchLedgerEntry': undefined,
206485
206992
  'fetchLeverage': true,
206486
206993
  'fetchLeverageTiers': false,
206994
+ 'fetchMarginAdjustmentHistory': true,
206487
206995
  'fetchMarketLeverageTiers': true,
206488
206996
  'fetchMarkets': true,
206489
206997
  'fetchMarkOHLCV': true,
@@ -212863,9 +213371,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212863
213371
  // }
212864
213372
  //
212865
213373
  const data = this.safeList(response, 'data', []);
213374
+ const entry = this.safeDict(data, 0, {});
212866
213375
  const errorCode = this.safeString(response, 'code');
212867
- const item = this.safeDict(data, 0, {});
212868
- return this.extend(this.parseMarginModification(item, market), {
213376
+ return this.extend(this.parseMarginModification(entry, market), {
212869
213377
  'status': (errorCode === '0') ? 'ok' : 'failed',
212870
213378
  });
212871
213379
  }
@@ -212880,22 +213388,68 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212880
213388
  // "type": "reduce"
212881
213389
  // }
212882
213390
  //
212883
- const amountRaw = this.safeNumber(data, 'amt');
213391
+ // fetchMarginAdjustmentHistory
213392
+ //
213393
+ // {
213394
+ // bal: '67621.4325135010619812',
213395
+ // balChg: '-10.0000000000000000',
213396
+ // billId: '691293628710342659',
213397
+ // ccy: 'USDT',
213398
+ // clOrdId: '',
213399
+ // execType: '',
213400
+ // fee: '0',
213401
+ // fillFwdPx: '',
213402
+ // fillIdxPx: '',
213403
+ // fillMarkPx: '',
213404
+ // fillMarkVol: '',
213405
+ // fillPxUsd: '',
213406
+ // fillPxVol: '',
213407
+ // fillTime: '1711089244850',
213408
+ // from: '',
213409
+ // instId: 'XRP-USDT-SWAP',
213410
+ // instType: 'SWAP',
213411
+ // interest: '0',
213412
+ // mgnMode: 'isolated',
213413
+ // notes: '',
213414
+ // ordId: '',
213415
+ // pnl: '0',
213416
+ // posBal: '73.12',
213417
+ // posBalChg: '10.00',
213418
+ // px: '',
213419
+ // subType: '160',
213420
+ // sz: '10',
213421
+ // tag: '',
213422
+ // to: '',
213423
+ // tradeId: '0',
213424
+ // ts: '1711089244699',
213425
+ // type: '6'
213426
+ // }
213427
+ //
213428
+ const amountRaw = this.safeString2(data, 'amt', 'posBalChg');
212884
213429
  const typeRaw = this.safeString(data, 'type');
212885
- const type = (typeRaw === 'reduce') ? 'reduce' : 'add';
213430
+ let type = undefined;
213431
+ if (typeRaw === '6') {
213432
+ type = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringGt(amountRaw, '0') ? 'add' : 'reduce';
213433
+ }
213434
+ else {
213435
+ type = typeRaw;
213436
+ }
213437
+ const amount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(amountRaw);
212886
213438
  const marketId = this.safeString(data, 'instId');
212887
213439
  const responseMarket = this.safeMarket(marketId, market);
212888
213440
  const code = responseMarket['inverse'] ? responseMarket['base'] : responseMarket['quote'];
213441
+ const timestamp = this.safeInteger(data, 'ts');
212889
213442
  return {
212890
213443
  'info': data,
212891
213444
  'symbol': responseMarket['symbol'],
212892
213445
  'type': type,
212893
- 'amount': amountRaw,
212894
- 'total': undefined,
213446
+ 'marginMode': 'isolated',
213447
+ 'amount': this.parseNumber(amount),
212895
213448
  'code': code,
213449
+ 'total': undefined,
212896
213450
  'status': undefined,
212897
- 'timestamp': undefined,
212898
- 'datetime': undefined,
213451
+ 'timestamp': timestamp,
213452
+ 'datetime': this.iso8601(timestamp),
212899
213453
  };
212900
213454
  }
212901
213455
  async reduceMargin(symbol, amount, params = {}) {
@@ -213997,6 +214551,108 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213997
214551
  }
213998
214552
  return undefined;
213999
214553
  }
214554
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
214555
+ /**
214556
+ * @method
214557
+ * @name okx#fetchMarginAdjustmentHistory
214558
+ * @description fetches the history of margin added or reduced from contract isolated positions
214559
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-7-days
214560
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months
214561
+ * @param {string} [symbol] not used by okx fetchMarginAdjustmentHistory
214562
+ * @param {string} [type] "add" or "reduce"
214563
+ * @param {object} params extra parameters specific to the exchange api endpoint
214564
+ * @param {boolean} [params.auto] true if fetching auto margin increases
214565
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
214566
+ */
214567
+ await this.loadMarkets();
214568
+ const auto = this.safeBool(params, 'auto');
214569
+ if (type === undefined) {
214570
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory () requires a type argument');
214571
+ }
214572
+ const isAdd = type === 'add';
214573
+ let subType = isAdd ? '160' : '161';
214574
+ if (auto) {
214575
+ if (isAdd) {
214576
+ subType = '162';
214577
+ }
214578
+ else {
214579
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' cannot fetch margin adjustments for type ' + type);
214580
+ }
214581
+ }
214582
+ const request = {
214583
+ 'subType': subType,
214584
+ 'mgnMode': 'isolated',
214585
+ };
214586
+ const until = this.safeInteger(params, 'until');
214587
+ params = this.omit(params, 'until');
214588
+ if (since !== undefined) {
214589
+ request['startTime'] = since;
214590
+ }
214591
+ if (limit !== undefined) {
214592
+ request['limit'] = limit;
214593
+ }
214594
+ if (until !== undefined) {
214595
+ request['endTime'] = until;
214596
+ }
214597
+ let response = undefined;
214598
+ const now = this.milliseconds();
214599
+ const oneWeekAgo = now - 604800000;
214600
+ const threeMonthsAgo = now - 7776000000;
214601
+ if ((since === undefined) || (since > oneWeekAgo)) {
214602
+ response = await this.privateGetAccountBills(this.extend(request, params));
214603
+ }
214604
+ else if (since > threeMonthsAgo) {
214605
+ response = await this.privateGetAccountBillsArchive(this.extend(request, params));
214606
+ }
214607
+ else {
214608
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' fetchMarginAdjustmentHistory () cannot fetch margin adjustments older than 3 months');
214609
+ }
214610
+ //
214611
+ // {
214612
+ // code: '0',
214613
+ // data: [
214614
+ // {
214615
+ // bal: '67621.4325135010619812',
214616
+ // balChg: '-10.0000000000000000',
214617
+ // billId: '691293628710342659',
214618
+ // ccy: 'USDT',
214619
+ // clOrdId: '',
214620
+ // execType: '',
214621
+ // fee: '0',
214622
+ // fillFwdPx: '',
214623
+ // fillIdxPx: '',
214624
+ // fillMarkPx: '',
214625
+ // fillMarkVol: '',
214626
+ // fillPxUsd: '',
214627
+ // fillPxVol: '',
214628
+ // fillTime: '1711089244850',
214629
+ // from: '',
214630
+ // instId: 'XRP-USDT-SWAP',
214631
+ // instType: 'SWAP',
214632
+ // interest: '0',
214633
+ // mgnMode: 'isolated',
214634
+ // notes: '',
214635
+ // ordId: '',
214636
+ // pnl: '0',
214637
+ // posBal: '73.12',
214638
+ // posBalChg: '10.00',
214639
+ // px: '',
214640
+ // subType: '160',
214641
+ // sz: '10',
214642
+ // tag: '',
214643
+ // to: '',
214644
+ // tradeId: '0',
214645
+ // ts: '1711089244699',
214646
+ // type: '6'
214647
+ // }
214648
+ // ],
214649
+ // msg: ''
214650
+ // }
214651
+ //
214652
+ const data = this.safeList(response, 'data');
214653
+ const modifications = this.parseMarginModifications(data);
214654
+ return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
214655
+ }
214000
214656
  }
214001
214657
 
214002
214658
 
@@ -221945,6 +222601,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
221945
222601
  'info': data,
221946
222602
  'symbol': this.safeSymbol(undefined, market),
221947
222603
  'type': 'set',
222604
+ 'marginMode': 'isolated',
221948
222605
  'amount': undefined,
221949
222606
  'total': undefined,
221950
222607
  'code': market[codeCurrency],
@@ -296285,6 +296942,63 @@ const hash_to_ristretto255 = (msg, options) => {
296285
296942
  };
296286
296943
 
296287
296944
 
296945
+ /***/ }),
296946
+
296947
+ /***/ 2572:
296948
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
296949
+
296950
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
296951
+ /* harmony export */ lA: () => (/* binding */ P256)
296952
+ /* harmony export */ });
296953
+ /* unused harmony exports secp256r1, hashToCurve, encodeToCurve */
296954
+ /* harmony import */ var _shortw_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(77);
296955
+ /* harmony import */ var _noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1372);
296956
+ /* harmony import */ var _abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(111);
296957
+ /* harmony import */ var _abstract_weierstrass_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9270);
296958
+ /* harmony import */ var _abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4945);
296959
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
296960
+
296961
+
296962
+
296963
+
296964
+
296965
+ // NIST secp256r1 aka P256
296966
+ // https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256
296967
+ // Field over which we'll do calculations; 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n
296968
+ const Fp = (0,_abstract_modular_js__WEBPACK_IMPORTED_MODULE_0__.Fp)(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff'));
296969
+ const CURVE_A = Fp.create(BigInt('-3'));
296970
+ const CURVE_B = BigInt('0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b');
296971
+ const mapSWU = (0,_abstract_weierstrass_js__WEBPACK_IMPORTED_MODULE_1__/* .mapToCurveSimpleSWU */ .L4)(Fp, {
296972
+ A: CURVE_A,
296973
+ B: CURVE_B,
296974
+ Z: Fp.create(BigInt('-10')),
296975
+ });
296976
+ const P256 = (0,_shortw_utils_js__WEBPACK_IMPORTED_MODULE_2__/* .createCurve */ ._)({
296977
+ // Params: a, b
296978
+ a: CURVE_A,
296979
+ b: CURVE_B,
296980
+ Fp,
296981
+ // Curve order, total count of valid points in the field
296982
+ n: BigInt('0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551'),
296983
+ // Base point (x, y) aka generator point
296984
+ Gx: BigInt('0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'),
296985
+ Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'),
296986
+ h: BigInt(1),
296987
+ lowS: false,
296988
+ }, _noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__/* .sha256 */ .J);
296989
+ const secp256r1 = P256;
296990
+ const { hashToCurve, encodeToCurve } = _abstract_hash_to_curve_js__WEBPACK_IMPORTED_MODULE_4__/* .createHasher */ .V1(secp256r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
296991
+ DST: 'P256_XMD:SHA-256_SSWU_RO_',
296992
+ encodeDST: 'P256_XMD:SHA-256_SSWU_NU_',
296993
+ p: Fp.ORDER,
296994
+ m: 1,
296995
+ k: 128,
296996
+ expand: 'xmd',
296997
+ hash: _noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__/* .sha256 */ .J,
296998
+ });
296999
+
297000
+
297001
+
296288
297002
  /***/ }),
296289
297003
 
296290
297004
  /***/ 1339:
@@ -311563,6 +312277,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
311563
312277
  'fetchIndexOHLCV': false,
311564
312278
  'fetchLedger': true,
311565
312279
  'fetchLeverage': true,
312280
+ 'fetchMarginAdjustmentHistory': false,
311566
312281
  'fetchMarginMode': false,
311567
312282
  'fetchMarkets': true,
311568
312283
  'fetchMarkOHLCV': false,
@@ -324652,7 +325367,7 @@ SOFTWARE.
324652
325367
 
324653
325368
  //-----------------------------------------------------------------------------
324654
325369
  // this is updated by vss.js when building
324655
- const version = '4.2.89';
325370
+ const version = '4.2.90';
324656
325371
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
324657
325372
  //-----------------------------------------------------------------------------
324658
325373