ccxt 4.2.86 → 4.2.87

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 (93) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +671 -130
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/ascendex.js +11 -1
  7. package/dist/cjs/src/binance.js +14 -1
  8. package/dist/cjs/src/bingx.js +37 -1
  9. package/dist/cjs/src/bitfinex.js +3 -0
  10. package/dist/cjs/src/bitfinex2.js +16 -1
  11. package/dist/cjs/src/bitflyer.js +19 -0
  12. package/dist/cjs/src/bitget.js +15 -1
  13. package/dist/cjs/src/bitopro.js +3 -0
  14. package/dist/cjs/src/bitrue.js +13 -7
  15. package/dist/cjs/src/bitvavo.js +3 -0
  16. package/dist/cjs/src/btcmarkets.js +1 -1
  17. package/dist/cjs/src/btcturk.js +2 -1
  18. package/dist/cjs/src/coinex.js +182 -54
  19. package/dist/cjs/src/currencycom.js +1 -1
  20. package/dist/cjs/src/delta.js +3 -1
  21. package/dist/cjs/src/digifinex.js +4 -2
  22. package/dist/cjs/src/exmo.js +11 -12
  23. package/dist/cjs/src/gate.js +5 -2
  24. package/dist/cjs/src/hitbtc.js +26 -2
  25. package/dist/cjs/src/htx.js +2 -2
  26. package/dist/cjs/src/huobijp.js +1 -1
  27. package/dist/cjs/src/hyperliquid.js +249 -12
  28. package/dist/cjs/src/idex.js +1 -1
  29. package/dist/cjs/src/krakenfutures.js +2 -6
  30. package/dist/cjs/src/lbank.js +3 -0
  31. package/dist/cjs/src/oceanex.js +1 -1
  32. package/dist/cjs/src/okx.js +24 -10
  33. package/dist/cjs/src/phemex.js +3 -1
  34. package/dist/cjs/src/pro/kucoin.js +11 -6
  35. package/dist/cjs/src/wazirx.js +1 -1
  36. package/dist/cjs/src/zonda.js +3 -0
  37. package/examples/js/benchmark.js +104 -0
  38. package/examples/ts/benchmark.ts +134 -0
  39. package/js/ccxt.d.ts +1 -1
  40. package/js/ccxt.js +1 -1
  41. package/js/src/ascendex.d.ts +5 -12
  42. package/js/src/ascendex.js +11 -1
  43. package/js/src/base/Exchange.d.ts +4 -4
  44. package/js/src/base/types.d.ts +11 -0
  45. package/js/src/binance.d.ts +4 -11
  46. package/js/src/binance.js +14 -1
  47. package/js/src/bingx.d.ts +5 -2
  48. package/js/src/bingx.js +37 -1
  49. package/js/src/bitfinex.js +3 -0
  50. package/js/src/bitfinex2.d.ts +3 -17
  51. package/js/src/bitfinex2.js +16 -1
  52. package/js/src/bitflyer.d.ts +1 -0
  53. package/js/src/bitflyer.js +20 -1
  54. package/js/src/bitget.d.ts +5 -12
  55. package/js/src/bitget.js +15 -1
  56. package/js/src/bitopro.js +3 -0
  57. package/js/src/bitrue.d.ts +3 -17
  58. package/js/src/bitrue.js +13 -7
  59. package/js/src/bitvavo.js +3 -0
  60. package/js/src/btcmarkets.js +1 -1
  61. package/js/src/btcturk.js +2 -1
  62. package/js/src/coinex.d.ts +4 -11
  63. package/js/src/coinex.js +182 -54
  64. package/js/src/currencycom.js +1 -1
  65. package/js/src/delta.d.ts +5 -37
  66. package/js/src/delta.js +3 -1
  67. package/js/src/digifinex.d.ts +5 -13
  68. package/js/src/digifinex.js +4 -2
  69. package/js/src/exmo.d.ts +5 -37
  70. package/js/src/exmo.js +11 -12
  71. package/js/src/gate.d.ts +5 -33
  72. package/js/src/gate.js +5 -2
  73. package/js/src/hitbtc.d.ts +5 -12
  74. package/js/src/hitbtc.js +26 -2
  75. package/js/src/htx.js +2 -2
  76. package/js/src/huobijp.js +1 -1
  77. package/js/src/hyperliquid.d.ts +7 -4
  78. package/js/src/hyperliquid.js +249 -12
  79. package/js/src/idex.js +1 -1
  80. package/js/src/krakenfutures.js +2 -6
  81. package/js/src/kucoinfutures.d.ts +2 -2
  82. package/js/src/lbank.js +3 -0
  83. package/js/src/mexc.d.ts +3 -3
  84. package/js/src/oceanex.js +1 -1
  85. package/js/src/okx.d.ts +5 -33
  86. package/js/src/okx.js +24 -10
  87. package/js/src/phemex.d.ts +3 -11
  88. package/js/src/phemex.js +3 -1
  89. package/js/src/pro/kucoin.js +11 -6
  90. package/js/src/wazirx.js +1 -1
  91. package/js/src/zonda.js +3 -0
  92. package/package.json +3 -2
  93. package/skip-tests.json +3 -3
