ccxt 4.2.38 → 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 (127) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1340 -407
  3. package/dist/ccxt.browser.min.js +3 -3
  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 +28 -16
  7. package/dist/cjs/src/binance.js +528 -181
  8. package/dist/cjs/src/bingx.js +250 -23
  9. package/dist/cjs/src/bitget.js +14 -3
  10. package/dist/cjs/src/bitso.js +18 -2
  11. package/dist/cjs/src/bitstamp.js +24 -2
  12. package/dist/cjs/src/bl3p.js +6 -0
  13. package/dist/cjs/src/blockchaincom.js +21 -0
  14. package/dist/cjs/src/btcalpha.js +9 -0
  15. package/dist/cjs/src/btcbox.js +9 -0
  16. package/dist/cjs/src/btcmarkets.js +19 -0
  17. package/dist/cjs/src/bybit.js +3 -1
  18. package/dist/cjs/src/coinbase.js +21 -8
  19. package/dist/cjs/src/coinbasepro.js +1 -0
  20. package/dist/cjs/src/coinlist.js +9 -7
  21. package/dist/cjs/src/coinmetro.js +2 -1
  22. package/dist/cjs/src/krakenfutures.js +133 -16
  23. package/dist/cjs/src/luno.js +1 -1
  24. package/dist/cjs/src/mexc.js +43 -43
  25. package/dist/cjs/src/okx.js +11 -17
  26. package/dist/cjs/src/phemex.js +1 -0
  27. package/dist/cjs/src/poloniexfutures.js +11 -5
  28. package/dist/cjs/src/pro/bitmart.js +141 -48
  29. package/dist/cjs/src/pro/bybit.js +5 -5
  30. package/dist/cjs/src/pro/mexc.js +1 -1
  31. package/dist/cjs/src/wavesexchange.js +1 -1
  32. package/dist/cjs/src/woo.js +1 -1
  33. package/js/ccxt.d.ts +1 -1
  34. package/js/ccxt.js +1 -1
  35. package/js/src/abstract/bingx.d.ts +4 -0
  36. package/js/src/abstract/coinbase.d.ts +1 -0
  37. package/js/src/abstract/coinbasepro.d.ts +1 -0
  38. package/js/src/abstract/okx.d.ts +1 -0
  39. package/js/src/ascendex.d.ts +2 -2
  40. package/js/src/ascendex.js +28 -24
  41. package/js/src/base/Exchange.d.ts +12 -8
  42. package/js/src/base/Exchange.js +28 -16
  43. package/js/src/base/types.d.ts +2 -0
  44. package/js/src/bigone.d.ts +2 -2
  45. package/js/src/binance.d.ts +9 -9
  46. package/js/src/binance.js +528 -181
  47. package/js/src/bingx.d.ts +6 -5
  48. package/js/src/bingx.js +250 -23
  49. package/js/src/bitfinex.d.ts +3 -3
  50. package/js/src/bitfinex2.d.ts +2 -2
  51. package/js/src/bitget.d.ts +5 -5
  52. package/js/src/bitget.js +14 -3
  53. package/js/src/bitmart.d.ts +2 -2
  54. package/js/src/bitmex.d.ts +2 -2
  55. package/js/src/bitrue.d.ts +2 -2
  56. package/js/src/bitso.d.ts +1 -1
  57. package/js/src/bitso.js +18 -2
  58. package/js/src/bitstamp.d.ts +1 -1
  59. package/js/src/bitstamp.js +24 -2
  60. package/js/src/bitvavo.d.ts +1 -1
  61. package/js/src/bl3p.js +6 -0
  62. package/js/src/blockchaincom.js +21 -0
  63. package/js/src/blofin.d.ts +2 -2
  64. package/js/src/btcalpha.js +9 -0
  65. package/js/src/btcbox.js +9 -0
  66. package/js/src/btcmarkets.js +19 -0
  67. package/js/src/bybit.d.ts +7 -7
  68. package/js/src/bybit.js +3 -1
  69. package/js/src/cex.d.ts +1 -1
  70. package/js/src/coinbase.d.ts +2 -2
  71. package/js/src/coinbase.js +21 -8
  72. package/js/src/coinbasepro.js +1 -0
  73. package/js/src/coinex.d.ts +4 -4
  74. package/js/src/coinlist.d.ts +2 -2
  75. package/js/src/coinlist.js +9 -7
  76. package/js/src/coinmetro.js +2 -1
  77. package/js/src/coinone.d.ts +1 -1
  78. package/js/src/delta.d.ts +2 -2
  79. package/js/src/deribit.d.ts +3 -3
  80. package/js/src/digifinex.d.ts +3 -3
  81. package/js/src/exmo.d.ts +2 -2
  82. package/js/src/gate.d.ts +6 -6
  83. package/js/src/hitbtc.d.ts +2 -2
  84. package/js/src/hollaex.d.ts +1 -1
  85. package/js/src/htx.d.ts +3 -3
  86. package/js/src/huobijp.d.ts +1 -1
  87. package/js/src/kraken.d.ts +2 -2
  88. package/js/src/krakenfutures.d.ts +4 -2
  89. package/js/src/krakenfutures.js +133 -16
  90. package/js/src/kucoin.d.ts +5 -5
  91. package/js/src/kucoinfutures.d.ts +2 -2
  92. package/js/src/latoken.d.ts +1 -1
  93. package/js/src/lbank.d.ts +2 -2
  94. package/js/src/luno.d.ts +1 -1
  95. package/js/src/luno.js +1 -1
  96. package/js/src/mexc.d.ts +4 -4
  97. package/js/src/mexc.js +43 -43
  98. package/js/src/ndax.d.ts +1 -1
  99. package/js/src/novadax.d.ts +1 -1
  100. package/js/src/okcoin.d.ts +2 -2
  101. package/js/src/okx.d.ts +7 -7
  102. package/js/src/okx.js +11 -17
  103. package/js/src/paymium.d.ts +2 -2
  104. package/js/src/phemex.d.ts +4 -4
  105. package/js/src/phemex.js +1 -0
  106. package/js/src/poloniex.d.ts +2 -2
  107. package/js/src/poloniexfutures.d.ts +2 -2
  108. package/js/src/poloniexfutures.js +11 -5
  109. package/js/src/pro/bitmart.d.ts +4 -0
  110. package/js/src/pro/bitmart.js +141 -48
  111. package/js/src/pro/bitvavo.d.ts +1 -1
  112. package/js/src/pro/bybit.d.ts +1 -1
  113. package/js/src/pro/bybit.js +5 -5
  114. package/js/src/pro/cex.d.ts +2 -2
  115. package/js/src/pro/coinbase.d.ts +2 -2
  116. package/js/src/pro/coinex.d.ts +1 -1
  117. package/js/src/pro/lbank.d.ts +1 -1
  118. package/js/src/pro/mexc.js +1 -1
  119. package/js/src/probit.d.ts +1 -1
  120. package/js/src/timex.d.ts +1 -1
  121. package/js/src/upbit.d.ts +1 -1
  122. package/js/src/wavesexchange.js +1 -1
  123. package/js/src/whitebit.d.ts +2 -2
  124. package/js/src/woo.d.ts +3 -3
  125. package/js/src/woo.js +1 -1
  126. package/js/src/zonda.d.ts +3 -3
  127. package/package.json +2 -2
