ccxt 4.3.14 → 4.3.16

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 (92) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +3 -3
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/alpaca.js +1 -0
  5. package/dist/cjs/src/ascendex.js +1 -0
  6. package/dist/cjs/src/base/Exchange.js +30 -21
  7. package/dist/cjs/src/base/errors.js +8 -1
  8. package/dist/cjs/src/base/functions/misc.js +2 -2
  9. package/dist/cjs/src/base/ws/Client.js +2 -1
  10. package/dist/cjs/src/base/ws/WsClient.js +4 -0
  11. package/dist/cjs/src/binance.js +4 -3
  12. package/dist/cjs/src/bingx.js +2 -0
  13. package/dist/cjs/src/bitmex.js +1 -0
  14. package/dist/cjs/src/bybit.js +7 -6
  15. package/dist/cjs/src/coinbaseinternational.js +1 -0
  16. package/dist/cjs/src/coinex.js +36 -35
  17. package/dist/cjs/src/coinmetro.js +1 -0
  18. package/dist/cjs/src/cryptocom.js +3 -1
  19. package/dist/cjs/src/currencycom.js +1 -0
  20. package/dist/cjs/src/deribit.js +1 -0
  21. package/dist/cjs/src/gate.js +1 -0
  22. package/dist/cjs/src/gemini.js +1 -0
  23. package/dist/cjs/src/hitbtc.js +2 -0
  24. package/dist/cjs/src/hollaex.js +1 -0
  25. package/dist/cjs/src/hyperliquid.js +5 -0
  26. package/dist/cjs/src/idex.js +1 -0
  27. package/dist/cjs/src/krakenfutures.js +1 -0
  28. package/dist/cjs/src/luno.js +2 -0
  29. package/dist/cjs/src/ndax.js +1 -0
  30. package/dist/cjs/src/okx.js +1 -0
  31. package/dist/cjs/src/phemex.js +2 -1
  32. package/dist/cjs/src/poloniex.js +1 -0
  33. package/dist/cjs/src/pro/hitbtc.js +1 -1
  34. package/dist/cjs/src/pro/independentreserve.js +3 -3
  35. package/dist/cjs/src/pro/poloniex.js +3 -3
  36. package/dist/cjs/src/probit.js +1 -0
  37. package/dist/cjs/src/wavesexchange.js +1 -0
  38. package/dist/cjs/src/woo.js +1 -0
  39. package/dist/cjs/src/zaif.js +1 -1
  40. package/js/ccxt.d.ts +3 -3
  41. package/js/ccxt.js +3 -3
  42. package/js/src/abstract/luno.d.ts +2 -0
  43. package/js/src/alpaca.d.ts +1 -1
  44. package/js/src/alpaca.js +1 -0
  45. package/js/src/ascendex.js +1 -0
  46. package/js/src/base/Exchange.d.ts +5 -4
  47. package/js/src/base/Exchange.js +30 -21
  48. package/js/src/base/errorHierarchy.d.ts +1 -0
  49. package/js/src/base/errorHierarchy.js +1 -0
  50. package/js/src/base/errors.d.ts +41 -37
  51. package/js/src/base/errors.js +8 -2
  52. package/js/src/base/functions/misc.d.ts +5 -4
  53. package/js/src/base/functions/misc.js +2 -2
  54. package/js/src/base/functions/number.d.ts +5 -5
  55. package/js/src/base/ws/Client.d.ts +8 -7
  56. package/js/src/base/ws/Client.js +2 -1
  57. package/js/src/base/ws/WsClient.d.ts +1 -1
  58. package/js/src/base/ws/WsClient.js +4 -0
  59. package/js/src/binance.js +5 -4
  60. package/js/src/bingx.d.ts +1 -1
  61. package/js/src/bingx.js +2 -0
  62. package/js/src/bitmex.js +1 -0
  63. package/js/src/bybit.js +7 -6
  64. package/js/src/coinbaseinternational.js +1 -0
  65. package/js/src/coinex.js +36 -35
  66. package/js/src/coinmetro.js +1 -0
  67. package/js/src/cryptocom.js +3 -1
  68. package/js/src/currencycom.js +1 -0
  69. package/js/src/deribit.js +1 -0
  70. package/js/src/gate.js +1 -0
  71. package/js/src/gemini.js +1 -0
  72. package/js/src/hitbtc.js +2 -0
  73. package/js/src/hollaex.js +1 -0
  74. package/js/src/hyperliquid.js +5 -0
  75. package/js/src/idex.js +1 -0
  76. package/js/src/krakenfutures.js +1 -0
  77. package/js/src/luno.js +2 -0
  78. package/js/src/ndax.js +1 -0
  79. package/js/src/okx.js +1 -0
  80. package/js/src/phemex.js +2 -1
  81. package/js/src/poloniex.js +1 -0
  82. package/js/src/pro/hitbtc.js +1 -1
  83. package/js/src/pro/independentreserve.js +3 -3
  84. package/js/src/pro/poloniex.js +3 -3
  85. package/js/src/probit.js +1 -0
  86. package/js/src/upbit.d.ts +1 -1
  87. package/js/src/wavesexchange.js +1 -0
  88. package/js/src/woo.d.ts +1 -1
  89. package/js/src/woo.js +1 -0
  90. package/js/src/zaif.js +1 -1
  91. package/js/src/zonda.d.ts +1 -1
  92. package/package.json +1 -1
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © 2022 Igor Kroitor
3
+ Copyright © 2024 Igor Kroitor
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -213,13 +213,13 @@ console.log(version, Object.keys(exchanges));
213
213
 
