ccxt 4.4.2 → 4.4.4

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 (137) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +2 -2
  5. package/dist/cjs/src/base/functions/misc.js +11 -0
  6. package/dist/cjs/src/base/functions.js +1 -0
  7. package/dist/cjs/src/base/ws/WsClient.js +2 -1
  8. package/dist/cjs/src/binance.js +49 -22
  9. package/dist/cjs/src/bingx.js +1 -0
  10. package/dist/cjs/src/bitfinex2.js +7 -6
  11. package/dist/cjs/src/bitget.js +10 -6
  12. package/dist/cjs/src/bitmart.js +3 -1
  13. package/dist/cjs/src/bitmex.js +11 -10
  14. package/dist/cjs/src/bitso.js +5 -4
  15. package/dist/cjs/src/bitstamp.js +33 -45
  16. package/dist/cjs/src/blofin.js +21 -23
  17. package/dist/cjs/src/bybit.js +22 -20
  18. package/dist/cjs/src/coinbase.js +28 -7
  19. package/dist/cjs/src/coinbaseexchange.js +11 -11
  20. package/dist/cjs/src/coinlist.js +6 -5
  21. package/dist/cjs/src/coinmetro.js +3 -3
  22. package/dist/cjs/src/cryptocom.js +9 -6
  23. package/dist/cjs/src/currencycom.js +6 -6
  24. package/dist/cjs/src/delta.js +5 -5
  25. package/dist/cjs/src/digifinex.js +8 -6
  26. package/dist/cjs/src/gate.js +6 -5
  27. package/dist/cjs/src/hashkey.js +9 -7
  28. package/dist/cjs/src/htx.js +13 -16
  29. package/dist/cjs/src/hyperliquid.js +67 -114
  30. package/dist/cjs/src/kraken.js +8 -6
  31. package/dist/cjs/src/kucoin.js +9 -8
  32. package/dist/cjs/src/luno.js +10 -9
  33. package/dist/cjs/src/mexc.js +54 -2
  34. package/dist/cjs/src/ndax.js +6 -5
  35. package/dist/cjs/src/okcoin.js +18 -27
  36. package/dist/cjs/src/okx.js +18 -26
  37. package/dist/cjs/src/p2b.js +2 -2
  38. package/dist/cjs/src/pro/bybit.js +56 -0
  39. package/dist/cjs/src/pro/cryptocom.js +191 -21
  40. package/dist/cjs/src/pro/mexc.js +165 -3
  41. package/dist/cjs/src/pro/okx.js +6 -3
  42. package/dist/cjs/src/pro/oxfun.js +75 -0
  43. package/dist/cjs/src/pro/phemex.js +45 -1
  44. package/dist/cjs/src/pro/woofipro.js +67 -0
  45. package/dist/cjs/src/woo.js +7 -6
  46. package/dist/cjs/src/woofipro.js +8 -6
  47. package/dist/cjs/src/xt.js +10 -4
  48. package/dist/cjs/src/zonda.js +6 -5
  49. package/js/ccxt.d.ts +1 -1
  50. package/js/ccxt.js +1 -1
  51. package/js/src/abstract/bitmart.d.ts +1 -0
  52. package/js/src/base/Exchange.d.ts +2 -2
  53. package/js/src/base/Exchange.js +2 -2
  54. package/js/src/base/functions/misc.d.ts +2 -1
  55. package/js/src/base/functions/misc.js +11 -1
  56. package/js/src/base/types.d.ts +1 -1
  57. package/js/src/base/ws/WsClient.js +2 -2
  58. package/js/src/binance.d.ts +4 -20
  59. package/js/src/binance.js +49 -22
  60. package/js/src/bingx.js +1 -0
  61. package/js/src/bitfinex2.d.ts +3 -19
  62. package/js/src/bitfinex2.js +7 -6
  63. package/js/src/bitget.d.ts +3 -19
  64. package/js/src/bitget.js +10 -6
  65. package/js/src/bitmart.js +3 -1
  66. package/js/src/bitmex.d.ts +3 -22
  67. package/js/src/bitmex.js +11 -10
  68. package/js/src/bitso.d.ts +3 -19
  69. package/js/src/bitso.js +5 -4
  70. package/js/src/bitstamp.d.ts +3 -35
  71. package/js/src/bitstamp.js +33 -45
  72. package/js/src/blofin.d.ts +3 -15
  73. package/js/src/blofin.js +21 -23
  74. package/js/src/bybit.d.ts +3 -19
  75. package/js/src/bybit.js +23 -21
  76. package/js/src/coinbase.d.ts +3 -19
  77. package/js/src/coinbase.js +28 -7
  78. package/js/src/coinbaseexchange.d.ts +3 -19
  79. package/js/src/coinbaseexchange.js +11 -11
  80. package/js/src/coinlist.d.ts +3 -19
  81. package/js/src/coinlist.js +6 -5
  82. package/js/src/coinmetro.d.ts +3 -19
  83. package/js/src/coinmetro.js +3 -3
  84. package/js/src/cryptocom.d.ts +3 -22
  85. package/js/src/cryptocom.js +9 -6
  86. package/js/src/currencycom.d.ts +3 -3
  87. package/js/src/currencycom.js +6 -6
  88. package/js/src/delta.d.ts +3 -19
  89. package/js/src/delta.js +5 -5
  90. package/js/src/digifinex.d.ts +3 -19
  91. package/js/src/digifinex.js +8 -6
  92. package/js/src/gate.d.ts +3 -19
  93. package/js/src/gate.js +6 -5
  94. package/js/src/hashkey.d.ts +3 -20
  95. package/js/src/hashkey.js +9 -7
  96. package/js/src/htx.d.ts +3 -19
  97. package/js/src/htx.js +13 -16
  98. package/js/src/hyperliquid.d.ts +3 -19
  99. package/js/src/hyperliquid.js +68 -115
  100. package/js/src/kraken.d.ts +5 -24
  101. package/js/src/kraken.js +8 -6
  102. package/js/src/kucoin.d.ts +3 -19
  103. package/js/src/kucoin.js +9 -8
  104. package/js/src/luno.d.ts +4 -20
  105. package/js/src/luno.js +10 -9
  106. package/js/src/mexc.js +54 -2
  107. package/js/src/ndax.d.ts +3 -19
  108. package/js/src/ndax.js +6 -5
  109. package/js/src/okcoin.d.ts +3 -19
  110. package/js/src/okcoin.js +18 -27
  111. package/js/src/okx.d.ts +3 -19
  112. package/js/src/okx.js +18 -26
  113. package/js/src/p2b.js +2 -2
  114. package/js/src/pro/bybit.d.ts +2 -0
  115. package/js/src/pro/bybit.js +56 -0
  116. package/js/src/pro/cryptocom.d.ts +7 -1
  117. package/js/src/pro/cryptocom.js +191 -21
  118. package/js/src/pro/mexc.d.ts +6 -1
  119. package/js/src/pro/mexc.js +166 -4
  120. package/js/src/pro/okx.js +6 -3
  121. package/js/src/pro/oxfun.d.ts +3 -0
  122. package/js/src/pro/oxfun.js +75 -0
  123. package/js/src/pro/phemex.d.ts +2 -1
  124. package/js/src/pro/phemex.js +45 -1
  125. package/js/src/pro/woofipro.d.ts +3 -0
  126. package/js/src/pro/woofipro.js +67 -0
  127. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  128. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  129. package/js/src/woo.d.ts +3 -19
  130. package/js/src/woo.js +7 -6
  131. package/js/src/woofipro.d.ts +3 -19
  132. package/js/src/woofipro.js +8 -6
  133. package/js/src/xt.d.ts +3 -22
  134. package/js/src/xt.js +10 -4
  135. package/js/src/zonda.d.ts +3 -19
  136. package/js/src/zonda.js +6 -5
  137. package/package.json +1 -1