package/dist/cjs/ccxt.js CHANGED
@@ -177,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
177
177
 
178
178
  //-----------------------------------------------------------------------------
179
179
  // this is updated by vss.js when building
180
- const version = '4.2.38';
180
+ const version = '4.2.40';
181
181
  Exchange["default"].ccxtVersion = version;
182
182
  const exchanges = {
183
183
  'ace': ace,
@@ -274,11 +274,14 @@ class ascendex extends ascendex$1 {
274
274
  'fillResponseFromRequest': true,
275
275
  },
276
276
  'networks': {
277
- 'BSC': 'BEP20 (BSC)',
277
+ 'BSC': 'BEP20 ' + '(BSC)',
278
278
  'ARB': 'arbitrum',
279
279
  'SOL': 'Solana',
280
280
  'AVAX': 'avalanche C chain',
281
281
  'OMNI': 'Omni',
282
+ 'TRC': 'TRC20',
283
+ 'TRX': 'TRC20',
284
+ 'ERC': 'ERC20',
282
285
  },
283
286
  'networksById': {
284
287
  'BEP20 (BSC)': 'BSC',
@@ -286,6 +289,16 @@ class ascendex extends ascendex$1 {
286
289
  'Solana': 'SOL',
287
290
  'avalanche C chain': 'AVAX',
288
291
  'Omni': 'OMNI',
292
+ 'TRC20': 'TRC20',
293
+ 'ERC20': 'ERC20',
294
+ 'GO20': 'GO20',
295
+ 'BEP2': 'BEP2',
296
+ 'Bitcoin': 'BTC',
297
+ 'Bitcoin ABC': 'BCH',
298
+ 'Litecoin': 'LTC',
299
+ 'Matic Network': 'MATIC',
300
+ 'xDai': 'STAKE',
301
+ 'Akash': 'AKT',
289
302
  },
290
303
  },
291
304
  'exceptions': {
@@ -2375,8 +2388,8 @@ class ascendex extends ascendex$1 {
2375
2388
  const tag = this.safeString(depositAddress, tagId);
2376
2389
  this.checkAddress(address);
2377
2390
  const code = (currency === undefined) ? undefined : currency['code'];
2378
- const chainName = this.safeString(depositAddress, 'chainName');
2379
- const network = this.safeNetwork(chainName);
2391
+ const chainName = this.safeString(depositAddress, 'blockchain');
2392
+ const network = this.networkIdToCode(chainName, code);
2380
2393
  return {
2381
2394
  'currency': code,
2382
2395
  'address': address,
@@ -2386,20 +2399,7 @@ class ascendex extends ascendex$1 {
2386
2399
  };
2387
2400
  }
2388
2401
  safeNetwork(networkId) {
2389
- const networksById = {
2390
- 'TRC20': 'TRC20',
2391
- 'ERC20': 'ERC20',
2392
- 'GO20': 'GO20',
2393
- 'BEP2': 'BEP2',
2394
- 'BEP20 (BSC)': 'BEP20',
2395
- 'Bitcoin': 'BTC',
2396
- 'Bitcoin ABC': 'BCH',
2397
- 'Litecoin': 'LTC',
2398
- 'Matic Network': 'MATIC',
2399
- 'Solana': 'SOL',
2400
- 'xDai': 'STAKE',
2401
- 'Akash': 'AKT',
2402
- };
2402
+ const networksById = this.safeDict(this.options, 'networksById');
2403
2403
  return this.safeString(networksById, networkId, networkId);
2404
2404
  }
2405
2405
  async fetchDepositAddress(code, params = {}) {
@@ -2407,16 +2407,20 @@ class ascendex extends ascendex$1 {
2407
2407
  * @method
2408
2408
  * @name ascendex#fetchDepositAddress
2409
2409
  * @description fetch the deposit address for a currency associated with this account
2410
+ * @see https://ascendex.github.io/ascendex-pro-api/#query-deposit-addresses
2410
2411
  * @param {string} code unified currency code
2411
2412
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2413
+ * @param {string} [params.network] unified network code for deposit chain
2412
2414
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2413
2415
  */
2414
2416
  await this.loadMarkets();
2415
2417
  const currency = this.currency(code);
2416
- const chainName = this.safeString(params, 'chainName');
2417
- params = this.omit(params, 'chainName');
2418
+ const networkCode = this.safeString2(params, 'network', 'chainName');
2419
+ const networkId = this.networkCodeToId(networkCode);
2420
+ params = this.omit(params, ['chainName']);
2418
2421
  const request = {
2419
2422
  'asset': currency['id'],
2423
+ 'blockchain': networkId,
2420
2424
  };
2421
2425
  const response = await this.v1PrivateGetWalletDepositAddress(this.extend(request, params));
2422
2426
  //
@@ -2452,22 +2456,22 @@ class ascendex extends ascendex$1 {
2452
2456
  // }
2453
2457
  // }
2454
2458
  //
2455
- const data = this.safeValue(response, 'data', {});
2456
- const addresses = this.safeValue(data, 'address', []);
2459
+ const data = this.safeDict(response, 'data', {});
2460
+ const addresses = this.safeList(data, 'address', []);
2457
2461
  const numAddresses = addresses.length;
2458
2462
  let address = undefined;
2459
2463
  if (numAddresses > 1) {
2460
2464
  const addressesByChainName = this.indexBy(addresses, 'chainName');
2461
- if (chainName === undefined) {
2465
+ if (networkId === undefined) {
2462
2466
  const chainNames = Object.keys(addressesByChainName);
2463
2467
  const chains = chainNames.join(', ');
2464
2468
  throw new errors.ArgumentsRequired(this.id + ' fetchDepositAddress() returned more than one address, a chainName parameter is required, one of ' + chains);
2465
2469
  }
2466
- address = this.safeValue(addressesByChainName, chainName, {});
2470
+ address = this.safeDict(addressesByChainName, networkId, {});
2467
2471
  }
2468
2472
  else {
2469
2473
  // first address
2470
- address = this.safeValue(addresses, 0, {});
2474
+ address = this.safeDict(addresses, 0, {});
2471
2475
  }
2472
2476
  const result = this.parseDepositAddress(address, currency);
2473
2477
  return this.extend(result, {
@@ -1936,6 +1936,18 @@ class Exchange {
1936
1936
  async setLeverage(leverage, symbol = undefined, params = {}) {
1937
1937
  throw new errors.NotSupported(this.id + ' setLeverage() is not supported yet');
1938
1938
  }
1939
+ async fetchLeverage(symbol, params = {}) {
1940
+ throw new errors.NotSupported(this.id + ' fetchLeverage() is not supported yet');
1941
+ }
1942
+ async setPositionMode(hedged, symbol = undefined, params = {}) {
1943
+ throw new errors.NotSupported(this.id + ' setPositionMode() is not supported yet');
1944
+ }
1945
+ async setMarginMode(marginMode, symbol = undefined, params = {}) {
1946
+ throw new errors.NotSupported(this.id + ' setMarginMode() is not supported yet');
1947
+ }
1948
+ async fetchDepositAddressesByNetwork(code, params = {}) {
1949
+ throw new errors.NotSupported(this.id + ' fetchDepositAddressesByNetwork() is not supported yet');
1950
+ }
1939
1951
  async fetchOpenInterestHistory(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
1940
1952
  throw new errors.NotSupported(this.id + ' fetchOpenInterestHistory() is not supported yet');
1941
1953
  }
@@ -3162,11 +3174,11 @@ class Exchange {
3162
3174
  * @param {string|undefined} currencyCode unified currency code, but this argument is not required by default, unless there is an exchange (like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
3163
3175
  * @returns {string|undefined} unified network code
3164
3176
  */
3165
- const networkCodesByIds = this.safeValue(this.options, 'networksById', {});
3177
+ const networkCodesByIds = this.safeDict(this.options, 'networksById', {});
3166
3178
  let networkCode = this.safeString(networkCodesByIds, networkId, networkId);
3167
3179
  // replace mainnet network-codes (i.e. ERC20->ETH)
3168
3180
  if (currencyCode !== undefined) {
3169
- const defaultNetworkCodeReplacements = this.safeValue(this.options, 'defaultNetworkCodeReplacements', {});
3181
+ const defaultNetworkCodeReplacements = this.safeDict(this.options, 'defaultNetworkCodeReplacements', {});
3170
3182
  if (currencyCode in defaultNetworkCodeReplacements) {
3171
3183
  const replacementObject = this.safeDict(defaultNetworkCodeReplacements, currencyCode, {});
3172
3184
  networkCode = this.safeString(replacementObject, networkCode, networkCode);
@@ -3184,14 +3196,14 @@ class Exchange {
3184
3196
  }
3185
3197
  defaultNetworkCode(currencyCode) {
3186
3198
  let defaultNetworkCode = undefined;
3187
- const defaultNetworks = this.safeValue(this.options, 'defaultNetworks', {});
3199
+ const defaultNetworks = this.safeDict(this.options, 'defaultNetworks', {});
3188
3200
  if (currencyCode in defaultNetworks) {
3189
3201
  // if currency had set its network in "defaultNetworks", use it
3190
3202
  defaultNetworkCode = defaultNetworks[currencyCode];
3191
3203
  }
3192
3204
  else {
3193
3205
  // 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)
3194
- const defaultNetwork = this.safeValue(this.options, 'defaultNetwork');
3206
+ const defaultNetwork = this.safeDict(this.options, 'defaultNetwork');
3195
3207
  if (defaultNetwork !== undefined) {
3196
3208
  defaultNetworkCode = defaultNetwork;
3197
3209
  }
@@ -3696,14 +3708,14 @@ class Exchange {
3696
3708
  throw new errors.NotSupported(this.id + ' fetchStatus() is not supported yet');
3697
3709
  }
3698
3710
  async fetchFundingFee(code, params = {}) {
3699
- const warnOnFetchFundingFee = this.safeValue(this.options, 'warnOnFetchFundingFee', true);
3711
+ const warnOnFetchFundingFee = this.safeBool(this.options, 'warnOnFetchFundingFee', true);
3700
3712
  if (warnOnFetchFundingFee) {
3701
3713
  throw new errors.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');
3702
3714
  }
3703
3715
  return await this.fetchTransactionFee(code, params);
3704
3716
  }
3705
3717
  async fetchFundingFees(codes = undefined, params = {}) {
3706
- const warnOnFetchFundingFees = this.safeValue(this.options, 'warnOnFetchFundingFees', true);
3718
+ const warnOnFetchFundingFees = this.safeBool(this.options, 'warnOnFetchFundingFees', true);
3707
3719
  if (warnOnFetchFundingFees) {
3708
3720
  throw new errors.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');
3709
3721
  }
@@ -3754,7 +3766,7 @@ class Exchange {
3754
3766
  throw new errors.NotSupported(this.id + ' fetchIsolatedBorrowRate() is not supported yet');
3755
3767
  }
3756
3768
  const borrowRates = await this.fetchIsolatedBorrowRates(params);
3757
- const rate = this.safeValue(borrowRates, symbol);
3769
+ const rate = this.safeDict(borrowRates, symbol);
3758
3770
  if (rate === undefined) {
3759
3771
  throw new errors.ExchangeError(this.id + ' fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ' + symbol);
3760
3772
  }
@@ -3815,7 +3827,7 @@ class Exchange {
3815
3827
  }
3816
3828
  handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
3817
3829
  const defaultType = this.safeString2(this.options, 'defaultType', 'type', 'spot');
3818
- const methodOptions = this.safeValue(this.options, methodName);
3830
+ const methodOptions = this.safeDict(this.options, methodName);
3819
3831
  let methodType = defaultType;
3820
3832
  if (methodOptions !== undefined) {
3821
3833
  if (typeof methodOptions === 'string') {
@@ -3851,7 +3863,7 @@ class Exchange {
3851
3863
  }
3852
3864
  // if it was not defined in market object
3853
3865
  if (subType === undefined) {
3854
- const values = this.handleOptionAndParams(undefined, methodName, 'subType', defaultValue); // no need to re-test params here
3866
+ const values = this.handleOptionAndParams({}, methodName, 'subType', defaultValue); // no need to re-test params here
3855
3867
  subType = values[0];
3856
3868
  }
3857
3869
  }
@@ -3907,7 +3919,7 @@ class Exchange {
3907
3919
  const market = this.market(symbol);
3908
3920
  symbol = market['symbol'];
3909
3921
  const tickers = await this.fetchTickers([symbol], params);
3910
- const ticker = this.safeValue(tickers, symbol);
3922
+ const ticker = this.safeDict(tickers, symbol);
3911
3923
  if (ticker === undefined) {
3912
3924
  throw new errors.NullResponse(this.id + ' fetchTickers() could not find a ticker for ' + symbol);
3913
3925
  }
@@ -3944,7 +3956,7 @@ class Exchange {
3944
3956
  return order['status'];
3945
3957
  }
3946
3958
  async fetchUnifiedOrder(order, params = {}) {
3947
- return await this.fetchOrder(this.safeValue(order, 'id'), this.safeValue(order, 'symbol'), params);
3959
+ return await this.fetchOrder(this.safeString(order, 'id'), this.safeString(order, 'symbol'), params);
3948
3960
  }
3949
3961
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
3950
3962
  throw new errors.NotSupported(this.id + ' createOrder() is not supported yet');
@@ -4214,7 +4226,7 @@ class Exchange {
4214
4226
  throw new errors.NotSupported(this.id + ' cancelAllOrdersWs() is not supported yet');
4215
4227
  }
4216
4228
  async cancelUnifiedOrder(order, params = {}) {
4217
- return this.cancelOrder(this.safeValue(order, 'id'), this.safeValue(order, 'symbol'), params);
4229
+ return this.cancelOrder(this.safeString(order, 'id'), this.safeString(order, 'symbol'), params);
4218
4230
  }
4219
4231
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4220
4232
  if (this.has['fetchOpenOrders'] && this.has['fetchClosedOrders']) {
@@ -4706,7 +4718,7 @@ class Exchange {
4706
4718
  return result;
4707
4719
  }
4708
4720
  isTriggerOrder(params) {
4709
- const isTrigger = this.safeValue2(params, 'trigger', 'stop');
4721
+ const isTrigger = this.safeBool2(params, 'trigger', 'stop');
4710
4722
  if (isTrigger) {
4711
4723
  params = this.omit(params, ['trigger', 'stop']);
4712
4724
  }
@@ -4722,7 +4734,7 @@ class Exchange {
4722
4734
  * @returns {boolean} true if a post only order, false otherwise
4723
4735
  */
4724
4736
  const timeInForce = this.safeStringUpper(params, 'timeInForce');
4725
- let postOnly = this.safeValue2(params, 'postOnly', 'post_only', false);
4737
+ let postOnly = this.safeBool2(params, 'postOnly', 'post_only', false);
4726
4738
  // we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
4727
4739
  const ioc = timeInForce === 'IOC';
4728
4740
  const fok = timeInForce === 'FOK';
@@ -4916,7 +4928,7 @@ class Exchange {
4916
4928
  * @param {string} account key for account name in this.options['accountsByType']
4917
4929
  * @returns the exchange specific account name or the isolated margin id for transfers
4918
4930
  */
4919
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
4931
+ const accountsByType = this.safeDict(this.options, 'accountsByType', {});
4920
4932
  const lowercaseAccount = account.toLowerCase();
4921
4933
  if (lowercaseAccount in accountsByType) {
4922
4934
  return accountsByType[lowercaseAccount];
@@ -5393,7 +5405,7 @@ class Exchange {
5393
5405
  return input;
5394
5406
  }
5395
5407
  handleUntilOption(key, request, params, multiplier = 1) {
5396
- const until = this.safeValue2(params, 'until', 'till');
5408
+ const until = this.safeInteger2(params, 'until', 'till');
5397
5409
  if (until !== undefined) {
5398
5410
  request[key] = this.parseToInt(until * multiplier);
5399
5411
  params = this.omit(params, ['until', 'till']);