ccxt 4.2.98 → 4.2.100

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.
package/README.md CHANGED
@@ -212,13 +212,13 @@ console.log(version, Object.keys(exchanges));
212
212
 
213
213
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
214
214
 
215
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.98/dist/ccxt.browser.js
216
- * unpkg: https://unpkg.com/ccxt@4.2.98/dist/ccxt.browser.js
215
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.100/dist/ccxt.browser.js
216
+ * unpkg: https://unpkg.com/ccxt@4.2.100/dist/ccxt.browser.js
217
217
 
218
218
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
219
219
 
220
220
  ```HTML
221
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.98/dist/ccxt.browser.js"></script>
221
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.100/dist/ccxt.browser.js"></script>
222
222
  ```
223
223
 
224
224
  Creates a global `ccxt` object:
@@ -4046,7 +4046,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
4046
4046
  '300013': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
4047
4047
  '300014': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
4048
4048
  '300020': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
4049
- '300021': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
4049
+ '300021': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
4050
4050
  '300031': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
4051
4051
  '310001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
4052
4052
  '310002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
@@ -96132,6 +96132,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96132
96132
  const contractExpiryType = this.safeString(futureProductDetails, 'contract_expiry_type');
96133
96133
  const contractSize = this.safeNumber(futureProductDetails, 'contract_size');
96134
96134
  const contractExpire = this.safeString(futureProductDetails, 'contract_expiry');
96135
+ const expireTimestamp = this.parse8601(contractExpire);
96135
96136
  const isSwap = (contractExpiryType === 'PERPETUAL');
96136
96137
  const baseId = this.safeString(futureProductDetails, 'contract_root_unit');
96137
96138
  const quoteId = this.safeString(market, 'quote_currency_id');
@@ -96146,7 +96147,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96146
96147
  }
96147
96148
  else {
96148
96149
  type = 'future';
96149
- symbol = symbol + ':' + quote + '-' + this.yymmdd(contractExpire);
96150
+ symbol = symbol + ':' + quote + '-' + this.yymmdd(expireTimestamp);
96150
96151
  }
96151
96152
  const takerFeeRate = this.safeNumber(feeTier, 'taker_fee_rate');
96152
96153
  const makerFeeRate = this.safeNumber(feeTier, 'maker_fee_rate');
@@ -96174,7 +96175,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96174
96175
  'taker': taker,
96175
96176
  'maker': maker,
96176
96177
  'contractSize': contractSize,
96177
- 'expiry': this.parse8601(contractExpire),
96178
+ 'expiry': expireTimestamp,
96178
96179
  'expiryDatetime': contractExpire,
96179
96180
  'strike': undefined,
96180
96181
  'optionType': undefined,
@@ -98961,6 +98962,33 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
98961
98962
  'takeProfitPrice': undefined,
98962
98963
  });
98963
98964
  }
98965
+ createAuthToken(seconds, method = undefined, url = undefined) {
98966
+ // it may not work for v2
98967
+ let uri = undefined;
98968
+ if (url !== undefined) {
98969
+ uri = method + ' ' + url.replace('https://', '');
98970
+ const quesPos = uri.indexOf('?');
98971
+ // Due to we use mb_strpos, quesPos could be false in php. In that case, the quesPos >= 0 is true
98972
+ // Also it's not possible that the question mark is first character, only check > 0 here.
98973
+ if (quesPos > 0) {
98974
+ uri = uri.slice(0, quesPos);
98975
+ }
98976
+ }
98977
+ const nonce = this.randomBytes(16);
98978
+ const request = {
98979
+ 'aud': ['retail_rest_api_proxy'],
98980
+ 'iss': 'coinbase-cloud',
98981
+ 'nbf': seconds,
98982
+ 'exp': seconds + 120,
98983
+ 'sub': this.apiKey,
98984
+ 'iat': seconds,
98985
+ };
98986
+ if (uri !== undefined) {
98987
+ request['uri'] = uri;
98988
+ }
98989
+ const token = (0,_base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__/* .jwt */ .F)(request, this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J, false, { 'kid': this.apiKey, 'nonce': nonce, 'alg': 'ES256' });
98990
+ return token;
98991
+ }
98964
98992
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
98965
98993
  const version = api[0];
98966
98994
  const signed = api[1] === 'private';
@@ -99010,25 +99038,26 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
99010
99038
  if (this.apiKey.startsWith('-----BEGIN')) {
99011
99039
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
99012
99040
  }