214
214
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
215
215
 
216
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.14/dist/ccxt.browser.js
217
- * unpkg: https://unpkg.com/ccxt@4.3.14/dist/ccxt.browser.js
216
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.16/dist/ccxt.browser.js
217
+ * unpkg: https://unpkg.com/ccxt@4.3.16/dist/ccxt.browser.js
218
218
 
219
219
  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.
220
220
 
221
221
  ```HTML
222
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.14/dist/ccxt.browser.js"></script>
222
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.16/dist/ccxt.browser.js"></script>
223
223
  ```
224
224
 
225
225
  Creates a global `ccxt` object:
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.3.14';
185
+ const version = '4.3.16';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -385,6 +385,7 @@ exports.InvalidAddress = errors.InvalidAddress;
385
385
  exports.InvalidNonce = errors.InvalidNonce;
386
386
  exports.InvalidOrder = errors.InvalidOrder;
387
387
  exports.MarginModeAlreadySet = errors.MarginModeAlreadySet;
388
+ exports.MarketClosed = errors.MarketClosed;
388
389
  exports.NetworkError = errors.NetworkError;
389
390
  exports.NoChange = errors.NoChange;
390
391
  exports.NotSupported = errors.NotSupported;
@@ -89,6 +89,7 @@ class alpaca extends alpaca$1 {
89
89
  'fetchTransactions': false,
90
90
  'fetchTransfers': false,
91
91
  'fetchWithdrawals': false,
92
+ 'sandbox': true,
92
93
  'setLeverage': false,
93
94
  'setMarginMode': false,
94
95
  'transfer': false,
@@ -91,6 +91,7 @@ class ascendex extends ascendex$1 {
91
91
  'fetchWithdrawal': false,
92
92
  'fetchWithdrawals': true,
93
93
  'reduceMargin': true,
94
+ 'sandbox': true,
94
95
  'setLeverage': true,
95
96
  'setMarginMode': true,
96
97
  'setPositionMode': false,
@@ -366,6 +366,7 @@ class Exchange {
366
366
  'publicAPI': true,
367
367
  'privateAPI': true,
368
368
  'CORS': undefined,
369
+ 'sandbox': undefined,
369
370
  'spot': undefined,
370
371
  'margin': undefined,
371
372
  'swap': undefined,
@@ -3058,15 +3059,15 @@ class Exchange {
3058
3059
  // timestamp and symbol operations don't belong in safeTicker
3059
3060
  // they should be done in the derived classes
3060
3061
  return this.extend(ticker, {
3061
- 'bid': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'bid'))),
3062
+ 'bid': this.parseNumber(this.omitZero(this.safeString(ticker, 'bid'))),
3062
3063
  'bidVolume': this.safeNumber(ticker, 'bidVolume'),
3063
- 'ask': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'ask'))),
3064
+ 'ask': this.parseNumber(this.omitZero(this.safeString(ticker, 'ask'))),
3064
3065
  'askVolume': this.safeNumber(ticker, 'askVolume'),
