ccxt 4.2.86 → 4.2.88

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 (103) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +4 -5
  3. package/dist/ccxt.browser.js +748 -169
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +6 -1
  6. package/dist/cjs/src/ascendex.js +11 -1
  7. package/dist/cjs/src/base/Exchange.js +26 -2
  8. package/dist/cjs/src/binance.js +24 -7
  9. package/dist/cjs/src/bingx.js +37 -1
  10. package/dist/cjs/src/bitfinex.js +3 -0
  11. package/dist/cjs/src/bitfinex2.js +16 -1
  12. package/dist/cjs/src/bitflyer.js +19 -0
  13. package/dist/cjs/src/bitget.js +32 -17
  14. package/dist/cjs/src/bitopro.js +3 -0
  15. package/dist/cjs/src/bitrue.js +13 -7
  16. package/dist/cjs/src/bitvavo.js +3 -0
  17. package/dist/cjs/src/btcmarkets.js +1 -1
  18. package/dist/cjs/src/btcturk.js +2 -1
  19. package/dist/cjs/src/coinex.js +182 -54
  20. package/dist/cjs/src/cryptocom.js +1 -1
  21. package/dist/cjs/src/currencycom.js +1 -1
  22. package/dist/cjs/src/delta.js +3 -1
  23. package/dist/cjs/src/digifinex.js +4 -2
  24. package/dist/cjs/src/exmo.js +11 -12
  25. package/dist/cjs/src/gate.js +13 -10
  26. package/dist/cjs/src/hitbtc.js +26 -2
  27. package/dist/cjs/src/htx.js +2 -2
  28. package/dist/cjs/src/huobijp.js +1 -1
  29. package/dist/cjs/src/hyperliquid.js +249 -12
  30. package/dist/cjs/src/idex.js +1 -1
  31. package/dist/cjs/src/krakenfutures.js +4 -7
  32. package/dist/cjs/src/kucoin.js +7 -4
  33. package/dist/cjs/src/lbank.js +3 -0
  34. package/dist/cjs/src/mexc.js +1 -1
  35. package/dist/cjs/src/oceanex.js +1 -1
  36. package/dist/cjs/src/okx.js +24 -10
  37. package/dist/cjs/src/phemex.js +3 -1
  38. package/dist/cjs/src/pro/kucoin.js +11 -6
  39. package/dist/cjs/src/wazirx.js +1 -1
  40. package/dist/cjs/src/zonda.js +3 -0
  41. package/examples/js/benchmark.js +104 -0
  42. package/examples/js/cli.js +0 -2
  43. package/examples/ts/benchmark.ts +134 -0
  44. package/examples/ts/cli.ts +0 -2
  45. package/js/ccxt.d.ts +3 -3
  46. package/js/ccxt.js +3 -3
  47. package/js/src/ascendex.d.ts +5 -12
  48. package/js/src/ascendex.js +11 -1
  49. package/js/src/base/Exchange.d.ts +5 -4
  50. package/js/src/base/Exchange.js +26 -2
  51. package/js/src/base/types.d.ts +12 -1
  52. package/js/src/binance.d.ts +5 -12
  53. package/js/src/binance.js +24 -7
  54. package/js/src/bingx.d.ts +5 -2
  55. package/js/src/bingx.js +37 -1
  56. package/js/src/bitfinex.js +3 -0
  57. package/js/src/bitfinex2.d.ts +3 -17
  58. package/js/src/bitfinex2.js +16 -1
  59. package/js/src/bitflyer.d.ts +1 -0
  60. package/js/src/bitflyer.js +20 -1
  61. package/js/src/bitget.d.ts +5 -12
  62. package/js/src/bitget.js +32 -17
  63. package/js/src/bitopro.js +3 -0
  64. package/js/src/bitrue.d.ts +3 -17
  65. package/js/src/bitrue.js +13 -7
  66. package/js/src/bitvavo.js +3 -0
  67. package/js/src/btcmarkets.js +1 -1
  68. package/js/src/btcturk.js +2 -1
  69. package/js/src/coinex.d.ts +4 -11
  70. package/js/src/coinex.js +182 -54
  71. package/js/src/cryptocom.js +1 -1
  72. package/js/src/currencycom.js +1 -1
  73. package/js/src/delta.d.ts +5 -37
  74. package/js/src/delta.js +3 -1
  75. package/js/src/digifinex.d.ts +5 -13
  76. package/js/src/digifinex.js +4 -2
  77. package/js/src/exmo.d.ts +5 -37
  78. package/js/src/exmo.js +11 -12
  79. package/js/src/gate.d.ts +5 -33
  80. package/js/src/gate.js +13 -10
  81. package/js/src/hitbtc.d.ts +5 -12
  82. package/js/src/hitbtc.js +26 -2
  83. package/js/src/htx.js +2 -2
  84. package/js/src/huobijp.js +1 -1
  85. package/js/src/hyperliquid.d.ts +7 -4
  86. package/js/src/hyperliquid.js +249 -12
  87. package/js/src/idex.js +1 -1
  88. package/js/src/krakenfutures.js +4 -7
  89. package/js/src/kucoin.js +7 -4
  90. package/js/src/kucoinfutures.d.ts +2 -2
  91. package/js/src/lbank.js +3 -0
  92. package/js/src/mexc.d.ts +3 -3
  93. package/js/src/mexc.js +1 -1
  94. package/js/src/oceanex.js +1 -1
  95. package/js/src/okx.d.ts +5 -33
  96. package/js/src/okx.js +24 -10
  97. package/js/src/phemex.d.ts +3 -11
  98. package/js/src/phemex.js +3 -1
  99. package/js/src/pro/kucoin.js +11 -6
  100. package/js/src/wazirx.js +1 -1
  101. package/js/src/zonda.js +3 -0
  102. package/package.json +3 -2
  103. package/skip-tests.json +3 -3
