ccxt 4.2.87 → 4.2.89

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 (131) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +4 -5
  3. package/dist/ccxt.browser.js +311 -167
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +6 -1
  6. package/dist/cjs/src/ascendex.js +2 -0
  7. package/dist/cjs/src/base/Exchange.js +41 -9
  8. package/dist/cjs/src/binance.js +12 -6
  9. package/dist/cjs/src/bitflyer.js +2 -0
  10. package/dist/cjs/src/bitget.js +24 -17
  11. package/dist/cjs/src/bitmart.js +2 -0
  12. package/dist/cjs/src/bitstamp.js +83 -99
  13. package/dist/cjs/src/blofin.js +2 -0
  14. package/dist/cjs/src/bybit.js +2 -0
  15. package/dist/cjs/src/coinsph.js +2 -0
  16. package/dist/cjs/src/cryptocom.js +1 -1
  17. package/dist/cjs/src/digifinex.js +2 -0
  18. package/dist/cjs/src/gate.js +10 -8
  19. package/dist/cjs/src/hitbtc.js +2 -0
  20. package/dist/cjs/src/htx.js +2 -0
  21. package/dist/cjs/src/krakenfutures.js +2 -1
  22. package/dist/cjs/src/kucoin.js +46 -19
  23. package/dist/cjs/src/latoken.js +4 -0
  24. package/dist/cjs/src/lbank.js +3 -1
  25. package/dist/cjs/src/luno.js +2 -0
  26. package/dist/cjs/src/mexc.js +55 -7
  27. package/dist/cjs/src/okx.js +2 -0
  28. package/dist/cjs/src/pro/bitget.js +2 -0
  29. package/dist/cjs/src/timex.js +2 -0
  30. package/examples/js/cli.js +0 -2
  31. package/examples/ts/cli.ts +0 -2
  32. package/js/ccxt.d.ts +3 -3
  33. package/js/ccxt.js +3 -3
  34. package/js/src/ascendex.d.ts +3 -3
  35. package/js/src/ascendex.js +2 -0
  36. package/js/src/base/Exchange.d.ts +9 -8
  37. package/js/src/base/Exchange.js +41 -9
  38. package/js/src/base/types.d.ts +35 -2
  39. package/js/src/bigone.d.ts +2 -2
  40. package/js/src/binance.d.ts +6 -16
  41. package/js/src/binance.js +12 -6
  42. package/js/src/bingx.d.ts +2 -2
  43. package/js/src/bit2c.d.ts +2 -2
  44. package/js/src/bitbank.d.ts +2 -2
  45. package/js/src/bitfinex.d.ts +2 -2
  46. package/js/src/bitfinex2.d.ts +3 -3
  47. package/js/src/bitflyer.d.ts +2 -7
  48. package/js/src/bitflyer.js +2 -0
  49. package/js/src/bitget.d.ts +6 -9
  50. package/js/src/bitget.js +24 -17
  51. package/js/src/bitmart.d.ts +4 -14
  52. package/js/src/bitmart.js +2 -0
  53. package/js/src/bitmex.d.ts +2 -2
  54. package/js/src/bitopro.d.ts +3 -3
  55. package/js/src/bitrue.d.ts +2 -2
  56. package/js/src/bitso.d.ts +2 -2
  57. package/js/src/bitstamp.d.ts +7 -19
  58. package/js/src/bitstamp.js +83 -99
  59. package/js/src/bitteam.d.ts +2 -2
  60. package/js/src/bitvavo.d.ts +3 -3
  61. package/js/src/bl3p.d.ts +2 -2
  62. package/js/src/blockchaincom.d.ts +2 -2
  63. package/js/src/blofin.d.ts +2 -7
  64. package/js/src/blofin.js +2 -0
  65. package/js/src/bybit.d.ts +5 -15
  66. package/js/src/bybit.js +2 -0
  67. package/js/src/cex.d.ts +3 -3
  68. package/js/src/coinbase.d.ts +2 -2
  69. package/js/src/coinbaseinternational.d.ts +2 -2
  70. package/js/src/coinbasepro.d.ts +3 -3
  71. package/js/src/coincheck.d.ts +2 -2
  72. package/js/src/coinex.d.ts +5 -19
  73. package/js/src/coinlist.d.ts +3 -3
  74. package/js/src/coinmate.d.ts +2 -9
  75. package/js/src/coinmetro.d.ts +2 -2
  76. package/js/src/coinone.d.ts +2 -2
  77. package/js/src/coinsph.d.ts +4 -14
  78. package/js/src/coinsph.js +2 -0
  79. package/js/src/cryptocom.js +1 -1
  80. package/js/src/currencycom.d.ts +3 -3
  81. package/js/src/delta.d.ts +2 -2
  82. package/js/src/deribit.d.ts +3 -3
  83. package/js/src/digifinex.d.ts +4 -14
  84. package/js/src/digifinex.js +2 -0
  85. package/js/src/exmo.d.ts +3 -3
  86. package/js/src/gate.d.ts +6 -9
  87. package/js/src/gate.js +10 -8
  88. package/js/src/gemini.d.ts +3 -3
  89. package/js/src/hitbtc.d.ts +5 -15
  90. package/js/src/hitbtc.js +2 -0
  91. package/js/src/hollaex.d.ts +3 -3
  92. package/js/src/htx.d.ts +4 -14
  93. package/js/src/htx.js +2 -0
  94. package/js/src/huobijp.d.ts +2 -2
  95. package/js/src/hyperliquid.d.ts +2 -2
  96. package/js/src/idex.d.ts +3 -3
  97. package/js/src/independentreserve.d.ts +2 -2
  98. package/js/src/kraken.d.ts +3 -10
  99. package/js/src/krakenfutures.js +2 -1
  100. package/js/src/kucoin.d.ts +3 -10
  101. package/js/src/kucoin.js +46 -19
  102. package/js/src/kuna.d.ts +2 -2
  103. package/js/src/latoken.d.ts +7 -8
  104. package/js/src/latoken.js +4 -0
  105. package/js/src/lbank.d.ts +4 -9
  106. package/js/src/lbank.js +3 -1
  107. package/js/src/luno.d.ts +2 -7
  108. package/js/src/luno.js +2 -0
  109. package/js/src/lykke.d.ts +2 -2
  110. package/js/src/mexc.d.ts +3 -3
  111. package/js/src/mexc.js +55 -7
  112. package/js/src/ndax.d.ts +2 -2
  113. package/js/src/oceanex.d.ts +2 -2
  114. package/js/src/okcoin.d.ts +2 -2
  115. package/js/src/okx.d.ts +4 -14
  116. package/js/src/okx.js +2 -0
  117. package/js/src/onetrading.d.ts +3 -3
  118. package/js/src/phemex.d.ts +2 -2
  119. package/js/src/poloniex.d.ts +3 -3
  120. package/js/src/pro/bitget.js +2 -0
  121. package/js/src/pro/bitvavo.d.ts +2 -2
  122. package/js/src/probit.d.ts +2 -2
  123. package/js/src/timex.d.ts +4 -14
  124. package/js/src/timex.js +2 -0
  125. package/js/src/upbit.d.ts +2 -9
  126. package/js/src/wazirx.d.ts +2 -2
  127. package/js/src/whitebit.d.ts +3 -3
  128. package/js/src/woo.d.ts +3 -3
  129. package/js/src/yobit.d.ts +2 -2
  130. package/package.json +1 -1
  131. package/skip-tests.json +6 -1