3065
3066
  'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high'))),
3066
- 'low': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'low'))),
3067
- 'open': this.parseNumber(this.omitZero(this.parseNumber(open))),
3068
- 'close': this.parseNumber(this.omitZero(this.parseNumber(close))),
3069
- 'last': this.parseNumber(this.omitZero(this.parseNumber(last))),
3067
+ 'low': this.parseNumber(this.omitZero(this.safeString(ticker, 'low'))),
3068
+ 'open': this.parseNumber(this.omitZero(open)),
3069
+ 'close': this.parseNumber(this.omitZero(close)),
3070
+ 'last': this.parseNumber(this.omitZero(last)),
3070
3071
  'change': this.parseNumber(change),
3071
3072
  'percentage': this.parseNumber(percentage),
3072
3073
  'average': this.parseNumber(average),
@@ -5848,24 +5849,26 @@ class Exchange {
5848
5849
  let maxRetries = undefined;
5849
5850
  [maxRetries, params] = this.handleOptionAndParams(params, method, 'maxRetries', 3);
5850
5851
  let errors$1 = 0;
5851
- try {
5852
- if (timeframe && method !== 'fetchFundingRateHistory') {
5853
- return await this[method](symbol, timeframe, since, limit, params);
5854
- }
5855
- else {
5856
- return await this[method](symbol, since, limit, params);
5857
- }
5858
- }
5859
- catch (e) {
5860
- if (e instanceof errors.RateLimitExceeded) {
5861
- throw e; // if we are rate limited, we should not retry and fail fast
5852
+ while (errors$1 <= maxRetries) {
5853
+ try {
5854
+ if (timeframe && method !== 'fetchFundingRateHistory') {
5855
+ return await this[method](symbol, timeframe, since, limit, params);
5856
+ }
5857
+ else {
5858
+ return await this[method](symbol, since, limit, params);
5859
+ }
5862
5860
  }
5863
- errors$1 += 1;
5864
- if (errors$1 > maxRetries) {
5865
- throw e;
5861
+ catch (e) {
5862
+ if (e instanceof errors.RateLimitExceeded) {
5863
+ throw e; // if we are rate limited, we should not retry and fail fast
5864
+ }
5865
+ errors$1 += 1;
5866
+ if (errors$1 > maxRetries) {
5867
+ throw e;
5868
+ }
5866
5869
  }
5867
5870
  }
5868
- return undefined;
5871
+ return [];
5869
5872
  }
5870
5873
  async fetchPaginatedCallDeterministic(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}, maxEntriesPerRequest = undefined) {
5871
5874
  let maxCalls = undefined;
@@ -5879,6 +5882,9 @@ class Exchange {
5879
5882
  if (since !== undefined) {
5880
5883
  currentSince = Math.max(currentSince, since);
5881
5884
  }
5885
+ else {
5886
+ currentSince = Math.max(currentSince, 1241440531000); // avoid timestamps older than 2009
5887
+ }
5882
5888
  const until = this.safeInteger2(params, 'until', 'till'); // do not omit it here
5883
5889
  if (until !== undefined) {
5884
5890
  const requiredCalls = Math.ceil((until - since) / step);
@@ -5890,6 +5896,9 @@ class Exchange {
5890
5896
  if ((until !== undefined) && (currentSince >= until)) {
5891
5897
  break;
5892
5898
  }
5899
+ if (currentSince >= current) {
5900
+ break;
5901
+ }
5893
5902
  tasks.push(this.safeDeterministicCall(method, symbol, currentSince, maxEntriesPerRequest, timeframe, params));
5894
5903
  currentSince = this.sum(currentSince, step) - 1;
5895
5904
  }
@@ -75,6 +75,12 @@ class MarginModeAlreadySet extends NoChange {
75
75
  this.name = 'MarginModeAlreadySet';
76
76
  }
77
77
  }
78
+ class MarketClosed extends OperationRejected {
79
+ constructor(message) {
80
+ super(message);
81
+ this.name = 'MarketClosed';
82
+ }
83
+ }
78
84
  class BadResponse extends ExchangeError {
79
85
  constructor(message) {
80
86
  super(message);
@@ -219,7 +225,7 @@ class RequestTimeout extends NetworkError {
219
225
  this.name = 'RequestTimeout';
220
226
  }
221
227
  }
222
- var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
228
+ var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
223
229
 
224
230
  exports.AccountNotEnabled = AccountNotEnabled;
225
231
  exports.AccountSuspended = AccountSuspended;
@@ -242,6 +248,7 @@ exports.InvalidAddress = InvalidAddress;
242
248
  exports.InvalidNonce = InvalidNonce;
243
249
  exports.InvalidOrder = InvalidOrder;
244
250
  exports.MarginModeAlreadySet = MarginModeAlreadySet;
251
+ exports.MarketClosed = MarketClosed;
245
252
  exports.NetworkError = NetworkError;
246
253
  exports.NoChange = NoChange;
247
254
  exports.NotSupported = NotSupported;
@@ -81,10 +81,10 @@ function aggregate(bidasks) {
81
81
  for (let i = 0; i < bidasks.length; i++) {
82
82
  const [price, volume] = bidasks[i];
83
83
  if (volume > 0) {
84
- result[price] = (result[price] || 0) + volume;
84
+ result[price] = (result[price] || 0) + volume; // TODO: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.ts(7053)
85
85
  }
86
86
  }
87
- return Object.keys(result).map((price) => [parseFloat(price), parseFloat(result[price])]);
87
+ return Object.keys(result).map((price) => [parseFloat(price), parseFloat(result[price])]); // TODO: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}', No index signature with a parameter of type 'string' was found on type '{}'.ts(7053)
88
88
  }
89
89
  /* ------------------------------------------------------------------------ */
90
90
 
@@ -12,6 +12,7 @@ var index = require('../../static_dependencies/scure-base/index.js');
12
12
 
13
13
  class Client {
14
14
  constructor(url, onMessageCallback, onErrorCallback, onCloseCallback, onConnectedCallback, config = {}) {
15
+ this.verbose = false;
15
16
  const defaults = {
16
17
  url,
17
18
  onMessageCallback,
@@ -61,7 +62,7 @@ class Client {
61
62
  if (this.verbose && (messageHash === undefined)) {
62
63
  this.log(new Date(), 'resolve received undefined messageHash');
63
64
  }
64
- if (messageHash in this.futures) {
65
+ if ((messageHash !== undefined) && (messageHash in this.futures)) {
65
66
  const promise = this.futures[messageHash];
66
67
  promise.resolve(result);
67
68
  delete this.futures[messageHash];
@@ -16,6 +16,10 @@ var WebSocket__default = /*#__PURE__*/_interopDefaultLegacy(WebSocket);
16
16
  // eslint-disable-next-line no-restricted-globals
17
17
  const WebSocketPlatform = platform.isNode ? WebSocket__default["default"] : self.WebSocket;
18
18
  class WsClient extends Client {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.startedConnecting = false;
22
+ }
19
23
  createConnection() {
20
24
  if (this.verbose) {
21
25
  this.log(new Date(), 'connecting to', this.url);
@@ -154,6 +154,7 @@ class binance extends binance$1 {
154
154
  'reduceMargin': true,
155
155
  'repayCrossMargin': true,
156
156
  'repayIsolatedMargin': true,
157
+ 'sandbox': true,
157
158
  'setLeverage': true,
158
159
  'setMargin': false,
159
160
  'setMarginMode': true,
@@ -2396,7 +2397,7 @@ class binance extends binance$1 {
2396
2397
  'Rest API trading is not enabled.': errors.PermissionDenied,
2397
2398
  'This account may not place or cancel orders.': errors.PermissionDenied,
2398
2399
  "You don't have permission.": errors.PermissionDenied,
2399
- 'Market is closed.': errors.OperationRejected,
2400
+ 'Market is closed.': errors.MarketClosed,
2400
2401
  'Too many requests. Please try again later.': errors.RateLimitExceeded,
2401
2402
  'This action is disabled on this account.': errors.AccountSuspended,
2402
2403
  'Limit orders require GTC for this phase.': errors.BadRequest,
@@ -3999,8 +4000,8 @@ class binance extends binance$1 {
3999
4000
  * @name binance#fetchLastPrices
4000
4001
  * @description fetches the last price for multiple markets
4001
4002
  * @see https://binance-docs.github.io/apidocs/spot/en/#symbol-price-ticker // spot
4002
- * @see https://binance-docs.github.io/apidocs/future/en/#symbol-price-ticker // swap
4003
- * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker // future
4003
+ * @see https://binance-docs.github.io/apidocs/futures/en/#symbol-price-ticker // swap
4004
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-tickers // future
4004
4005
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
4005
4006
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4006
4007
  * @param {string} [params.subType] "linear" or "inverse"
@@ -83,6 +83,7 @@ class bingx extends bingx$1 {
83
83
  'fetchTransfers': true,
84
84
  'fetchWithdrawals': true,
85
85
  'reduceMargin': true,
86
+ 'sandbox': true,
86
87
  'setLeverage': true,
87
88
  'setMargin': true,
88
89
  'setMarginMode': true,
@@ -386,6 +387,7 @@ class bingx extends bingx$1 {
386
387
  '100202': errors.InsufficientFunds,
387
388
  '100204': errors.BadRequest,
388
389
  '100400': errors.BadRequest,
390
+ '100410': errors.OperationFailed,
389
391
  '100421': errors.BadSymbol,
390
392
  '100440': errors.ExchangeError,
391
393
  '100500': errors.OperationFailed,
@@ -88,6 +88,7 @@ class bitmex extends bitmex$1 {
88
88
  'fetchTransfer': false,
89
89
  'fetchTransfers': false,
90
90
  'reduceMargin': undefined,
91
+ 'sandbox': true,
91
92
  'setLeverage': true,
92
93
  'setMargin': undefined,
93
94
  'setMarginMode': true,
@@ -119,6 +119,7 @@ class bybit extends bybit$1 {
119
119
  'fetchVolatilityHistory': true,
120
120
  'fetchWithdrawals': true,
121
121
  'repayCrossMargin': true,
122
+ 'sandbox': true,
122
123
  'setLeverage': true,
123
124
  'setMarginMode': true,
124
125
  'setPositionMode': true,
@@ -6752,20 +6753,20 @@ class bybit extends bybit$1 {
6752
6753
  const isUsdcSettled = market['settle'] === 'USDC';
6753
6754
  // engage in leverage setting
6754
6755
  // we reuse the code here instead of having two methods
6755
- leverage = this.numberToString(leverage);
6756
+ const leverageString = this.numberToString(leverage);
6756
6757
  const request = {
6757
6758
  'symbol': market['id'],
6758
- 'buyLeverage': leverage,
6759
- 'sellLeverage': leverage,
6759
+ 'buyLeverage': leverageString,
6760
+ 'sellLeverage': leverageString,
6760
6761
  };
6761
6762
  let response = undefined;
6762
6763
  if (isUsdcSettled && !isUnifiedAccount) {
6763
- request['leverage'] = leverage;
6764
+ request['leverage'] = leverageString;
6764
6765
  response = await this.privatePostPerpetualUsdcOpenapiPrivateV1PositionLeverageSave(this.extend(request, params));
6765
6766
  }
6766
6767
  else {
6767
- request['buyLeverage'] = leverage;
6768
- request['sellLeverage'] = leverage;
6768
+ request['buyLeverage'] = leverageString;
6769
+ request['sellLeverage'] = leverageString;
6769
6770
  if (market['linear']) {
6770
6771
  request['category'] = 'linear';
6771
6772
  }
@@ -104,6 +104,7 @@ class coinbaseinternational extends coinbaseinternational$1 {
104
104
  'fetchTradingFees': false,
105
105
  'fetchWithdrawals': true,
106
106
  'reduceMargin': false,
107
+ 'sandbox': true,
107
108
  'setLeverage': false,
108
109
  'setMargin': true,
109
110
  'setMarginMode': false,
@@ -3698,31 +3698,34 @@ class coinex extends coinex$1 {
3698
3698
  * @method
3699
3699
  * @name coinex#createDepositAddress
3700
3700
  * @description create a currency deposit address
3701
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account019_update_deposit_address
3701
+ * @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/update-deposit-address
3702
3702
  * @param {string} code unified currency code of the currency for the deposit address
3703
3703
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3704
+ * @param {string} [params.network] the blockchain network to create a deposit address on
3704
3705
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3705
3706
  */
3706
3707
  await this.loadMarkets();
3707
3708
  const currency = this.currency(code);
3709
+ const network = this.safeString2(params, 'chain', 'network');
3710
+ if (network === undefined) {
3711
+ throw new errors.ArgumentsRequired(this.id + ' createDepositAddress() requires a network parameter');
3712
+ }
3713
+ params = this.omit(params, 'network');
3708
3714
  const request = {
3709
- 'coin_type': currency['id'],
3715
+ 'ccy': currency['id'],
3716
+ 'chain': this.networkCodeToId(network, currency['code']),
3710
3717
  };
3711
- if ('network' in params) {
3712
- const network = this.safeString(params, 'network');
3713
- params = this.omit(params, 'network');
3714
- request['smart_contract_name'] = network;
3715
- }
3716
- const response = await this.v1PrivatePutBalanceDepositAddressCoinType(this.extend(request, params));
3718
+ const response = await this.v2PrivatePostAssetsRenewalDepositAddress(this.extend(request, params));
3717
3719
  //
3718
3720
  // {
3719
3721
  // "code": 0,
3720
3722
  // "data": {
3721
- // "coin_address": "TV639dSpb9iGRtoFYkCp4AoaaDYKrK1pw5",
3722
- // "is_bitcoin_cash": false
3723
+ // "address": "0x321bd6479355142334f45653ad5d8b76105a1234",
3724
+ // "memo": ""
3723
3725
  // },
3724
- // "message": "Success"
3726
+ // "message": "OK"
3725
3727
  // }
3728
+ //
3726
3729
  const data = this.safeDict(response, 'data', {});
3727
3730
  return this.parseDepositAddress(data, currency);
3728
3731
  }
@@ -3731,18 +3734,16 @@ class coinex extends coinex$1 {
3731
3734
  * @method
3732
3735
  * @name coinex#fetchDepositAddress
3733
3736
  * @description fetch the deposit address for a currency associated with this account
3734
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account020_query_deposit_address
3737
+ * @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-address
3735
3738
  * @param {string} code unified currency code
3736
3739
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3740
+ * @param {string} [params.network] the blockchain network to create a deposit address on
3737
3741
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3738
3742
  */
3739
3743
  await this.loadMarkets();
3740
3744
  const currency = this.currency(code);
3741
- const request = {
3742
- 'coin_type': currency['id'],
3743
- };
3744
- const networks = this.safeValue(currency, 'networks', {});
3745
- const network = this.safeString(params, 'network');
3745
+ const networks = this.safeDict(currency, 'networks', {});
3746
+ const network = this.safeString2(params, 'network', 'chain');
3746
3747
  params = this.omit(params, 'network');
3747
3748
  const networksKeys = Object.keys(networks);
3748
3749
  const numOfNetworks = networksKeys.length;
@@ -3754,24 +3755,24 @@ class coinex extends coinex$1 {
3754
3755
  throw new errors.ExchangeError(this.id + ' fetchDepositAddress() ' + network + ' network not supported for ' + code);
3755
3756
  }
3756
3757
  }
3757
- if (network !== undefined) {
3758
- request['smart_contract_name'] = network;
3759
- }
3760
- const response = await this.v1PrivateGetBalanceDepositAddressCoinType(this.extend(request, params));
3758
+ const request = {
3759
+ 'ccy': currency['id'],
3760
+ 'chain': network,
3761
+ };
3762
+ const response = await this.v2PrivateGetAssetsDepositAddress(this.extend(request, params));
3761
3763
  //
3762
- // {
3763
- // "code": 0,
3764
- // "data": {
3765
- // "coin_address": "1P1JqozxioQwaqPwgMAQdNDYNyaVSqgARq",
3766
- // // coin_address: "xxxxxxxxxxxxxx:yyyyyyyyy", // with embedded tag/memo
3767
- // "is_bitcoin_cash": false
3768
- // },
3769
- // "message": "Success"
3770
- // }
3764
+ // {
3765
+ // "code": 0,
3766
+ // "data": {
3767
+ // "address": "0x321bd6479355142334f45653ad5d8b76105a1234",
3768
+ // "memo": ""
3769
+ // },
3770
+ // "message": "OK"
3771
+ // }
3771
3772
  //
3772
- const data = this.safeValue(response, 'data', {});
3773
+ const data = this.safeDict(response, 'data', {});
3773
3774
  const depositAddress = this.parseDepositAddress(data, currency);
3774
- const options = this.safeValue(this.options, 'fetchDepositAddress', {});
3775
+ const options = this.safeDict(this.options, 'fetchDepositAddress', {});
3775
3776
  const fillResponseFromRequest = this.safeBool(options, 'fillResponseFromRequest', true);
3776
3777
  if (fillResponseFromRequest) {
3777
3778
  depositAddress['network'] = this.safeNetworkCode(network, currency);
@@ -3797,11 +3798,11 @@ class coinex extends coinex$1 {
3797
3798
  parseDepositAddress(depositAddress, currency = undefined) {
3798
3799
  //
3799
3800
  // {
3800
- // "coin_address": "1P1JqozxioQwaqPwgMAQdNDYNyaVSqgARq",
3801
- // "is_bitcoin_cash": false
3801
+ // "address": "1P1JqozxioQwaqPwgMAQdNDYNyaVSqgARq",
3802
+ // "memo": ""
3802
3803
  // }
3803
3804
  //
3804
- const coinAddress = this.safeString(depositAddress, 'coin_address');
3805
+ const coinAddress = this.safeString(depositAddress, 'address');
3805
3806
  const parts = coinAddress.split(':');
3806
3807
  let address = undefined;
3807
3808
  let tag = undefined;
@@ -112,6 +112,7 @@ class coinmetro extends coinmetro$1 {
112
112
  'reduceMargin': false,
113
113
  'repayCrossMargin': false,
114
114
  'repayIsolatedMargin': false,
115
+ 'sandbox': true,
115
116
  'setLeverage': false,
116
117
  'setMargin': false,
117
118
  'setMarginMode': false,
@@ -102,6 +102,7 @@ class cryptocom extends cryptocom$1 {
102
102
  'reduceMargin': false,
103
103
  'repayCrossMargin': false,
104
104
  'repayIsolatedMargin': false,
105
+ 'sandbox': true,
105
106
  'setLeverage': false,
106
107
  'setMarginMode': false,
107
108
  'setPositionMode': false,
@@ -496,7 +497,8 @@ class cryptocom extends cryptocom$1 {
496
497
  const strike = this.safeString(market, 'strike');
497
498
  const marginBuyEnabled = this.safeValue(market, 'margin_buy_enabled');
498
499
  const marginSellEnabled = this.safeValue(market, 'margin_sell_enabled');
499
- const expiry = this.omitZero(this.safeInteger(market, 'expiry_timestamp_ms'));
500
+ const expiryString = this.omitZero(this.safeString(market, 'expiry_timestamp_ms'));
501
+ const expiry = (expiryString !== undefined) ? parseInt(expiryString) : undefined;
500
502
  let symbol = base + '/' + quote;
501
503
  let type = undefined;
502
504
  let contract = undefined;
@@ -101,6 +101,7 @@ class currencycom extends currencycom$1 {
101
101
  'fetchWithdrawal': undefined,
102
102
  'fetchWithdrawals': true,
103
103
  'reduceMargin': undefined,
104
+ 'sandbox': true,
104
105
  'setLeverage': undefined,
105
106
  'setMarginMode': undefined,
106
107
  'setPositionMode': undefined,
@@ -94,6 +94,7 @@ class deribit extends deribit$1 {
94
94
  'fetchVolatilityHistory': true,
95
95
  'fetchWithdrawal': false,
96
96
  'fetchWithdrawals': true,
97
+ 'sandbox': true,
97
98
  'transfer': true,
98
99
  'withdraw': true,
99
100
  },
@@ -157,6 +157,7 @@ class gate extends gate$1 {
157
157
  'reduceMargin': true,
158
158
  'repayCrossMargin': true,
159
159
  'repayIsolatedMargin': true,
160
+ 'sandbox': true,
160
161
  'setLeverage': true,
161
162
  'setMarginMode': false,
162
163
  'setPositionMode': true,
@@ -81,6 +81,7 @@ class gemini extends gemini$1 {
81
81
  'fetchTransactions': 'emulated',
82
82
  'postOnly': true,
83
83
  'reduceMargin': false,
84
+ 'sandbox': true,
84
85
  'setLeverage': false,
85
86
  'setMarginMode': false,
86
87
  'setPositionMode': false,
@@ -91,6 +91,7 @@ class hitbtc extends hitbtc$1 {
91
91
  'fetchTransactions': 'emulated',
92
92
  'fetchWithdrawals': true,
93
93
  'reduceMargin': true,
94
+ 'sandbox': true,
94
95
  'setLeverage': true,
95
96
  'setMargin': false,
96
97
  'setMarginMode': false,
@@ -615,6 +616,7 @@ class hitbtc extends hitbtc$1 {
615
616
  'accountsByType': {
616
617
  'spot': 'spot',
617
618
  'funding': 'wallet',
619
+ 'swap': 'derivatives',
618
620
  'future': 'derivatives',
619
621
  },
620
622
  'withdraw': {
@@ -88,6 +88,7 @@ class hollaex extends hollaex$1 {
88
88
  'fetchWithdrawal': true,
89
89
  'fetchWithdrawals': true,
90
90
  'reduceMargin': false,
91
+ 'sandbox': true,
91
92
  'setLeverage': false,
92
93
  'setMarginMode': false,
93
94
  'setPositionMode': false,
@@ -106,6 +106,7 @@ class hyperliquid extends hyperliquid$1 {
106
106
  'reduceMargin': true,
107
107
  'repayCrossMargin': false,
108
108
  'repayIsolatedMargin': false,
109
+ 'sandbox': true,
109
110
  'setLeverage': true,
110
111
  'setMarginMode': true,
111
112
  'setPositionMode': false,
@@ -440,6 +441,10 @@ class hyperliquid extends hyperliquid$1 {
440
441
  for (let i = 0; i < meta.length; i++) {
441
442
  const market = this.safeDict(meta, i, {});
442
443
  const marketName = this.safeString(market, 'name');
444
+ if (marketName.indexOf('/') < 0) {
445
+ // there are some weird spot markets in testnet, eg @2
446
+ continue;
447
+ }
443
448
  const marketParts = marketName.split('/');
444
449
  const baseName = this.safeString(marketParts, 0);
445
450
  const quoteId = this.safeString(marketParts, 1);
@@ -95,6 +95,7 @@ class idex extends idex$1 {
95
95
  'fetchWithdrawal': true,
96
96
  'fetchWithdrawals': true,
97
97
  'reduceMargin': false,
98
+ 'sandbox': true,
98
99
  'setLeverage': false,
99
100
  'setMarginMode': false,
100
101
  'setPositionMode': false,
@@ -71,6 +71,7 @@ class krakenfutures extends krakenfutures$1 {
71
71
  'fetchPremiumIndexOHLCV': false,
72
72
  'fetchTickers': true,
73
73
  'fetchTrades': true,
74
+ 'sandbox': true,
74
75
  'setLeverage': true,
75
76
  'setMarginMode': false,
76
77
  'transfer': true,
@@ -147,6 +147,7 @@ class luno extends luno$1 {
147
147
  'withdrawals': 1,
148
148
  'send': 1,
149
149
  'oauth2/grant': 1,
150
+ 'beneficiaries': 1,
150
151
  // POST /api/exchange/1/move
151
152
  },
152
153
  'put': {
@@ -154,6 +155,7 @@ class luno extends luno$1 {
154
155
  },
155
156
  'delete': {
156
157
  'withdrawals/{id}': 1,
158
+ 'beneficiaries/{id}': 1,
157
159
  },
158
160
  },
159
161
  },
@@ -85,6 +85,7 @@ class ndax extends ndax$1 {
85
85
  'fetchTradingFees': false,
86
86
  'fetchWithdrawals': true,
87
87
  'reduceMargin': false,
88
+ 'sandbox': true,
88
89
  'setLeverage': false,
89
90
  'setMarginMode': false,
90
91
  'setPositionMode': false,
@@ -138,6 +138,7 @@ class okx extends okx$1 {
138
138
  'fetchWithdrawalWhitelist': false,
139
139
  'reduceMargin': true,
140
140
  'repayCrossMargin': true,
141
+ 'sandbox': true,
141
142
  'setLeverage': true,
142
143
  'setMargin': false,
143
144
  'setMarginMode': true,