99013
- // it may not work for v2
99014
- let uri = method + ' ' + url.replace('https://', '');
99015
- const quesPos = uri.indexOf('?');
99016
- // Due to we use mb_strpos, quesPos could be false in php. In that case, the quesPos >= 0 is true
99017
- // Also it's not possible that the question mark is first character, only check > 0 here.
99018
- if (quesPos > 0) {
99019
- uri = uri.slice(0, quesPos);
99020
- }
99021
- const nonce = this.randomBytes(16);
99022
- const request = {
99023
- 'aud': ['retail_rest_api_proxy'],
99024
- 'iss': 'coinbase-cloud',
99025
- 'nbf': seconds,
99026
- 'exp': seconds + 120,
99027
- 'sub': this.apiKey,
99028
- 'uri': uri,
99029
- 'iat': seconds,
99030
- };
99031
- const token = (0,_base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__/* .jwt */ .F)(request, this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J, false, { 'kid': this.apiKey, 'nonce': nonce, 'alg': 'ES256' });
99041
+ // // it may not work for v2
99042
+ // let uri = method + ' ' + url.replace ('https://', '');
99043
+ // const quesPos = uri.indexOf ('?');
99044
+ // // Due to we use mb_strpos, quesPos could be false in php. In that case, the quesPos >= 0 is true
99045
+ // // Also it's not possible that the question mark is first character, only check > 0 here.
99046
+ // if (quesPos > 0) {
99047
+ // uri = uri.slice (0, quesPos);
99048
+ // }
99049
+ // const nonce = this.randomBytes (16);
99050
+ // const request = {
99051
+ // 'aud': [ 'retail_rest_api_proxy' ],
99052
+ // 'iss': 'coinbase-cloud',
99053
+ // 'nbf': seconds,
99054
+ // 'exp': seconds + 120,
99055
+ // 'sub': this.apiKey,
99056
+ // 'uri': uri,
99057
+ // 'iat': seconds,
99058
+ // };
99059
+ const token = this.createAuthToken(seconds, method, url);
99060
+ // const token = jwt (request, this.encode (this.secret), sha256, false, { 'kid': this.apiKey, 'nonce': nonce, 'alg': 'ES256' });
99032
99061
  authorizationString = 'Bearer ' + token;
99033
99062
  }
99034
99063
  else {
@@ -172228,9 +172257,10 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172228
172257
  // }
172229
172258
  //
172230
172259
  const description = this.safeDict(order, 'descr', {});
172260
+ const orderDescriptionObj = this.safeDict(order, 'descr'); // can be null
172231
172261
  let orderDescription = undefined;
172232
- if (description !== undefined) {
172233
- orderDescription = this.safeString(description, 'order');
172262
+ if (orderDescriptionObj !== undefined) {
172263
+ orderDescription = this.safeString(orderDescriptionObj, 'order');
172234
172264
  }
172235
172265
  else {
172236
172266
  orderDescription = this.safeString(order, 'descr');
@@ -172305,8 +172335,8 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172305
172335
  }
172306
172336
  const status = this.parseOrderStatus(this.safeString(order, 'status'));
172307
172337
  let id = this.safeString2(order, 'id', 'txid');
172308
- if ((id === undefined) || (id.slice(0, 1) === '[')) {
172309
- const txid = this.safeValue(order, 'txid');
172338
+ if ((id === undefined) || (id.startsWith('['))) {
172339
+ const txid = this.safeList(order, 'txid');
172310
172340
  id = this.safeString(txid, 0);
172311
172341
  }
172312
172342
  const clientOrderId = this.safeString(order, 'userref');
@@ -177583,10 +177613,10 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
177583
177613
  // }
177584
177614
  //
177585
177615
  const responses = await Promise.all(promises);
177586
- const currenciesResponse = this.safeValue(responses, 0, {});
177587
- const currenciesData = this.safeValue(currenciesResponse, 'data', []);
177588
- const additionalResponse = this.safeValue(responses, 1, {});
177589
- const additionalData = this.safeValue(additionalResponse, 'data', []);
177616
+ const currenciesResponse = this.safeDict(responses, 0, {});
177617
+ const currenciesData = this.safeList(currenciesResponse, 'data', []);
177618
+ const additionalResponse = this.safeDict(responses, 1, {});
177619
+ const additionalData = this.safeList(additionalResponse, 'data', []);
177590
177620
  const additionalDataGrouped = this.groupBy(additionalData, 'currency');
177591
177621
  const result = {};
177592
177622
  for (let i = 0; i < currenciesData.length; i++) {
@@ -177598,7 +177628,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
177598
177628
  let isDepositEnabled = undefined;
177599
177629
  const networks = {};
177600
177630
  const chains = this.safeList(entry, 'chains', []);
177601
- const extraChainsData = this.indexBy(this.safeValue(additionalDataGrouped, id, []), 'chain');
177631
+ const extraChainsData = this.indexBy(this.safeList(additionalDataGrouped, id, []), 'chain');
177602
177632
  const rawPrecision = this.safeString(entry, 'precision');
177603
177633
  const precision = this.parseNumber(this.parsePrecision(rawPrecision));
177604
177634
  const chainsLength = chains.length;
@@ -177739,7 +177769,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
177739
177769
  request['chain'] = this.networkCodeToId(networkCode).toLowerCase();
177740
177770
  }
177741
177771
  const response = await this.privateGetWithdrawalsQuotas(this.extend(request, params));
177742
- const data = this.safeValue(response, 'data');
177772
+ const data = this.safeDict(response, 'data', {});
177743
177773
  const withdrawFees = {};
177744
177774
  withdrawFees[code] = this.safeNumber(data, 'withdrawMinFee');
177745
177775
  return {
@@ -248913,8 +248943,8 @@ class cex extends _cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
248913
248943
  /* harmony export */ Z: () => (/* binding */ coinbase)
248914
248944
  /* harmony export */ });
248915
248945
  /* harmony import */ var _coinbase_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(437);
248916
- /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6689);
248917
- /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3020);
248946
+ /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
248947
+ /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3020);
248918
248948
  /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1372);