package/dist/cjs/ccxt.js CHANGED
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
182
182
 
183
183
  //-----------------------------------------------------------------------------
184
184
  // this is updated by vss.js when building
185
- const version = '4.2.87';
185
+ const version = '4.2.89';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -374,8 +374,10 @@ exports.BadResponse = errors.BadResponse;
374
374
  exports.BadSymbol = errors.BadSymbol;
375
375
  exports.BaseError = errors.BaseError;
376
376
  exports.CancelPending = errors.CancelPending;
377
+ exports.ContractUnavailable = errors.ContractUnavailable;
377
378
  exports.DDoSProtection = errors.DDoSProtection;
378
379
  exports.DuplicateOrderId = errors.DuplicateOrderId;
380
+ exports.ExchangeClosedByUser = errors.ExchangeClosedByUser;
379
381
  exports.ExchangeError = errors.ExchangeError;
380
382
  exports.ExchangeNotAvailable = errors.ExchangeNotAvailable;
381
383
  exports.InsufficientFunds = errors.InsufficientFunds;
@@ -388,11 +390,14 @@ exports.NoChange = errors.NoChange;
388
390
  exports.NotSupported = errors.NotSupported;
389
391
  exports.NullResponse = errors.NullResponse;
390
392
  exports.OnMaintenance = errors.OnMaintenance;
393
+ exports.OperationFailed = errors.OperationFailed;
394
+ exports.OperationRejected = errors.OperationRejected;
391
395
  exports.OrderImmediatelyFillable = errors.OrderImmediatelyFillable;
392
396
  exports.OrderNotCached = errors.OrderNotCached;
393
397
  exports.OrderNotFillable = errors.OrderNotFillable;
394
398
  exports.OrderNotFound = errors.OrderNotFound;
395
399
  exports.PermissionDenied = errors.PermissionDenied;
400
+ exports.ProxyError = errors.ProxyError;
396
401
  exports.RateLimitExceeded = errors.RateLimitExceeded;
397
402
  exports.RequestTimeout = errors.RequestTimeout;
398
403
  exports.errors = errors;
@@ -1483,6 +1483,8 @@ class ascendex extends ascendex$1 {
1483
1483
  'symbol': symbol,
1484
1484
  'maker': this.safeNumber(takerMaker, 'maker'),
1485
1485
  'taker': this.safeNumber(takerMaker, 'taker'),
1486
+ 'percentage': undefined,
1487
+ 'tierBased': undefined,
1486
1488
  };
