ccxt 4.2.39 → 4.2.40

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 (47) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +923 -310
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ascendex.js +28 -24
  6. package/dist/cjs/src/base/Exchange.js +14 -14
  7. package/dist/cjs/src/binance.js +372 -146
  8. package/dist/cjs/src/bingx.js +250 -23
  9. package/dist/cjs/src/bitget.js +13 -2
  10. package/dist/cjs/src/bybit.js +3 -1
  11. package/dist/cjs/src/coinbase.js +8 -6
  12. package/dist/cjs/src/coinbasepro.js +1 -0
  13. package/dist/cjs/src/coinlist.js +9 -7
  14. package/dist/cjs/src/coinmetro.js +2 -1
  15. package/dist/cjs/src/krakenfutures.js +126 -2
  16. package/dist/cjs/src/mexc.js +43 -43
  17. package/dist/cjs/src/okx.js +9 -15
  18. package/dist/cjs/src/phemex.js +1 -0
  19. package/dist/cjs/src/pro/bitmart.js +38 -20
  20. package/dist/cjs/src/pro/bybit.js +5 -5
  21. package/js/ccxt.d.ts +1 -1
  22. package/js/ccxt.js +1 -1
  23. package/js/src/abstract/bingx.d.ts +4 -0
  24. package/js/src/abstract/coinbasepro.d.ts +1 -0
  25. package/js/src/ascendex.js +28 -24
  26. package/js/src/base/Exchange.d.ts +8 -8
  27. package/js/src/base/Exchange.js +14 -14
  28. package/js/src/binance.d.ts +1 -1
  29. package/js/src/binance.js +372 -146
  30. package/js/src/bingx.d.ts +1 -0
  31. package/js/src/bingx.js +250 -23
  32. package/js/src/bitget.js +13 -2
  33. package/js/src/bybit.js +3 -1
  34. package/js/src/coinbase.js +8 -6
  35. package/js/src/coinbasepro.js +1 -0
  36. package/js/src/coinlist.js +9 -7
  37. package/js/src/coinmetro.js +2 -1
  38. package/js/src/krakenfutures.d.ts +2 -0
  39. package/js/src/krakenfutures.js +126 -2
  40. package/js/src/mexc.js +43 -43
  41. package/js/src/okx.js +9 -15
  42. package/js/src/phemex.js +1 -0
  43. package/js/src/pro/bitmart.d.ts +2 -0
  44. package/js/src/pro/bitmart.js +38 -20
  45. package/js/src/pro/bybit.d.ts +1 -1
  46. package/js/src/pro/bybit.js +5 -5
  47. package/package.json +1 -1
@@ -3928,11 +3928,14 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
3928
3928
  'fillResponseFromRequest': true,
3929
3929
  },
3930
3930
  'networks': {
3931
- 'BSC': 'BEP20 (BSC)',
3931
+ 'BSC': 'BEP20 ' + '(BSC)',
3932
3932
  'ARB': 'arbitrum',
3933
3933
  'SOL': 'Solana',
3934
3934
  'AVAX': 'avalanche C chain',
3935
3935
  'OMNI': 'Omni',
3936
+ 'TRC': 'TRC20',
3937
+ 'TRX': 'TRC20',
3938
+ 'ERC': 'ERC20',
3936
3939
  },
3937
3940
  'networksById': {
3938
3941
  'BEP20 (BSC)': 'BSC',
@@ -3940,6 +3943,16 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
3940
3943
  'Solana': 'SOL',
3941
3944
  'avalanche C chain': 'AVAX',
3942
3945
  'Omni': 'OMNI',
3946
+ 'TRC20': 'TRC20',
3947
+ 'ERC20': 'ERC20',
3948
+ 'GO20': 'GO20',
3949
+ 'BEP2': 'BEP2',
3950
+ 'Bitcoin': 'BTC',
3951
+ 'Bitcoin ABC': 'BCH',
3952
+ 'Litecoin': 'LTC',
3953
+ 'Matic Network': 'MATIC',
3954
+ 'xDai': 'STAKE',
3955
+ 'Akash': 'AKT',
3943
3956
  },
3944
3957
  },
3945
3958
  'exceptions': {
@@ -6029,8 +6042,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
6029
6042
  const tag = this.safeString(depositAddress, tagId);
6030
6043
  this.checkAddress(address);
6031
6044
  const code = (currency === undefined) ? undefined : currency['code'];
6032
- const chainName = this.safeString(depositAddress, 'chainName');
6033
- const network = this.safeNetwork(chainName);
6045
+ const chainName = this.safeString(depositAddress, 'blockchain');
6046
+ const network = this.networkIdToCode(chainName, code);
6034
6047
  return {
6035
6048
  'currency': code,
6036
6049
  'address': address,
@@ -6040,20 +6053,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
6040
6053
  };
6041
6054
  }
6042
6055
  safeNetwork(networkId) {
6043
- const networksById = {
6044
- 'TRC20': 'TRC20',
6045
- 'ERC20': 'ERC20',
6046
- 'GO20': 'GO20',
6047
- 'BEP2': 'BEP2',
6048
- 'BEP20 (BSC)': 'BEP20',
6049
- 'Bitcoin': 'BTC',
6050
- 'Bitcoin ABC': 'BCH',
6051
- 'Litecoin': 'LTC',
6052
- 'Matic Network': 'MATIC',
6053
- 'Solana': 'SOL',
6054
- 'xDai': 'STAKE',
6055
- 'Akash': 'AKT',
6056
- };
6056
+ const networksById = this.safeDict(this.options, 'networksById');
6057
6057
  return this.safeString(networksById, networkId, networkId);
6058
6058
  }