248919
248949
  // ---------------------------------------------------------------------------
248920
248950
 
@@ -248990,15 +249020,36 @@ class coinbase extends _coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
248990
249020
  }
248991
249021
  const url = this.urls['api']['ws'];
248992
249022
  const timestamp = this.numberToString(this.seconds());
249023
+ const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
248993
249024
  const auth = timestamp + name + productIds.join(',');
248994
249025
  const subscribe = {
248995
249026
  'type': 'subscribe',
248996
249027
  'product_ids': productIds,
248997
249028
  'channel': name,
248998
- 'api_key': this.apiKey,
248999
- 'timestamp': timestamp,
249000
- 'signature': this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_1__/* .sha256 */ .J),
249029
+ // 'api_key': this.apiKey,
249030
+ // 'timestamp': timestamp,
249031
+ // 'signature': this.hmac (this.encode (auth), this.encode (this.secret), sha256),
249001
249032
  };
249033
+ if (!isCloudAPiKey) {
249034
+ subscribe['api_key'] = this.apiKey;
249035
+ subscribe['timestamp'] = timestamp;
249036
+ subscribe['signature'] = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_1__/* .sha256 */ .J);
249037
+ }
249038
+ else {
249039
+ if (this.apiKey.startsWith('-----BEGIN')) {
249040
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
249041
+ }
249042
+ const currentToken = this.safeString(this.options, 'wsToken');
249043
+ const tokenTimestamp = this.safeInteger(this.options, 'wsTokenTimestamp', 0);
249044
+ const seconds = this.seconds();
249045
+ if (currentToken === undefined || tokenTimestamp + 120 < seconds) {
249046
+ // we should generate new token
249047
+ const token = this.createAuthToken(seconds);
249048
+ this.options['wsToken'] = token;
249049
+ this.options['wsTokenTimestamp'] = seconds;
249050
+ }
249051
+ subscribe['jwt'] = this.safeString(this.options, 'wsToken');
249052
+ }
249002
249053
  return await this.watch(url, messageHash, subscribe, messageHash);
249003
249054
  }
249004
249055
  async watchTicker(symbol, params = {}) {
@@ -249270,7 +249321,7 @@ class coinbase extends _coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
249270
249321
  let tradesArray = this.safeValue(this.trades, symbol);
249271
249322
  if (tradesArray === undefined) {
249272
249323
  const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
249273
- tradesArray = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(tradesLimit);
249324
+ tradesArray = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolById */ .hl(tradesLimit);
249274
249325
  this.trades[symbol] = tradesArray;
249275
249326
  }
249276
249327
  for (let i = 0; i < events.length; i++) {
@@ -249320,7 +249371,7 @@ class coinbase extends _coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
249320
249371
  const marketIds = [];
249321
249372
  if (this.orders === undefined) {
249322
249373
  const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
249323
- this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
249374
+ this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolById */ .hl(limit);
249324
249375
  }
249325
249376
  for (let i = 0; i < events.length; i++) {
249326
249377
  const event = events[i];
@@ -249500,7 +249551,7 @@ class coinbase extends _coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
249500
249551
  const type = this.safeString(message, 'type');
249501
249552
  if (type === 'error') {
249502
249553
  const errorMessage = this.safeString(message, 'message');
249503
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError(errorMessage);
249554
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(errorMessage);
249504
249555
  }
249505
249556
  const method = this.safeValue(methods, channel);
249506
249557
  method.call(this, client, message);
@@ -326840,7 +326891,7 @@ SOFTWARE.
326840
326891
 
326841
326892
  //-----------------------------------------------------------------------------
326842
326893
  // this is updated by vss.js when building
326843
- const version = '4.2.98';
326894
+ const version = '4.2.100';
326844
326895
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
326845
326896
  //-----------------------------------------------------------------------------
326846
326897