1487
1489
  }
1488
1490
  return result;
@@ -109,7 +109,7 @@ class Exchange {
109
109
  this.markets_by_id = undefined;
110
110
  this.symbols = undefined;
111
111
  this.ids = undefined;
112
- this.currencies = undefined;
112
+ this.currencies = {};
113
113
  this.baseCurrencies = undefined;
114
114
  this.quoteCurrencies = undefined;
115
115
  this.currencies_by_id = undefined;
@@ -3788,11 +3788,11 @@ class Exchange {
3788
3788
  if (currencyId !== undefined) {
3789
3789
  code = this.commonCurrencyCode(currencyId.toUpperCase());
3790
3790
  }
3791
- return {
3791
+ return this.safeCurrencyStructure({
3792
3792
  'id': currencyId,
3793
3793
  'code': code,
3794
3794
  'precision': undefined,
3795
- };
3795
+ });
3796
3796
  }
3797
3797
  safeMarket(marketId, market = undefined, delimiter = undefined, marketType = undefined) {
3798
3798
  const result = this.safeMarketStructure({
@@ -4561,11 +4561,18 @@ class Exchange {
4561
4561
  'total': undefined,
4562
4562
  };
4563
4563
  }
4564
- commonCurrencyCode(currency) {
4564
+ commonCurrencyCode(code) {
4565
4565
  if (!this.substituteCommonCurrencyCodes) {
4566
- return currency;
4566
+ return code;
4567
+ }
4568
+ // if the provided code already exists as a value in commonCurrencies dict, then we should not again transform it
4569
+ // more details at: https://github.com/ccxt/ccxt/issues/21112#issuecomment-2031293691
4570
+ const commonCurrencies = Object.values(this.commonCurrencies);
4571
+ const exists = this.inArray(code, commonCurrencies);
4572
+ if (exists) {
4573
+ return code;
4567
4574
  }
4568
- return this.safeString(this.commonCurrencies, currency, currency);
4575
+ return this.safeString(this.commonCurrencies, code, code);
4569
4576
  }
4570
4577
  currency(code) {
4571
4578
  if (this.currencies === undefined) {
@@ -4720,6 +4727,30 @@ class Exchange {
4720
4727
  }
4721
4728
  return parsedPrecision + '1';
4722
4729
  }
4730
+ integerPrecisionToAmount(precision) {
4731
+ /**
4732
+ * @ignore
4733
+ * @method
4734
+ * @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
4735
+ * @param {string} precision The number of digits to the right of the decimal
4736
+ * @returns {string} a string number equal to 1e-precision
4737
+ */
4738
+ if (precision === undefined) {
4739
+ return undefined;
4740
+ }
4741
+ if (Precise["default"].stringGe(precision, '0')) {
4742
+ return this.parsePrecision(precision);
4743
+ }
4744
+ else {
4745
+ const positivePrecisionString = Precise["default"].stringAbs(precision);
4746
+ const positivePrecision = parseInt(positivePrecisionString);
4747
+ let parsedPrecision = '1';
4748
+ for (let i = 0; i < positivePrecision - 1; i++) {
4749
+ parsedPrecision = parsedPrecision + '0';
4750
+ }
4751
+ return parsedPrecision + '0';
4752
+ }
4753
+ }
4723
4754
  async loadTimeDifference(params = {}) {
4724
4755
  const serverTime = await this.fetchTime(params);
4725
4756
  const after = this.milliseconds();
@@ -5004,7 +5035,8 @@ class Exchange {
5004
5035
  if (!this.has['fetchTradingFees']) {
5005
5036
  throw new errors.NotSupported(this.id + ' fetchTradingFee() is not supported yet');
5006
5037
  }
5007
- return await this.fetchTradingFees(params);
5038
+ const fees = await this.fetchTradingFees(params);
5039
+ return this.safeDict(fees, symbol);
5008
5040
  }
5009
5041
  parseOpenInterest(interest, market = undefined) {
5010
5042
  throw new errors.NotSupported(this.id + ' parseOpenInterest () is not supported yet');
@@ -5200,8 +5232,8 @@ class Exchange {
5200
5232
  const entry = responseKeys[i];
5201
5233
  const dictionary = isArray ? entry : response[entry];
5202
5234
  const currencyId = isArray ? this.safeString(dictionary, currencyIdKey) : entry;
5203
- const currency = this.safeValue(this.currencies_by_id, currencyId);
5204
- const code = this.safeString(currency, 'code', currencyId);
5235
+ const currency = this.safeCurrency(currencyId);
5236
+ const code = this.safeString(currency, 'code');
5205
5237
  if ((codes === undefined) || (this.inArray(code, codes))) {
5206
5238
  depositWithdrawFees[code] = this.parseDepositWithdrawFee(dictionary, currency);
5207
5239
  }
@@ -1860,7 +1860,7 @@ class binance extends binance$1 {
1860
1860
  '-4140': errors.BadRequest,
1861
1861
  '-4141': errors.OperationRejected,
1862
1862
  '-4144': errors.BadSymbol,
1863
- '-4164': errors.OperationRejected,
1863
+ '-4164': errors.InvalidOrder,
1864
1864
  '-4165': errors.BadRequest,
1865
1865
  '-4167': errors.BadRequest,
1866
1866
  '-4168': errors.BadRequest,
@@ -8653,6 +8653,8 @@ class binance extends binance$1 {
8653
8653
  'symbol': symbol,
8654
8654
  'maker': this.safeNumber2(fee, 'makerCommission', 'makerCommissionRate'),
8655
8655
  'taker': this.safeNumber2(fee, 'takerCommission', 'takerCommissionRate'),
8656
+ 'percentage': undefined,
8657
+ 'tierBased': undefined,
8656
8658
  };
8657
8659
  }
8658
8660
  async fetchTradingFee(symbol, params = {}) {
@@ -9140,7 +9142,7 @@ class binance extends binance$1 {
9140
9142
  'previousFundingDatetime': undefined,
9141
9143
  };
9142
9144
  }
9143
- parseAccountPositions(account) {
9145
+ parseAccountPositions(account, filterClosed = false) {
9144
9146
  const positions = this.safeList(account, 'positions');
9145
9147
  const assets = this.safeList(account, 'assets', []);
9146
9148
  const balances = {};
@@ -9163,7 +9165,8 @@ class binance extends binance$1 {
9163
9165
  const code = market['linear'] ? market['quote'] : market['base'];
9164
9166
  const maintenanceMargin = this.safeString(position, 'maintMargin');
9165
9167
  // check for maintenance margin so empty positions are not returned
9166
- if ((maintenanceMargin !== '0') && (maintenanceMargin !== '0.00000000')) {
9168
+ const isPositionOpen = (maintenanceMargin !== '0') && (maintenanceMargin !== '0.00000000');
9169
+ if (!filterClosed || isPositionOpen) {
9167
9170
  // sometimes not all the codes are correctly returned...
9168
9171
  if (code in balances) {
9169
9172
  const parsed = this.parseAccountPosition(this.extend(position, {
@@ -10005,10 +10008,11 @@ class binance extends binance$1 {
10005
10008
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
10006
10009
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
10007
10010
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
10008
- * @param {string[]|undefined} symbols list of unified market symbols
10011
+ * @param {string[]} [symbols] list of unified market symbols
10009
10012
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10010
10013
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
10011
10014
  * @param {string} [params.subType] "linear" or "inverse"
10015
+ * @param {boolean} [params.filterClosed] set to true if you would like to filter out closed positions, default is false
10012
10016
  * @returns {object} data on account positions
10013
10017
  */
10014
10018
  if (symbols !== undefined) {
@@ -10045,7 +10049,9 @@ class binance extends binance$1 {
10045
10049
  else {
10046
10050
  throw new errors.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
10047
10051
  }
10048
- const result = this.parseAccountPositions(response);
10052
+ let filterClosed = undefined;
10053
+ [filterClosed, params] = this.handleOptionAndParams(params, 'fetchAccountPositions', 'filterClosed', false);
10054
+ const result = this.parseAccountPositions(response, filterClosed);
10049
10055
  symbols = this.marketSymbols(symbols);
10050
10056
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
10051
10057
  }
@@ -11183,7 +11189,7 @@ class binance extends binance$1 {
11183
11189
  }
11184
11190
  await this.loadMarkets();
11185
11191
  const market = this.market(symbol);
11186
- amount = this.costToPrecision(symbol, amount);
11192
+ amount = this.amountToPrecision(symbol, amount);
11187
11193
  const request = {
11188
11194
  'type': addOrReduce,
11189
11195
  'symbol': market['id'],
@@ -540,6 +540,8 @@ class bitflyer extends bitflyer$1 {
540
540
  'symbol': market['symbol'],
541
541
  'maker': fee,
542
542
  'taker': fee,
543
+ 'percentage': undefined,
544
+ 'tierBased': undefined,
543
545
  };
544
546
  }
545
547
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -1295,6 +1295,7 @@ class bitget extends bitget$1 {
1295
1295
  'commonCurrencies': {
1296
1296
  'JADE': 'Jade Protocol',
1297
1297
  'DEGEN': 'DegenReborn',
1298
+ 'TONCOIN': 'TON',
1298
1299
  },
1299
1300
  'options': {
1300
1301
  'timeframes': {
@@ -1874,8 +1875,8 @@ class bitget extends bitget$1 {
1874
1875
  const data = this.safeValue(response, 'data', []);
1875
1876
  for (let i = 0; i < data.length; i++) {
1876
1877
  const entry = data[i];
1877
- const id = this.safeString(entry, 'coinId');
1878
- const code = this.safeCurrencyCode(this.safeString(entry, 'coin'));
1878
+ const id = this.safeString(entry, 'coin'); // we don't use 'coinId' as it has no use. it is 'coin' field that needs to be used in currency related endpoints (deposit, withdraw, etc..)
1879
+ const code = this.safeCurrencyCode(id);
1879
1880
  const chains = this.safeValue(entry, 'chains', []);
1880
1881
  const networks = {};
1881
1882
  let deposit = false;
@@ -2004,7 +2005,7 @@ class bitget extends bitget$1 {
2004
2005
  }
2005
2006
  params = this.omit(params, 'code');
2006
2007
  const currency = this.currency(code);
2007
- request['coin'] = currency['code'];
2008
+ request['coin'] = currency['id'];
2008
2009
  response = await this.privateMarginGetV2MarginCrossedTierData(this.extend(request, params));
2009
2010
  }
2010
2011
  else {
@@ -2160,7 +2161,7 @@ class bitget extends bitget$1 {
2160
2161
  since = this.milliseconds() - 7776000000; // 90 days
2161
2162
  }
2162
2163
  let request = {
2163
- 'coin': currency['code'],
2164
+ 'coin': currency['id'],
2164
2165
  'startTime': since,
2165
2166
  'endTime': this.milliseconds(),
2166
2167
  };
@@ -2219,7 +2220,7 @@ class bitget extends bitget$1 {
2219
2220
  const currency = this.currency(code);
2220
2221
  const networkId = this.networkCodeToId(chain);
2221
2222
  const request = {
2222
- 'coin': currency['code'],
2223
+ 'coin': currency['id'],
2223
2224
  'address': address,
2224
2225
  'chain': networkId,
2225
2226
  'size': amount,
@@ -2305,7 +2306,7 @@ class bitget extends bitget$1 {
2305
2306
  since = this.milliseconds() - 7776000000; // 90 days
2306
2307
  }
2307
2308
  let request = {
2308
- 'coin': currency['code'],
2309
+ 'coin': currency['id'],
2309
2310
  'startTime': since,
2310
2311
  'endTime': this.milliseconds(),
2311
2312
  };
@@ -2448,7 +2449,7 @@ class bitget extends bitget$1 {
2448
2449
  }
2449
2450
  const currency = this.currency(code);
2450
2451
  const request = {
2451
- 'coin': currency['code'],
2452
+ 'coin': currency['id'],
2452
2453
  };
2453
2454
  if (networkId !== undefined) {
2454
2455
  request['chain'] = networkId;
@@ -2623,7 +2624,11 @@ class bitget extends bitget$1 {
2623
2624
  //
2624
2625
  const marketId = this.safeString(ticker, 'symbol');
2625
2626
  const close = this.safeString(ticker, 'lastPr');
2626
- const timestamp = this.safeInteger(ticker, 'ts');
2627
+ const timestampString = this.omitZero(this.safeString(ticker, 'ts')); // exchange sometimes provided 0
2628
+ let timestamp = undefined;
2629
+ if (timestampString !== undefined) {
2630
+ timestamp = this.parseToInt(timestampString);
2631
+ }
2627
2632
  const change = this.safeString(ticker, 'change24h');
2628
2633
  const open24 = this.safeString(ticker, 'open24');
2629
2634
  const open = this.safeString(ticker, 'open');
@@ -3276,6 +3281,8 @@ class bitget extends bitget$1 {
3276
3281
  'symbol': this.safeSymbol(marketId, market),
3277
3282
  'maker': this.safeNumber(data, 'makerFeeRate'),
3278
3283
  'taker': this.safeNumber(data, 'takerFeeRate'),
3284
+ 'percentage': undefined,
3285
+ 'tierBased': undefined,
3279
3286
  };
3280
3287
  }
3281
3288
  parseOHLCV(ohlcv, market = undefined) {
@@ -5901,7 +5908,7 @@ class bitget extends bitget$1 {
5901
5908
  let request = {};
5902
5909
  if (code !== undefined) {
5903
5910
  currency = this.currency(code);
5904
- request['coin'] = currency['code'];
5911
+ request['coin'] = currency['id'];
5905
5912
  }
5906
5913
  [request, params] = this.handleUntilOption('endTime', request, params);
5907
5914
  if (since !== undefined) {
@@ -7340,7 +7347,7 @@ class bitget extends bitget$1 {
7340
7347
  type = this.safeString(accountsByType, fromAccount);
7341
7348
  const currency = this.currency(code);
7342
7349
  let request = {
7343
- 'coin': currency['code'],
7350
+ 'coin': currency['id'],
7344
7351
  'fromType': type,
7345
7352
  };
7346
7353
  if (since !== undefined) {
@@ -7399,7 +7406,7 @@ class bitget extends bitget$1 {
7399
7406
  'fromType': fromType,
7400
7407
  'toType': toType,
7401
7408
  'amount': amount,
7402
- 'coin': currency['code'],
7409
+ 'coin': currency['id'],
7403
7410
  };
7404
7411
  const symbol = this.safeString(params, 'symbol');
7405
7412
  params = this.omit(params, 'symbol');
@@ -7586,7 +7593,7 @@ class bitget extends bitget$1 {
7586
7593
  await this.loadMarkets();
7587
7594
  const currency = this.currency(code);
7588
7595
  const request = {
7589
- 'coin': currency['code'],
7596
+ 'coin': currency['id'],
7590
7597
  'borrowAmount': this.currencyToPrecision(code, amount),
7591
7598
  };
7592
7599
  const response = await this.privateMarginPostV2MarginCrossedAccountBorrow(this.extend(request, params));
@@ -7621,7 +7628,7 @@ class bitget extends bitget$1 {
7621
7628
  const currency = this.currency(code);
7622
7629
  const market = this.market(symbol);
7623
7630
  const request = {
7624
- 'coin': currency['code'],
7631
+ 'coin': currency['id'],
7625
7632
  'borrowAmount': this.currencyToPrecision(code, amount),
7626
7633
  'symbol': market['id'],
7627
7634
  };
@@ -7658,7 +7665,7 @@ class bitget extends bitget$1 {
7658
7665
  const currency = this.currency(code);
7659
7666
  const market = this.market(symbol);
7660
7667
  const request = {
7661
- 'coin': currency['code'],
7668
+ 'coin': currency['id'],
7662
7669
  'repayAmount': this.currencyToPrecision(code, amount),
7663
7670
  'symbol': market['id'],
7664
7671
  };
@@ -7694,7 +7701,7 @@ class bitget extends bitget$1 {
7694
7701
  await this.loadMarkets();
7695
7702
  const currency = this.currency(code);
7696
7703
  const request = {
7697
- 'coin': currency['code'],
7704
+ 'coin': currency['id'],
7698
7705
  'repayAmount': this.currencyToPrecision(code, amount),
7699
7706
  };
7700
7707
  const response = await this.privateMarginPostV2MarginCrossedAccountRepay(this.extend(request, params));
@@ -8056,7 +8063,7 @@ class bitget extends bitget$1 {
8056
8063
  await this.loadMarkets();
8057
8064
  const currency = this.currency(code);
8058
8065
  const request = {
8059
- 'coin': currency['code'],
8066
+ 'coin': currency['id'],
8060
8067
  };
8061
8068
  const response = await this.privateMarginGetV2MarginCrossedInterestRateAndLimit(this.extend(request, params));
8062
8069
  //
@@ -8151,7 +8158,7 @@ class bitget extends bitget$1 {
8151
8158
  let currency = undefined;
8152
8159
  if (code !== undefined) {
8153
8160
  currency = this.currency(code);
8154
- request['coin'] = currency['code'];
8161
+ request['coin'] = currency['id'];
8155
8162
  }
8156
8163
  if (since !== undefined) {
8157
8164
  request['startTime'] = since;
@@ -2095,6 +2095,8 @@ class bitmart extends bitmart$1 {
2095
2095
  'symbol': symbol,
2096
2096
  'maker': this.safeNumber(fee, 'maker_fee_rate'),
2097
2097
  'taker': this.safeNumber(fee, 'taker_fee_rate'),
2098
+ 'percentage': undefined,
2099
+ 'tierBased': undefined,
2098
2100
  };
2099
2101
  }
2100
2102
  async fetchTradingFee(symbol, params = {}) {
@@ -428,6 +428,30 @@ class bitstamp extends bitstamp$1 {
428
428
  'commonCurrencies': {
429
429
  'UST': 'USTC',
430
430
  },
431
+ // exchange-specific options
432
+ 'options': {
433
+ 'networksById': {
434
+ 'bitcoin-cash': 'BCH',
435
+ 'bitcoin': 'BTC',
436
+ 'ethereum': 'ERC20',
437
+ 'litecoin': 'LTC',
438
+ 'stellar': 'XLM',
439
+ 'xrpl': 'XRP',
440
+ 'tron': 'TRC20',
441
+ 'algorand': 'ALGO',
442
+ 'flare': 'FLR',
443
+ 'hedera': 'HBAR',
444
+ 'cardana': 'ADA',
445
+ 'songbird': 'FLR',
446
+ 'avalanche-c-chain': 'AVAX',
447
+ 'solana': 'SOL',
448
+ 'polkadot': 'DOT',
449
+ 'near': 'NEAR',
450
+ 'doge': 'DOGE',
451
+ 'sui': 'SUI',
452
+ 'casper': 'CSRP',
453
+ },
454
+ },
431
455
  'exceptions': {
432
456
  'exact': {
433
457
  'No permission found': errors.PermissionDenied,
@@ -1200,6 +1224,8 @@ class bitstamp extends bitstamp$1 {
1200
1224
  'symbol': this.safeSymbol(marketId, market),
1201
1225
  'maker': this.safeNumber(fees, 'maker'),
1202
1226
  'taker': this.safeNumber(fees, 'taker'),
1227
+ 'percentage': undefined,
1228
+ 'tierBased': undefined,
1203
1229
  };
1204
1230
  }
1205
1231
  parseTradingFees(fees) {
@@ -1245,60 +1271,41 @@ class bitstamp extends bitstamp$1 {
1245
1271
  * @name bitstamp#fetchTransactionFees
1246
1272
  * @deprecated
1247
1273
  * @description please use fetchDepositWithdrawFees instead
1248
- * @see https://www.bitstamp.net/api/#balance
1274
+ * @see https://www.bitstamp.net/api/#tag/Fees
1249
1275
  * @param {string[]|undefined} codes list of unified currency codes
1250
1276
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1251
1277
  * @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
1252
1278
  */
1253
1279
  await this.loadMarkets();
1254
- const balance = await this.privatePostBalance(params);
1255
- return this.parseTransactionFees(balance);
1280
+ const response = await this.privatePostFeesWithdrawal(params);
1281
+ //
1282
+ // [
1283
+ // {
1284
+ // "currency": "btc",
1285
+ // "fee": "0.00015000",
1286
+ // "network": "bitcoin"
1287
+ // }
1288
+ // ...
1289
+ // ]
1290
+ //
1291
+ return this.parseTransactionFees(response);
1256
1292
  }
1257
1293
  parseTransactionFees(response, codes = undefined) {
1258
- //
1259
- // {
1260
- // "yfi_available": "0.00000000",
1261
- // "yfi_balance": "0.00000000",
1262
- // "yfi_reserved": "0.00000000",
1263
- // "yfi_withdrawal_fee": "0.00070000",
1264
- // "yfieur_fee": "0.000",
1265
- // "yfiusd_fee": "0.000",
1266
- // "zrx_available": "0.00000000",
1267
- // "zrx_balance": "0.00000000",
1268
- // "zrx_reserved": "0.00000000",
1269
- // "zrx_withdrawal_fee": "12.00000000",
1270
- // "zrxeur_fee": "0.000",
1271
- // "zrxusd_fee": "0.000",
1272
- // ...
1273
- // }
1274
- //
1275
- if (codes === undefined) {
1276
- codes = Object.keys(this.currencies);
1277
- }
1278
1294
  const result = {};
1279
- let mainCurrencyId = undefined;
1280
- const ids = Object.keys(response);
1295
+ const currencies = this.indexBy(response, 'currency');
1296
+ const ids = Object.keys(currencies);
1281
1297
  for (let i = 0; i < ids.length; i++) {
1282
1298
  const id = ids[i];
1283
- const currencyId = id.split('_')[0];
1284
- const code = this.safeCurrencyCode(currencyId);
1285
- if (codes !== undefined && !this.inArray(code, codes)) {
1299
+ const fees = this.safeValue(response, i, {});
1300
+ const code = this.safeCurrencyCode(id);
1301
+ if ((codes !== undefined) && !this.inArray(code, codes)) {
1286
1302
  continue;
1287
1303
  }
1288
- if (id.indexOf('_available') >= 0) {
1289
- mainCurrencyId = currencyId;
1290
- result[code] = {
1291
- 'deposit': undefined,
1292
- 'withdraw': undefined,
1293
- 'info': {},
1294
- };
1295
- }
1296
- if (currencyId === mainCurrencyId) {
1297
- result[code]['info'][id] = this.safeNumber(response, id);
1298
- }
1299
- if (id.indexOf('_withdrawal_fee') >= 0) {
1300
- result[code]['withdraw'] = this.safeNumber(response, id);
1301
- }
1304
+ result[code] = {
1305
+ 'withdraw_fee': this.safeNumber(fees, 'fee'),
1306
+ 'deposit': {},
1307
+ 'info': this.safeDict(currencies, id),
1308
+ };
1302
1309
  }
1303
1310
  return result;
1304
1311
  }
@@ -1313,64 +1320,41 @@ class bitstamp extends bitstamp$1 {
1313
1320
  * @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
1314
1321
  */
1315
1322
  await this.loadMarkets();
1316
- const response = await this.privatePostBalance(params);
1317
- //
1318
- // {
1319
- // "yfi_available": "0.00000000",
1320
- // "yfi_balance": "0.00000000",
1321
- // "yfi_reserved": "0.00000000",
1322
- // "yfi_withdrawal_fee": "0.00070000",
1323
- // "yfieur_fee": "0.000",
1324
- // "yfiusd_fee": "0.000",
1325
- // "zrx_available": "0.00000000",
1326
- // "zrx_balance": "0.00000000",
1327
- // "zrx_reserved": "0.00000000",
1328
- // "zrx_withdrawal_fee": "12.00000000",
1329
- // "zrxeur_fee": "0.000",
1330
- // "zrxusd_fee": "0.000",
1331
- // ...
1332
- // }
1333
- //
1334
- return this.parseDepositWithdrawFees(response, codes);
1335
- }
1336
- parseDepositWithdrawFees(response, codes = undefined, currencyIdKey = undefined) {
1337
- //
1338
- // {
1339
- // "yfi_available": "0.00000000",
1340
- // "yfi_balance": "0.00000000",
1341
- // "yfi_reserved": "0.00000000",
1342
- // "yfi_withdrawal_fee": "0.00070000",
1343
- // "yfieur_fee": "0.000",
1344
- // "yfiusd_fee": "0.000",
1345
- // "zrx_available": "0.00000000",
1346
- // "zrx_balance": "0.00000000",
1347
- // "zrx_reserved": "0.00000000",
1348
- // "zrx_withdrawal_fee": "12.00000000",
1349
- // "zrxeur_fee": "0.000",
1350
- // "zrxusd_fee": "0.000",
1351
- // ...
1352
- // }
1323
+ const response = await this.privatePostFeesWithdrawal(params);
1353
1324
  //
1354
- const result = {};
1355
- const ids = Object.keys(response);
1356
- for (let i = 0; i < ids.length; i++) {
1357
- const id = ids[i];
1358
- const currencyId = id.split('_')[0];
1359
- const code = this.safeCurrencyCode(currencyId);
1360
- const dictValue = this.safeNumber(response, id);
1361
- if (codes !== undefined && !this.inArray(code, codes)) {
1362
- continue;
1363
- }
1364
- if (id.indexOf('_available') >= 0) {
1365
- result[code] = this.depositWithdrawFee({});
1366
- }
1367
- if (id.indexOf('_withdrawal_fee') >= 0) {
1368
- result[code]['withdraw']['fee'] = dictValue;
1369
- }
1370
- const resultValue = this.safeValue(result, code);
1371
- if (resultValue !== undefined) {
1372
- result[code]['info'][id] = dictValue;
1373
- }
1325
+ // [
1326
+ // {
1327
+ // "currency": "btc",
1328
+ // "fee": "0.00015000",
1329
+ // "network": "bitcoin"
1330
+ // }
1331
+ // ...
1332
+ // ]
1333
+ //
1334
+ const responseByCurrencyId = this.groupBy(response, 'currency');
1335
+ return this.parseDepositWithdrawFees(responseByCurrencyId, codes);
1336
+ }
1337
+ parseDepositWithdrawFee(fee, currency = undefined) {
1338
+ const result = this.depositWithdrawFee(fee);
1339
+ for (let j = 0; j < fee.length; j++) {
1340
+ const networkEntry = fee[j];
1341
+ const networkId = this.safeString(networkEntry, 'network');
1342
+ const networkCode = this.networkIdToCode(networkId);
1343
+ const withdrawFee = this.safeNumber(networkEntry, 'fee');
1344
+ result['withdraw'] = {
1345
+ 'fee': withdrawFee,
1346
+ 'percentage': undefined,
1347
+ };
1348
+ result['networks'][networkCode] = {
1349
+ 'withdraw': {
1350
+ 'fee': withdrawFee,
1351
+ 'percentage': undefined,
1352
+ },
1353
+ 'deposit': {
1354
+ 'fee': undefined,
1355
+ 'percentage': undefined,
1356
+ },
1357
+ };
1374
1358
  }
1375
1359
  return result;
1376
1360
  }
@@ -941,6 +941,8 @@ class blofin extends blofin$1 {
941
941
  // blofin returns the fees as negative values opposed to other exchanges, so the sign needs to be flipped
942
942
  'maker': this.parseNumber(Precise["default"].stringNeg(this.safeString2(fee, 'maker', 'makerU'))),
943
943
  'taker': this.parseNumber(Precise["default"].stringNeg(this.safeString2(fee, 'taker', 'takerU'))),
944
+ 'percentage': undefined,
945
+ 'tierBased': undefined,
944
946
  };
945
947
  }
946
948
  async fetchBalance(params = {}) {
@@ -7264,6 +7264,8 @@ class bybit extends bybit$1 {
7264
7264
  'symbol': symbol,
7265
7265
  'maker': this.safeNumber(fee, 'makerFeeRate'),
7266
7266
  'taker': this.safeNumber(fee, 'takerFeeRate'),
7267
+ 'percentage': undefined,
7268
+ 'tierBased': undefined,
7267
7269
  };
7268
7270
  }
7269
7271
  async fetchTradingFee(symbol, params = {}) {
@@ -1574,6 +1574,8 @@ class coinsph extends coinsph$1 {
1574
1574
  'symbol': symbol,
1575
1575
  'maker': this.safeNumber(fee, 'makerCommission'),
1576
1576
  'taker': this.safeNumber(fee, 'takerCommission'),
1577
+ 'percentage': undefined,
1578
+ 'tierBased': undefined,
1577
1579
  };
1578
1580
  }
1579
1581
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -2755,7 +2755,7 @@ class cryptocom extends cryptocom$1 {
2755
2755
  //
2756
2756
  const result = this.safeDict(response, 'result', {});
2757
2757
  const data = this.safeList(result, 'data', []);
2758
- return this.parsePosition(data[0], market);
2758
+ return this.parsePosition(this.safeDict(data, 0), market);
2759
2759
  }
2760
2760
  async fetchPositions(symbols = undefined, params = {}) {
2761
2761
  /**