@@ -26,7 +26,7 @@ class hyperliquid extends hyperliquid$1 {
26
26
  'pro': true,
27
27
  'has': {
28
28
  'CORS': undefined,
29
- 'spot': false,
29
+ 'spot': true,
30
30
  'margin': false,
31
31
  'swap': true,
32
32
  'future': true,
@@ -159,6 +159,10 @@ class hyperliquid extends hyperliquid$1 {
159
159
  'taker': this.parseNumber('0.00035'),
160
160
  'maker': this.parseNumber('0.0001'),
161
161
  },
162
+ 'spot': {
163
+ 'taker': this.parseNumber('0.00035'),
164
+ 'maker': this.parseNumber('0.0001'),
165
+ },
162
166
  },
163
167
  'requiredCredentials': {
164
168
  'apiKey': false,
@@ -184,6 +188,7 @@ class hyperliquid extends hyperliquid$1 {
184
188
  'precisionMode': number.TICK_SIZE,
185
189
  'commonCurrencies': {},
186
190
  'options': {
191
+ 'defaultType': 'swap',
187
192
  'sandboxMode': false,
188
193
  'defaultSlippage': 0.05,
189
194
  'zeroAddress': '0x0000000000000000000000000000000000000000',
@@ -254,6 +259,24 @@ class hyperliquid extends hyperliquid$1 {
254
259
  * @param {object} [params] extra parameters specific to the exchange API endpoint
255
260
  * @returns {object[]} an array of objects representing market data
256
261
  */
262
+ const rawPromises = [
263
+ this.fetchSwapMarkets(params),
264
+ this.fetchSpotMarkets(params),
265
+ ];
266
+ const promises = await Promise.all(rawPromises);
267
+ const swapMarkets = promises[0];
268
+ const spotMarkets = promises[1];
269
+ return this.arrayConcat(swapMarkets, spotMarkets);
270
+ }
271
+ async fetchSwapMarkets(params = {}) {
272
+ /**
273
+ * @method
274
+ * @name hyperliquid#fetchMarkets
275
+ * @description retrieves data on all swap markets for hyperliquid
276
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
277
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
278
+ * @returns {object[]} an array of objects representing market data
279
+ */
257
280
  const request = {
258
281
  'type': 'metaAndAssetCtxs',
259
282
  };
@@ -299,6 +322,132 @@ class hyperliquid extends hyperliquid$1 {
299
322
  }
300
323
  return this.parseMarkets(result);
301
324
  }
325
+ async fetchSpotMarkets(params = {}) {
326
+ /**
327
+ * @method
328
+ * @name hyperliquid#fetchMarkets
329
+ * @description retrieves data on all spot markets for hyperliquid
330
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
331
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
332
+ * @returns {object[]} an array of objects representing market data
333
+ */
334
+ const request = {
335
+ 'type': 'spotMetaAndAssetCtxs',
336
+ };
337
+ const response = await this.publicPostInfo(this.extend(request, params));
338
+ //
339
+ // [
340
+ // {
341
+ // 'tokens': [
342
+ // {
343
+ // 'name': 'USDC',
344
+ // 'szDecimals': '8',
345
+ // 'weiDecimals': '8',
346
+ // },
347
+ // {
348
+ // 'name': 'PURR',
349
+ // 'szDecimals': '0',
350
+ // 'weiDecimals': '5',
351
+ // },
352
+ // ],
353
+ // 'universe': [
354
+ // {
355
+ // 'name': 'PURR/USDC',
356
+ // 'tokens': [
357
+ // 1,
358
+ // 0,
359
+ // ],
360
+ // },
361
+ // ],
362
+ // },
363
+ // [
364
+ // {
365
+ // 'dayNtlVlm': '264250385.14640012',
366
+ // 'markPx': '0.018314',
367
+ // 'midPx': '0.0182235',
368
+ // 'prevDayPx': '0.017427',
369
+ // },
370
+ // ],
371
+ // ];
372
+ //
373
+ const first = this.safeDict(response, 0, {});
374
+ const meta = this.safeList(first, 'universe', []);
375
+ const tokens = this.safeList(first, 'tokens', []);
376
+ const markets = [];
377
+ for (let i = 0; i < meta.length; i++) {
378
+ const market = this.safeDict(meta, i, {});
379
+ const marketName = this.safeString(market, 'name');
380
+ const marketParts = marketName.split('/');
381
+ const baseName = this.safeString(marketParts, 0);
382
+ const quoteId = this.safeString(marketParts, 1);
383
+ const base = this.safeCurrencyCode(baseName);
384
+ const quote = this.safeCurrencyCode(quoteId);
385
+ const symbol = base + '/' + quote;
386
+ const fees = this.safeDict(this.fees, 'spot', {});
387
+ const taker = this.safeNumber(fees, 'taker');
388
+ const maker = this.safeNumber(fees, 'maker');
389
+ const tokensPos = this.safeList(market, 'tokens', []);
390
+ const baseTokenPos = this.safeInteger(tokensPos, 0);
391
+ const quoteTokenPos = this.safeInteger(tokensPos, 1);
392
+ const baseTokenInfo = this.safeDict(tokens, baseTokenPos, {});
393
+ const quoteTokenInfo = this.safeDict(tokens, quoteTokenPos, {});
394
+ const baseDecimals = this.safeString(baseTokenInfo, 'szDecimals');
395
+ const quoteDecimals = this.safeInteger(quoteTokenInfo, 'szDecimals');
396
+ const baseId = this.numberToString(i + 10000);
397
+ markets.push(this.safeMarketStructure({
398
+ 'id': baseId,
399
+ 'symbol': symbol,
400
+ 'base': base,
401
+ 'quote': quote,
402
+ 'settle': undefined,
403
+ 'baseId': baseId,
404
+ 'quoteId': quoteId,
405
+ 'settleId': undefined,
406
+ 'type': 'spot',
407
+ 'spot': true,
408
+ 'margin': undefined,
409
+ 'swap': false,
410
+ 'future': false,
411
+ 'option': false,
412
+ 'active': true,
413
+ 'contract': false,
414
+ 'linear': true,
415
+ 'inverse': false,
416
+ 'taker': taker,
417
+ 'maker': maker,
418
+ 'contractSize': undefined,
419
+ 'expiry': undefined,
420
+ 'expiryDatetime': undefined,
421
+ 'strike': undefined,
422
+ 'optionType': undefined,
423
+ 'precision': {
424
+ 'amount': this.parseNumber(this.parsePrecision(baseDecimals)),
425
+ 'price': quoteDecimals, // significant digits
426
+ },
427
+ 'limits': {
428
+ 'leverage': {
429
+ 'min': undefined,
430
+ 'max': undefined,
431
+ },
432
+ 'amount': {
433
+ 'min': undefined,
434
+ 'max': undefined,
435
+ },
436
+ 'price': {
437
+ 'min': undefined,
438
+ 'max': undefined,
439
+ },
440
+ 'cost': {
441
+ 'min': undefined,
442
+ 'max': undefined,
443
+ },
444
+ },
445
+ 'created': undefined,
446
+ 'info': market,
447
+ }));
448
+ }
449
+ return markets;
450
+ }
302
451
  parseMarket(market) {
303
452
  //
304
453
  // {
@@ -397,12 +546,17 @@ class hyperliquid extends hyperliquid$1 {
397
546
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
398
547
  * @param {object} [params] extra parameters specific to the exchange API endpoint
399
548
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
549
+ * @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap
400
550
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
401
551
  */
402
552
  let userAddress = undefined;
403
553
  [userAddress, params] = this.handlePublicAddress('fetchBalance', params);
554
+ let type = undefined;
555
+ [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
556
+ const isSpot = (type === 'spot');
557
+ const reqType = (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState';
404
558
  const request = {
405
- 'type': 'clearinghouseState',
559
+ 'type': reqType,
406
560
  'user': userAddress,
407
561
  };
408
562
  const response = await this.publicPostInfo(this.extend(request, params));
@@ -425,7 +579,37 @@ class hyperliquid extends hyperliquid$1 {
425
579
  // "time": "1704261007014",
426
580
  // "withdrawable": "100.0"
427
581
  // }
582
+ // spot
583
+ //
584
+ // {
585
+ // "balances":[
586
+ // {
587
+ // "coin":"USDC",
588
+ // "hold":"0.0",
589
+ // "total":"1481.844"
590
+ // },
591
+ // {
592
+ // "coin":"PURR",
593
+ // "hold":"0.0",
594
+ // "total":"999.65004"
595
+ // }
596
+ // }
428
597
  //
598
+ const balances = this.safeList(response, 'balances');
599
+ if (balances !== undefined) {
600
+ const spotBalances = { 'info': response };
601
+ for (let i = 0; i < balances.length; i++) {
602
+ const balance = balances[i];
603
+ const code = this.safeCurrencyCode(this.safeString(balance, 'coin'));
604
+ const account = this.account();
605
+ const total = this.safeString(balance, 'total');
606
+ const free = this.safeString(balance, 'hold');
607
+ account['total'] = total;
608
+ account['free'] = free;
609
+ spotBalances[code] = account;
610
+ }
611
+ return this.safeBalance(spotBalances);
612
+ }
429
613
  const data = this.safeDict(response, 'marginSummary', {});
430
614
  const result = {
431
615
  'info': response,
@@ -951,6 +1135,7 @@ class hyperliquid extends hyperliquid$1 {
951
1135
  * @param {string} symbol unified symbol of the market the order was made in
952
1136
  * @param {object} [params] extra parameters specific to the exchange API endpoint
953
1137
  * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
1138
+ * @param {string} [params.vaultAddress] the vault address for order
954
1139
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
955
1140
  */
956
1141
  return await this.cancelOrders([id], symbol, params);
@@ -966,6 +1151,7 @@ class hyperliquid extends hyperliquid$1 {
966
1151
  * @param {string} [symbol] unified market symbol
967
1152
  * @param {object} [params] extra parameters specific to the exchange API endpoint
968
1153
  * @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
1154
+ * @param {string} [params.vaultAddress] the vault address
969
1155
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
970
1156
  */
971
1157
  this.checkRequiredCredentials();
@@ -1448,7 +1634,12 @@ class hyperliquid extends hyperliquid$1 {
1448
1634
  const coin = this.safeString(entry, 'coin');
1449
1635
  let marketId = undefined;
1450
1636
  if (coin !== undefined) {
1451
- marketId = coin + '/USDC:USDC';
1637
+ if (coin.indexOf('/') > -1) {
1638
+ marketId = coin;
1639
+ }
1640
+ else {
1641
+ marketId = coin + '/USDC:USDC';
1642
+ }
1452
1643
  }
1453
1644
  if (this.safeString(entry, 'id') === undefined) {
1454
1645
  market = this.safeMarket(marketId, undefined);
@@ -1932,10 +2123,27 @@ class hyperliquid extends hyperliquid$1 {
1932
2123
  // 'status': 'ok'
1933
2124
  // }
1934
2125
  //
1935
- return response;
1936
- // return this.extend (this.parseMarginModification (response, market), {
1937
- // 'code': code,
1938
- // });
2126
+ return this.extend(this.parseMarginModification(response, market), {
2127
+ 'code': this.safeString(response, 'status'),
2128
+ });
2129
+ }
2130
+ parseMarginModification(data, market = undefined) {
2131
+ //
2132
+ // {
2133
+ // 'type': 'default'
2134
+ // }
2135
+ //
2136
+ return {
2137
+ 'info': data,
2138
+ 'symbol': this.safeSymbol(undefined, market),
2139
+ 'type': undefined,
2140
+ 'amount': undefined,
2141
+ 'total': undefined,
2142
+ 'code': this.safeString(market, 'settle'),
2143
+ 'status': undefined,
2144
+ 'timestamp': undefined,
2145
+ 'datetime': undefined,
2146
+ };
1939
2147
  }
1940
2148
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
1941
2149
  /**
@@ -1945,13 +2153,44 @@ class hyperliquid extends hyperliquid$1 {
1945
2153
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#l1-usdc-transfer
1946
2154
  * @param {string} code unified currency code
1947
2155
  * @param {float} amount amount to transfer
1948
- * @param {string} fromAccount account to transfer from
1949
- * @param {string} toAccount account to transfer to
2156
+ * @param {string} fromAccount account to transfer from *spot, swap*
2157
+ * @param {string} toAccount account to transfer to *swap, spot or address*
1950
2158
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2159
+ * @param {string} [params.vaultAddress] the vault address for order
1951
2160
  * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
1952
2161
  */
1953
2162
  this.checkRequiredCredentials();
1954
2163
  await this.loadMarkets();
2164
+ const isSandboxMode = this.safeBool(this.options, 'sandboxMode');
2165
+ const nonce = this.milliseconds();
2166
+ if (this.inArray(fromAccount, ['spot', 'swap', 'perp'])) {
2167
+ // handle swap <> spot account transfer
2168
+ if (!this.inArray(toAccount, ['spot', 'swap', 'perp'])) {
2169
+ throw new errors.NotSupported(this.id + 'transfer() only support spot <> swap transfer');
2170
+ }
2171
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
2172
+ params = this.omit(params, 'vaultAddress');
2173
+ const toPerp = (toAccount === 'perp') || (toAccount === 'swap');
2174
+ const action = {
2175
+ 'type': 'spotUser',
2176
+ 'classTransfer': {
2177
+ 'usdc': amount,
2178
+ 'toPerp': toPerp,
2179
+ },
2180
+ };
2181
+ const signature = this.signL1Action(action, nonce, vaultAddress);
2182
+ const innerRequest = {
2183
+ 'action': this.extend(action, params),
2184
+ 'nonce': nonce,
2185
+ 'signature': signature,
2186
+ };
2187
+ if (vaultAddress !== undefined) {
2188
+ innerRequest['vaultAddress'] = vaultAddress;
2189
+ }
2190
+ const transferResponse = await this.privatePostExchange(innerRequest);
2191
+ return transferResponse;
2192
+ }
2193
+ // handle sub-account/different account transfer
1955
2194
  this.checkAddress(toAccount);
1956
2195
  if (code !== undefined) {
1957
2196
  code = code.toUpperCase();
@@ -1959,11 +2198,9 @@ class hyperliquid extends hyperliquid$1 {
1959
2198
  throw new errors.NotSupported(this.id + 'withdraw() only support USDC');
1960
2199
  }
1961
2200
  }
1962
- const isSandboxMode = this.safeBool(this.options, 'sandboxMode');
1963
- const nonce = this.milliseconds();
1964
2201
  const payload = {
1965
2202
  'destination': toAccount,
1966
- 'amount': amount.toString(),
2203
+ 'amount': this.numberToString(amount),
1967
2204
  'time': nonce,
1968
2205
  };
1969
2206
  const sig = this.buildTransferSig(payload);
@@ -463,7 +463,7 @@ class idex extends idex$1 {
463
463
  request['start'] = since;
464
464
  }
465
465
  if (limit !== undefined) {
466
- request['limit'] = limit;
466
+ request['limit'] = Math.min(limit, 1000);
467
467
  }
468
468
  const response = await this.publicGetCandles(this.extend(request, params));
469
469
  if (Array.isArray(response)) {
@@ -352,7 +352,8 @@ class krakenfutures extends krakenfutures$1 {
352
352
  // swap == perpetual
353
353
  let settle = undefined;
354
354
  let settleId = undefined;
355
- const amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'contractValueTradePrecision', '0')));
355
+ const cvtp = this.safeString(market, 'contractValueTradePrecision');
356
+ const amountPrecision = this.parseNumber(this.integerPrecisionToAmount(cvtp));
356
357
  const pricePrecision = this.safeNumber(market, 'tickSize');
357
358
  const contract = (swap || future || index);
358
359
  const swapOrFutures = (swap || future);
@@ -641,17 +642,13 @@ class krakenfutures extends krakenfutures$1 {
641
642
  if (limit === undefined) {
642
643
  limit = 5000;
643
644
  }
644
- else if (limit > 5000) {
645
- throw new errors.BadRequest(this.id + ' fetchOHLCV() limit cannot exceed 5000');
646
- }
645
+ limit = Math.min(limit, 5000);
647
646
  const toTimestamp = this.sum(request['from'], limit * duration - 1);
648
647
  const currentTimestamp = this.seconds();
649
648
  request['to'] = Math.min(toTimestamp, currentTimestamp);
650
649
  }
651
650
  else if (limit !== undefined) {
652
- if (limit > 5000) {
653
- throw new errors.BadRequest(this.id + ' fetchOHLCV() limit cannot exceed 5000');
654
- }
651
+ limit = Math.min(limit, 5000);
655
652
  const duration = this.parseTimeframe(timeframe);
656
653
  request['to'] = this.seconds();
657
654
  request['from'] = this.parseToInt(request['to'] - (duration * limit));
@@ -3537,9 +3537,9 @@ class kucoin extends kucoin$1 {
3537
3537
  * @method
3538
3538
  * @name kucoin#fetchBalance
3539
3539
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
3540
- * @see https://docs.kucoin.com/#list-accounts
3541
3540
  * @see https://www.kucoin.com/docs/rest/account/basic-info/get-account-list-spot-margin-trade_hf
3542
- * @see https://docs.kucoin.com/#query-isolated-margin-account-info
3541
+ * @see https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-margin
3542
+ * @see https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-isolated-margin
3543
3543
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3544
3544
  * @param {object} [params.marginMode] 'cross' or 'isolated', margin type for fetching margin balance
3545
3545
  * @param {object} [params.type] extra parameters specific to the exchange API endpoint
@@ -3566,7 +3566,7 @@ class kucoin extends kucoin$1 {
3566
3566
  let response = undefined;
3567
3567
  const request = {};
3568
3568
  const isolated = (marginMode === 'isolated') || (type === 'isolated');
3569
- const cross = (marginMode === 'cross') || (type === 'cross');
3569
+ const cross = (marginMode === 'cross') || (type === 'margin');
3570
3570
  if (isolated) {
3571
3571
  if (currency !== undefined) {
3572
3572
  request['balanceCurrency'] = currency['id'];
@@ -3636,13 +3636,14 @@ class kucoin extends kucoin$1 {
3636
3636
  // }
3637
3637
  // }
3638
3638
  //
3639
- const data = this.safeList(response, 'data', []);
3639
+ let data = undefined;
3640
3640
  const result = {
3641
3641
  'info': response,
3642
3642
  'timestamp': undefined,
3643
3643
  'datetime': undefined,
3644
3644
  };
3645
3645
  if (isolated) {
3646
+ data = this.safeDict(response, 'data', {});
3646
3647
  const assets = this.safeValue(data, 'assets', data);
3647
3648
  for (let i = 0; i < assets.length; i++) {
3648
3649
  const entry = assets[i];
@@ -3659,6 +3660,7 @@ class kucoin extends kucoin$1 {
3659
3660
  }
3660
3661
  }
3661
3662
  else if (cross) {
3663
+ data = this.safeDict(response, 'data', {});
3662
3664
  const accounts = this.safeList(data, 'accounts', []);
3663
3665
  for (let i = 0; i < accounts.length; i++) {
3664
3666
  const balance = accounts[i];
@@ -3668,6 +3670,7 @@ class kucoin extends kucoin$1 {
3668
3670
  }
3669
3671
  }
3670
3672
  else {
3673
+ data = this.safeList(response, 'data', []);
3671
3674
  for (let i = 0; i < data.length; i++) {
3672
3675
  const balance = data[i];
3673
3676
  const balanceType = this.safeString(balance, 'type');
@@ -1000,6 +1000,9 @@ class lbank extends lbank$1 {
1000
1000
  if (limit === undefined) {
1001
1001
  limit = 100;
1002
1002
  }
1003
+ else {
1004
+ limit = Math.min(limit, 2000);
1005
+ }
1003
1006
  if (since === undefined) {
1004
1007
  const duration = this.parseTimeframe(timeframe);
1005
1008
  since = this.milliseconds() - duration * 1000 * limit;
@@ -4511,7 +4511,7 @@ class mexc extends mexc$1 {
4511
4511
  }
4512
4512
  }
4513
4513
  if (result === undefined) {
4514
- throw new errors.InvalidAddress(this.id + ' fetchDepositAddress() cannot find a deposit address for ' + code + ', and network' + network + 'consider creating one using the MEXC platform');
4514
+ throw new errors.InvalidAddress(this.id + ' fetchDepositAddress() cannot find a deposit address for ' + code + ', and network' + network + 'consider creating one using .createDepositAddress() method or in MEXC website');
4515
4515
  }
4516
4516
  return result;
4517
4517
  }
@@ -794,7 +794,7 @@ class oceanex extends oceanex$1 {
794
794
  request['timestamp'] = since;
795
795
  }
796
796
  if (limit !== undefined) {
797
- request['limit'] = limit;
797
+ request['limit'] = Math.min(limit, 10000);
798
798
  }
799
799
  const response = await this.publicPostK(this.extend(request, params));
800
800
  const ohlcvs = this.safeList(response, 'data', []);
@@ -6460,26 +6460,40 @@ class okx extends okx$1 {
6460
6460
  // "msg": ""
6461
6461
  // }
6462
6462
  //
6463
- return this.parseMarginModification(response, market);
6463
+ const data = this.safeList(response, 'data', []);
6464
+ const errorCode = this.safeString(response, 'code');
6465
+ const item = this.safeDict(data, 0, {});
6466
+ return this.extend(this.parseMarginModification(item, market), {
6467
+ 'status': (errorCode === '0') ? 'ok' : 'failed',
6468
+ });
6464
6469
  }
6465
6470
  parseMarginModification(data, market = undefined) {
6466
- const innerData = this.safeValue(data, 'data', []);
6467
- const entry = this.safeValue(innerData, 0, {});
6468
- const errorCode = this.safeString(data, 'code');
6469
- const status = (errorCode === '0') ? 'ok' : 'failed';
6470
- const amountRaw = this.safeNumber(entry, 'amt');
6471
- const typeRaw = this.safeString(entry, 'type');
6471
+ //
6472
+ // addMargin/reduceMargin
6473
+ //
6474
+ // {
6475
+ // "amt": "0.01",
6476
+ // "instId": "ETH-USD-SWAP",
6477
+ // "posSide": "net",
6478
+ // "type": "reduce"
6479
+ // }
6480
+ //
6481
+ const amountRaw = this.safeNumber(data, 'amt');
6482
+ const typeRaw = this.safeString(data, 'type');
6472
6483
  const type = (typeRaw === 'reduce') ? 'reduce' : 'add';
6473
- const marketId = this.safeString(entry, 'instId');
6484
+ const marketId = this.safeString(data, 'instId');
6474
6485
  const responseMarket = this.safeMarket(marketId, market);
6475
6486
  const code = responseMarket['inverse'] ? responseMarket['base'] : responseMarket['quote'];
6476
6487
  return {
6477
6488
  'info': data,
6489
+ 'symbol': responseMarket['symbol'],
6478
6490
  'type': type,
6479
6491
  'amount': amountRaw,
6492
+ 'total': undefined,
6480
6493
  'code': code,
6481
- 'symbol': responseMarket['symbol'],
6482
- 'status': status,
6494
+ 'status': undefined,
6495
+ 'timestamp': undefined,
6496
+ 'datetime': undefined,
6483
6497
  };
6484
6498
  }
6485
6499
  async reduceMargin(symbol, amount, params = {}) {
@@ -4060,12 +4060,14 @@ class phemex extends phemex$1 {
4060
4060
  const codeCurrency = inverse ? 'base' : 'quote';
4061
4061
  return {
4062
4062
  'info': data,
4063
+ 'symbol': this.safeSymbol(undefined, market),
4063
4064
  'type': 'set',
4064
4065
  'amount': undefined,
4065
4066
  'total': undefined,
4066
4067
  'code': market[codeCurrency],
4067
- 'symbol': this.safeSymbol(undefined, market),
4068
4068
  'status': this.parseMarginStatus(this.safeString(data, 'code')),
4069
+ 'timestamp': undefined,
4070
+ 'datetime': undefined,
4069
4071
  };
4070
4072
  }
4071
4073
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -570,17 +570,22 @@ class kucoin extends kucoin$1 {
570
570
  const marketId = this.safeString(data, 'symbol', topicSymbol);
571
571
  const symbol = this.safeSymbol(marketId, undefined, '-');
572
572
  const messageHash = 'orderbook:' + symbol;
573
- let orderbook = this.safeDict(this.orderbooks, symbol);
573
+ // let orderbook = this.safeDict (this.orderbooks, symbol);
574
574
  if (subject === 'level2') {
575
- if (orderbook === undefined) {
576
- orderbook = this.orderBook();
575
+ if (!(symbol in this.orderbooks)) {
576
+ this.orderbooks[symbol] = this.orderBook();
577
577
  }
578
578
  else {
579
+ const orderbook = this.orderbooks[symbol];
579
580
  orderbook.reset();
580
581
  }
581
- orderbook['symbol'] = symbol;
582
+ this.orderbooks[symbol]['symbol'] = symbol;
582
583
  }
583
584
  else {
585
+ if (!(symbol in this.orderbooks)) {
586
+ this.orderbooks[symbol] = this.orderBook();
587
+ }
588
+ const orderbook = this.orderbooks[symbol];
584
589
  const nonce = this.safeInteger(orderbook, 'nonce');
585
590
  const deltaEnd = this.safeInteger2(data, 'sequenceEnd', 'timestamp');
586
591
  if (nonce === undefined) {
@@ -606,8 +611,8 @@ class kucoin extends kucoin$1 {
606
611
  return;
607
612
  }
608
613
  }
609
- this.handleDelta(orderbook, data);
610
- client.resolve(orderbook, messageHash);
614
+ this.handleDelta(this.orderbooks[symbol], data);
615
+ client.resolve(this.orderbooks[symbol], messageHash);
611
616
  }
612
617
  getCacheIndex(orderbook, cache) {
613
618
  const firstDelta = this.safeValue(cache, 0);
@@ -319,7 +319,7 @@ class wazirx extends wazirx$1 {
319
319
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
320
320
  };
321
321
  if (limit !== undefined) {
322
- request['limit'] = limit;
322
+ request['limit'] = Math.min(limit, 2000);
323
323
  }
324
324
  const until = this.safeInteger(params, 'until');
325
325
  params = this.omit(params, ['until']);
@@ -1201,6 +1201,9 @@ class zonda extends zonda$1 {
1201
1201
  if (limit === undefined) {
1202
1202
  limit = 100;
1203
1203
  }
1204
+ else {
1205
+ limit = Math.min(limit, 11000); // supports up to 11k candles diapason
1206
+ }
1204
1207
  const duration = this.parseTimeframe(timeframe);
1205
1208
  const timerange = limit * duration * 1000;
1206
1209
  if (since === undefined) {