@@ -8,7 +8,7 @@
8
8
  import Exchange from './abstract/hyperliquid.js';
9
9
  import { ExchangeError, ArgumentsRequired, NotSupported, InvalidOrder, OrderNotFound, BadRequest } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
- import { TICK_SIZE, ROUND, SIGNIFICANT_DIGITS, DECIMAL_PLACES } from './base/functions/number.js';
11
+ import { ROUND, SIGNIFICANT_DIGITS, DECIMAL_PLACES } from './base/functions/number.js';
12
12
  import { keccak_256 as keccak } from './static_dependencies/noble-hashes/sha3.js';
13
13
  import { secp256k1 } from './static_dependencies/noble-curves/secp256k1.js';
14
14
  import { ecdsa } from './base/functions/crypto.js';
@@ -191,9 +191,11 @@ export default class hyperliquid extends Exchange {
191
191
  'No liquidity available for market order.': InvalidOrder,
192
192
  'Order was never placed, already canceled, or filled.': OrderNotFound,
193
193
  'User or API Wallet ': InvalidOrder,
194
+ 'Order has invalid size': InvalidOrder,
195
+ 'Order price cannot be more than 80% away from the reference price': InvalidOrder,
194
196
  },
195
197
  },
196
- 'precisionMode': TICK_SIZE,
198
+ 'precisionMode': DECIMAL_PLACES,
197
199
  'commonCurrencies': {},
