ccxt 4.5.18 → 4.5.20

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 (152) hide show
  1. package/README.md +7 -6
  2. package/dist/ccxt.browser.min.js +40 -16
  3. package/dist/cjs/_virtual/index.cjs.js +1459 -9
  4. package/dist/cjs/ccxt.js +8 -2
  5. package/dist/cjs/src/abstract/dydx.js +11 -0
  6. package/dist/cjs/src/base/Exchange.js +164 -10
  7. package/dist/cjs/src/base/ws/Client.js +3 -1
  8. package/dist/cjs/src/binance.js +8 -1
  9. package/dist/cjs/src/bingx.js +20 -0
  10. package/dist/cjs/src/bitget.js +43 -41
  11. package/dist/cjs/src/bybit.js +21 -23
  12. package/dist/cjs/src/deribit.js +6 -0
  13. package/dist/cjs/src/dydx.js +2454 -0
  14. package/dist/cjs/src/gate.js +4 -4
  15. package/dist/cjs/src/hibachi.js +1 -1
  16. package/dist/cjs/src/hyperliquid.js +207 -9
  17. package/dist/cjs/src/kucoin.js +711 -109
  18. package/dist/cjs/src/mexc.js +2 -3
  19. package/dist/cjs/src/pro/binance.js +59 -144
  20. package/dist/cjs/src/pro/dydx.js +418 -0
  21. package/dist/cjs/src/pro/kraken.js +4 -3
  22. package/dist/cjs/src/pro/xt.js +218 -4
  23. package/dist/cjs/src/protobuf/mexc/compiled.cjs.js +1 -0
  24. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +56 -0
  25. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +56 -0
  26. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +48 -0
  27. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +343 -0
  28. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +717 -0
  29. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +60 -0
  30. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +45 -0
  31. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +380 -0
  32. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +72 -0
  33. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +211 -0
  34. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +195 -0
  35. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +49 -0
  36. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +57 -0
  37. package/dist/cjs/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +56 -0
  38. package/dist/cjs/src/static_dependencies/dydx-v4-client/helpers.js +79 -0
  39. package/dist/cjs/src/static_dependencies/dydx-v4-client/long/index.cjs.js +9 -0
  40. package/dist/cjs/src/static_dependencies/dydx-v4-client/onboarding.js +59 -0
  41. package/dist/cjs/src/static_dependencies/dydx-v4-client/registry.js +39 -0
  42. package/dist/cjs/src/static_dependencies/noble-hashes/pbkdf2.js +69 -0
  43. package/dist/cjs/src/static_dependencies/noble-hashes/ripemd160.js +108 -0
  44. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +50 -1
  45. package/dist/cjs/src/static_dependencies/scure-base/index.js +29 -0
  46. package/dist/cjs/src/static_dependencies/scure-bip32/index.js +278 -0
  47. package/dist/cjs/src/static_dependencies/scure-bip39/index.js +97 -0
  48. package/dist/cjs/src/static_dependencies/scure-bip39/wordlists/english.js +2060 -0
  49. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2 -0
  50. package/dist/cjs/src/toobit.js +2 -1
  51. package/js/ccxt.d.ts +8 -2
  52. package/js/ccxt.js +6 -2
  53. package/js/src/abstract/binance.d.ts +7 -0
  54. package/js/src/abstract/binancecoinm.d.ts +7 -0
  55. package/js/src/abstract/binanceus.d.ts +7 -0
  56. package/js/src/abstract/binanceusdm.d.ts +7 -0
  57. package/js/src/abstract/bitget.d.ts +1 -0
  58. package/js/src/abstract/dydx.d.ts +61 -0
  59. package/js/src/abstract/dydx.js +11 -0
  60. package/js/src/abstract/kucoin.d.ts +1 -1
  61. package/js/src/abstract/kucoinfutures.d.ts +1 -1
  62. package/js/src/base/Exchange.d.ts +7 -0
  63. package/js/src/base/Exchange.js +163 -10
  64. package/js/src/base/ws/Client.js +3 -1
  65. package/js/src/binance.js +8 -1
  66. package/js/src/bingx.js +20 -0
  67. package/js/src/bitget.d.ts +3 -3
  68. package/js/src/bitget.js +43 -41
  69. package/js/src/bybit.d.ts +3 -3
  70. package/js/src/bybit.js +21 -23
  71. package/js/src/deribit.js +6 -0
  72. package/js/src/dydx.d.ts +364 -0
  73. package/js/src/dydx.js +2453 -0
  74. package/js/src/gate.d.ts +2 -2
  75. package/js/src/gate.js +4 -4
  76. package/js/src/hibachi.js +1 -1
  77. package/js/src/hyperliquid.d.ts +17 -0
  78. package/js/src/hyperliquid.js +207 -9
  79. package/js/src/kucoin.d.ts +48 -1
  80. package/js/src/kucoin.js +711 -109
  81. package/js/src/mexc.js +2 -3
  82. package/js/src/pro/binance.d.ts +2 -2
  83. package/js/src/pro/binance.js +59 -144
  84. package/js/src/pro/dydx.d.ts +81 -0
  85. package/js/src/pro/dydx.js +417 -0
  86. package/js/src/pro/kraken.js +4 -3
  87. package/js/src/pro/xt.d.ts +85 -2
  88. package/js/src/pro/xt.js +218 -4
  89. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.d.ts +90 -0
  90. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +163 -0
  91. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.d.ts +26 -0
  92. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +51 -0
  93. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.d.ts +48 -0
  94. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +85 -0
  95. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.d.ts +40 -0
  96. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +77 -0
  97. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.d.ts +162 -0
  98. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +329 -0
  99. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.d.ts +460 -0
  100. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +698 -0
  101. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.d.ts +127 -0
  102. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +286 -0
  103. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.d.ts +66 -0
  104. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +109 -0
  105. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.d.ts +127 -0
  106. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +257 -0
  107. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.d.ts +48 -0
  108. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +93 -0
  109. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.d.ts +23 -0
  110. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +43 -0
  111. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.d.ts +92 -0
  112. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +164 -0
  113. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.d.ts +124 -0
  114. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +196 -0
  115. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.d.ts +159 -0
  116. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +324 -0
  117. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.d.ts +546 -0
  118. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +872 -0
  119. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.d.ts +84 -0
  120. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +181 -0
  121. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.d.ts +397 -0
  122. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +757 -0
  123. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.d.ts +120 -0
  124. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +246 -0
  125. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.d.ts +79 -0
  126. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +147 -0
  127. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.d.ts +32 -0
  128. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +59 -0
  129. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.d.ts +34 -0
  130. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +66 -0
  131. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.d.ts +62 -0
  132. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +111 -0
  133. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.d.ts +207 -0
  134. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +50 -0
  135. package/js/src/static_dependencies/dydx-v4-client/helpers.d.ts +82 -0
  136. package/js/src/static_dependencies/dydx-v4-client/helpers.js +172 -0
  137. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +1473 -0
  138. package/js/src/static_dependencies/dydx-v4-client/long/index.d.cts +2 -0
  139. package/js/src/static_dependencies/dydx-v4-client/onboarding.d.ts +35 -0
  140. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +56 -0
  141. package/js/src/static_dependencies/dydx-v4-client/registry.d.ts +7 -0
  142. package/js/src/static_dependencies/dydx-v4-client/registry.js +36 -0
  143. package/js/src/static_dependencies/noble-hashes/utils.d.ts +1 -0
  144. package/js/src/static_dependencies/noble-hashes/utils.js +4 -0
  145. package/js/src/static_dependencies/scure-bip32/index.d.ts +49 -0
  146. package/js/src/static_dependencies/scure-bip32/index.js +295 -0
  147. package/js/src/static_dependencies/scure-bip39/index.d.ts +54 -0
  148. package/js/src/static_dependencies/scure-bip39/index.js +140 -0
  149. package/js/src/static_dependencies/scure-bip39/wordlists/english.d.ts +1 -0
  150. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +2054 -0
  151. package/js/src/toobit.js +2 -1
  152. package/package.json +9 -3