@@ -985,7 +985,7 @@ class currencycom extends currencycom$1 {
985
985
  request['startTime'] = since;
986
986
  }
987
987
  if (limit !== undefined) {
988
- request['limit'] = limit; // default 500, max 1000
988
+ request['limit'] = Math.min(limit, 1000); // default 500, max 1000
989
989
  }
990
990
  const response = await this.publicGetV2Klines(this.extend(request, params));
991
991
  //
@@ -2663,12 +2663,14 @@ class delta extends delta$1 {
2663
2663
  market = this.safeMarket(marketId, market);
2664
2664
  return {
2665
2665
  'info': data,
2666
+ 'symbol': market['symbol'],
2666
2667
  'type': undefined,
2667
2668
  'amount': undefined,
2668
2669
  'total': this.safeNumber(data, 'margin'),
2669
2670
  'code': undefined,
2670
- 'symbol': market['symbol'],
2671
2671
  'status': undefined,
2672
+ 'timestamp': undefined,
2673
+ 'datetime': undefined,
2672
2674
  };
2673
2675
  }
2674
2676
  async fetchOpenInterest(symbol, params = {}) {
@@ -1505,7 +1505,7 @@ class digifinex extends digifinex$1 {
1505
1505
  request['instrument_id'] = market['id'];
1506
1506
  request['granularity'] = timeframe;
1507
1507
  if (limit !== undefined) {
1508
- request['limit'] = limit;
1508
+ request['limit'] = Math.min(limit, 100);
1509
1509
  }
1510
1510
  response = await this.publicSwapGetPublicCandles(this.extend(request, params));
1511
1511
  }
@@ -4131,12 +4131,14 @@ class digifinex extends digifinex$1 {
4131
4131
  const rawType = this.safeInteger(data, 'type');
4132
4132
  return {
4133
4133
  'info': data,
4134
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
4134
4135
  'type': (rawType === 1) ? 'add' : 'reduce',
4135
4136
  'amount': this.safeNumber(data, 'amount'),
4136
4137
  'total': undefined,
4137
4138
  'code': market['settle'],
4138
- 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
4139
4139
  'status': undefined,
4140
+ 'timestamp': undefined,
4141
+ 'datetime': undefined,
4140
4142
  };
4141
4143
  }
4142
4144
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -262,12 +262,14 @@ class exmo extends exmo$1 {
262
262
  //
263
263
  return {
264
264
  'info': data,
265
+ 'symbol': this.safeSymbol(undefined, market),
265
266
  'type': undefined,
266
267
  'amount': undefined,
267
- 'code': this.safeValue(market, 'quote'),
268
- 'symbol': this.safeSymbol(undefined, market),
269
268
  'total': undefined,
269
+ 'code': this.safeValue(market, 'quote'),
270
270
  'status': 'ok',
271
+ 'timestamp': undefined,
272
+ 'datetime': undefined,
271
273
  };
272
274
  }
273
275
  async reduceMargin(symbol, amount, params = {}) {
@@ -860,16 +862,15 @@ class exmo extends exmo$1 {
860
862
  'symbol': market['id'],
861
863
  'resolution': this.safeString(this.timeframes, timeframe, timeframe),
862
864
  };
863
- const options = this.safeValue(this.options, 'fetchOHLCV');
864
- const maxLimit = this.safeInteger(options, 'maxLimit', 3000);
865
+ const maxLimit = 3000;
865
866
  const duration = this.parseTimeframe(timeframe);
866
867
  const now = this.milliseconds();
867
868
  if (since === undefined) {
868
869
  if (limit === undefined) {
869
870
  limit = 1000; // cap default at generous amount
870
871
  }
871
- if (limit > maxLimit) {
872
- limit = maxLimit; // avoid exception
872
+ else {
873
+ limit = Math.min(limit, maxLimit);
873
874
  }
874
875
  request['from'] = this.parseToInt(now / 1000) - limit * duration - 1;
875
876
  request['to'] = this.parseToInt(now / 1000);
@@ -877,15 +878,13 @@ class exmo extends exmo$1 {
877
878
  else {
878
879
  request['from'] = this.parseToInt(since / 1000) - 1;
879
880
  if (limit === undefined) {
880
- request['to'] = this.parseToInt(now / 1000);
881
+ limit = maxLimit;
881
882
  }
882
883
  else {
883
- if (limit > maxLimit) {
884
- throw new errors.BadRequest(this.id + ' fetchOHLCV() will serve ' + maxLimit.toString() + ' candles at most');
885
- }
886
- const to = this.sum(since, limit * duration * 1000);
887
- request['to'] = this.parseToInt(to / 1000);
884
+ limit = Math.min(limit, maxLimit);
888
885
  }
886
+ const to = this.sum(since, limit * duration * 1000);
887
+ request['to'] = this.parseToInt(to / 1000);
889
888
  }
890
889
  const response = await this.publicGetCandlesHistory(this.extend(request, params));
891
890
  //
@@ -6115,11 +6115,14 @@ class gate extends gate$1 {
6115
6115
  const total = this.safeNumber(data, 'margin');
6116
6116
  return {
6117
6117
  'info': data,
6118
- 'amount': undefined,
6119
- 'code': this.safeValue(market, 'quote'),
6120
6118
  'symbol': market['symbol'],
6119
+ 'type': undefined,
6120
+ 'amount': undefined,
6121
6121
  'total': total,
6122
+ 'code': this.safeValue(market, 'quote'),
6122
6123
  'status': 'ok',
6124
+ 'timestamp': undefined,
6125
+ 'datetime': undefined,
6123
6126
  };
6124
6127
  }
6125
6128
  async reduceMargin(symbol, amount, params = {}) {
@@ -1734,7 +1734,7 @@ class hitbtc extends hitbtc$1 {
1734
1734
  }
1735
1735
  [request, params] = this.handleUntilOption('till', request, params);
1736
1736
  if (limit !== undefined) {
1737
- request['limit'] = limit;
1737
+ request['limit'] = Math.min(limit, 1000);
1738
1738
  }
1739
1739
  const price = this.safeString(params, 'price');
1740
1740
  params = this.omit(params, 'price');
@@ -3292,15 +3292,39 @@ class hitbtc extends hitbtc$1 {
3292
3292
  });
3293
3293
  }
3294
3294
  parseMarginModification(data, market = undefined) {
3295
+ //
3296
+ // addMargin/reduceMargin
3297
+ //
3298
+ // {
3299
+ // "symbol": "BTCUSDT_PERP",
3300
+ // "type": "isolated",
3301
+ // "leverage": "8.00",
3302
+ // "created_at": "2022-03-30T23:34:27.161Z",
3303
+ // "updated_at": "2022-03-30T23:34:27.161Z",
3304
+ // "currencies": [
3305
+ // {
3306
+ // "code": "USDT",
3307
+ // "margin_balance": "7.000000000000",
3308
+ // "reserved_orders": "0",
3309
+ // "reserved_positions": "0"
3310
+ // }
3311
+ // ],
3312
+ // "positions": null
3313
+ // }
3314
+ //
3295
3315
  const currencies = this.safeValue(data, 'currencies', []);
3296
3316
  const currencyInfo = this.safeValue(currencies, 0);
3317
+ const datetime = this.safeString(data, 'updated_at');
3297
3318
  return {
3298
3319
  'info': data,
3320
+ 'symbol': market['symbol'],
3299
3321
  'type': undefined,
3300
3322
  'amount': undefined,
3323
+ 'total': undefined,
3301
3324
  'code': this.safeString(currencyInfo, 'code'),
3302
- 'symbol': market['symbol'],
3303
3325
  'status': undefined,
3326
+ 'timestamp': this.parse8601(datetime),
3327
+ 'datetime': datetime,
3304
3328
  };
3305
3329
  }
3306
3330
  async reduceMargin(symbol, amount, params = {}) {
@@ -2962,7 +2962,7 @@ class htx extends htx$1 {
2962
2962
  const untilSeconds = (until !== undefined) ? this.parseToInt(until / 1000) : undefined;
2963
2963
  if (market['contract']) {
2964
2964
  if (limit !== undefined) {
2965
- request['size'] = limit; // when using limit: from & to are ignored
2965
+ request['size'] = Math.min(limit, 2000); // when using limit: from & to are ignored
2966
2966
  // https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
2967
2967
  }
2968
2968
  else {
@@ -3054,7 +3054,7 @@ class htx extends htx$1 {
3054
3054
  [useHistorical, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', true);
3055
3055
  if (!useHistorical) {
3056
3056
  if (limit !== undefined) {
3057
- request['size'] = Math.min(2000, limit); // max 2000
3057
+ request['size'] = Math.min(limit, 2000); // max 2000
3058
3058
  }
3059
3059
  response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
3060
3060
  }
@@ -952,7 +952,7 @@ class huobijp extends huobijp$1 {
952
952
  'period': this.safeString(this.timeframes, timeframe, timeframe),
953
953
  };
954
954
  if (limit !== undefined) {
955
- request['size'] = limit;
955
+ request['size'] = Math.min(limit, 2000);
956
956
  }
957
957
  const response = await this.marketGetHistoryKline(this.extend(request, params));
958
958
  //
@@ -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)) {
@@ -641,17 +641,13 @@ class krakenfutures extends krakenfutures$1 {
641
641
  if (limit === undefined) {
642
642
  limit = 5000;
643
643
  }
644
- else if (limit > 5000) {
645
- throw new errors.BadRequest(this.id + ' fetchOHLCV() limit cannot exceed 5000');
646
- }
644
+ limit = Math.min(limit, 5000);
647
645
  const toTimestamp = this.sum(request['from'], limit * duration - 1);
648
646
  const currentTimestamp = this.seconds();
649
647
  request['to'] = Math.min(toTimestamp, currentTimestamp);
650
648
  }
651
649
  else if (limit !== undefined) {
652
- if (limit > 5000) {
653
- throw new errors.BadRequest(this.id + ' fetchOHLCV() limit cannot exceed 5000');
654
- }
650
+ limit = Math.min(limit, 5000);
655
651
  const duration = this.parseTimeframe(timeframe);
656
652
  request['to'] = this.seconds();
657
653
  request['from'] = this.parseToInt(request['to'] - (duration * limit));
@@ -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;
@@ -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', []);