198
200
  'options': {
199
201
  'defaultType': 'swap',
@@ -212,7 +214,7 @@ export default class hyperliquid extends Exchange {
212
214
  * @method
213
215
  * @name hyperliquid#fetchCurrencies
214
216
  * @description fetches all available currencies on an exchange
215
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-exchange-metadata
217
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata
216
218
  * @param {object} [params] extra parameters specific to the exchange API endpoint
217
219
  * @returns {object} an associative dictionary of currencies
218
220
  */
@@ -271,7 +273,8 @@ export default class hyperliquid extends Exchange {
271
273
  * @method
272
274
  * @name hyperliquid#fetchMarkets
273
275
  * @description retrieves data on all markets for hyperliquid
274
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
276
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
277
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
275
278
  * @param {object} [params] extra parameters specific to the exchange API endpoint
276
279
  * @returns {object[]} an array of objects representing market data
277
280
  */
@@ -289,7 +292,7 @@ export default class hyperliquid extends Exchange {
289
292
  * @method
290
293
  * @name hyperliquid#fetchMarkets
291
294
  * @description retrieves data on all swap markets for hyperliquid
292
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
295
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
293
296
  * @param {object} [params] extra parameters specific to the exchange API endpoint
294
297
  * @returns {object[]} an array of objects representing market data
295
298
  */
@@ -344,7 +347,7 @@ export default class hyperliquid extends Exchange {
344
347
  * @method
345
348
  * @name hyperliquid#fetchMarkets
346
349
  * @description retrieves data on all spot markets for hyperliquid
347
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
350
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
348
351
  * @param {object} [params] extra parameters specific to the exchange API endpoint
349
352
  * @returns {object[]} an array of objects representing market data
350
353
  */
@@ -355,102 +358,51 @@ export default class hyperliquid extends Exchange {
355
358
  //
356
359
  // [
357
360
  // {
358
- // 'tokens': [
361
+ // "tokens": [
359
362
  // {
360
- // 'name': 'USDC',
361
- // 'szDecimals': '8',
362
- // 'weiDecimals': '8',
363
+ // "name": "USDC",
364
+ // "szDecimals": 8,
365
+ // "weiDecimals" 8,
366
+ // "index": 0,
367
+ // "tokenId": "0x6d1e7cde53ba9467b783cb7c530ce054",
368
+ // "isCanonical": true,
369
+ // "evmContract":null,
370
+ // "fullName":null
363
371
  // },
364
372
  // {
365
- // 'name': 'PURR',
366
- // 'szDecimals': '0',
367
- // 'weiDecimals': '5',
368
- // },
373
+ // "name": "PURR",
374
+ // "szDecimals": 0,
375
+ // "weiDecimals": 5,
376
+ // "index": 1,
377
+ // "tokenId": "0xc1fb593aeffbeb02f85e0308e9956a90",
378
+ // "isCanonical": true,
379
+ // "evmContract":null,
380
+ // "fullName":null
381
+ // }
369
382
  // ],
370
- // 'universe': [
383
+ // "universe": [
371
384
  // {
372
- // 'name': 'PURR/USDC',
373
- // 'tokens': [
374
- // 1,
375
- // 0,
376
- // ],
377
- // },
378
- // ],
385
+ // "name": "PURR/USDC",
386
+ // "tokens": [1, 0],
387
+ // "index": 0,
388
+ // "isCanonical": true
389
+ // }
390
+ // ]
379
391
  // },
380
392
  // [
381
393
  // {
382
- // 'dayNtlVlm': '264250385.14640012',
383
- // 'markPx': '0.018314',
384
- // 'midPx': '0.0182235',
385
- // 'prevDayPx': '0.017427',
386
- // },
387
- // ],
388
- // ];
389
- // mainnet
390
- // [
391
- // {
392
- // "canonical_tokens2":[
393
- // 0,
394
- // 1
395
- // ],
396
- // "spot_infos":[
397
- // {
398
- // "name":"PURR/USDC",
399
- // "tokens":[
400
- // 1,
401
- // 0
402
- // ]
403
- // }
404
- // ],
405
- // "token_id_to_token":[
406
- // [
407
- // "0x6d1e7cde53ba9467b783cb7c530ce054",
408
- // 0
409
- // ],
410
- // [
411
- // "0xc1fb593aeffbeb02f85e0308e9956a90",
412
- // 1
413
- // ]
414
- // ],
415
- // "token_infos":[
416
- // {
417
- // "deployer":null,
418
- // "spec":{
419
- // "name":"USDC",
420
- // "szDecimals":"8",
421
- // "weiDecimals":"8"
422
- // },
423
- // "spots":[
424
- // ]
425
- // },
426
- // {
427
- // "deployer":null,
428
- // "spec":{
429
- // "name":"PURR",
430
- // "szDecimals":"0",
431
- // "weiDecimals":"5"
432
- // },
433
- // "spots":[
434
- // 0
435
- // ]
436
- // }
437
- // ]
438
- // },
439
- // [
440
- // {
441
- // "dayNtlVlm":"35001170.16631",
442
- // "markPx":"0.15743",
443
- // "midPx":"0.157555",
444
- // "prevDayPx":"0.158"
445
- // }
394
+ // "dayNtlVlm":"8906.0",
395
+ // "markPx":"0.14",
396
+ // "midPx":"0.209265",
397
+ // "prevDayPx":"0.20432"
398
+ // }
446
399
  // ]
447
400
  // ]
448
401
  //
449
- // response differs depending on the environment (mainnet vs sandbox)
450
402
  const first = this.safeDict(response, 0, {});
451
403
  const second = this.safeList(response, 1, []);
452
- const meta = this.safeList2(first, 'universe', 'spot_infos', []);
453
- const tokens = this.safeList2(first, 'tokens', 'token_infos', []);
404
+ const meta = this.safeList(first, 'universe', []);
405
+ const tokens = this.safeList(first, 'tokens', []);
454
406
  const markets = [];
455
407
  for (let i = 0; i < meta.length; i++) {
456
408
  const market = this.safeDict(meta, i, {});
@@ -478,7 +430,7 @@ export default class hyperliquid extends Exchange {
478
430
  const symbol = base + '/' + quote;
479
431
  const innerBaseTokenInfo = this.safeDict(baseTokenInfo, 'spec', baseTokenInfo);
480
432
  // const innerQuoteTokenInfo = this.safeDict (quoteTokenInfo, 'spec', quoteTokenInfo);
481
- const amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(innerBaseTokenInfo, 'szDecimals')));
433
+ const amountPrecision = this.safeInteger(innerBaseTokenInfo, 'szDecimals');
482
434
  // const quotePrecision = this.parseNumber (this.parsePrecision (this.safeString (innerQuoteTokenInfo, 'szDecimals')));
483
435
  const baseId = this.numberToString(i + 10000);
484
436
  markets.push(this.safeMarketStructure({
@@ -510,7 +462,7 @@ export default class hyperliquid extends Exchange {
510
462
  'optionType': undefined,
511
463
  'precision': {
512
464
  'amount': amountPrecision,
513
- 'price': 5, // significant digits
465
+ 'price': 8 - amountPrecision, // MAX_DECIMALS is 8
514
466
  },
515
467
  'limits': {
516
468
  'leverage': {
@@ -526,7 +478,7 @@ export default class hyperliquid extends Exchange {
526
478
  'max': undefined,
527
479
  },
528
480
  'cost': {
529
- 'min': undefined,
481
+ 'min': this.parseNumber('10'),
530
482
  'max': undefined,
531
483
  },
532
484
  },
@@ -574,7 +526,8 @@ export default class hyperliquid extends Exchange {
574
526
  const fees = this.safeDict(this.fees, 'swap', {});
575
527
  const taker = this.safeNumber(fees, 'taker');
576
528
  const maker = this.safeNumber(fees, 'maker');
577
- return {
529
+ const amountPrecision = this.safeInteger(market, 'szDecimals');
530
+ return this.safeMarketStructure({
578
531
  'id': baseId,
579
532
  'symbol': symbol,
580
533
  'base': base,
@@ -601,8 +554,8 @@ export default class hyperliquid extends Exchange {
601
554
  'strike': undefined,
602
555
  'optionType': undefined,
603
556
  'precision': {
604
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'szDecimals'))),
605
- 'price': 5, // significant digits
557
+ 'amount': amountPrecision,
558
+ 'price': 6 - amountPrecision, // MAX_DECIMALS is 6
606
559
  },
607
560
  'limits': {
608
561
  'leverage': {
@@ -618,20 +571,21 @@ export default class hyperliquid extends Exchange {
618
571
  'max': undefined,
619
572
  },
620
573
  'cost': {
621
- 'min': undefined,
574
+ 'min': this.parseNumber('10'),
622
575
  'max': undefined,
623
576
  },
624
577
  },
625
578
  'created': undefined,
626
579
  'info': market,
627
- };
580
+ });
628
581
  }
629
582
  async fetchBalance(params = {}) {
630
583
  /**
631
584
  * @method
632
585
  * @name hyperliquid#fetchBalance
633
586
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
634
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
587
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances
588
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
635
589
  * @param {object} [params] extra parameters specific to the exchange API endpoint
636
590
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
637
591
  * @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap
@@ -716,7 +670,7 @@ export default class hyperliquid extends Exchange {
716
670
  * @method
717
671
  * @name hyperliquid#fetchOrderBook
718
672
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
719
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#info
673
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#l2-book-snapshot
720
674
  * @param {string} symbol unified symbol of the market to fetch the order book for
721
675
  * @param {int} [limit] the maximum amount of order book entries to return
722
676
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -764,7 +718,8 @@ export default class hyperliquid extends Exchange {
764
718
  * @method
765
719
  * @name hyperliquid#fetchTickers
766
720
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
767
- * @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActiveAndIndices
721
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
722
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
768
723
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
769
724
  * @param {object} [params] extra parameters specific to the exchange API endpoint
770
725
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -818,7 +773,7 @@ export default class hyperliquid extends Exchange {
818
773
  * @method
819
774
  * @name hyperliquid#fetchOHLCV
820
775
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
821
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#info-1
776
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot
822
777
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
823
778
  * @param {string} timeframe the length of time each candle represents, support '1m', '15m', '1h', '1d'
824
779
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -947,15 +902,13 @@ export default class hyperliquid extends Exchange {
947
902
  }
948
903
  amountToPrecision(symbol, amount) {
949
904
  const market = this.market(symbol);
950
- if (market['spot']) {
951
- return super.amountToPrecision(symbol, amount);
952
- }
953
- return this.decimalToPrecision(amount, ROUND, this.markets[symbol]['precision']['amount'], this.precisionMode);
905
+ return this.decimalToPrecision(amount, ROUND, market['precision']['amount'], this.precisionMode, this.paddingMode);
954
906
  }
955
907
  priceToPrecision(symbol, price) {
956
908
  const market = this.market(symbol);
957
- const result = this.decimalToPrecision(price, ROUND, market['precision']['price'], SIGNIFICANT_DIGITS, this.paddingMode);
958
- const decimalParsedResult = this.decimalToPrecision(result, ROUND, 6, DECIMAL_PLACES, this.paddingMode);
909
+ // https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/tick-and-lot-size
910
+ const result = this.decimalToPrecision(price, ROUND, 5, SIGNIFICANT_DIGITS, this.paddingMode);
911
+ const decimalParsedResult = this.decimalToPrecision(result, ROUND, market['precision']['price'], this.precisionMode, this.paddingMode);
959
912
  return decimalParsedResult;
960
913
  }
961
914
  hashMessage(message) {
@@ -1647,7 +1600,7 @@ export default class hyperliquid extends Exchange {
1647
1600
  * @method
1648
1601
  * @name hyperliquid#fetchFundingRateHistory
1649
1602
  * @description fetches historical funding rate prices
1650
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-historical-funding-rates
1603
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates
1651
1604
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
1652
1605
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1653
1606
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
@@ -2152,7 +2105,7 @@ export default class hyperliquid extends Exchange {
2152
2105
  * @method
2153
2106
  * @name hyperliquid#fetchPosition
2154
2107
  * @description fetch data on an open position
2155
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
2108
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
2156
2109
  * @param {string} symbol unified market symbol of the market the position is held in
2157
2110
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2158
2111
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
@@ -2166,7 +2119,7 @@ export default class hyperliquid extends Exchange {
2166
2119
  * @method
2167
2120
  * @name hyperliquid#fetchPositions
2168
2121
  * @description fetch all open positions
2169
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
2122
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
2170
2123
  * @param {string[]} [symbols] list of unified market symbols
2171
2124
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2172
2125
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
@@ -2797,9 +2750,9 @@ export default class hyperliquid extends Exchange {
2797
2750
  * @method
2798
2751
  * @name hyperliquid#fetchLedger
2799
2752
  * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2800
- * @param {string} code unified currency code
2753
+ * @param {string} [code] unified currency code
2801
2754
  * @param {int} [since] timestamp in ms of the earliest ledger entry
2802
- * @param {int} [limit] max number of ledger entrys to return
2755
+ * @param {int} [limit] max number of ledger entries to return
2803
2756
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2804
2757
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
2805
2758
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
@@ -2859,7 +2812,8 @@ export default class hyperliquid extends Exchange {
2859
2812
  }
2860
2813
  const type = this.safeString(delta, 'type');
2861
2814
  const amount = this.safeString(delta, 'usdc');
2862
- return {
2815
+ return this.safeLedgerEntry({
2816
+ 'info': item,
2863
2817
  'id': this.safeString(item, 'hash'),
2864
2818
  'direction': undefined,
2865
2819
  'account': undefined,
@@ -2874,8 +2828,7 @@ export default class hyperliquid extends Exchange {
2874
2828
  'after': undefined,
2875
2829
  'status': undefined,
2876
2830
  'fee': fee,
2877
- 'info': item,
2878
- };
2831
+ }, currency);
2879
2832
  }
2880
2833
  parseLedgerEntryType(type) {
2881
2834
  const ledgerType = {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/kraken.js';
2
- import type { IndexType, Int, OrderSide, OrderType, OHLCV, Trade, Order, Balances, Str, Dict, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, TransferEntry, Num, TradingFeeInterface, Currencies, int } from './base/types.js';
2
+ import type { IndexType, Int, OrderSide, OrderType, OHLCV, Trade, Order, Balances, Str, Dict, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, TransferEntry, Num, TradingFeeInterface, Currencies, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class kraken
5
5
  * @augments Exchange
@@ -36,29 +36,10 @@ export default class kraken extends Exchange {
36
36
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
37
37
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
38
38
  parseLedgerEntryType(type: any): string;
39
- parseLedgerEntry(item: Dict, currency?: Currency): {
40
- info: Dict;
41
- id: string;
42
- direction: any;
43
- account: any;
44
- referenceId: string;
45
- referenceAccount: any;
46
- type: string;
47
- currency: string;
48
- amount: number;
49
- before: any;
50
- after: number;
51
- status: string;
52
- timestamp: number;
53
- datetime: string;
54
- fee: {
55
- cost: number;
56
- currency: string;
57
- };
58
- };
59
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
60
- fetchLedgerEntriesByIds(ids: any, code?: Str, params?: {}): Promise<any>;
61
- fetchLedgerEntry(id: string, code?: Str, params?: {}): Promise<any>;
39
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
40
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
41
+ fetchLedgerEntriesByIds(ids: any, code?: Str, params?: {}): Promise<LedgerEntry[]>;
42
+ fetchLedgerEntry(id: string, code?: Str, params?: {}): Promise<LedgerEntry>;
62
43
  parseTrade(trade: Dict, market?: Market): Trade;
63
44
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
64
45
  parseBalance(response: any): Balances;
package/js/src/kraken.js CHANGED
@@ -1070,7 +1070,9 @@ export default class kraken extends Exchange {
1070
1070
  const referenceId = this.safeString(item, 'refid');
1071
1071
  const referenceAccount = undefined;
1072
1072
  const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
1073
- const code = this.safeCurrencyCode(this.safeString(item, 'asset'), currency);
1073
+ const currencyId = this.safeString(item, 'asset');
1074
+ const code = this.safeCurrencyCode(currencyId, currency);
1075
+ currency = this.safeCurrency(currencyId, currency);
1074
1076
  let amount = this.safeString(item, 'amount');
1075
1077
  if (Precise.stringLt(amount, '0')) {
1076
1078
  direction = 'out';
@@ -1080,7 +1082,7 @@ export default class kraken extends Exchange {
1080
1082
  direction = 'in';
1081
1083
  }
1082
1084
  const timestamp = this.safeIntegerProduct(item, 'time', 1000);
1083
- return {
1085
+ return this.safeLedgerEntry({
1084
1086
  'info': item,
1085
1087
  'id': id,
1086
1088
  'direction': direction,
@@ -1099,17 +1101,17 @@ export default class kraken extends Exchange {
1099
1101
  'cost': this.safeNumber(item, 'fee'),
1100
1102
  'currency': code,
1101
1103
  },
1102
- };
1104
+ }, currency);
1103
1105
  }
1104
1106
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1105
1107
  /**
1106
1108
  * @method
1107
1109
  * @name kraken#fetchLedger
1108
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1110
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1109
1111
  * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getLedgers
1110
- * @param {string} code unified currency code, default is undefined
1112
+ * @param {string} [code] unified currency code, default is undefined
1111
1113
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1112
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1114
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1113
1115
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1114
1116
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
1115
1117
  * @param {int} [params.end] timestamp in seconds of the latest ledger entry
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/kucoin.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, Order, OHLCV, Trade, Balances, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, Num, Account, Dict, TradingFeeInterface, Currencies, int } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, Order, OHLCV, Trade, Balances, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, Num, Account, Dict, TradingFeeInterface, Currencies, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class kucoin
5
5
  * @augments Exchange
@@ -89,24 +89,8 @@ export default class kucoin extends Exchange {
89
89
  parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
90
90
  parseTransferStatus(status: Str): Str;
91
91
  parseLedgerEntryType(type: any): string;
92
- parseLedgerEntry(item: Dict, currency?: Currency): {
93
- id: string;
94
- direction: string;
95
- account: string;
96
- referenceId: any;
97
- referenceAccount: string;
98
- type: string;
99
- currency: string;
100
- amount: number;
101
- timestamp: number;
102
- datetime: string;
103
- before: any;
104
- after: any;
105
- status: any;
106
- fee: any;
107
- info: Dict;
108
- };
109
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
92
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
93
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
110
94
  calculateRateLimiterCost(api: any, method: any, path: any, params: any, config?: {}): any;
111
95
  parseBorrowRateHistory(response: any, code: any, since: any, limit: any): any;
112
96
  parseBorrowRate(info: any, currency?: Currency): {
package/js/src/kucoin.js CHANGED
@@ -4202,6 +4202,7 @@ export default class kucoin extends Exchange {
4202
4202
  const id = this.safeString(item, 'id');
4203
4203
  const currencyId = this.safeString(item, 'currency');
4204
4204
  const code = this.safeCurrencyCode(currencyId, currency);
4205
+ currency = this.safeCurrency(currencyId, currency);
4205
4206
  const amount = this.safeNumber(item, 'amount');
4206
4207
  const balanceAfter = undefined;
4207
4208
  // const balanceAfter = this.safeNumber (item, 'balance'); only returns zero string
@@ -4250,7 +4251,8 @@ export default class kucoin extends Exchange {
4250
4251
  feeCurrency = code;
4251
4252
  fee = { 'cost': this.parseNumber(feeCost), 'currency': feeCurrency };
4252
4253
  }
4253
- return {
4254
+ return this.safeLedgerEntry({
4255
+ 'info': item,
4254
4256
  'id': id,
4255
4257
  'direction': direction,
4256
4258
  'account': account,
@@ -4265,24 +4267,23 @@ export default class kucoin extends Exchange {
4265
4267
  'after': balanceAfter,
4266
4268
  'status': undefined,
4267
4269
  'fee': fee,
4268
- 'info': item,
4269
- };
4270
+ }, currency);
4270
4271
  }
4271
4272
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
4272
4273
  /**
4273
4274
  * @method
4274
4275
  * @name kucoin#fetchLedger
4276
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
4275
4277
  * @see https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-spot-margin
4276
4278
  * @see https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-trade_hf
4277
4279
  * @see https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-margin_hf
4278
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
4279
- * @param {string} code unified currency code, default is undefined
4280
+ * @param {string} [code] unified currency code, default is undefined
4280
4281
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
4281
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
4282
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
4282
4283
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4283
4284
  * @param {boolean} [params.hf] default false, when true will fetch ledger entries for the high frequency trading account
4284
4285
  * @param {int} [params.until] the latest time in ms to fetch entries for
4285
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4286
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4286
4287
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
4287
4288
  */
4288
4289
  await this.loadMarkets();
@@ -5064,7 +5065,7 @@ export default class kucoin extends Exchange {
5064
5065
  //
5065
5066
  const errorCode = this.safeString(response, 'code');
5066
5067
  const message = this.safeString2(response, 'msg', 'data', '');
5067
- const feedback = this.id + ' ' + message;
5068
+ const feedback = this.id + ' ' + body;
5068
5069
  this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
5069
5070
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
5070
5071
  this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
package/js/src/luno.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/luno.js';
2
- import type { Balances, Currency, Int, Market, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, OHLCV, Num, Account, TradingFeeInterface, Dict, int } from './base/types.js';
2
+ import type { Balances, Currency, Int, Market, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, OHLCV, Num, Account, TradingFeeInterface, Dict, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class luno
5
5
  * @augments Exchange
@@ -29,29 +29,13 @@ export default class luno extends Exchange {
29
29
  fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
30
30
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
31
31
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
32
- fetchLedgerByEntries(code?: Str, entry?: any, limit?: any, params?: {}): Promise<any>;
33
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
32
+ fetchLedgerByEntries(code?: Str, entry?: any, limit?: any, params?: {}): Promise<LedgerEntry[]>;
33
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
34
34
  parseLedgerComment(comment: any): {
35
35
  type: string;
36
36
  referenceId: any;
37
37
  };
38
- parseLedgerEntry(entry: any, currency?: Currency): {
39
- id: string;
40
- direction: any;
41
- account: string;
42
- referenceId: any;
43
- referenceAccount: any;
44
- type: string;
45
- currency: string;
46
- amount: number;
47
- timestamp: number;
48
- datetime: string;
49
- before: number;
50
- after: number;
51
- status: any;
52
- fee: any;
53
- info: any;
54
- };
38
+ parseLedgerEntry(entry: any, currency?: Currency): LedgerEntry;
55
39
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
56
40
  url: string;
57
41
  method: string;
package/js/src/luno.js CHANGED
@@ -993,11 +993,11 @@ export default class luno extends Exchange {
993
993
  /**
994
994
  * @method
995
995
  * @name luno#fetchLedger
996
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
996
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
997
997
  * @see https://www.luno.com/en/developers/api#tag/Accounts/operation/ListTransactions
998
- * @param {string} code unified currency code, default is undefined
998
+ * @param {string} [code] unified currency code, default is undefined
999
999
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1000
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1000
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1001
1001
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1002
1002
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1003
1003
  */
@@ -1084,6 +1084,7 @@ export default class luno extends Exchange {
1084
1084
  const timestamp = this.safeInteger(entry, 'timestamp');
1085
1085
  const currencyId = this.safeString(entry, 'currency');
1086
1086
  const code = this.safeCurrencyCode(currencyId, currency);
1087
+ currency = this.safeCurrency(currencyId, currency);
1087
1088
  const available_delta = this.safeString(entry, 'available_delta');
1088
1089
  const balance_delta = this.safeString(entry, 'balance_delta');
1089
1090
  const after = this.safeString(entry, 'balance');
@@ -1114,7 +1115,8 @@ export default class luno extends Exchange {
1114
1115
  else if (Precise.stringLt(balance_delta, '0') || Precise.stringLt(available_delta, '0')) {
1115
1116
  direction = 'out';
1116
1117
  }
1117
- return {
1118
+ return this.safeLedgerEntry({
1119
+ 'info': entry,
1118
1120
  'id': id,
1119
1121
  'direction': direction,
1120
1122
  'account': account_id,
@@ -1122,15 +1124,14 @@ export default class luno extends Exchange {
1122
1124
  'referenceAccount': undefined,
1123
1125
  'type': type,
1124
1126
  'currency': code,
1125
- 'amount': this.parseNumber(amount),
1127
+ 'amount': this.parseToNumeric(amount),
1126
1128
  'timestamp': timestamp,
1127
1129
  'datetime': this.iso8601(timestamp),
1128
- 'before': this.parseNumber(before),
1129
- 'after': this.parseNumber(after),
1130
+ 'before': this.parseToNumeric(before),
1131
+ 'after': this.parseToNumeric(after),
1130
1132
  'status': status,
1131
1133
  'fee': undefined,
1132
- 'info': entry,
1133
- };
1134
+ }, currency);
1134
1135
  }
1135
1136
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1136
1137
  let url = this.urls['api'][api] + '/' + this.version + '/' + this.implodeParams(path, params);