6059
6059
  async fetchDepositAddress(code, params = {}) {
@@ -6061,16 +6061,20 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
6061
6061
  * @method
6062
6062
  * @name ascendex#fetchDepositAddress
6063
6063
  * @description fetch the deposit address for a currency associated with this account
6064
+ * @see https://ascendex.github.io/ascendex-pro-api/#query-deposit-addresses
6064
6065
  * @param {string} code unified currency code
6065
6066
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6067
+ * @param {string} [params.network] unified network code for deposit chain
6066
6068
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
6067
6069
  */
6068
6070
  await this.loadMarkets();
6069
6071
  const currency = this.currency(code);
6070
- const chainName = this.safeString(params, 'chainName');
6071
- params = this.omit(params, 'chainName');
6072
+ const networkCode = this.safeString2(params, 'network', 'chainName');
6073
+ const networkId = this.networkCodeToId(networkCode);
6074
+ params = this.omit(params, ['chainName']);
6072
6075
  const request = {
6073
6076
  'asset': currency['id'],
6077
+ 'blockchain': networkId,
6074
6078
  };
6075
6079
  const response = await this.v1PrivateGetWalletDepositAddress(this.extend(request, params));
6076
6080
  //
@@ -6106,22 +6110,22 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
6106
6110
  // }
6107
6111
  // }
6108
6112
  //
6109
- const data = this.safeValue(response, 'data', {});
6110
- const addresses = this.safeValue(data, 'address', []);
6113
+ const data = this.safeDict(response, 'data', {});
6114
+ const addresses = this.safeList(data, 'address', []);
6111
6115
  const numAddresses = addresses.length;
6112
6116
  let address = undefined;
6113
6117
  if (numAddresses > 1) {
6114
6118
  const addressesByChainName = this.indexBy(addresses, 'chainName');
6115
- if (chainName === undefined) {
6119
+ if (networkId === undefined) {
6116
6120
  const chainNames = Object.keys(addressesByChainName);
6117
6121
  const chains = chainNames.join(', ');
6118
6122
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchDepositAddress() returned more than one address, a chainName parameter is required, one of ' + chains);
6119
6123
  }
6120
- address = this.safeValue(addressesByChainName, chainName, {});
6124
+ address = this.safeDict(addressesByChainName, networkId, {});
6121
6125
  }
6122
6126
  else {
6123
6127
  // first address
6124
- address = this.safeValue(addresses, 0, {});
6128
+ address = this.safeDict(addresses, 0, {});
6125
6129
  }
6126
6130
  const result = this.parseDepositAddress(address, currency);
6127
6131
  return this.extend(result, {
@@ -10225,14 +10229,14 @@ class Exchange {
10225
10229
  }
10226
10230
  defaultNetworkCode(currencyCode) {
10227
10231
  let defaultNetworkCode = undefined;
10228
- const defaultNetworks = this.safeValue(this.options, 'defaultNetworks', {});
10232
+ const defaultNetworks = this.safeDict(this.options, 'defaultNetworks', {});
10229
10233
  if (currencyCode in defaultNetworks) {
10230
10234
  // if currency had set its network in "defaultNetworks", use it
10231
10235
  defaultNetworkCode = defaultNetworks[currencyCode];
10232
10236
  }
10233
10237
  else {
10234
10238
  // otherwise, try to use the global-scope 'defaultNetwork' value (even if that network is not supported by currency, it doesn't make any problem, this will be just used "at first" if currency supports this network at all)
10235
- const defaultNetwork = this.safeValue(this.options, 'defaultNetwork');
10239
+ const defaultNetwork = this.safeDict(this.options, 'defaultNetwork');
10236
10240
  if (defaultNetwork !== undefined) {
10237
10241
  defaultNetworkCode = defaultNetwork;
10238
10242
  }
@@ -10737,14 +10741,14 @@ class Exchange {
10737
10741
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchStatus() is not supported yet');
10738
10742
  }
10739
10743
  async fetchFundingFee(code, params = {}) {
10740
- const warnOnFetchFundingFee = this.safeValue(this.options, 'warnOnFetchFundingFee', true);
10744
+ const warnOnFetchFundingFee = this.safeBool(this.options, 'warnOnFetchFundingFee', true);
10741
10745
  if (warnOnFetchFundingFee) {
10742
10746
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchFundingFee() method is deprecated, it will be removed in July 2022, please, use fetchTransactionFee() or set exchange.options["warnOnFetchFundingFee"] = false to suppress this warning');
10743
10747
  }
10744
10748
  return await this.fetchTransactionFee(code, params);
10745
10749
  }
10746
10750
  async fetchFundingFees(codes = undefined, params = {}) {
10747
- const warnOnFetchFundingFees = this.safeValue(this.options, 'warnOnFetchFundingFees', true);
10751
+ const warnOnFetchFundingFees = this.safeBool(this.options, 'warnOnFetchFundingFees', true);
10748
10752
  if (warnOnFetchFundingFees) {
10749
10753
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchFundingFees() method is deprecated, it will be removed in July 2022. Please, use fetchTransactionFees() or set exchange.options["warnOnFetchFundingFees"] = false to suppress this warning');
10750
10754
  }
@@ -10795,7 +10799,7 @@ class Exchange {
10795
10799
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchIsolatedBorrowRate() is not supported yet');
10796
10800
  }
10797
10801
  const borrowRates = await this.fetchIsolatedBorrowRates(params);
10798
- const rate = this.safeValue(borrowRates, symbol);
10802
+ const rate = this.safeDict(borrowRates, symbol);
10799
10803
  if (rate === undefined) {
10800
10804
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError(this.id + ' fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ' + symbol);
10801
10805
  }
@@ -10856,7 +10860,7 @@ class Exchange {
10856
10860
  }
10857
10861
  handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
10858
10862
  const defaultType = this.safeString2(this.options, 'defaultType', 'type', 'spot');
10859
- const methodOptions = this.safeValue(this.options, methodName);
10863
+ const methodOptions = this.safeDict(this.options, methodName);
10860
10864
  let methodType = defaultType;
10861
10865
  if (methodOptions !== undefined) {
10862
10866
  if (typeof methodOptions === 'string') {
@@ -10892,7 +10896,7 @@ class Exchange {
10892
10896
  }
10893
10897
  // if it was not defined in market object
10894
10898
  if (subType === undefined) {
10895
- const values = this.handleOptionAndParams(undefined, methodName, 'subType', defaultValue); // no need to re-test params here
10899
+ const values = this.handleOptionAndParams({}, methodName, 'subType', defaultValue); // no need to re-test params here
10896
10900
  subType = values[0];
10897
10901
  }
10898
10902
  }
@@ -10948,7 +10952,7 @@ class Exchange {
10948
10952
  const market = this.market(symbol);
10949
10953
  symbol = market['symbol'];
10950
10954
  const tickers = await this.fetchTickers([symbol], params);
10951
- const ticker = this.safeValue(tickers, symbol);
10955
+ const ticker = this.safeDict(tickers, symbol);
10952
10956
  if (ticker === undefined) {
10953
10957
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NullResponse(this.id + ' fetchTickers() could not find a ticker for ' + symbol);
10954
10958
  }
@@ -10985,7 +10989,7 @@ class Exchange {
10985
10989
  return order['status'];
10986
10990
  }
10987
10991
  async fetchUnifiedOrder(order, params = {}) {
10988
- return await this.fetchOrder(this.safeValue(order, 'id'), this.safeValue(order, 'symbol'), params);
10992
+ return await this.fetchOrder(this.safeString(order, 'id'), this.safeString(order, 'symbol'), params);
10989
10993
  }
10990
10994
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
10991
10995
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrder() is not supported yet');
@@ -11255,7 +11259,7 @@ class Exchange {
11255
11259
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' cancelAllOrdersWs() is not supported yet');
11256
11260
  }
11257
11261
  async cancelUnifiedOrder(order, params = {}) {
11258
- return this.cancelOrder(this.safeValue(order, 'id'), this.safeValue(order, 'symbol'), params);
11262
+ return this.cancelOrder(this.safeString(order, 'id'), this.safeString(order, 'symbol'), params);
11259
11263
  }
11260
11264
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
11261
11265
  if (this.has['fetchOpenOrders'] && this.has['fetchClosedOrders']) {
@@ -11747,7 +11751,7 @@ class Exchange {
11747
11751
  return result;
11748
11752
  }
11749
11753
  isTriggerOrder(params) {
11750
- const isTrigger = this.safeValue2(params, 'trigger', 'stop');
11754
+ const isTrigger = this.safeBool2(params, 'trigger', 'stop');
11751
11755
  if (isTrigger) {
11752
11756
  params = this.omit(params, ['trigger', 'stop']);
11753
11757
  }
@@ -11763,7 +11767,7 @@ class Exchange {
11763
11767
  * @returns {boolean} true if a post only order, false otherwise
11764
11768
  */
11765
11769
  const timeInForce = this.safeStringUpper(params, 'timeInForce');
11766
- let postOnly = this.safeValue2(params, 'postOnly', 'post_only', false);
11770
+ let postOnly = this.safeBool2(params, 'postOnly', 'post_only', false);
11767
11771
  // we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
11768
11772
  const ioc = timeInForce === 'IOC';
11769
11773
  const fok = timeInForce === 'FOK';
@@ -11957,7 +11961,7 @@ class Exchange {
11957
11961
  * @param {string} account key for account name in this.options['accountsByType']
11958
11962
  * @returns the exchange specific account name or the isolated margin id for transfers
11959
11963
  */
11960
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
11964
+ const accountsByType = this.safeDict(this.options, 'accountsByType', {});
11961
11965
  const lowercaseAccount = account.toLowerCase();
11962
11966
  if (lowercaseAccount in accountsByType) {
11963
11967
  return accountsByType[lowercaseAccount];
@@ -12434,7 +12438,7 @@ class Exchange {
12434
12438
  return input;
12435
12439
  }
12436
12440
  handleUntilOption(key, request, params, multiplier = 1) {
12437
- const until = this.safeValue2(params, 'until', 'till');
12441
+ const until = this.safeInteger2(params, 'until', 'till');
12438
12442
  if (until !== undefined) {
12439
12443
  request[key] = this.parseToInt(until * multiplier);
12440
12444
  params = this.omit(params, ['until', 'till']);
@@ -20633,7 +20637,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20633
20637
  let minPrecision = undefined;
20634
20638
  let isWithdrawEnabled = true;
20635
20639
  let isDepositEnabled = true;
20636
- const networkList = this.safeValue(entry, 'networkList', []);
20640
+ const networkList = this.safeList(entry, 'networkList', []);
20637
20641
  const fees = {};
20638
20642
  let fee = undefined;
20639
20643
  for (let j = 0; j < networkList.length; j++) {
@@ -20641,12 +20645,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20641
20645
  const network = this.safeString(networkItem, 'network');
20642
20646
  // const name = this.safeString (networkItem, 'name');
20643
20647
  const withdrawFee = this.safeNumber(networkItem, 'withdrawFee');
20644
- const depositEnable = this.safeValue(networkItem, 'depositEnable');
20645
- const withdrawEnable = this.safeValue(networkItem, 'withdrawEnable');
20648
+ const depositEnable = this.safeBool(networkItem, 'depositEnable');
20649
+ const withdrawEnable = this.safeBool(networkItem, 'withdrawEnable');
20646
20650
  isDepositEnabled = isDepositEnabled || depositEnable;
20647
20651
  isWithdrawEnabled = isWithdrawEnabled || withdrawEnable;
20648
20652
  fees[network] = withdrawFee;
20649
- const isDefault = this.safeValue(networkItem, 'isDefault');
20653
+ const isDefault = this.safeBool(networkItem, 'isDefault');
20650
20654
  if (isDefault || (fee === undefined)) {
20651
20655
  fee = withdrawFee;
20652
20656
  }
@@ -20657,7 +20661,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20657
20661
  minPrecision = (minPrecision === undefined) ? precisionTick : _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMin(minPrecision, precisionTick);
20658
20662
  }
20659
20663
  }
20660
- const trading = this.safeValue(entry, 'trading');
20664
+ const trading = this.safeBool(entry, 'trading');
20661
20665
  const active = (isWithdrawEnabled && isDepositEnabled && trading);
20662
20666
  let maxDecimalPlaces = undefined;
20663
20667
  if (minPrecision !== undefined) {
@@ -20693,8 +20697,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20693
20697
  * @returns {object[]} an array of objects representing market data
20694
20698
  */
20695
20699
  const promisesRaw = [];
20696
- const rawFetchMarkets = this.safeValue(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']);
20697
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
20700
+ const rawFetchMarkets = this.safeList(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']);
20701
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
20698
20702
  const fetchMarkets = [];
20699
20703
  for (let i = 0; i < rawFetchMarkets.length; i++) {
20700
20704
  const type = rawFetchMarkets[i];
@@ -20972,7 +20976,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20972
20976
  }
20973
20977
  const settle = this.safeCurrencyCode(settleId);
20974
20978
  const spot = !contract;
20975
- const filters = this.safeValue(market, 'filters', []);
20979
+ const filters = this.safeList(market, 'filters', []);
20976
20980
  const filtersByType = this.indexBy(filters, 'filterType');
20977
20981
  const status = this.safeString2(market, 'status', 'contractStatus');
20978
20982
  let contractSize = undefined;
@@ -20995,11 +20999,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20995
20999
  linear = settle === quote;
20996
21000
  inverse = settle === base;
20997
21001
  const feesType = linear ? 'linear' : 'inverse';
20998
- fees = this.safeValue(this.fees, feesType, {});
21002
+ fees = this.safeDict(this.fees, feesType, {});
20999
21003
  }
21000
21004
  let active = (status === 'TRADING');
21001
21005
  if (spot) {
21002
- const permissions = this.safeValue(market, 'permissions', []);
21006
+ const permissions = this.safeList(market, 'permissions', []);
21003
21007
  for (let j = 0; j < permissions.length; j++) {
21004
21008
  if (permissions[j] === 'TRD_GRP_003') {
21005
21009
  active = false;
@@ -21077,7 +21081,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21077
21081
  'created': this.safeInteger(market, 'onboardDate'), // present in inverse & linear apis
21078
21082
  };
21079
21083
  if ('PRICE_FILTER' in filtersByType) {
21080
- const filter = this.safeValue(filtersByType, 'PRICE_FILTER', {});
21084
+ const filter = this.safeDict(filtersByType, 'PRICE_FILTER', {});
21081
21085
  // PRICE_FILTER reports zero values for maxPrice
21082
21086
  // since they updated filter types in November 2018
21083
21087
  // https://github.com/ccxt/ccxt/issues/4286
@@ -21089,7 +21093,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21089
21093
  entry['precision']['price'] = this.precisionFromString(filter['tickSize']);
21090
21094
  }
21091
21095
  if ('LOT_SIZE' in filtersByType) {
21092
- const filter = this.safeValue(filtersByType, 'LOT_SIZE', {});
21096
+ const filter = this.safeDict(filtersByType, 'LOT_SIZE', {});
21093
21097
  const stepSize = this.safeString(filter, 'stepSize');
21094
21098
  entry['precision']['amount'] = this.precisionFromString(stepSize);
21095
21099
  entry['limits']['amount'] = {
@@ -21098,14 +21102,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21098
21102
  };
21099
21103
  }
21100
21104
  if ('MARKET_LOT_SIZE' in filtersByType) {
21101
- const filter = this.safeValue(filtersByType, 'MARKET_LOT_SIZE', {});
21105
+ const filter = this.safeDict(filtersByType, 'MARKET_LOT_SIZE', {});
21102
21106
  entry['limits']['market'] = {
21103
21107
  'min': this.safeNumber(filter, 'minQty'),
21104
21108
  'max': this.safeNumber(filter, 'maxQty'),
21105
21109
  };
21106
21110
  }
21107
21111
  if (('MIN_NOTIONAL' in filtersByType) || ('NOTIONAL' in filtersByType)) { // notional added in 12/04/23 to spot testnet
21108
- const filter = this.safeValue2(filtersByType, 'MIN_NOTIONAL', 'NOTIONAL', {});
21112
+ const filter = this.safeDict2(filtersByType, 'MIN_NOTIONAL', 'NOTIONAL', {});
21109
21113
  entry['limits']['cost']['min'] = this.safeNumber2(filter, 'minNotional', 'notional');
21110
21114
  entry['limits']['cost']['max'] = this.safeNumber(filter, 'maxNotional');
21111
21115
  }
@@ -21799,7 +21803,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21799
21803
  }
21800
21804
  }
21801
21805
  if (Array.isArray(response)) {
21802
- const firstTicker = this.safeValue(response, 0, {});
21806
+ const firstTicker = this.safeDict(response, 0, {});
21803
21807
  return this.parseTicker(firstTicker, market);
21804
21808
  }
21805
21809
  return this.parseTicker(response, market);
@@ -23225,7 +23229,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23225
23229
  cost = this.safeString(order, 'cumBase', cost);
23226
23230
  let type = this.safeStringLower(order, 'type');
23227
23231
  const side = this.safeStringLower(order, 'side');
23228
- const fills = this.safeValue(order, 'fills', []);
23232
+ const fills = this.safeList(order, 'fills', []);
23229
23233
  let timeInForce = this.safeString(order, 'timeInForce');
23230
23234
  if (timeInForce === 'GTX') {
23231
23235
  // GTX means "Good Till Crossing" and is an equivalent way of saying Post Only
@@ -23258,7 +23262,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23258
23262
  'type': type,
23259
23263
  'timeInForce': timeInForce,
23260
23264
  'postOnly': postOnly,
23261
- 'reduceOnly': this.safeValue(order, 'reduceOnly'),
23265
+ 'reduceOnly': this.safeBool(order, 'reduceOnly'),
23262
23266
  'side': side,
23263
23267
  'price': price,
23264
23268
  'triggerPrice': stopPrice,
@@ -23292,7 +23296,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23292
23296
  const side = this.safeString(rawOrder, 'side');
23293
23297
  const amount = this.safeValue(rawOrder, 'amount');
23294
23298
  const price = this.safeValue(rawOrder, 'price');
23295
- const orderParams = this.safeValue(rawOrder, 'params', {});
23299
+ const orderParams = this.safeDict(rawOrder, 'params', {});
23296
23300
  const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
23297
23301
  ordersRequests.push(orderRequest);
23298
23302
  }
@@ -24684,11 +24688,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24684
24688
  // },
24685
24689
  // ]
24686
24690
  // }
24687
- const results = this.safeValue(response, 'userAssetDribblets', []);
24691
+ const results = this.safeList(response, 'userAssetDribblets', []);
24688
24692
  const rows = this.safeInteger(response, 'total', 0);
24689
24693
  const data = [];
24690
24694
  for (let i = 0; i < rows; i++) {
24691
- const logs = this.safeValue(results[i], 'userAssetDribbletDetails', []);
24695
+ const logs = this.safeList(results[i], 'userAssetDribbletDetails', []);
24692
24696
  for (let j = 0; j < logs.length; j++) {
24693
24697
  logs[j]['isDustTrade'] = true;
24694
24698
  data.push(logs[j]);
@@ -24795,7 +24799,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24795
24799
  let currency = undefined;
24796
24800
  let response = undefined;
24797
24801
  const request = {};
24798
- const legalMoney = this.safeValue(this.options, 'legalMoney', {});
24802
+ const legalMoney = this.safeDict(this.options, 'legalMoney', {});
24799
24803
  const fiatOnly = this.safeBool(params, 'fiat', false);
24800
24804
  params = this.omit(params, 'fiatOnly');
24801
24805
  const until = this.safeInteger(params, 'until');
@@ -24907,7 +24911,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24907
24911
  if (paginate) {
24908
24912
  return await this.fetchPaginatedCallDynamic('fetchWithdrawals', code, since, limit, params);
24909
24913
  }
24910
- const legalMoney = this.safeValue(this.options, 'legalMoney', {});
24914
+ const legalMoney = this.safeDict(this.options, 'legalMoney', {});
24911
24915
  const fiatOnly = this.safeBool(params, 'fiat', false);
24912
24916
  params = this.omit(params, 'fiatOnly');
24913
24917
  const request = {};
@@ -25051,7 +25055,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25051
25055
  'Refund Failed': 'failed',
25052
25056
  },
25053
25057
  };
25054
- const statuses = this.safeValue(statusesByType, type, {});
25058
+ const statuses = this.safeDict(statusesByType, type, {});
25055
25059
  return this.safeString(statuses, status, status);
25056
25060
  }
25057
25061
  parseTransaction(transaction, currency = undefined) {
@@ -25216,7 +25220,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25216
25220
  const type = this.safeString(transfer, 'type');
25217
25221
  let fromAccount = undefined;
25218
25222
  let toAccount = undefined;
25219
- const accountsById = this.safeValue(this.options, 'accountsById', {});
25223
+ const accountsById = this.safeDict(this.options, 'accountsById', {});
25220
25224
  if (type !== undefined) {
25221
25225
  const parts = type.split('_');
25222
25226
  fromAccount = this.safeValue(parts, 0);
@@ -25252,20 +25256,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25252
25256
  // }
25253
25257
  //
25254
25258
  const marketId = this.safeString(income, 'symbol');
25255
- const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
25256
- const amount = this.safeNumber(income, 'income');
25257
25259
  const currencyId = this.safeString(income, 'asset');
25258
- const code = this.safeCurrencyCode(currencyId);
25259
- const id = this.safeString(income, 'tranId');
25260
25260
  const timestamp = this.safeInteger(income, 'time');
25261
25261
  return {
25262
25262
  'info': income,
25263
- 'symbol': symbol,
25264
- 'code': code,
25263
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
25264
+ 'code': this.safeCurrencyCode(currencyId),
25265
25265
  'timestamp': timestamp,
25266
25266
  'datetime': this.iso8601(timestamp),
25267
- 'id': id,
25268
- 'amount': amount,
25267
+ 'id': this.safeString(income, 'tranId'),
25268
+ 'amount': this.safeNumber(income, 'income'),
25269
25269
  };
25270
25270
  }
25271
25271
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
@@ -25314,7 +25314,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25314
25314
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' transfer () requires params["symbol"] when toAccount is ' + toAccount);
25315
25315
  }
25316
25316
  }
25317
- const accountsById = this.safeValue(this.options, 'accountsById', {});
25317
+ const accountsById = this.safeDict(this.options, 'accountsById', {});
25318
25318
  const fromIsolated = !(fromId in accountsById);
25319
25319
  const toIsolated = !(toId in accountsById);
25320
25320
  if (fromIsolated && (market === undefined)) {
@@ -25404,7 +25404,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25404
25404
  const defaultTo = (fromAccount === 'future') ? 'spot' : 'future';
25405
25405
  const toAccount = this.safeString(params, 'toAccount', defaultTo);
25406
25406
  let type = this.safeString(params, 'type');
25407
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
25407
+ const accountsByType = this.safeDict(this.options, 'accountsByType', {});
25408
25408
  const fromId = this.safeString(accountsByType, fromAccount);
25409
25409
  const toId = this.safeString(accountsByType, toAccount);
25410
25410
  if (type === undefined) {
@@ -25448,7 +25448,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25448
25448
  // ]
25449
25449
  // }
25450
25450
  //
25451
- const rows = this.safeValue(response, 'rows', []);
25451
+ const rows = this.safeList(response, 'rows', []);
25452
25452
  return this.parseTransfers(rows, currency, since, limit);
25453
25453
  }
25454
25454
  async fetchDepositAddress(code, params = {}) {
@@ -25467,7 +25467,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25467
25467
  'coin': currency['id'],
25468
25468
  // 'network': 'ETH', // 'BSC', 'XMR', you can get network and isDefault in networkList in the response of sapiGetCapitalConfigDetail
25469
25469
  };
25470
- const networks = this.safeValue(this.options, 'networks', {});
25470
+ const networks = this.safeDict(this.options, 'networks', {});
25471
25471
  let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
25472
25472
  network = this.safeString(networks, network, network); // handle ERC20>ETH alias
25473
25473
  if (network !== undefined) {
@@ -25494,7 +25494,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25494
25494
  const url = this.safeString(response, 'url');
25495
25495
  let impliedNetwork = undefined;
25496
25496
  if (url !== undefined) {
25497
- const reverseNetworks = this.safeValue(this.options, 'reverseNetworks', {});
25497
+ const reverseNetworks = this.safeDict(this.options, 'reverseNetworks', {});
25498
25498
  const parts = url.split('/');
25499
25499
  let topLevel = this.safeString(parts, 2);
25500
25500
  if ((topLevel === 'blockchair.com') || (topLevel === 'viewblock.io')) {
@@ -25509,7 +25509,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25509
25509
  'TRX': { 'TRC20': 'TRX' },
25510
25510
  });
25511
25511
  if (code in impliedNetworks) {
25512
- const conversion = this.safeValue(impliedNetworks, code, {});
25512
+ const conversion = this.safeDict(impliedNetworks, code, {});
25513
25513
  impliedNetwork = this.safeString(conversion, impliedNetwork, impliedNetwork);
25514
25514
  }
25515
25515
  }
@@ -25625,7 +25625,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25625
25625
  const entry = response[i];
25626
25626
  const currencyId = this.safeString(entry, 'coin');
25627
25627
  const code = this.safeCurrencyCode(currencyId);
25628
- const networkList = this.safeValue(entry, 'networkList', []);
25628
+ const networkList = this.safeList(entry, 'networkList', []);
25629
25629
  withdrawFees[code] = {};
25630
25630
  for (let j = 0; j < networkList.length; j++) {
25631
25631
  const networkEntry = networkList[j];
@@ -25738,14 +25738,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25738
25738
  // ]
25739
25739
  // }
25740
25740
  //
25741
- const networkList = this.safeValue(fee, 'networkList', []);
25741
+ const networkList = this.safeList(fee, 'networkList', []);
25742
25742
  const result = this.depositWithdrawFee(fee);
25743
25743
  for (let j = 0; j < networkList.length; j++) {
25744
25744
  const networkEntry = networkList[j];
25745
25745
  const networkId = this.safeString(networkEntry, 'network');
25746
25746
  const networkCode = this.networkIdToCode(networkId);
25747
25747
  const withdrawFee = this.safeNumber(networkEntry, 'withdrawFee');
25748
- const isDefault = this.safeValue(networkEntry, 'isDefault');
25748
+ const isDefault = this.safeBool(networkEntry, 'isDefault');
25749
25749
  if (isDefault === true) {
25750
25750
  result['withdraw'] = {
25751
25751
  'fee': withdrawFee,
@@ -25793,7 +25793,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25793
25793
  if (tag !== undefined) {
25794
25794
  request['addressTag'] = tag;
25795
25795
  }
25796
- const networks = this.safeValue(this.options, 'networks', {});
25796
+ const networks = this.safeDict(this.options, 'networks', {});
25797
25797
  let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
25798
25798
  network = this.safeString(networks, network, network); // handle ERC20>ETH alias
25799
25799
  if (network !== undefined) {
@@ -25885,7 +25885,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25885
25885
  //
25886
25886
  let data = response;
25887
25887
  if (Array.isArray(data)) {
25888
- data = this.safeValue(data, 0, {});
25888
+ data = this.safeDict(data, 0, {});
25889
25889
  }
25890
25890
  return this.parseTradingFee(data);
25891
25891
  }
@@ -26299,8 +26299,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26299
26299
  };
26300
26300
  }
26301
26301
  parseAccountPositions(account) {
26302
- const positions = this.safeValue(account, 'positions');
26303
- const assets = this.safeValue(account, 'assets', []);
26302
+ const positions = this.safeList(account, 'positions');
26303
+ const assets = this.safeList(account, 'assets', []);
26304
26304
  const balances = {};
26305
26305
  for (let i = 0; i < assets.length; i++) {
26306
26306
  const entry = assets[i];
@@ -26319,13 +26319,17 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26319
26319
  const marketId = this.safeString(position, 'symbol');
26320
26320
  const market = this.safeMarket(marketId, undefined, undefined, 'contract');
26321
26321
  const code = market['linear'] ? market['quote'] : market['base'];
26322
- // sometimes not all the codes are correctly returned...
26323
- if (code in balances) {
26324
- const parsed = this.parseAccountPosition(this.extend(position, {
26325
- 'crossMargin': balances[code]['crossMargin'],
26326
- 'crossWalletBalance': balances[code]['crossWalletBalance'],
26327
- }), market);
26328
- result.push(parsed);
26322
+ const maintenanceMargin = this.safeString(position, 'maintMargin');
26323
+ // check for maintenance margin so empty positions are not returned
26324
+ if ((maintenanceMargin !== '0') && (maintenanceMargin !== '0.00000000')) {
26325
+ // sometimes not all the codes are correctly returned...
26326
+ if (code in balances) {
26327
+ const parsed = this.parseAccountPosition(this.extend(position, {
26328
+ 'crossMargin': balances[code]['crossMargin'],
26329
+ 'crossWalletBalance': balances[code]['crossWalletBalance'],
26330
+ }), market);
26331
+ result.push(parsed);
26332
+ }
26329
26333
  }
26330
26334
  }
26331
26335
  return result;
@@ -26333,6 +26337,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26333
26337
  parseAccountPosition(position, market = undefined) {
26334
26338
  //
26335
26339
  // usdm
26340
+ //
26336
26341
  // {
26337
26342
  // "symbol": "BTCBUSD",
26338
26343
  // "initialMargin": "0",
@@ -26353,6 +26358,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26353
26358
  // }
26354
26359
  //
26355
26360
  // coinm
26361
+ //
26356
26362
  // {
26357
26363
  // "symbol": "BTCUSD_210625",
26358
26364
  // "initialMargin": "0.00024393",
@@ -26371,6 +26377,46 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26371
26377
  // "crossWalletBalance": "34",
26372
26378
  // }
26373
26379
  //
26380
+ // linear portfolio margin
26381
+ //
26382
+ // {
26383
+ // "symbol": "CTSIUSDT",
26384
+ // "initialMargin": "0",
26385
+ // "maintMargin": "0",
26386
+ // "unrealizedProfit": "0.00000000",
26387
+ // "positionInitialMargin": "0",
26388
+ // "openOrderInitialMargin": "0",
26389
+ // "leverage": "20",
26390
+ // "entryPrice": "0.0",
26391
+ // "maxNotional": "25000",
26392
+ // "bidNotional": "0",
26393
+ // "askNotional": "0",
26394
+ // "positionSide": "SHORT",
26395
+ // "positionAmt": "0",
26396
+ // "updateTime": 0,
26397
+ // "notional": "0",
26398
+ // "breakEvenPrice": "0.0"
26399
+ // }
26400
+ //
26401
+ // inverse portoflio margin
26402
+ //
26403
+ // {
26404
+ // "symbol": "TRXUSD_PERP",
26405
+ // "initialMargin": "0",
26406
+ // "maintMargin": "0",
26407
+ // "unrealizedProfit": "0.00000000",
26408
+ // "positionInitialMargin": "0",
26409
+ // "openOrderInitialMargin": "0",
26410
+ // "leverage": "20",
26411
+ // "entryPrice": "0.00000000",
26412
+ // "positionSide": "SHORT",
26413
+ // "positionAmt": "0",
26414
+ // "maxQty": "5000000",
26415
+ // "updateTime": 0,
26416
+ // "notionalValue": "0",
26417
+ // "breakEvenPrice": "0.00000000"
26418
+ // }
26419
+ //
26374
26420
  const marketId = this.safeString(position, 'symbol');
26375
26421
  market = this.safeMarket(marketId, market, undefined, 'contract');
26376
26422
  const symbol = this.safeString(market, 'symbol');
@@ -26401,8 +26447,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26401
26447
  contractsStringAbs = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(contractsString, '0.5'), '1', 0);
26402
26448
  }
26403
26449
  const contracts = this.parseNumber(contractsStringAbs);
26404
- const leverageBrackets = this.safeValue(this.options, 'leverageBrackets', {});
26405
- const leverageBracket = this.safeValue(leverageBrackets, symbol, []);
26450
+ const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
26451
+ const leverageBracket = this.safeList(leverageBrackets, symbol, []);
26406
26452
  let maintenanceMarginPercentageString = undefined;
26407
26453
  for (let i = 0; i < leverageBracket.length; i++) {
26408
26454
  const bracket = leverageBracket[i];
@@ -26418,7 +26464,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26418
26464
  if (timestamp === 0) {
26419
26465
  timestamp = undefined;
26420
26466
  }
26421
- const isolated = this.safeValue(position, 'isolated');
26467
+ const isolated = this.safeBool(position, 'isolated');
26422
26468
  let marginMode = undefined;
26423
26469
  let collateralString = undefined;
26424
26470
  let walletBalance = undefined;
@@ -26571,11 +26617,45 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26571
26617
  // "isolatedWallet": "0.00268058"
26572
26618
  // }
26573
26619
  //
26620
+ // inverse portfolio margin
26621
+ //
26622
+ // {
26623
+ // "symbol": "ETHUSD_PERP",
26624
+ // "positionAmt": "1",
26625
+ // "entryPrice": "2422.400000007",
26626
+ // "markPrice": "2424.51267823",
26627
+ // "unRealizedProfit": "0.0000036",
26628
+ // "liquidationPrice": "293.57678898",
26629
+ // "leverage": "100",
26630
+ // "positionSide": "LONG",
26631
+ // "updateTime": 1707371941861,
26632
+ // "maxQty": "15",
26633
+ // "notionalValue": "0.00412454",
26634
+ // "breakEvenPrice": "2423.368960034"
26635
+ // }
26636
+ //
26637
+ // linear portfolio margin
26638
+ //
26639
+ // {
26640
+ // "symbol": "BTCUSDT",
26641
+ // "positionAmt": "0.01",
26642
+ // "entryPrice": "44525.0",
26643
+ // "markPrice": "45464.1735922",
26644
+ // "unRealizedProfit": "9.39173592",
26645
+ // "liquidationPrice": "38007.16308568",
26646
+ // "leverage": "100",
26647
+ // "positionSide": "LONG",
26648
+ // "updateTime": 1707371879042,
26649
+ // "maxNotionalValue": "500000.0",
26650
+ // "notional": "454.64173592",
26651
+ // "breakEvenPrice": "44542.81"
26652
+ // }
26653
+ //
26574
26654
  const marketId = this.safeString(position, 'symbol');
26575
26655
  market = this.safeMarket(marketId, market, undefined, 'contract');
26576
26656
  const symbol = this.safeString(market, 'symbol');
26577
- const leverageBrackets = this.safeValue(this.options, 'leverageBrackets', {});
26578
- const leverageBracket = this.safeValue(leverageBrackets, symbol, []);
26657
+ const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
26658
+ const leverageBracket = this.safeList(leverageBrackets, symbol, []);
26579
26659
  const notionalString = this.safeString2(position, 'notional', 'notionalValue');
26580
26660
  const notionalStringAbs = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(notionalString);
26581
26661
  let maintenanceMarginPercentageString = undefined;
@@ -26612,7 +26692,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26612
26692
  const linear = ('notional' in position);
26613
26693
  if (marginMode === 'cross') {
26614
26694
  // calculate collateral
26615
- const precision = this.safeValue(market, 'precision', {});
26695
+ const precision = this.safeDict(market, 'precision', {});
26616
26696
  if (linear) {
26617
26697
  // walletBalance = (liquidationPrice * (±1 + mmp) ± entryPrice) * contracts
26618
26698
  let onePlusMaintenanceMarginPercentageString = undefined;
@@ -26719,12 +26799,24 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26719
26799
  const query = this.omit(params, 'type');
26720
26800
  let subType = undefined;
26721
26801
  [subType, params] = this.handleSubTypeAndParams('loadLeverageBrackets', undefined, params, 'linear');
26802
+ let isPortfolioMargin = undefined;
26803
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'loadLeverageBrackets', 'papi', 'portfolioMargin', false);
26722
26804
  let response = undefined;
26723
26805
  if (this.isLinear(type, subType)) {
26724
- response = await this.fapiPrivateGetLeverageBracket(query);
26806
+ if (isPortfolioMargin) {
26807
+ response = await this.papiGetUmLeverageBracket(query);
26808
+ }
26809
+ else {
26810
+ response = await this.fapiPrivateGetLeverageBracket(query);
26811
+ }
26725
26812
  }
26726
26813
  else if (this.isInverse(type, subType)) {
26727
- response = await this.dapiPrivateV2GetLeverageBracket(query);
26814
+ if (isPortfolioMargin) {
26815
+ response = await this.papiGetCmLeverageBracket(query);
26816
+ }
26817
+ else {
26818
+ response = await this.dapiPrivateV2GetLeverageBracket(query);
26819
+ }
26728
26820
  }
26729
26821
  else {
26730
26822
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' loadLeverageBrackets() supports linear and inverse contracts only');
@@ -26734,7 +26826,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26734
26826
  const entry = response[i];
26735
26827
  const marketId = this.safeString(entry, 'symbol');
26736
26828
  const symbol = this.safeSymbol(marketId, undefined, undefined, 'contract');
26737
- const brackets = this.safeValue(entry, 'brackets', []);
26829
+ const brackets = this.safeList(entry, 'brackets', []);
26738
26830
  const result = [];
26739
26831
  for (let j = 0; j < brackets.length; j++) {
26740
26832
  const bracket = brackets[j];
@@ -26754,8 +26846,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26754
26846
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
26755
26847
  * @see https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-user_data
26756
26848
  * @see https://binance-docs.github.io/apidocs/delivery/en/#notional-bracket-for-symbol-user_data
26849
+ * @see https://binance-docs.github.io/apidocs/pm/en/#um-notional-and-leverage-brackets-user_data
26850
+ * @see https://binance-docs.github.io/apidocs/pm/en/#cm-notional-and-leverage-brackets-user_data
26757
26851
  * @param {string[]|undefined} symbols list of unified market symbols
26758
26852
  * @param {object} [params] extra parameters specific to the exchange API endpoint
26853
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the leverage tiers for a portfolio margin account
26759
26854
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
26760
26855
  */
26761
26856
  await this.loadMarkets();
@@ -26763,12 +26858,24 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26763
26858
  [type, params] = this.handleMarketTypeAndParams('fetchLeverageTiers', undefined, params);
26764
26859
  let subType = undefined;
26765
26860
  [subType, params] = this.handleSubTypeAndParams('fetchLeverageTiers', undefined, params, 'linear');
26861
+ let isPortfolioMargin = undefined;
26862
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverageTiers', 'papi', 'portfolioMargin', false);
26766
26863
  let response = undefined;
26767
26864
  if (this.isLinear(type, subType)) {
26768
- response = await this.fapiPrivateGetLeverageBracket(params);
26865
+ if (isPortfolioMargin) {
26866
+ response = await this.papiGetUmLeverageBracket(params);
26867
+ }
26868
+ else {
26869
+ response = await this.fapiPrivateGetLeverageBracket(params);
26870
+ }
26769
26871
  }
26770
26872
  else if (this.isInverse(type, subType)) {
26771
- response = await this.dapiPrivateV2GetLeverageBracket(params);
26873
+ if (isPortfolioMargin) {
26874
+ response = await this.papiGetCmLeverageBracket(params);
26875
+ }
26876
+ else {
26877
+ response = await this.dapiPrivateV2GetLeverageBracket(params);
26878
+ }
26772
26879
  }
26773
26880
  else {
26774
26881
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverageTiers() supports linear and inverse contracts only');
@@ -26838,7 +26945,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26838
26945
  //
26839
26946
  const marketId = this.safeString(info, 'symbol');
26840
26947
  market = this.safeMarket(marketId, market, undefined, 'contract');
26841
- const brackets = this.safeValue(info, 'brackets', []);
26948
+ const brackets = this.safeList(info, 'brackets', []);
26842
26949
  const tiers = [];
26843
26950
  for (let j = 0; j < brackets.length; j++) {
26844
26951
  const bracket = brackets[j];
@@ -27053,8 +27160,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27053
27160
  * @description fetch account positions
27054
27161
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
27055
27162
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
27163
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
27164
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
27056
27165
  * @param {string[]|undefined} symbols list of unified market symbols
27057
27166
  * @param {object} [params] extra parameters specific to the exchange API endpoint
27167
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
27058
27168
  * @returns {object} data on account positions
27059
27169
  */
27060
27170
  if (symbols !== undefined) {
@@ -27066,15 +27176,27 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27066
27176
  await this.loadLeverageBrackets(false, params);
27067
27177
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
27068
27178
  const type = this.safeString(params, 'type', defaultType);
27069
- let query = this.omit(params, 'type');
27179
+ params = this.omit(params, 'type');
27070
27180
  let subType = undefined;
27071
- [subType, query] = this.handleSubTypeAndParams('fetchAccountPositions', undefined, params, 'linear');
27181
+ [subType, params] = this.handleSubTypeAndParams('fetchAccountPositions', undefined, params, 'linear');
27182
+ let isPortfolioMargin = undefined;
27183
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchAccountPositions', 'papi', 'portfolioMargin', false);
27072
27184
  let response = undefined;
27073
27185
  if (this.isLinear(type, subType)) {
27074
- response = await this.fapiPrivateV2GetAccount(query);
27186
+ if (isPortfolioMargin) {
27187
+ response = await this.papiGetUmAccount(params);
27188
+ }
27189
+ else {
27190
+ response = await this.fapiPrivateV2GetAccount(params);
27191
+ }
27075
27192
  }
27076
27193
  else if (this.isInverse(type, subType)) {
27077
- response = await this.dapiPrivateGetAccount(query);
27194
+ if (isPortfolioMargin) {
27195
+ response = await this.papiGetCmAccount(params);
27196
+ }
27197
+ else {
27198
+ response = await this.dapiPrivateGetAccount(params);
27199
+ }
27078
27200
  }
27079
27201
  else {
27080
27202
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
@@ -27091,8 +27213,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27091
27213
  * @description fetch positions risk
27092
27214
  * @see https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
27093
27215
  * @see https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
27216
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-um-position-information-user_data
27217
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-cm-position-information-user_data
27094
27218
  * @param {string[]|undefined} symbols list of unified market symbols
27095
27219
  * @param {object} [params] extra parameters specific to the exchange API endpoint
27220
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
27096
27221
  * @returns {object} data on the positions risk
27097
27222
  */
27098
27223
  if (symbols !== undefined) {
@@ -27108,71 +27233,124 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27108
27233
  const type = this.safeString(params, 'type', defaultType);
27109
27234
  let subType = undefined;
27110
27235
  [subType, params] = this.handleSubTypeAndParams('fetchPositionsRisk', undefined, params, 'linear');
27236
+ let isPortfolioMargin = undefined;
27237
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchPositionsRisk', 'papi', 'portfolioMargin', false);
27111
27238
  params = this.omit(params, 'type');
27112
27239
  let response = undefined;
27113
27240
  if (this.isLinear(type, subType)) {
27114
- response = await this.fapiPrivateV2GetPositionRisk(this.extend(request, params));
27115
- // ### Response examples ###
27116
- //
27117
- // For One-way position mode:
27118
- // [
27119
- // {
27120
- // "entryPrice": "0.00000",
27121
- // "marginType": "isolated",
27122
- // "isAutoAddMargin": "false",
27123
- // "isolatedMargin": "0.00000000",
27124
- // "leverage": "10",
27125
- // "liquidationPrice": "0",
27126
- // "markPrice": "6679.50671178",
27127
- // "maxNotionalValue": "20000000",
27128
- // "positionAmt": "0.000",
27129
- // "symbol": "BTCUSDT",
27130
- // "unRealizedProfit": "0.00000000",
27131
- // "positionSide": "BOTH",
27132
- // "updateTime": 0
27133
- // }
27134
- // ]
27135
- //
27136
- // For Hedge position mode:
27137
- // [
27138
- // {
27139
- // "entryPrice": "6563.66500",
27140
- // "marginType": "isolated",
27141
- // "isAutoAddMargin": "false",
27142
- // "isolatedMargin": "15517.54150468",
27143
- // "leverage": "10",
27144
- // "liquidationPrice": "5930.78",
27145
- // "markPrice": "6679.50671178",
27146
- // "maxNotionalValue": "20000000",
27147
- // "positionAmt": "20.000",
27148
- // "symbol": "BTCUSDT",
27149
- // "unRealizedProfit": "2316.83423560"
27150
- // "positionSide": "LONG",
27151
- // "updateTime": 1625474304765
27152
- // },
27153
- // {
27154
- // "entryPrice": "0.00000",
27155
- // "marginType": "isolated",
27156
- // "isAutoAddMargin": "false",
27157
- // "isolatedMargin": "5413.95799991",
27158
- // "leverage": "10",
27159
- // "liquidationPrice": "7189.95",
27160
- // "markPrice": "6679.50671178",
27161
- // "maxNotionalValue": "20000000",
27162
- // "positionAmt": "-10.000",
27163
- // "symbol": "BTCUSDT",
27164
- // "unRealizedProfit": "-1156.46711780",
27165
- // "positionSide": "SHORT",
27166
- // "updateTime": 0
27167
- // }
27168
- // ]
27241
+ if (isPortfolioMargin) {
27242
+ response = await this.papiGetUmPositionRisk(this.extend(request, params));
27243
+ }
27244
+ else {
27245
+ response = await this.fapiPrivateV2GetPositionRisk(this.extend(request, params));
27246
+ }
27169
27247
  }
27170
27248
  else if (this.isInverse(type, subType)) {
27171
- response = await this.dapiPrivateGetPositionRisk(this.extend(request, params));
27249
+ if (isPortfolioMargin) {
27250
+ response = await this.papiGetCmPositionRisk(this.extend(request, params));
27251
+ }
27252
+ else {
27253
+ response = await this.dapiPrivateGetPositionRisk(this.extend(request, params));
27254
+ }
27172
27255
  }
27173
27256
  else {
27174
27257
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositionsRisk() supports linear and inverse contracts only');
27175
27258
  }
27259
+ // ### Response examples ###
27260
+ //
27261
+ // For One-way position mode:
27262
+ //
27263
+ // [
27264
+ // {
27265
+ // "entryPrice": "0.00000",
27266
+ // "marginType": "isolated",
27267
+ // "isAutoAddMargin": "false",
27268
+ // "isolatedMargin": "0.00000000",
27269
+ // "leverage": "10",
27270
+ // "liquidationPrice": "0",
27271
+ // "markPrice": "6679.50671178",
27272
+ // "maxNotionalValue": "20000000",
27273
+ // "positionAmt": "0.000",
27274
+ // "symbol": "BTCUSDT",
27275
+ // "unRealizedProfit": "0.00000000",
27276
+ // "positionSide": "BOTH",
27277
+ // "updateTime": 0
27278
+ // }
27279
+ // ]
27280
+ //
27281
+ // For Hedge position mode:
27282
+ //
27283
+ // [
27284
+ // {
27285
+ // "entryPrice": "6563.66500",
27286
+ // "marginType": "isolated",
27287
+ // "isAutoAddMargin": "false",
27288
+ // "isolatedMargin": "15517.54150468",
27289
+ // "leverage": "10",
27290
+ // "liquidationPrice": "5930.78",
27291
+ // "markPrice": "6679.50671178",
27292
+ // "maxNotionalValue": "20000000",
27293
+ // "positionAmt": "20.000",
27294
+ // "symbol": "BTCUSDT",
27295
+ // "unRealizedProfit": "2316.83423560"
27296
+ // "positionSide": "LONG",
27297
+ // "updateTime": 1625474304765
27298
+ // },
27299
+ // {
27300
+ // "entryPrice": "0.00000",
27301
+ // "marginType": "isolated",
27302
+ // "isAutoAddMargin": "false",
27303
+ // "isolatedMargin": "5413.95799991",
27304
+ // "leverage": "10",
27305
+ // "liquidationPrice": "7189.95",
27306
+ // "markPrice": "6679.50671178",
27307
+ // "maxNotionalValue": "20000000",
27308
+ // "positionAmt": "-10.000",
27309
+ // "symbol": "BTCUSDT",
27310
+ // "unRealizedProfit": "-1156.46711780",
27311
+ // "positionSide": "SHORT",
27312
+ // "updateTime": 0
27313
+ // }
27314
+ // ]
27315
+ //
27316
+ // inverse portfolio margin:
27317
+ //
27318
+ // [
27319
+ // {
27320
+ // "symbol": "ETHUSD_PERP",
27321
+ // "positionAmt": "1",
27322
+ // "entryPrice": "2422.400000007",
27323
+ // "markPrice": "2424.51267823",
27324
+ // "unRealizedProfit": "0.0000036",
27325
+ // "liquidationPrice": "293.57678898",
27326
+ // "leverage": "100",
27327
+ // "positionSide": "LONG",
27328
+ // "updateTime": 1707371941861,
27329
+ // "maxQty": "15",
27330
+ // "notionalValue": "0.00412454",
27331
+ // "breakEvenPrice": "2423.368960034"
27332
+ // }
27333
+ // ]
27334
+ //
27335
+ // linear portfolio margin:
27336
+ //
27337
+ // [
27338
+ // {
27339
+ // "symbol": "BTCUSDT",
27340
+ // "positionAmt": "0.01",
27341
+ // "entryPrice": "44525.0",
27342
+ // "markPrice": "45464.1735922",
27343
+ // "unRealizedProfit": "9.39173592",
27344
+ // "liquidationPrice": "38007.16308568",
27345
+ // "leverage": "100",
27346
+ // "positionSide": "LONG",
27347
+ // "updateTime": 1707371879042,
27348
+ // "maxNotionalValue": "500000.0",
27349
+ // "notional": "454.64173592",
27350
+ // "breakEvenPrice": "44542.81"
27351
+ // }
27352
+ // ]
27353
+ //
27176
27354
  const result = [];
27177
27355
  for (let i = 0; i < response.length; i++) {
27178
27356
  const parsed = this.parsePositionRisk(response[i]);
@@ -27188,15 +27366,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27188
27366
  * @description fetch the history of funding payments paid and received on this account
27189
27367
  * @see https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data
27190
27368
  * @see https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data
27369
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-income-history-user_data
27370
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-income-history-user_data
27191
27371
  * @param {string} symbol unified market symbol
27192
27372
  * @param {int} [since] the earliest time in ms to fetch funding history for
27193
27373
  * @param {int} [limit] the maximum number of funding history structures to retrieve
27194
27374
  * @param {object} [params] extra parameters specific to the exchange API endpoint
27375
+ * @param {int} [params.until] timestamp in ms of the latest funding history entry
27376
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the funding history for a portfolio margin account
27195
27377
  * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
27196
27378
  */
27197
27379
  await this.loadMarkets();
27198
27380
  let market = undefined;
27199
- const request = {
27381
+ let request = {
27200
27382
  'incomeType': 'FUNDING_FEE', // "TRANSFER","WELCOME_BONUS", "REALIZED_PNL","FUNDING_FEE", "COMMISSION" and "INSURANCE_CLEAR"
27201
27383
  };
27202
27384
  if (symbol !== undefined) {
@@ -27208,6 +27390,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27208
27390
  }
27209
27391
  let subType = undefined;
27210
27392
  [subType, params] = this.handleSubTypeAndParams('fetchFundingHistory', market, params, 'linear');
27393
+ let isPortfolioMargin = undefined;
27394
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchFundingHistory', 'papi', 'portfolioMargin', false);
27395
+ [request, params] = this.handleUntilOption('endTime', request, params);
27211
27396
  if (since !== undefined) {
27212
27397
  request['startTime'] = since;
27213
27398
  }
@@ -27219,10 +27404,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27219
27404
  params = this.omit(params, 'type');
27220
27405
  let response = undefined;
27221
27406
  if (this.isLinear(type, subType)) {
27222
- response = await this.fapiPrivateGetIncome(this.extend(request, params));
27407
+ if (isPortfolioMargin) {
27408
+ response = await this.papiGetUmIncome(this.extend(request, params));
27409
+ }
27410
+ else {
27411
+ response = await this.fapiPrivateGetIncome(this.extend(request, params));
27412
+ }
27223
27413
  }
27224
27414
  else if (this.isInverse(type, subType)) {
27225
- response = await this.dapiPrivateGetIncome(this.extend(request, params));
27415
+ if (isPortfolioMargin) {
27416
+ response = await this.papiGetCmIncome(this.extend(request, params));
27417
+ }
27418
+ else {
27419
+ response = await this.dapiPrivateGetIncome(this.extend(request, params));
27420
+ }
27226
27421
  }
27227
27422
  else {
27228
27423
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingHistory() supports linear and inverse contracts only');
@@ -27597,12 +27792,15 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27597
27792
  * @see https://binance-docs.github.io/apidocs/voptions/en/#account-funding-flow-user_data
27598
27793
  * @see https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data
27599
27794
  * @see https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data
27795
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-income-history-user_data
27796
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-income-history-user_data
27600
27797
  * @param {string} code unified currency code
27601
27798
  * @param {int} [since] timestamp in ms of the earliest ledger entry
27602
27799
  * @param {int} [limit] max number of ledger entrys to return
27603
27800
  * @param {object} [params] extra parameters specific to the exchange API endpoint
27604
27801
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
27605
- * @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)
27802
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
27803
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the ledger for a portfolio margin account
27606
27804
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
27607
27805
  */
27608
27806
  await this.loadMarkets();
@@ -27631,6 +27829,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27631
27829
  params = this.omit(params, 'until');
27632
27830
  request['endTime'] = until;
27633
27831
  }
27832
+ let isPortfolioMargin = undefined;
27833
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLedger', 'papi', 'portfolioMargin', false);
27634
27834
  let response = undefined;
27635
27835
  if (type === 'option') {
27636
27836
  this.checkRequiredArgument('fetchLedger', code, 'code');
@@ -27638,10 +27838,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27638
27838
  response = await this.eapiPrivateGetBill(this.extend(request, params));
27639
27839
  }
27640
27840
  else if (this.isLinear(type, subType)) {
27641
- response = await this.fapiPrivateGetIncome(this.extend(request, params));
27841
+ if (isPortfolioMargin) {
27842
+ response = await this.papiGetUmIncome(this.extend(request, params));
27843
+ }
27844
+ else {
27845
+ response = await this.fapiPrivateGetIncome(this.extend(request, params));
27846
+ }
27642
27847
  }
27643
27848
  else if (this.isInverse(type, subType)) {
27644
- response = await this.dapiPrivateGetIncome(this.extend(request, params));
27849
+ if (isPortfolioMargin) {
27850
+ response = await this.papiGetCmIncome(this.extend(request, params));
27851
+ }
27852
+ else {
27853
+ response = await this.dapiPrivateGetIncome(this.extend(request, params));
27854
+ }
27645
27855
  }
27646
27856
  else {
27647
27857
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLedger() supports contract wallets only');
@@ -27659,7 +27869,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27659
27869
  // }
27660
27870
  // ]
27661
27871
  //
27662
- // futures (fapi, dapi)
27872
+ // futures (fapi, dapi, papi)
27663
27873
  //
27664
27874
  // [
27665
27875
  // {
@@ -27688,7 +27898,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27688
27898
  // "createDate": 1676621042489
27689
27899
  // }
27690
27900
  //
27691
- // futures (fapi, dapi)
27901
+ // futures (fapi, dapi, papi)
27692
27902
  //
27693
27903
  // {
27694
27904
  // "symbol": "",
@@ -27797,7 +28007,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27797
28007
  const isSpotOrMargin = (api.indexOf('sapi') > -1 || api === 'private');
27798
28008
  const marketType = isSpotOrMargin ? 'spot' : 'future';
27799
28009
  const defaultId = (!isSpotOrMargin) ? 'x-xcKtGhcu' : 'x-R4BD3S82';
27800
- const broker = this.safeValue(this.options, 'broker', {});
28010
+ const broker = this.safeDict(this.options, 'broker', {});
27801
28011
  const brokerId = this.safeString(broker, marketType, defaultId);
27802
28012
  params['newClientOrderId'] = brokerId + this.uuid22();
27803
28013
  }
@@ -27825,8 +28035,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27825
28035
  }
27826
28036
  else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path.indexOf('staking') >= 0)) {
27827
28037
  if ((method === 'DELETE') && (path === 'batchOrders')) {
27828
- const orderidlist = this.safeValue(extendedParams, 'orderidlist', []);
27829
- const origclientorderidlist = this.safeValue(extendedParams, 'origclientorderidlist', []);
28038
+ const orderidlist = this.safeList(extendedParams, 'orderidlist', []);
28039
+ const origclientorderidlist = this.safeList(extendedParams, 'origclientorderidlist', []);
27830
28040
  extendedParams = this.omit(extendedParams, ['orderidlist', 'origclientorderidlist']);
27831
28041
  query = this.rawencode(extendedParams);
27832
28042
  const orderidlistLength = orderidlist.length;
@@ -27895,8 +28105,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27895
28105
  marketType = 'portfoliomargin';
27896
28106
  }
27897
28107
  if (marketType !== undefined) {
27898
- const exceptionsForMarketType = this.safeValue(this.exceptions, marketType, {});
27899
- return this.safeValue(exceptionsForMarketType, exactOrBroad, {});
28108
+ const exceptionsForMarketType = this.safeDict(this.exceptions, marketType, {});
28109
+ return this.safeDict(exceptionsForMarketType, exactOrBroad, {});
27900
28110
  }
27901
28111
  return {};
27902
28112
  }
@@ -28130,7 +28340,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28130
28340
  // },
28131
28341
  // ]
28132
28342
  //
28133
- const rate = this.safeValue(response, 0);
28343
+ const rate = this.safeDict(response, 0);
28134
28344
  return this.parseBorrowRate(rate);
28135
28345
  }
28136
28346
  async fetchBorrowRateHistory(code, since = undefined, limit = undefined, params = {}) {
@@ -28234,7 +28444,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28234
28444
  // "success": true
28235
28445
  // }
28236
28446
  //
28237
- const data = this.safeValue(response, 'data');
28447
+ const data = this.safeDict(response, 'data');
28238
28448
  const giftcardCode = this.safeString(data, 'code');
28239
28449
  const id = this.safeString(data, 'referenceNo');
28240
28450
  return {
@@ -28343,7 +28553,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28343
28553
  // "total": 1
28344
28554
  // }
28345
28555
  //
28346
- const rows = this.safeValue(response, 'rows');
28556
+ const rows = this.safeList(response, 'rows');
28347
28557
  const interest = this.parseBorrowInterests(rows, market);
28348
28558
  return this.filterByCurrencySinceLimit(interest, code, since, limit);
28349
28559
  }
@@ -28370,9 +28580,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28370
28580
  * @name binance#repayCrossMargin
28371
28581
  * @description repay borrowed margin and interest
28372
28582
  * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-repay-margin
28583
+ * @see https://binance-docs.github.io/apidocs/pm/en/#margin-account-repay-margin
28373
28584
  * @param {string} code unified currency code of the currency to repay
28374
28585
  * @param {float} amount the amount to repay
28375
28586
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28587
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to repay margin in a portfolio margin account
28376
28588
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
28377
28589
  */
28378
28590
  await this.loadMarkets();
@@ -28380,10 +28592,18 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28380
28592
  const request = {
28381
28593
  'asset': currency['id'],
28382
28594
  'amount': this.currencyToPrecision(code, amount),
28383
- 'isIsolated': 'FALSE',
28384
- 'type': 'REPAY',
28385
28595
  };
28386
- const response = await this.sapiPostMarginBorrowRepay(this.extend(request, params));
28596
+ let response = undefined;
28597
+ let isPortfolioMargin = undefined;
28598
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'repayCrossMargin', 'papi', 'portfolioMargin', false);
28599
+ if (isPortfolioMargin) {
28600
+ response = await this.papiPostRepayLoan(this.extend(request, params));
28601
+ }
28602
+ else {
28603
+ request['isIsolated'] = 'FALSE';
28604
+ request['type'] = 'REPAY';
28605
+ response = await this.sapiPostMarginBorrowRepay(this.extend(request, params));
28606
+ }
28387
28607
  //
28388
28608
  // {
28389
28609
  // "tranId": 108988250265,
@@ -28429,9 +28649,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28429
28649
  * @name binance#borrowCrossMargin
28430
28650
  * @description create a loan to borrow margin
28431
28651
  * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-repay-margin
28652
+ * @see https://binance-docs.github.io/apidocs/pm/en/#margin-account-borrow-margin
28432
28653
  * @param {string} code unified currency code of the currency to borrow
28433
28654
  * @param {float} amount the amount to borrow
28434
28655
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28656
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to borrow margin in a portfolio margin account
28435
28657
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
28436
28658
  */
28437
28659
  await this.loadMarkets();
@@ -28439,10 +28661,18 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28439
28661
  const request = {
28440
28662
  'asset': currency['id'],
28441
28663
  'amount': this.currencyToPrecision(code, amount),
28442
- 'isIsolated': 'FALSE',
28443
- 'type': 'BORROW',
28444
28664
  };
28445
- const response = await this.sapiPostMarginBorrowRepay(this.extend(request, params));
28665
+ let response = undefined;
28666
+ let isPortfolioMargin = undefined;
28667
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'borrowCrossMargin', 'papi', 'portfolioMargin', false);
28668
+ if (isPortfolioMargin) {
28669
+ response = await this.papiPostMarginLoan(this.extend(request, params));
28670
+ }
28671
+ else {
28672
+ request['isIsolated'] = 'FALSE';
28673
+ request['type'] = 'BORROW';
28674
+ response = await this.sapiPostMarginBorrowRepay(this.extend(request, params));
28675
+ }
28446
28676
  //
28447
28677
  // {
28448
28678
  // "tranId": 108988250265,
@@ -29454,6 +29684,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
29454
29684
  'trade/order': 3,
29455
29685
  'trade/cancel': 3,
29456
29686
  'trade/batchOrders': 3,
29687
+ 'trade/order/cancelReplace': 3,
29457
29688
  'trade/cancelOrders': 3,
29458
29689
  'trade/cancelOpenOrders': 3,
29459
29690
  },
@@ -29475,12 +29706,19 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
29475
29706
  },
29476
29707
  'swap': {
29477
29708
  'v1': {
29709
+ 'public': {
29710
+ 'get': {
29711
+ 'ticker/price': 1,
29712
+ },
29713
+ },
29478
29714
  'private': {
29479
29715
  'get': {
29480
29716
  'positionSide/dual': 1,
29481
29717
  'market/markPriceKlines': 1,
29718
+ 'trade/batchCancelReplace': 1,
29482
29719
  },
29483
29720
  'post': {
29721
+ 'trade/cancelReplace': 1,
29484
29722
  'positionSide/dual': 1,
29485
29723
  },
29486
29724
  },
@@ -31555,22 +31793,104 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31555
31793
  // reduceOnly: false
31556
31794
  // }
31557
31795
  //
31796
+ // editOrder (swap)
31797
+ //
31798
+ // {
31799
+ // cancelResult: 'true',
31800
+ // cancelMsg: '',
31801
+ // cancelResponse: {
31802
+ // cancelClientOrderId: '',
31803
+ // cancelOrderId: '1755336244265705472',
31804
+ // symbol: 'SOL-USDT',
31805
+ // orderId: '1755336244265705472',
31806
+ // side: 'SELL',
31807
+ // positionSide: 'SHORT',
31808
+ // type: 'LIMIT',
31809
+ // origQty: '1',
31810
+ // price: '100.000',
31811
+ // executedQty: '0',
31812
+ // avgPrice: '0.000',
31813
+ // cumQuote: '0',
31814
+ // stopPrice: '',
31815
+ // profit: '0.0000',
31816
+ // commission: '0.000000',
31817
+ // status: 'PENDING',
31818
+ // time: '1707339747860',
31819
+ // updateTime: '1707339747860',
31820
+ // clientOrderId: '',
31821
+ // leverage: '20X',
31822
+ // workingType: 'MARK_PRICE',
31823
+ // onlyOnePosition: false,
31824
+ // reduceOnly: false
31825
+ // },
31826
+ // replaceResult: 'true',
31827
+ // replaceMsg: '',
31828
+ // newOrderResponse: {
31829
+ // orderId: '1755338440612995072',
31830
+ // symbol: 'SOL-USDT',
31831
+ // positionSide: 'SHORT',
31832
+ // side: 'SELL',
31833
+ // type: 'LIMIT',
31834
+ // price: '99',
31835
+ // quantity: '2',
31836
+ // stopPrice: '0',
31837
+ // workingType: 'MARK_PRICE',
31838
+ // clientOrderID: '',
31839
+ // timeInForce: 'GTC',
31840
+ // priceRate: '0',
31841
+ // stopLoss: '',
31842
+ // takeProfit: '',
31843
+ // reduceOnly: false
31844
+ // }
31845
+ // }
31846
+ //
31847
+ // editOrder (spot)
31848
+ //
31849
+ // {
31850
+ // cancelResult: { code: '0', msg: '', result: true },
31851
+ // openResult: { code: '0', msg: '', result: true },
31852
+ // orderOpenResponse: {
31853
+ // symbol: 'SOL-USDT',
31854
+ // orderId: '1755334007697866752',
31855
+ // transactTime: '1707339214620',
31856
+ // price: '99',
31857
+ // stopPrice: '0',
31858
+ // origQty: '0.2',
31859
+ // executedQty: '0',
31860
+ // cummulativeQuoteQty: '0',
31861
+ // status: 'PENDING',
31862
+ // type: 'LIMIT',
31863
+ // side: 'SELL',
31864
+ // clientOrderID: ''
31865
+ // },
31866
+ // orderCancelResponse: {
31867
+ // symbol: 'SOL-USDT',
31868
+ // orderId: '1755117055251480576',
31869
+ // price: '100',
31870
+ // stopPrice: '0',
31871
+ // origQty: '0.2',
31872
+ // executedQty: '0',
31873
+ // cummulativeQuoteQty: '0',
31874
+ // status: 'CANCELED',
31875
+ // type: 'LIMIT',
31876
+ // side: 'SELL'
31877
+ // }
31878
+ // }
31879
+ //
31880
+ const info = order;
31881
+ const newOrder = this.safeDict2(order, 'newOrderResponse', 'orderOpenResponse');
31882
+ if (newOrder !== undefined) {
31883
+ order = newOrder;
31884
+ }
31558
31885
  const positionSide = this.safeString2(order, 'positionSide', 'ps');
31559
31886
  const marketType = (positionSide === undefined) ? 'spot' : 'swap';
31560
31887
  const marketId = this.safeString2(order, 'symbol', 's');
31561
31888
  if (market === undefined) {
31562
31889
  market = this.safeMarket(marketId, undefined, undefined, marketType);
31563
31890
  }
31564
- const symbol = this.safeSymbol(marketId, market, '-', marketType);
31565
- const orderId = this.safeString2(order, 'orderId', 'i');
31566
31891
  const side = this.safeStringLower2(order, 'side', 'S');
31567
- const type = this.safeStringLower2(order, 'type', 'o');
31568
31892
  const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E']);
31569
31893
  const lastTradeTimestamp = this.safeInteger2(order, 'updateTime', 'T');
31570
- const price = this.safeString2(order, 'price', 'p');
31571
- const average = this.safeString2(order, 'avgPrice', 'ap');
31572
- const amount = this.safeString2(order, 'origQty', 'q');
31573
- const filled = this.safeString2(order, 'executedQty', 'z');
31574
31894
  const statusId = this.safeString2(order, 'status', 'X');
31575
31895
  let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
31576
31896
  const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
@@ -31587,11 +31907,6 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31587
31907
  feeCurrencyCode = market['quote'];
31588
31908
  }
31589
31909
  }
31590
- const fee = {
31591
- 'currency': feeCurrencyCode,
31592
- 'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeCost),
31593
- };
31594
- const clientOrderId = this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']);
31595
31910
  let stopLoss = this.safeValue(order, 'stopLoss');
31596
31911
  let stopLossPrice = undefined;
31597
31912
  if ((stopLoss !== undefined) && (stopLoss !== '')) {
@@ -31617,31 +31932,35 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31617
31932
  takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
31618
31933
  }
31619
31934
  return this.safeOrder({
31620
- 'info': order,
31621
- 'id': orderId,
31622
- 'clientOrderId': clientOrderId,
31935
+ 'info': info,
31936
+ 'id': this.safeString2(order, 'orderId', 'i'),
31937
+ 'clientOrderId': this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']),
31938
+ 'symbol': this.safeSymbol(marketId, market, '-', marketType),
31623
31939
  'timestamp': timestamp,
31624
31940
  'datetime': this.iso8601(timestamp),
31625
31941
  'lastTradeTimestamp': lastTradeTimestamp,
31626
31942
  'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
31627
- 'symbol': symbol,
31628
- 'type': type,
31629
- 'timeInForce': undefined,
31943
+ 'type': this.safeStringLower2(order, 'type', 'o'),
31944
+ 'timeInForce': this.safeString(order, 'timeInForce'),
31630
31945
  'postOnly': undefined,
31631
31946
  'side': this.parseOrderSide(side),
31632
- 'price': price,
31947
+ 'price': this.safeString2(order, 'price', 'p'),
31633
31948
  'stopPrice': this.safeNumber(order, 'stopPrice'),
31634
31949
  'triggerPrice': this.safeNumber(order, 'stopPrice'),
31635
31950
  'stopLossPrice': stopLossPrice,
31636
31951
  'takeProfitPrice': takeProfitPrice,
31637
- 'average': average,
31952
+ 'average': this.safeString2(order, 'avgPrice', 'ap'),
31638
31953
  'cost': undefined,
31639
- 'amount': amount,
31640
- 'filled': filled,
31954
+ 'amount': this.safeStringN(order, ['origQty', 'q', 'quantity']),
31955
+ 'filled': this.safeString2(order, 'executedQty', 'z'),
31641
31956
  'remaining': undefined,
31642
31957
  'status': this.parseOrderStatus(statusId),
31643
- 'fee': fee,
31958
+ 'fee': {
31959
+ 'currency': feeCurrencyCode,
31960
+ 'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeCost),
31961
+ },
31644
31962
  'trades': undefined,
31963
+ 'reduceOnly': this.safeBool(order, 'reduceOnly'),
31645
31964
  }, market);
31646
31965
  }
31647
31966
  parseOrderStatus(status) {
@@ -33150,6 +33469,144 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
33150
33469
  //
33151
33470
  return await this.swapV1PrivatePostPositionSideDual(this.extend(request, params));
33152
33471
  }
33472
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
33473
+ /**
33474
+ * @method
33475
+ * @name bingx#editOrder
33476
+ * @description cancels an order and places a new order
33477
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20order%20and%20place%20a%20new%20order // spot
33478
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20an%20order%20and%20then%20Place%20a%20new%20order // swap
33479
+ * @param {string} id order id
33480
+ * @param {string} symbol unified symbol of the market to create an order in
33481
+ * @param {string} type 'market' or 'limit'
33482
+ * @param {string} side 'buy' or 'sell'
33483
+ * @param {float} amount how much of the currency you want to trade in units of the base currency
33484
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
33485
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
33486
+ * @param {string} [params.stopPrice] Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
33487
+ * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
33488
+ * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
33489
+ * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
33490
+ * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
33491
+ *
33492
+ * EXCHANGE SPECIFIC PARAMETERS
33493
+ * @param {string} [params.cancelClientOrderID] the user-defined id of the order to be canceled, 1-40 characters, different orders cannot use the same clientOrderID, only supports a query range of 2 hours
33494
+ * @param {string} [params.cancelRestrictions] cancel orders with specified status, NEW: New order, PENDING: Pending order, PARTIALLY_FILLED: Partially filled
33495
+ * @param {string} [params.cancelReplaceMode] STOP_ON_FAILURE - if the cancel order fails, it will not continue to place a new order, ALLOW_FAILURE - regardless of whether the cancel order succeeds or fails, it will continue to place a new order
33496
+ * @param {float} [params.quoteOrderQty] order amount
33497
+ * @param {string} [params.newClientOrderId] custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
33498
+ * @param {string} [params.positionSide] *contract only* position direction, required for single position as BOTH, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
33499
+ * @param {string} [params.reduceOnly] *contract only* true or false, default=false for single position mode. this parameter is not accepted for both long and short positions mode
33500
+ * @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market, Max = 1
33501
+ * @param {string} [params.workingType] *contract only* StopPrice trigger price types, MARK_PRICE (default), CONTRACT_PRICE, or INDEX_PRICE
33502
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
33503
+ */
33504
+ await this.loadMarkets();
33505
+ const market = this.market(symbol);
33506
+ const request = this.createOrderRequest(symbol, type, side, amount, price, params);
33507
+ request['cancelOrderId'] = id;
33508
+ request['cancelReplaceMode'] = 'STOP_ON_FAILURE';
33509
+ let response = undefined;
33510
+ if (market['swap']) {
33511
+ response = await this.swapV1PrivatePostTradeCancelReplace(this.extend(request, params));
33512
+ //
33513
+ // {
33514
+ // code: '0',
33515
+ // msg: '',
33516
+ // data: {
33517
+ // cancelResult: 'true',
33518
+ // cancelMsg: '',
33519
+ // cancelResponse: {
33520
+ // cancelClientOrderId: '',
33521
+ // cancelOrderId: '1755336244265705472',
33522
+ // symbol: 'SOL-USDT',
33523
+ // orderId: '1755336244265705472',
33524
+ // side: 'SELL',
33525
+ // positionSide: 'SHORT',
33526
+ // type: 'LIMIT',
33527
+ // origQty: '1',
33528
+ // price: '100.000',
33529
+ // executedQty: '0',
33530
+ // avgPrice: '0.000',
33531
+ // cumQuote: '0',
33532
+ // stopPrice: '',
33533
+ // profit: '0.0000',
33534
+ // commission: '0.000000',
33535
+ // status: 'PENDING',
33536
+ // time: '1707339747860',
33537
+ // updateTime: '1707339747860',
33538
+ // clientOrderId: '',
33539
+ // leverage: '20X',
33540
+ // workingType: 'MARK_PRICE',
33541
+ // onlyOnePosition: false,
33542
+ // reduceOnly: false
33543
+ // },
33544
+ // replaceResult: 'true',
33545
+ // replaceMsg: '',
33546
+ // newOrderResponse: {
33547
+ // orderId: '1755338440612995072',
33548
+ // symbol: 'SOL-USDT',
33549
+ // positionSide: 'SHORT',
33550
+ // side: 'SELL',
33551
+ // type: 'LIMIT',
33552
+ // price: '99',
33553
+ // quantity: '2',
33554
+ // stopPrice: '0',
33555
+ // workingType: 'MARK_PRICE',
33556
+ // clientOrderID: '',
33557
+ // timeInForce: 'GTC',
33558
+ // priceRate: '0',
33559
+ // stopLoss: '',
33560
+ // takeProfit: '',
33561
+ // reduceOnly: false
33562
+ // }
33563
+ // }
33564
+ // }
33565
+ //
33566
+ }
33567
+ else {
33568
+ response = await this.spotV1PrivatePostTradeOrderCancelReplace(this.extend(request, params));
33569
+ //
33570
+ // {
33571
+ // code: '0',
33572
+ // msg: '',
33573
+ // debugMsg: '',
33574
+ // data: {
33575
+ // cancelResult: { code: '0', msg: '', result: true },
33576
+ // openResult: { code: '0', msg: '', result: true },
33577
+ // orderOpenResponse: {
33578
+ // symbol: 'SOL-USDT',
33579
+ // orderId: '1755334007697866752',
33580
+ // transactTime: '1707339214620',
33581
+ // price: '99',
33582
+ // stopPrice: '0',
33583
+ // origQty: '0.2',
33584
+ // executedQty: '0',
33585
+ // cummulativeQuoteQty: '0',
33586
+ // status: 'PENDING',
33587
+ // type: 'LIMIT',
33588
+ // side: 'SELL',
33589
+ // clientOrderID: ''
33590
+ // },
33591
+ // orderCancelResponse: {
33592
+ // symbol: 'SOL-USDT',
33593
+ // orderId: '1755117055251480576',
33594
+ // price: '100',
33595
+ // stopPrice: '0',
33596
+ // origQty: '0.2',
33597
+ // executedQty: '0',
33598
+ // cummulativeQuoteQty: '0',
33599
+ // status: 'CANCELED',
33600
+ // type: 'LIMIT',
33601
+ // side: 'SELL'
33602
+ // }
33603
+ // }
33604
+ // }
33605
+ //
33606
+ }
33607
+ const data = this.safeDict(response, 'data');
33608
+ return this.parseOrder(data, market);
33609
+ }
33153
33610
  sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
33154
33611
  const type = section[0];
33155
33612
  const version = section[1];
@@ -47767,6 +48224,13 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47767
48224
  size = this.safeString(order, 'size');
47768
48225
  filled = this.safeString(order, 'baseVolume');
47769
48226
  }
48227
+ let side = this.safeString(order, 'side');
48228
+ const posMode = this.safeString(order, 'posMode');
48229
+ if (posMode === 'hedge_mode' && reduceOnly) {
48230
+ side = (side === 'buy') ? 'sell' : 'buy';
48231
+ // on bitget hedge mode if the position is long the side is always buy, and if the position is short the side is always sell
48232
+ // so the side of the reduceOnly order is inversed
48233
+ }
47770
48234
  return this.safeOrder({
47771
48235
  'info': order,
47772
48236
  'id': this.safeString2(order, 'orderId', 'data'),
@@ -47777,7 +48241,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47777
48241
  'lastUpdateTimestamp': updateTimestamp,
47778
48242
  'symbol': market['symbol'],
47779
48243
  'type': this.safeString(order, 'orderType'),
47780
- 'side': this.safeString(order, 'side'),
48244
+ 'side': side,
47781
48245
  'price': price,
47782
48246
  'amount': size,
47783
48247
  'cost': this.safeString2(order, 'quoteVolume', 'quoteSize'),
@@ -52104,7 +52568,11 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
52104
52568
  }
52105
52569
  else {
52106
52570
  if (Object.keys(params).length) {
52107
- const queryInner = '?' + this.urlencode(this.keysort(params));
52571
+ let queryInner = '?' + this.urlencode(this.keysort(params));
52572
+ // check #21169 pr
52573
+ if (queryInner.indexOf('%24') > -1) {
52574
+ queryInner = queryInner.replace('%24', '$');
52575
+ }
52108
52576
  url += queryInner;
52109
52577
  auth += queryInner;
52110
52578
  }
@@ -83774,6 +84242,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
83774
84242
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
83775
84243
  * @param {int} [limit] the maximum amount of candles to fetch
83776
84244
  * @param {object} [params] extra parameters specific to the exchange API endpoint
84245
+ * @param {int} [params.until] the latest time in ms to fetch orders for
83777
84246
  * @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)
83778
84247
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
83779
84248
  */
@@ -83787,7 +84256,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
83787
84256
  return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
83788
84257
  }
83789
84258
  const market = this.market(symbol);
83790
- const request = {
84259
+ let request = {
83791
84260
  'symbol': market['id'],
83792
84261
  };
83793
84262
  if (limit === undefined) {
@@ -83799,6 +84268,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
83799
84268
  if (limit !== undefined) {
83800
84269
  request['limit'] = limit; // max 1000, default 1000
83801
84270
  }
84271
+ [request, params] = this.handleUntilOption('end', request, params);
83802
84272
  request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
83803
84273
  let response = undefined;
83804
84274
  if (market['spot']) {
@@ -91370,11 +91840,12 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
91370
91840
  // ]
91371
91841
  // }
91372
91842
  //
91373
- const data = this.safeValue(response, 'data', []);
91374
- const pagination = this.safeValue(response, 'pagination', {});
91843
+ const data = this.safeList(response, 'data', []);
91844
+ const pagination = this.safeDict(response, 'pagination', {});
91375
91845
  const cursor = this.safeString(pagination, 'next_starting_after');
91376
- const accounts = this.safeValue(response, 'data', []);
91377
- const lastIndex = accounts.length - 1;
91846
+ const accounts = this.safeList(response, 'data', []);
91847
+ const length = accounts.length;
91848
+ const lastIndex = length - 1;
91378
91849
  const last = this.safeValue(accounts, lastIndex);
91379
91850
  if ((cursor !== undefined) && (cursor !== '')) {
91380
91851
  last['next_starting_after'] = cursor;
@@ -91423,8 +91894,9 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
91423
91894
  // "size": 9
91424
91895
  // }
91425
91896
  //
91426
- const accounts = this.safeValue(response, 'accounts', []);
91427
- const lastIndex = accounts.length - 1;
91897
+ const accounts = this.safeList(response, 'accounts', []);
91898
+ const length = accounts.length;
91899
+ const lastIndex = length - 1;
91428
91900
  const last = this.safeValue(accounts, lastIndex);
91429
91901
  const cursor = this.safeString(response, 'cursor');
91430
91902
  if ((cursor !== undefined) && (cursor !== '')) {
@@ -94557,6 +95029,7 @@ class coinbasepro extends _abstract_coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/
94557
95029
  'users/self/trailing-volume',
94558
95030
  'withdrawals/fee-estimate',
94559
95031
  'conversions/{conversion_id}',
95032
+ 'conversions/fees',
94560
95033
  ],
94561
95034
  'post': [
94562
95035
  'conversions',
@@ -103648,13 +104121,15 @@ class coinlist extends _abstract_coinlist_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
103648
104121
  }
103649
104122
  takerFees = this.sortBy(takerFees, 1, true);
103650
104123
  makerFees = this.sortBy(makerFees, 1, true);
103651
- const firstTier = this.safeValue(takerFees, 0, []);
103652
- const exchangeFees = this.safeValue(this, 'fees', {});
103653
- const exchangeFeesTrading = this.safeValue(exchangeFees, 'trading', {});
103654
- const exchangeFeesTradingTiers = this.safeValue(exchangeFeesTrading, 'tiers', {});
103655
- const exchangeFeesTradingTiersTaker = this.safeValue(exchangeFeesTradingTiers, 'taker', []);
103656
- const exchangeFeesTradingTiersMaker = this.safeValue(exchangeFeesTradingTiers, 'maker', []);
103657
- if ((keysLength === exchangeFeesTradingTiersTaker.length) && (firstTier.length > 0)) {
104124
+ const firstTier = this.safeDict(takerFees, 0, []);
104125
+ const exchangeFees = this.safeDict(this, 'fees', {});
104126
+ const exchangeFeesTrading = this.safeDict(exchangeFees, 'trading', {});
104127
+ const exchangeFeesTradingTiers = this.safeDict(exchangeFeesTrading, 'tiers', {});
104128
+ const exchangeFeesTradingTiersTaker = this.safeList(exchangeFeesTradingTiers, 'taker', []);
104129
+ const exchangeFeesTradingTiersMaker = this.safeList(exchangeFeesTradingTiers, 'maker', []);
104130
+ const exchangeFeesTradingTiersTakerLength = exchangeFeesTradingTiersTaker.length;
104131
+ const firstTierLength = firstTier.length;
104132
+ if ((keysLength === exchangeFeesTradingTiersTakerLength) && (firstTierLength > 0)) {
103658
104133
  for (let i = 0; i < keysLength; i++) {
103659
104134
  takerFees[i][0] = exchangeFeesTradingTiersTaker[i][0];
103660
104135
  makerFees[i][0] = exchangeFeesTradingTiersMaker[i][0];
@@ -107125,7 +107600,8 @@ class coinmetro extends _abstract_coinmetro_js__WEBPACK_IMPORTED_MODULE_0__/* ["
107125
107600
  }
107126
107601
  let type = undefined;
107127
107602
  let referenceId = undefined;
107128
- if (descriptionArray.length > 1) {
107603
+ const length = descriptionArray.length;
107604
+ if (length > 1) {
107129
107605
  type = this.parseLedgerEntryType(descriptionArray[0]);
107130
107606
  if (descriptionArray[1] !== '-') {
107131
107607
  referenceId = descriptionArray[1];
@@ -162615,7 +163091,8 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
162615
163091
  'fetchBalance': true,
162616
163092
  'fetchBorrowRateHistories': false,
162617
163093
  'fetchBorrowRateHistory': false,
162618
- 'fetchClosedOrders': undefined,
163094
+ 'fetchCanceledOrders': true,
163095
+ 'fetchClosedOrders': true,
162619
163096
  'fetchCrossBorrowRate': false,
162620
163097
  'fetchCrossBorrowRates': false,
162621
163098
  'fetchDepositAddress': false,
@@ -163762,6 +164239,102 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
163762
164239
  const orders = this.safeValue(response, 'openOrders', []);
163763
164240
  return this.parseOrders(orders, market, since, limit);
163764
164241
  }
164242
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
164243
+ /**
164244
+ * @method
164245
+ * @name krakenfutures#fetchClosedOrders
164246
+ * @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
164247
+ * @description Gets all closed orders, including trigger orders, for an account from the exchange api
164248
+ * @param {string} symbol Unified market symbol
164249
+ * @param {int} [since] Timestamp (ms) of earliest order.
164250
+ * @param {int} [limit] How many orders to return.
164251
+ * @param {object} [params] Exchange specific parameters
164252
+ * @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
164253
+ */
164254
+ await this.loadMarkets();
164255
+ let market = undefined;
164256
+ if (symbol !== undefined) {
164257
+ market = this.market(symbol);
164258
+ }
164259
+ const request = {};
164260
+ if (limit !== undefined) {
164261
+ request['count'] = limit;
164262
+ }
164263
+ if (since !== undefined) {
164264
+ request['from'] = since;
164265
+ }
164266
+ const response = await this.historyGetOrders(this.extend(request, params));
164267
+ const allOrders = this.safeList(response, 'elements', []);
164268
+ const closedOrders = [];
164269
+ for (let i = 0; i < allOrders.length; i++) {
164270
+ const order = allOrders[i];
164271
+ const event = this.safeDict(order, 'event', {});
164272
+ const orderPlaced = this.safeDict(event, 'OrderPlaced');
164273
+ if (orderPlaced !== undefined) {
164274
+ const innerOrder = this.safeDict(orderPlaced, 'order', {});
164275
+ const filled = this.safeString(innerOrder, 'filled');
164276
+ if (filled !== '0') {
164277
+ innerOrder['status'] = 'closed'; // status not available in the response
164278
+ closedOrders.push(innerOrder);
164279
+ }
164280
+ }
164281
+ }
164282
+ return this.parseOrders(closedOrders, market, since, limit);
164283
+ }
164284
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
164285
+ /**
164286
+ * @method
164287
+ * @name krakenfutures#fetchCanceledOrders
164288
+ * @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
164289
+ * @description Gets all canceled orders, including trigger orders, for an account from the exchange api
164290
+ * @param {string} symbol Unified market symbol
164291
+ * @param {int} [since] Timestamp (ms) of earliest order.
164292
+ * @param {int} [limit] How many orders to return.
164293
+ * @param {object} [params] Exchange specific parameters
164294
+ * @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
164295
+ */
164296
+ await this.loadMarkets();
164297
+ let market = undefined;
164298
+ if (symbol !== undefined) {
164299
+ market = this.market(symbol);
164300
+ }
164301
+ const request = {};
164302
+ if (limit !== undefined) {
164303
+ request['count'] = limit;
164304
+ }
164305
+ if (since !== undefined) {
164306
+ request['from'] = since;
164307
+ }
164308
+ const response = await this.historyGetOrders(this.extend(request, params));
164309
+ const allOrders = this.safeList(response, 'elements', []);
164310
+ const canceledAndRejected = [];
164311
+ for (let i = 0; i < allOrders.length; i++) {
164312
+ const order = allOrders[i];
164313
+ const event = this.safeDict(order, 'event', {});
164314
+ const orderPlaced = this.safeDict(event, 'OrderPlaced');
164315
+ if (orderPlaced !== undefined) {
164316
+ const innerOrder = this.safeDict(orderPlaced, 'order', {});
164317
+ const filled = this.safeString(innerOrder, 'filled');
164318
+ if (filled === '0') {
164319
+ innerOrder['status'] = 'canceled'; // status not available in the response
164320
+ canceledAndRejected.push(innerOrder);
164321
+ }
164322
+ }
164323
+ const orderCanceled = this.safeDict(event, 'OrderCancelled');
164324
+ if (orderCanceled !== undefined) {
164325
+ const innerOrder = this.safeDict(orderCanceled, 'order', {});
164326
+ innerOrder['status'] = 'canceled'; // status not available in the response
164327
+ canceledAndRejected.push(innerOrder);
164328
+ }
164329
+ const orderRejected = this.safeDict(event, 'OrderRejected');
164330
+ if (orderRejected !== undefined) {
164331
+ const innerOrder = this.safeDict(orderRejected, 'order', {});
164332
+ innerOrder['status'] = 'rejected'; // status not available in the response
164333
+ canceledAndRejected.push(innerOrder);
164334
+ }
164335
+ }
164336
+ return this.parseOrders(canceledAndRejected, market, since, limit);
164337
+ }
163765
164338
  parseOrderType(orderType) {
163766
164339
  const map = {
163767
164340
  'lmt': 'limit',
@@ -164005,6 +164578,32 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
164005
164578
  // "status": "requiredArgumentMissing",
164006
164579
  // "orderEvents": []
164007
164580
  // }
164581
+ // closed orders
164582
+ // {
164583
+ // uid: '2f00cd63-e61d-44f8-8569-adabde885941',
164584
+ // timestamp: '1707258274849',
164585
+ // event: {
164586
+ // OrderPlaced: {
164587
+ // order: {
164588
+ // uid: '85805e01-9eed-4395-8360-ed1a228237c9',
164589
+ // accountUid: '406142dd-7c5c-4a8b-acbc-5f16eca30009',
164590
+ // tradeable: 'PF_LTCUSD',
164591
+ // direction: 'Buy',
164592
+ // quantity: '0',
164593
+ // filled: '0.1',
164594
+ // timestamp: '1707258274849',
164595
+ // limitPrice: '69.2200000000',
164596
+ // orderType: 'IoC',
164597
+ // clientId: '',
164598
+ // reduceOnly: false,
164599
+ // lastUpdateTimestamp: '1707258274849'
164600
+ // },
164601
+ // reason: 'new_user_order',
164602
+ // reducedQuantity: '',
164603
+ // algoId: ''
164604
+ // }
164605
+ // }
164606
+ // }
164008
164607
  //
164009
164608
  const orderEvents = this.safeValue(order, 'orderEvents', []);
164010
164609
  const errorStatus = this.safeString(order, 'status');
@@ -164067,7 +164666,8 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
164067
164666
  let remaining = this.safeString(details, 'unfilledSize');
164068
164667
  let average = undefined;
164069
164668
  let filled2 = '0.0';
164070
- if (trades.length) {
164669
+ const tradesLength = trades.length;
164670
+ if (tradesLength > 0) {
164071
164671
  let vwapSum = '0.0';
164072
164672
  for (let i = 0; i < trades.length; i++) {
164073
164673
  const trade = trades[i];
@@ -182795,7 +183395,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
182795
183395
  async fetchStatus(params = {}) {
182796
183396
  /**
182797
183397
  * @method
182798
- * @name mexc3#fetchStatus
183398
+ * @name mexc#fetchStatus
182799
183399
  * @description the latest known information on the availability of the exchange API
182800
183400
  * @param {object} [params] extra parameters specific to the exchange API endpoint
182801
183401
  * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
@@ -182832,7 +183432,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
182832
183432
  async fetchTime(params = {}) {
182833
183433
  /**
182834
183434
  * @method
182835
- * @name mexc3#fetchTime
183435
+ * @name mexc#fetchTime
182836
183436
  * @description fetches the current integer timestamp in milliseconds from the exchange server
182837
183437
  * @param {object} [params] extra parameters specific to the exchange API endpoint
182838
183438
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
@@ -182858,7 +183458,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
182858
183458
  async fetchCurrencies(params = {}) {
182859
183459
  /**
182860
183460
  * @method
182861
- * @name mexc3#fetchCurrencies
183461
+ * @name mexc#fetchCurrencies
182862
183462
  * @description fetches all available currencies on an exchange
182863
183463
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
182864
183464
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -183023,8 +183623,8 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
183023
183623
  async fetchMarkets(params = {}) {
183024
183624
  /**
183025
183625
  * @method
183026
- * @name mexc3#fetchMarkets
183027
- * @description retrieves data on all markets for mexc3
183626
+ * @name mexc#fetchMarkets
183627
+ * @description retrieves data on all markets for mexc
183028
183628
  * @param {object} [params] extra parameters specific to the exchange API endpoint
183029
183629
  * @returns {object[]} an array of objects representing market data
183030
183630
  */
@@ -183264,7 +183864,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
183264
183864
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
183265
183865
  /**
183266
183866
  * @method
183267
- * @name mexc3#fetchOrderBook
183867
+ * @name mexc#fetchOrderBook
183268
183868
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
183269
183869
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
183270
183870
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
@@ -183341,7 +183941,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
183341
183941
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
183342
183942
  /**
183343
183943
  * @method
183344
- * @name mexc3#fetchTrades
183944
+ * @name mexc#fetchTrades
183345
183945
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#recent-trades-list
183346
183946
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#compressed-aggregate-trades-list
183347
183947
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-transaction-data
@@ -183617,7 +184217,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
183617
184217
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
183618
184218
  /**
183619
184219
  * @method
183620
- * @name mexc3#fetchOHLCV
184220
+ * @name mexc#fetchOHLCV
183621
184221
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
183622
184222
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#k-line-data
183623
184223
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
@@ -183739,7 +184339,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
183739
184339
  async fetchTickers(symbols = undefined, params = {}) {
183740
184340
  /**
183741
184341
  * @method
183742
- * @name mexc3#fetchTickers
184342
+ * @name mexc#fetchTickers
183743
184343
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
183744
184344
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
183745
184345
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -183827,7 +184427,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
183827
184427
  async fetchTicker(symbol, params = {}) {
183828
184428
  /**
183829
184429
  * @method
183830
- * @name mexc3#fetchTicker
184430
+ * @name mexc#fetchTicker
183831
184431
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
183832
184432
  * @param {string} symbol unified symbol of the market to fetch the ticker for
183833
184433
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -184017,7 +184617,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184017
184617
  async fetchBidsAsks(symbols = undefined, params = {}) {
184018
184618
  /**
184019
184619
  * @method
184020
- * @name mexc3#fetchBidsAsks
184620
+ * @name mexc#fetchBidsAsks
184021
184621
  * @description fetches the bid and ask price and volume for multiple markets
184022
184622
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
184023
184623
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -184078,7 +184678,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184078
184678
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
184079
184679
  /**
184080
184680
  * @method
184081
- * @name mexc3#createOrder
184681
+ * @name mexc#createOrder
184082
184682
  * @description create a trade order
184083
184683
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
184084
184684
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
@@ -184359,7 +184959,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184359
184959
  async fetchOrder(id, symbol = undefined, params = {}) {
184360
184960
  /**
184361
184961
  * @method
184362
- * @name mexc3#fetchOrder
184962
+ * @name mexc#fetchOrder
184363
184963
  * @description fetches information on an order made by the user
184364
184964
  * @param {string} symbol unified symbol of the market the order was made in
184365
184965
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -184481,7 +185081,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184481
185081
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
184482
185082
  /**
184483
185083
  * @method
184484
- * @name mexc3#fetchOrders
185084
+ * @name mexc#fetchOrders
184485
185085
  * @description fetches information on multiple orders made by the user
184486
185086
  * @param {string} symbol unified market symbol of the market orders were made in
184487
185087
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -184713,7 +185313,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184713
185313
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
184714
185314
  /**
184715
185315
  * @method
184716
- * @name mexc3#fetchOpenOrders
185316
+ * @name mexc#fetchOpenOrders
184717
185317
  * @description fetch all unfilled currently open orders
184718
185318
  * @param {string} symbol unified market symbol
184719
185319
  * @param {int} [since] the earliest time in ms to fetch open orders for
@@ -184804,7 +185404,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184804
185404
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
184805
185405
  /**
184806
185406
  * @method
184807
- * @name mexc3#fetchClosedOrders
185407
+ * @name mexc#fetchClosedOrders
184808
185408
  * @description fetches information on multiple closed orders made by the user
184809
185409
  * @param {string} symbol unified market symbol of the market orders were made in
184810
185410
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -184817,7 +185417,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184817
185417
  async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
184818
185418
  /**
184819
185419
  * @method
184820
- * @name mexc3#fetchCanceledOrders
185420
+ * @name mexc#fetchCanceledOrders
184821
185421
  * @description fetches information on multiple canceled orders made by the user
184822
185422
  * @param {string} symbol unified market symbol of the market orders were made in
184823
185423
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
@@ -184846,7 +185446,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184846
185446
  async cancelOrder(id, symbol = undefined, params = {}) {
184847
185447
  /**
184848
185448
  * @method
184849
- * @name mexc3#cancelOrder
185449
+ * @name mexc#cancelOrder
184850
185450
  * @description cancels an open order
184851
185451
  * @param {string} id order id
184852
185452
  * @param {string} symbol unified symbol of the market the order was made in
@@ -184963,7 +185563,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184963
185563
  async cancelOrders(ids, symbol = undefined, params = {}) {
184964
185564
  /**
184965
185565
  * @method
184966
- * @name mexc3#cancelOrders
185566
+ * @name mexc#cancelOrders
184967
185567
  * @description cancel multiple orders
184968
185568
  * @param {string[]} ids order ids
184969
185569
  * @param {string} symbol unified market symbol, default is undefined
@@ -184998,7 +185598,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184998
185598
  async cancelAllOrders(symbol = undefined, params = {}) {
184999
185599
  /**
185000
185600
  * @method
185001
- * @name mexc3#cancelAllOrders
185601
+ * @name mexc#cancelAllOrders
185002
185602
  * @description cancel all open orders
185003
185603
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
185004
185604
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -185401,7 +186001,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185401
186001
  async fetchAccounts(params = {}) {
185402
186002
  /**
185403
186003
  * @method
185404
- * @name mexc3#fetchAccounts
186004
+ * @name mexc#fetchAccounts
185405
186005
  * @description fetch all the accounts associated with a profile
185406
186006
  * @param {object} [params] extra parameters specific to the exchange API endpoint
185407
186007
  * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
@@ -185428,7 +186028,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185428
186028
  async fetchTradingFees(params = {}) {
185429
186029
  /**
185430
186030
  * @method
185431
- * @name mexc3#fetchTradingFees
186031
+ * @name mexc#fetchTradingFees
185432
186032
  * @description fetch the trading fees for multiple markets
185433
186033
  * @param {object} [params] extra parameters specific to the exchange API endpoint
185434
186034
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
@@ -185579,7 +186179,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185579
186179
  async fetchBalance(params = {}) {
185580
186180
  /**
185581
186181
  * @method
185582
- * @name mexc3#fetchBalance
186182
+ * @name mexc#fetchBalance
185583
186183
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
185584
186184
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
185585
186185
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
@@ -185713,7 +186313,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185713
186313
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
185714
186314
  /**
185715
186315
  * @method
185716
- * @name mexc3#fetchMyTrades
186316
+ * @name mexc#fetchMyTrades
185717
186317
  * @description fetch all trades made by the user
185718
186318
  * @param {string} symbol unified market symbol
185719
186319
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -185803,7 +186403,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185803
186403
  async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
185804
186404
  /**
185805
186405
  * @method
185806
- * @name mexc3#fetchOrderTrades
186406
+ * @name mexc#fetchOrderTrades
185807
186407
  * @description fetch all the trades made from a single order
185808
186408
  * @param {string} id order id
185809
186409
  * @param {string} symbol unified market symbol
@@ -185901,7 +186501,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185901
186501
  async reduceMargin(symbol, amount, params = {}) {
185902
186502
  /**
185903
186503
  * @method
185904
- * @name mexc3#reduceMargin
186504
+ * @name mexc#reduceMargin
185905
186505
  * @description remove margin from a position
185906
186506
  * @param {string} symbol unified market symbol
185907
186507
  * @param {float} amount the amount of margin to remove
@@ -185913,7 +186513,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185913
186513
  async addMargin(symbol, amount, params = {}) {
185914
186514
  /**
185915
186515
  * @method
185916
- * @name mexc3#addMargin
186516
+ * @name mexc#addMargin
185917
186517
  * @description add margin
185918
186518
  * @param {string} symbol unified market symbol
185919
186519
  * @param {float} amount amount of margin to add
@@ -185925,7 +186525,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185925
186525
  async setLeverage(leverage, symbol = undefined, params = {}) {
185926
186526
  /**
185927
186527
  * @method
185928
- * @name mexc3#setLeverage
186528
+ * @name mexc#setLeverage
185929
186529
  * @description set the level of leverage for a market
185930
186530
  * @param {float} leverage the rate of leverage
185931
186531
  * @param {string} symbol unified market symbol
@@ -185958,7 +186558,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
185958
186558
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
185959
186559
  /**
185960
186560
  * @method
185961
- * @name mexc3#fetchFundingHistory
186561
+ * @name mexc#fetchFundingHistory
185962
186562
  * @description fetch the history of funding payments paid and received on this account
185963
186563
  * @param {string} symbol unified market symbol
185964
186564
  * @param {int} [since] the earliest time in ms to fetch funding history for
@@ -186073,7 +186673,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186073
186673
  async fetchFundingRate(symbol, params = {}) {
186074
186674
  /**
186075
186675
  * @method
186076
- * @name mexc3#fetchFundingRate
186676
+ * @name mexc#fetchFundingRate
186077
186677
  * @description fetch the current funding rate
186078
186678
  * @param {string} symbol unified market symbol
186079
186679
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -186174,7 +186774,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186174
186774
  async fetchLeverageTiers(symbols = undefined, params = {}) {
186175
186775
  /**
186176
186776
  * @method
186177
- * @name mexc3#fetchLeverageTiers
186777
+ * @name mexc#fetchLeverageTiers
186178
186778
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
186179
186779
  * @param {string[]|undefined} symbols list of unified market symbols
186180
186780
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -186287,7 +186887,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186287
186887
  async fetchDepositAddressesByNetwork(code, params = {}) {
186288
186888
  /**
186289
186889
  * @method
186290
- * @name mexc3#fetchDepositAddressesByNetwork
186890
+ * @name mexc#fetchDepositAddressesByNetwork
186291
186891
  * @description fetch a dictionary of addresses for a currency, indexed by network
186292
186892
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
186293
186893
  * @param {string} code unified currency code of the currency for the deposit address
@@ -186327,7 +186927,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186327
186927
  async createDepositAddress(code, params = {}) {
186328
186928
  /**
186329
186929
  * @method
186330
- * @name mexc3#createDepositAddress
186930
+ * @name mexc#createDepositAddress
186331
186931
  * @description create a currency deposit address
186332
186932
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
186333
186933
  * @param {string} code unified currency code of the currency for the deposit address
@@ -186367,7 +186967,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186367
186967
  async fetchDepositAddress(code, params = {}) {
186368
186968
  /**
186369
186969
  * @method
186370
- * @name mexc3#fetchDepositAddress
186970
+ * @name mexc#fetchDepositAddress
186371
186971
  * @description fetch the deposit address for a currency associated with this account
186372
186972
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
186373
186973
  * @param {string} code unified currency code
@@ -186395,7 +186995,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186395
186995
  async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
186396
186996
  /**
186397
186997
  * @method
186398
- * @name mexc3#fetchDeposits
186998
+ * @name mexc#fetchDeposits
186399
186999
  * @description fetch all deposits made to an account
186400
187000
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
186401
187001
  * @param {string} code unified currency code
@@ -186455,7 +187055,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186455
187055
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
186456
187056
  /**
186457
187057
  * @method
186458
- * @name mexc3#fetchWithdrawals
187058
+ * @name mexc#fetchWithdrawals
186459
187059
  * @description fetch all withdrawals made from an account
186460
187060
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
186461
187061
  * @param {string} code unified currency code
@@ -186632,7 +187232,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186632
187232
  async fetchPosition(symbol, params = {}) {
186633
187233
  /**
186634
187234
  * @method
186635
- * @name mexc3#fetchPosition
187235
+ * @name mexc#fetchPosition
186636
187236
  * @description fetch data on a single open contract trade position
186637
187237
  * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
186638
187238
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -186649,7 +187249,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186649
187249
  async fetchPositions(symbols = undefined, params = {}) {
186650
187250
  /**
186651
187251
  * @method
186652
- * @name mexc3#fetchPositions
187252
+ * @name mexc#fetchPositions
186653
187253
  * @description fetch all open positions
186654
187254
  * @param {string[]|undefined} symbols list of unified market symbols
186655
187255
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -186789,7 +187389,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186789
187389
  async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
186790
187390
  /**
186791
187391
  * @method
186792
- * @name mexc3#fetchTransfers
187392
+ * @name mexc#fetchTransfers
186793
187393
  * @description fetch a history of internal transfers made on an account
186794
187394
  * @param {string} code unified currency code of the currency transferred
186795
187395
  * @param {int} [since] the earliest time in ms to fetch transfers for
@@ -186876,7 +187476,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
186876
187476
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
186877
187477
  /**
186878
187478
  * @method
186879
- * @name mexc3#transfer
187479
+ * @name mexc#transfer
186880
187480
  * @description transfer currency internally between wallets on the same account
186881
187481
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
186882
187482
  * @param {string} code unified currency code
@@ -187009,7 +187609,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
187009
187609
  async withdraw(code, amount, address, tag = undefined, params = {}) {
187010
187610
  /**
187011
187611
  * @method
187012
- * @name mexc3#withdraw
187612
+ * @name mexc#withdraw
187013
187613
  * @description make a withdrawal
187014
187614
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw
187015
187615
  * @param {string} code unified currency code
@@ -187077,7 +187677,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
187077
187677
  async fetchTransactionFees(codes = undefined, params = {}) {
187078
187678
  /**
187079
187679
  * @method
187080
- * @name mexc3#fetchTransactionFees
187680
+ * @name mexc#fetchTransactionFees
187081
187681
  * @description fetch deposit and withdrawal fees
187082
187682
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
187083
187683
  * @param {string[]|undefined} codes returns fees for all currencies if undefined
@@ -187175,7 +187775,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
187175
187775
  async fetchDepositWithdrawFees(codes = undefined, params = {}) {
187176
187776
  /**
187177
187777
  * @method
187178
- * @name mexc3#fetchDepositWithdrawFees
187778
+ * @name mexc#fetchDepositWithdrawFees
187179
187779
  * @description fetch deposit and withdrawal fees
187180
187780
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
187181
187781
  * @param {string[]|undefined} codes returns fees for all currencies if undefined
@@ -199214,12 +199814,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
199214
199814
  if (trailing) {
199215
199815
  request['ordType'] = 'move_order_stop';
199216
199816
  }
199217
- else if (stop || (ordType in algoOrderTypes)) {
199218
- if (stop) {
199219
- if (ordType === undefined) {
199220
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
199221
- }
199222
- }
199817
+ else if (stop && (ordType === undefined)) {
199818
+ request['ordType'] = 'trigger';
199223
199819
  }
199224
199820
  const query = this.omit(params, ['method', 'stop', 'trigger', 'trailing']);
199225
199821
  let response = undefined;
@@ -199526,7 +200122,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
199526
200122
  * @param {int} [since] the earliest time in ms to fetch orders for
199527
200123
  * @param {int} [limit] the maximum number of order structures to retrieve
199528
200124
  * @param {object} [params] extra parameters specific to the exchange API endpoint
199529
- * @param {bool} [params.stop] True if fetching trigger or conditional orders
200125
+ * @param {bool} [params.trigger] True if fetching trigger or conditional orders
199530
200126
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
199531
200127
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
199532
200128
  * @param {int} [params.until] timestamp in ms to fetch orders for
@@ -199564,12 +200160,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
199564
200160
  if (limit !== undefined) {
199565
200161
  request['limit'] = limit; // default 100, max 100
199566
200162
  }
199567
- const options = this.safeValue(this.options, 'fetchClosedOrders', {});
199568
- const algoOrderTypes = this.safeValue(this.options, 'algoOrderTypes', {});
200163
+ const options = this.safeDict(this.options, 'fetchClosedOrders', {});
200164
+ const algoOrderTypes = this.safeDict(this.options, 'algoOrderTypes', {});
199569
200165
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
199570
200166
  let method = this.safeString(params, 'method', defaultMethod);
199571
200167
  const ordType = this.safeString(params, 'ordType');
199572
- const stop = this.safeValue2(params, 'stop', 'trigger');
200168
+ const stop = this.safeBool2(params, 'stop', 'trigger');
199573
200169
  const trailing = this.safeBool(params, 'trailing', false);
199574
200170
  if (trailing || stop || (ordType in algoOrderTypes)) {
199575
200171
  method = 'privateGetTradeOrdersAlgoHistory';
@@ -199578,11 +200174,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
199578
200174
  if (trailing) {
199579
200175
  request['ordType'] = 'move_order_stop';
199580
200176
  }
199581
- else if (stop || (ordType in algoOrderTypes)) {
199582
- if (stop) {
199583
- if (ordType === undefined) {
199584
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchClosedOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
199585
- }
200177
+ else if (stop) {
200178
+ if (ordType === undefined) {
200179
+ request['ordType'] = 'trigger';
199586
200180
  }
199587
200181
  }
199588
200182
  else {
@@ -206831,6 +207425,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
206831
207425
  'addMargin': false,
206832
207426
  'cancelAllOrders': true,
206833
207427
  'cancelOrder': true,
207428
+ 'closePosition': false,
206834
207429
  'createOrder': true,
206835
207430
  'createReduceOnlyOrder': true,
206836
207431
  'createStopLimitOrder': true,
@@ -225185,6 +225780,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
225185
225780
  'watchOrderBookForSymbols': true,
225186
225781
  'watchOrders': true,
225187
225782
  'watchTrades': true,
225783
+ 'watchTradesForSymbols': true,
225188
225784
  'watchOHLCV': true,
225189
225785
  'watchPosition': 'emulated',
225190
225786
  'watchPositions': true,
@@ -225429,17 +226025,43 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
225429
226025
  * @param {object} [params] extra parameters specific to the exchange API endpoint
225430
226026
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
225431
226027
  */
226028
+ return await this.watchTradesForSymbols([symbol], since, limit, params);
226029
+ }
226030
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
226031
+ /**
226032
+ * @method
226033
+ * @name bitmart#watchTradesForSymbols
226034
+ * @see https://developer-pro.bitmart.com/en/spot/#public-trade-channel
226035
+ * @description get the list of most recent trades for a list of symbols
226036
+ * @param {string[]} symbols unified symbol of the market to fetch trades for
226037
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
226038
+ * @param {int} [limit] the maximum amount of trades to fetch
226039
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
226040
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
226041
+ */
225432
226042
  await this.loadMarkets();
225433
- symbol = this.symbol(symbol);
225434
- const market = this.market(symbol);
225435
- let type = 'spot';
225436
- [type, params] = this.handleMarketTypeAndParams('watchTrades', market, params);
225437
- const trades = await this.subscribe('trade', symbol, type, params);
226043
+ let marketType = undefined;
226044
+ [symbols, marketType, params] = this.getParamsForMultipleSub('watchTradesForSymbols', symbols, limit, params);
226045
+ const channelName = 'trade';
226046
+ const trades = await this.subscribeMultiple(channelName, marketType, symbols, params);
225438
226047
  if (this.newUpdates) {
225439
- limit = trades.getLimit(symbol, limit);
226048
+ const first = this.safeDict(trades, 0);
226049
+ const tradeSymbol = this.safeString(first, 'symbol');
226050
+ limit = trades.getLimit(tradeSymbol, limit);
225440
226051
  }
225441
226052
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
225442
226053
  }
226054
+ getParamsForMultipleSub(methodName, symbols, limit = undefined, params = {}) {
226055
+ symbols = this.marketSymbols(symbols, undefined, false, true);
226056
+ const length = symbols.length;
226057
+ if (length > 20) {
226058
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' ' + methodName + '() accepts a maximum of 20 symbols in one request');
226059
+ }
226060
+ const market = this.market(symbols[0]);
226061
+ let marketType = undefined;
226062
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, market, params);
226063
+ return [symbols, marketType, params];
226064
+ }
225443
226065
  async watchTicker(symbol, params = {}) {
225444
226066
  /**
225445
226067
  * @method
@@ -225977,16 +226599,15 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
225977
226599
  // ]
225978
226600
  // }
225979
226601
  //
225980
- const channel = this.safeString2(message, 'table', 'group');
225981
- const isSpot = (channel.indexOf('spot') >= 0);
225982
226602
  const data = this.safeValue(message, 'data');
225983
226603
  if (data === undefined) {
225984
226604
  return;
225985
226605
  }
225986
226606
  let stored = undefined;
226607
+ let symbol = undefined;
225987
226608
  for (let i = 0; i < data.length; i++) {
225988
226609
  const trade = this.parseWsTrade(data[i]);
225989
- const symbol = trade['symbol'];
226610
+ symbol = trade['symbol'];
225990
226611
  const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
225991
226612
  stored = this.safeValue(this.trades, symbol);
225992
226613
  if (stored === undefined) {
@@ -225995,10 +226616,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
225995
226616
  }
225996
226617
  stored.append(trade);
225997
226618
  }
225998
- let messageHash = channel;
225999
- if (isSpot) {
226000
- messageHash += ':' + this.safeString(data[0], 'symbol');
226001
- }
226619
+ const messageHash = 'trade:' + symbol;
226002
226620
  client.resolve(stored, messageHash);
226003
226621
  }
226004
226622
  parseWsTrade(trade, market = undefined) {
@@ -226531,15 +227149,10 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
226531
227149
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
226532
227150
  */
226533
227151
  await this.loadMarkets();
226534
- symbols = this.marketSymbols(symbols, undefined, false, true);
226535
- if (symbols.length > 20) {
226536
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' watchOrderBookForSymbols() accepts a maximum of 20 symbols in one request');
226537
- }
226538
- const market = this.market(symbols[0]);
227152
+ let type = undefined;
227153
+ [symbols, type, params] = this.getParamsForMultipleSub('watchOrderBookForSymbols', symbols, limit, params);
226539
227154
  let channel = undefined;
226540
227155
  [channel, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'depth', 'depth/increase100');
226541
- let type = 'spot';
226542
- [type, params] = this.handleMarketTypeAndParams('watchOrderBookForSymbols', market, params);
226543
227156
  if (type === 'swap' && channel === 'depth/increase100') {
226544
227157
  channel = 'depth50';
226545
227158
  }
@@ -232231,7 +232844,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
232231
232844
  const market = this.market(symbol);
232232
232845
  symbol = market['symbol'];
232233
232846
  const messageHash = 'ticker:' + symbol;
232234
- const url = this.getUrlByMarketType(symbol, false, params);
232847
+ const url = this.getUrlByMarketType(symbol, false, 'watchTicker', params);
232235
232848
  params = this.cleanParams(params);
232236
232849
  const options = this.safeValue(this.options, 'watchTicker', {});
232237
232850
  let topic = this.safeString(options, 'name', 'tickers');
@@ -232256,7 +232869,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
232256
232869
  await this.loadMarkets();
232257
232870
  symbols = this.marketSymbols(symbols, undefined, false);
232258
232871
  const messageHashes = [];
232259
- const url = this.getUrlByMarketType(symbols[0], false, params);
232872
+ const url = this.getUrlByMarketType(symbols[0], false, 'watchTickers', params);
232260
232873
  params = this.cleanParams(params);
232261
232874
  const options = this.safeValue(this.options, 'watchTickers', {});
232262
232875
  const topic = this.safeString(options, 'name', 'tickers');
@@ -232423,7 +233036,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
232423
233036
  await this.loadMarkets();
232424
233037
  const market = this.market(symbol);
232425
233038
  symbol = market['symbol'];
232426
- const url = this.getUrlByMarketType(symbol, false, params);
233039
+ const url = this.getUrlByMarketType(symbol, false, 'watchOHLCV', params);
232427
233040
  params = this.cleanParams(params);
232428
233041
  let ohlcv = undefined;
232429
233042
  const timeframeId = this.safeString(this.timeframes, timeframe, timeframe);
@@ -232541,7 +233154,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
232541
233154
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols');
232542
233155
  }
232543
233156
  symbols = this.marketSymbols(symbols);
232544
- const url = this.getUrlByMarketType(symbols[0], false, params);
233157
+ const url = this.getUrlByMarketType(symbols[0], false, 'watchOrderBook', params);
232545
233158
  params = this.cleanParams(params);
232546
233159
  const market = this.market(symbols[0]);
232547
233160
  if (limit === undefined) {
@@ -232673,7 +233286,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
232673
233286
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
232674
233287
  }
232675
233288
  params = this.cleanParams(params);
232676
- const url = this.getUrlByMarketType(symbols[0], false, params);
233289
+ const url = this.getUrlByMarketType(symbols[0], false, 'watchTrades', params);
232677
233290
  const topics = [];
232678
233291
  const messageHashes = [];
232679
233292
  for (let i = 0; i < symbols.length; i++) {
@@ -304456,7 +305069,7 @@ SOFTWARE.
304456
305069
 
304457
305070
  //-----------------------------------------------------------------------------
304458
305071
  // this is updated by vss.js when building
304459
- const version = '4.2.39';
305072
+ const version = '4.2.40';
304460
305073
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
304461
305074
  //-----------------------------------------------------------------------------
304462
305075