package/js/src/gate.d.ts CHANGED
@@ -63,8 +63,8 @@ export default class gate extends Exchange {
63
63
  contract: boolean;
64
64
  linear: boolean;
65
65
  inverse: boolean;
66
- taker: any;
67
- maker: any;
66
+ taker: number;
67
+ maker: number;
68
68
  contractSize: number;
69
69
  expiry: number;
70
70
  expiryDatetime: string;
package/js/src/gate.js CHANGED
@@ -1607,8 +1607,8 @@ export default class gate extends Exchange {
1607
1607
  'contract': true,
1608
1608
  'linear': isLinear,
1609
1609
  'inverse': !isLinear,
1610
- 'taker': undefined,
1611
- 'maker': undefined,
1610
+ 'taker': this.parseNumber('0.0005'),
1611
+ 'maker': this.parseNumber('0.0002'),
1612
1612
  'contractSize': this.parseNumber(contractSize),
1613
1613
  'expiry': expiry,
1614
1614
  'expiryDatetime': this.iso8601(expiry),
@@ -1726,8 +1726,8 @@ export default class gate extends Exchange {
1726
1726
  'contract': true,
1727
1727
  'linear': true,
1728
1728
  'inverse': false,
1729
- 'taker': undefined,
1730
- 'maker': undefined,
1729
+ 'taker': this.parseNumber('0.0003'),
1730
+ 'maker': this.parseNumber('0.0003'),
1731
1731
  'contractSize': this.parseNumber('1'),
1732
1732
  'expiry': expiry,
1733
1733
  'expiryDatetime': this.iso8601(expiry),
package/js/src/hibachi.js CHANGED
@@ -830,7 +830,7 @@ export default class hibachi extends Exchange {
830
830
  }
831
831
  createOrderRequest(nonce, symbol, type, side, amount, price = undefined, params = {}) {
832
832
  const market = this.market(symbol);
833
- const feeRate = Math.max(this.safeNumber(market, 'taker'), this.safeNumber(market, 'maker'));
833
+ const feeRate = Math.max(this.safeNumber(market, 'taker', this.safeNumber(this.options, 'defaultTakerFee', 0.00045)), this.safeNumber(market, 'maker', this.safeNumber(this.options, 'defaultMakerFee', 0.00015)));
834
834
  let sideInternal = '';
835
835
  if (side === 'sell') {
836
836
  sideInternal = 'ASK';
@@ -28,6 +28,16 @@ export default class hyperliquid extends Exchange {
28
28
  * @returns {object[]} an array of objects representing market data
29
29
  */
30
30
  fetchMarkets(params?: {}): Promise<Market[]>;
31
+ /**
32
+ * @method
33
+ * @name hyperliquid#fetchHip3Markets
34
+ * @description retrieves data on all hip3 markets for hyperliquid
35
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-all-perpetual-dexs
36
+ * @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
37
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
38
+ * @returns {object[]} an array of objects representing market data
39
+ */
40
+ fetchHip3Markets(params?: {}): Promise<Market[]>;
31
41
  /**
32
42
  * @method
33
43
  * @name hyperliquid#fetchSwapMarkets
@@ -177,6 +187,11 @@ export default class hyperliquid extends Exchange {
177
187
  s: string;
178
188
  v: any;
179
189
  };
190
+ buildUserDexAbstractionSig(message: any): {
191
+ r: string;
192
+ s: string;
193
+ v: any;
194
+ };
180
195
  buildApproveBuilderFeeSig(message: any): {
181
196
  r: string;
182
197
  s: string;
@@ -186,6 +201,7 @@ export default class hyperliquid extends Exchange {
186
201
  approveBuilderFee(builder: string, maxFeeRate: string): Promise<any>;
187
202
  initializeClient(): Promise<boolean>;
188
203
  handleBuilderFeeApproval(): Promise<boolean>;
204
+ enableUserDexAbstraction(enabled: boolean, params?: {}): Promise<any>;
189
205
  /**
190
206
  * @method
191
207
  * @name hyperliquid#createOrder
@@ -344,6 +360,7 @@ export default class hyperliquid extends Exchange {
344
360
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
345
361
  * @param {string} [params.method] 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders'
346
362
  * @param {string} [params.subAccountAddress] sub account user address
363
+ * @param {string} [params.dex] perp dex name. default is null
347
364
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
348
365
  */
349
366
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
@@ -236,6 +236,13 @@ export default class hyperliquid extends Exchange {
236
236
  'XAUT0': 'XAUT',
237
237
  'UXPL': 'XPL',
238
238
  },
239
+ 'fetchMarkets': {
240
+ 'types': ['spot', 'swap', 'hip3'], // 'spot', 'swap', 'hip3'
241
+ // 'hip3': {
242
+ // 'limit': 5, // how many dexes to load max if dexes are not specified
243
+ // 'dex': [ 'xyz' ],
244
+ // },
245
+ },
239
246
  },
240
247
  'features': {
241
248
  'default': {
@@ -474,14 +481,144 @@ export default class hyperliquid extends Exchange {
474
481
  * @returns {object[]} an array of objects representing market data
475
482
  */
476
483
  async fetchMarkets(params = {}) {
477
- const rawPromises = [
478
- this.fetchSwapMarkets(params),
479
- this.fetchSpotMarkets(params),
480
- ];
484
+ const options = this.safeDict(this.options, 'fetchMarkets', {});
485
+ const types = this.safeList(options, 'types');
486
+ const rawPromises = [];
487
+ for (let i = 0; i < types.length; i++) {
488
+ const marketType = types[i];
489
+ if (marketType === 'swap') {
490
+ rawPromises.push(this.fetchSwapMarkets(params));
491
+ }
492
+ else if (marketType === 'spot') {
493
+ rawPromises.push(this.fetchSpotMarkets(params));
494
+ }
495
+ else if (marketType === 'hip3') {
496
+ rawPromises.push(this.fetchHip3Markets(params));
497
+ }
498
+ }
499
+ const promises = await Promise.all(rawPromises);
500
+ let result = [];
501
+ for (let i = 0; i < promises.length; i++) {
502
+ result = this.arrayConcat(result, promises[i]);
503
+ }
504
+ return result;
505
+ }
506
+ /**
507
+ * @method
508
+ * @name hyperliquid#fetchHip3Markets
509
+ * @description retrieves data on all hip3 markets for hyperliquid
510
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-all-perpetual-dexs
511
+ * @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
512
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
513
+ * @returns {object[]} an array of objects representing market data
514
+ */
515
+ async fetchHip3Markets(params = {}) {
516
+ const fetchDexes = await this.publicPostInfo({
517
+ 'type': 'perpDexs',
518
+ });
519
+ //
520
+ // [
521
+ // null,
522
+ // {
523
+ // "name": "xyz",
524
+ // "fullName": "XYZ",
525
+ // "deployer": "0x88806a71d74ad0a510b350545c9ae490912f0888",
526
+ // "oracleUpdater": "0x1234567890545d1df9ee64b35fdd16966e08acec",
527
+ // "feeRecipient": "0x79c0650064b10f73649b7b64c5ebf0b319606140",
528
+ // "assetToStreamingOiCap": [
529
+ // [
530
+ // "xyz:XYZ100",
531
+ // "100000000.0"
532
+ // ]
533
+ // ]
534
+ // }
535
+ // ]
536
+ //
537
+ const perpDexesOffset = {};
538
+ for (let i = 1; i < fetchDexes.length; i++) {
539
+ // builder-deployed perp dexs start at 110000
540
+ const dex = fetchDexes[i];
541
+ const offset = 110000 + (i - 1) * 10000;
542
+ perpDexesOffset[dex['name']] = offset;
543
+ }
544
+ let fetchDexesList = [];
545
+ const options = this.safeDict(this.options, 'fetchMarkets', {});
546
+ const hip3 = this.safeDict(options, 'hip3', {});
547
+ const defaultLimit = this.safeInteger(hip3, 'limit', 5);
548
+ const dexesLength = fetchDexes.length;
549
+ if (dexesLength >= defaultLimit) { // first element is null
550
+ const defaultDexes = this.safeList(hip3, 'dex', []);
551
+ if (defaultDexes.length === 0) {
552
+ throw new ArgumentsRequired(this.id + ' fetchHip3Markets() Too many DEXes found. Please specify a list of DEXes in the exchange.options["fetchMarkets"]["hip3"]["dex"] parameter to fetch markets from those DEXes only. The limit is set to ' + defaultLimit.toString() + ' DEXes by default.');
553
+ }
554
+ else {
555
+ fetchDexesList = defaultDexes;
556
+ }
557
+ }
558
+ else {
559
+ for (let i = 1; i < fetchDexes.length; i++) {
560
+ const dex = this.safeDict(fetchDexes, i, {});
561
+ const dexName = this.safeString(dex, 'name');
562
+ fetchDexesList.push(dexName);
563
+ }
564
+ }
565
+ const rawPromises = [];
566
+ for (let i = 0; i < fetchDexesList.length; i++) {
567
+ const request = {
568
+ 'type': 'metaAndAssetCtxs',
569
+ 'dex': this.safeString(fetchDexesList, i),
570
+ };
571
+ rawPromises.push(this.publicPostInfo(this.extend(request, params)));
572
+ }
481
573
  const promises = await Promise.all(rawPromises);
482
- const swapMarkets = promises[0];
483
- const spotMarkets = promises[1];
484
- return this.arrayConcat(swapMarkets, spotMarkets);
574
+ let markets = [];
575
+ for (let i = 0; i < promises.length; i++) {
576
+ const dexName = fetchDexesList[i];
577
+ const offset = perpDexesOffset[dexName];
578
+ const response = promises[i];
579
+ const meta = this.safeDict(response, 0, {});
580
+ const universe = this.safeList(meta, 'universe', []);
581
+ const assetCtxs = this.safeList(response, 1, []);
582
+ const result = [];
583
+ for (let j = 0; j < universe.length; j++) {
584
+ const data = this.extend(this.safeDict(universe, j, {}), this.safeDict(assetCtxs, j, {}));
585
+ data['baseId'] = j + offset;
586
+ result.push(data);
587
+ }
588
+ markets = this.arrayConcat(markets, this.parseMarkets(result));
589
+ }
590
+ //
591
+ // [
592
+ // {
593
+ // "universe": [
594
+ // {
595
+ // "maxLeverage": 50,
596
+ // "name": "SOL",
597
+ // "onlyIsolated": false,
598
+ // "szDecimals": 2
599
+ // }
600
+ // ]
601
+ // },
602
+ // [
603
+ // {
604
+ // "dayNtlVlm": "9450588.2273",
605
+ // "funding": "0.0000198",
606
+ // "impactPxs": [
607
+ // "108.04",
608
+ // "108.06"
609
+ // ],
610
+ // "markPx": "108.04",
611
+ // "midPx": "108.05",
612
+ // "openInterest": "10764.48",
613
+ // "oraclePx": "107.99",
614
+ // "premium": "0.00055561",
615
+ // "prevDayPx": "111.81"
616
+ // }
617
+ // ]
618
+ // ]
619
+ //
620
+ //
621
+ return markets;
485
622
  }
486
623
  /**
487
624
  * @method
@@ -787,7 +924,7 @@ export default class hyperliquid extends Exchange {
787
924
  const baseId = this.safeString(market, 'baseId');
788
925
  const settleId = 'USDC';
789
926
  const settle = this.safeCurrencyCode(settleId);
790
- let symbol = base + '/' + quote;
927
+ let symbol = base.replace(':', '-') + '/' + quote;
791
928
  const contract = true;
792
929
  const swap = true;
793
930
  if (contract) {
@@ -1462,6 +1599,17 @@ export default class hyperliquid extends Exchange {
1462
1599
  };
1463
1600
  return this.signUserSignedAction(messageTypes, message);
1464
1601
  }
1602
+ buildUserDexAbstractionSig(message) {
1603
+ const messageTypes = {
1604
+ 'HyperliquidTransaction:UserDexAbstraction': [
1605
+ { 'name': 'hyperliquidChain', 'type': 'string' },
1606
+ { 'name': 'user', 'type': 'address' },
1607
+ { 'name': 'enabled', 'type': 'bool' },
1608
+ { 'name': 'nonce', 'type': 'uint64' },
1609
+ ],
1610
+ };
1611
+ return this.signUserSignedAction(messageTypes, message);
1612
+ }
1465
1613
  buildApproveBuilderFeeSig(message) {
1466
1614
  const messageTypes = {
1467
1615
  'HyperliquidTransaction:ApproveBuilderFee': [
@@ -1562,6 +1710,42 @@ export default class hyperliquid extends Exchange {
1562
1710
  }
1563
1711
  return true;
1564
1712
  }
1713
+ async enableUserDexAbstraction(enabled, params = {}) {
1714
+ let userAddress = undefined;
1715
+ [userAddress, params] = this.handlePublicAddress('enableUserDexAbstraction', params);
1716
+ const nonce = this.milliseconds();
1717
+ const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1718
+ const payload = {
1719
+ 'hyperliquidChain': isSandboxMode ? 'Testnet' : 'Mainnet',
1720
+ 'user': userAddress,
1721
+ 'enabled': enabled,
1722
+ 'nonce': nonce,
1723
+ };
1724
+ const sig = this.buildUserDexAbstractionSig(payload);
1725
+ const action = {
1726
+ 'hyperliquidChain': payload['hyperliquidChain'],
1727
+ 'signatureChainId': '0x66eee',
1728
+ 'enabled': payload['enabled'],
1729
+ 'user': payload['user'],
1730
+ 'nonce': nonce,
1731
+ 'type': 'userDexAbstraction',
1732
+ };
1733
+ const request = {
1734
+ 'action': action,
1735
+ 'nonce': nonce,
1736
+ 'signature': sig,
1737
+ 'vaultAddress': undefined,
1738
+ };
1739
+ //
1740
+ // {
1741
+ // "status": "ok",
1742
+ // "response": {
1743
+ // "type": "default"
1744
+ // }
1745
+ // }
1746
+ //
1747
+ return await this.privatePostExchange(request);
1748
+ }
1565
1749
  /**
1566
1750
  * @method
1567
1751
  * @name hyperliquid#createOrder
@@ -2380,6 +2564,7 @@ export default class hyperliquid extends Exchange {
2380
2564
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
2381
2565
  * @param {string} [params.method] 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders'
2382
2566
  * @param {string} [params.subAccountAddress] sub account user address
2567
+ * @param {string} [params.dex] perp dex name. default is null
2383
2568
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2384
2569
  */
2385
2570
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2388,11 +2573,21 @@ export default class hyperliquid extends Exchange {
2388
2573
  let method = undefined;
2389
2574
  [method, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'method', 'frontendOpenOrders');
2390
2575
  await this.loadMarkets();
2391
- const market = this.safeMarket(symbol);
2392
2576
  const request = {
2393
2577
  'type': method,
2394
2578
  'user': userAddress,
2395
2579
  };
2580
+ let market = undefined;
2581
+ if (symbol !== undefined) {
2582
+ market = this.market(symbol);
2583
+ // check if is hip3 symbol
2584
+ const baseName = this.safeString(market, 'baseName', '');
2585
+ const part = baseName.split(':');
2586
+ const partsLength = part.length;
2587
+ if (partsLength > 1) {
2588
+ request['dex'] = this.safeString(part, 0);
2589
+ }
2590
+ }
2396
2591
  const response = await this.publicPostInfo(this.extend(request, params));
2397
2592
  //
2398
2593
  // [
@@ -4017,6 +4212,9 @@ export default class hyperliquid extends Exchange {
4017
4212
  if (coin.indexOf('/') > -1 || coin.indexOf('@') > -1) {
4018
4213
  return coin; // spot
4019
4214
  }
4215
+ if (coin.indexOf(':') > -1) {
4216
+ coin = coin.replace(':', '-'); // hip3
4217
+ }
4020
4218
  return this.safeCurrencyCode(coin) + '/USDC:USDC';
4021
4219
  }
4022
4220
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
@@ -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, LedgerEntry, DepositAddress, BorrowInterest } 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, DepositAddress, BorrowInterest, FundingRate } from './base/types.js';
3
3
  /**
4
4
  * @class kucoin
5
5
  * @augments Exchange
@@ -21,7 +21,10 @@ export default class kucoin extends Exchange {
21
21
  * @name kucoin#fetchStatus
22
22
  * @description the latest known information on the availability of the exchange API
23
23
  * @see https://docs.kucoin.com/#service-status
24
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-service-status
24
25
  * @param {object} [params] extra parameters specific to the exchange API endpoint
26
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
27
+ * @param {string} [params.tradeType] *uta only* set to SPOT or FUTURES
25
28
  * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
26
29
  */
27
30
  fetchStatus(params?: {}): Promise<{
@@ -38,9 +41,11 @@ export default class kucoin extends Exchange {
38
41
  * @see https://docs.kucoin.com/#get-symbols-list-deprecated
39
42
  * @see https://docs.kucoin.com/#get-all-tickers
40
43
  * @param {object} [params] extra parameters specific to the exchange API endpoint
44
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
41
45
  * @returns {object[]} an array of objects representing market data
42
46
  */
43
47
  fetchMarkets(params?: {}): Promise<Market[]>;
48
+ fetchUtaMarkets(params?: {}): Promise<Market[]>;
44
49
  /**
45
50
  * @method
46
51
  * @name kucoin#loadMigrationStatus
@@ -102,8 +107,11 @@ export default class kucoin extends Exchange {
102
107
  * @name kucoin#fetchTickers
103
108
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
104
109
  * @see https://docs.kucoin.com/#get-all-tickers
110
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-ticker
105
111
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
106
112
  * @param {object} [params] extra parameters specific to the exchange API endpoint
113
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
114
+ * @param {string} [params.tradeType] *uta only* set to SPOT or FUTURES
107
115
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
108
116
  */
109
117
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
@@ -122,8 +130,10 @@ export default class kucoin extends Exchange {
122
130
  * @name kucoin#fetchTicker
123
131
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
124
132
  * @see https://docs.kucoin.com/#get-24hr-stats
133
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-ticker
125
134
  * @param {string} symbol unified symbol of the market to fetch the ticker for
126
135
  * @param {object} [params] extra parameters specific to the exchange API endpoint
136
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
127
137
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
128
138
  */
129
139
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
@@ -143,11 +153,13 @@ export default class kucoin extends Exchange {
143
153
  * @name kucoin#fetchOHLCV
144
154
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
145
155
  * @see https://docs.kucoin.com/#get-klines
156
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-klines
146
157
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
147
158
  * @param {string} timeframe the length of time each candle represents
148
159
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
149
160
  * @param {int} [limit] the maximum amount of candles to fetch
150
161
  * @param {object} [params] extra parameters specific to the exchange API endpoint
162
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
151
163
  * @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)
152
164
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
153
165
  */
@@ -191,9 +203,11 @@ export default class kucoin extends Exchange {
191
203
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
192
204
  * @see https://www.kucoin.com/docs/rest/spot-trading/market-data/get-part-order-book-aggregated-
193
205
  * @see https://www.kucoin.com/docs/rest/spot-trading/market-data/get-full-order-book-aggregated-
206
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-orderbook
194
207
  * @param {string} symbol unified symbol of the market to fetch the order book for
195
208
  * @param {int} [limit] the maximum amount of order book entries to return
196
209
  * @param {object} [params] extra parameters specific to the exchange API endpoint
210
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
197
211
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
198
212
  */
199
213
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
@@ -471,10 +485,12 @@ export default class kucoin extends Exchange {
471
485
  * @name kucoin#fetchTrades
472
486
  * @description get the list of most recent trades for a particular symbol
473
487
  * @see https://www.kucoin.com/docs/rest/spot-trading/market-data/get-trade-histories
488
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-trades
474
489
  * @param {string} symbol unified symbol of the market to fetch trades for
475
490
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
476
491
  * @param {int} [limit] the maximum amount of trades to fetch
477
492
  * @param {object} [params] extra parameters specific to the exchange API endpoint
493
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
478
494
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
479
495
  */
480
496
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
@@ -749,6 +765,37 @@ export default class kucoin extends Exchange {
749
765
  * @returns {object} response from the exchange
750
766
  */
751
767
  setLeverage(leverage: int, symbol?: Str, params?: {}): Promise<any>;
768
+ /**
769
+ * @method
770
+ * @name kucoin#fetchFundingRate
771
+ * @description fetch the current funding rate
772
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-current-funding-rate
773
+ * @param {string} symbol unified market symbol
774
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
775
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
776
+ */
777
+ fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
778
+ parseFundingRate(data: any, market?: Market): FundingRate;
779
+ /**
780
+ * @method
781
+ * @name kucoin#fetchFundingRateHistory
782
+ * @description fetches historical funding rate prices
783
+ * @see https://www.kucoin.com/docs-new/rest/ua/get-history-funding-rate
784
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
785
+ * @param {int} [since] not used by kucuoinfutures
786
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
787
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
788
+ * @param {int} [params.until] end time in ms
789
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
790
+ */
791
+ fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").FundingRateHistory[]>;
792
+ parseFundingRateHistory(info: any, market?: Market): {
793
+ info: any;
794
+ symbol: string;
795
+ fundingRate: number;
796
+ timestamp: number;
797
+ datetime: string;
798
+ };
752
799
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
753
800
  url: any;
754
801
  method: string;