ccxt 4.3.94 → 4.3.96

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 (63) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +8 -8
  3. package/dist/cjs/ccxt.js +1 -7
  4. package/dist/cjs/src/ascendex.js +8 -6
  5. package/dist/cjs/src/base/Exchange.js +3 -7
  6. package/dist/cjs/src/bingx.js +2 -1
  7. package/dist/cjs/src/bitfinex.js +3 -2
  8. package/dist/cjs/src/bitfinex2.js +6 -5
  9. package/dist/cjs/src/blofin.js +0 -1
  10. package/dist/cjs/src/btcturk.js +2 -2
  11. package/dist/cjs/src/bybit.js +8 -2
  12. package/dist/cjs/src/gate.js +3 -2
  13. package/dist/cjs/src/gemini.js +3 -2
  14. package/dist/cjs/src/hyperliquid.js +337 -42
  15. package/dist/cjs/src/independentreserve.js +4 -3
  16. package/dist/cjs/src/indodax.js +3 -0
  17. package/dist/cjs/src/kucoin.js +12 -12
  18. package/dist/cjs/src/mexc.js +78 -154
  19. package/dist/cjs/src/okx.js +2 -1
  20. package/dist/cjs/src/p2b.js +0 -1
  21. package/dist/cjs/src/pro/binance.js +100 -2
  22. package/dist/cjs/src/pro/bybit.js +65 -4
  23. package/dist/cjs/src/pro/cryptocom.js +224 -0
  24. package/dist/cjs/src/pro/okx.js +264 -35
  25. package/dist/cjs/src/tradeogre.js +0 -1
  26. package/js/ccxt.d.ts +2 -8
  27. package/js/ccxt.js +2 -6
  28. package/js/src/abstract/okx.d.ts +2 -0
  29. package/js/src/ascendex.js +8 -6
  30. package/js/src/base/Exchange.d.ts +1 -3
  31. package/js/src/base/Exchange.js +3 -7
  32. package/js/src/bingx.js +2 -1
  33. package/js/src/bitfinex.js +3 -2
  34. package/js/src/bitfinex2.js +6 -5
  35. package/js/src/blofin.js +0 -1
  36. package/js/src/btcturk.d.ts +2 -2
  37. package/js/src/btcturk.js +2 -2
  38. package/js/src/bybit.js +8 -2
  39. package/js/src/gate.js +3 -2
  40. package/js/src/gemini.js +3 -2
  41. package/js/src/hyperliquid.d.ts +25 -0
  42. package/js/src/hyperliquid.js +337 -42
  43. package/js/src/independentreserve.js +4 -3
  44. package/js/src/indodax.js +3 -0
  45. package/js/src/kucoin.d.ts +1 -1
  46. package/js/src/kucoin.js +12 -12
  47. package/js/src/mexc.js +78 -154
  48. package/js/src/okx.js +2 -1
  49. package/js/src/p2b.js +0 -1
  50. package/js/src/pro/binance.d.ts +2 -0
  51. package/js/src/pro/binance.js +100 -2
  52. package/js/src/pro/bybit.d.ts +3 -1
  53. package/js/src/pro/bybit.js +65 -4
  54. package/js/src/pro/cryptocom.d.ts +10 -1
  55. package/js/src/pro/cryptocom.js +225 -1
  56. package/js/src/pro/okx.d.ts +10 -1
  57. package/js/src/pro/okx.js +264 -35
  58. package/js/src/tradeogre.js +0 -1
  59. package/package.json +1 -1
  60. package/js/src/abstract/bitbay.d.ts +0 -56
  61. package/js/src/abstract/bitbay.js +0 -11
  62. package/js/src/abstract/hitbtc3.d.ts +0 -118
  63. package/js/src/abstract/hitbtc3.js +0 -11
@@ -54,14 +54,15 @@ class hyperliquid extends hyperliquid$1 {
54
54
  'fetchBorrowInterest': false,
55
55
  'fetchBorrowRateHistories': false,
56
56
  'fetchBorrowRateHistory': false,
57
- 'fetchCanceledOrders': false,
57
+ 'fetchCanceledAndClosedOrders': true,
58
+ 'fetchCanceledOrders': true,
58
59
  'fetchClosedOrders': true,
59
60
  'fetchCrossBorrowRate': false,
60
61
  'fetchCrossBorrowRates': false,
61
62
  'fetchCurrencies': true,
62
63
  'fetchDepositAddress': false,
63
64
  'fetchDepositAddresses': false,
64
- 'fetchDeposits': false,
65
+ 'fetchDeposits': true,
65
66
  'fetchDepositWithdrawFee': 'emulated',
66
67
  'fetchDepositWithdrawFees': false,
67
68
  'fetchFundingHistory': false,
@@ -71,7 +72,7 @@ class hyperliquid extends hyperliquid$1 {
71
72
  'fetchIndexOHLCV': false,
72
73
  'fetchIsolatedBorrowRate': false,
73
74
  'fetchIsolatedBorrowRates': false,
74
- 'fetchLedger': false,
75
+ 'fetchLedger': true,
75
76
  'fetchLeverage': false,
76
77
  'fetchLeverageTiers': false,
77
78
  'fetchLiquidations': false,
@@ -87,7 +88,7 @@ class hyperliquid extends hyperliquid$1 {
87
88
  'fetchOpenOrders': true,
88
89
  'fetchOrder': true,
89
90
  'fetchOrderBook': true,
90
- 'fetchOrders': false,
91
+ 'fetchOrders': true,
91
92
  'fetchOrderTrades': false,
92
93
  'fetchPosition': true,
93
94
  'fetchPositionMode': false,
@@ -103,7 +104,7 @@ class hyperliquid extends hyperliquid$1 {
103
104
  'fetchTransfer': false,
104
105
  'fetchTransfers': false,
105
106
  'fetchWithdrawal': false,
106
- 'fetchWithdrawals': false,
107
+ 'fetchWithdrawals': true,
107
108
  'reduceMargin': true,
108
109
  'repayCrossMargin': false,
109
110
  'repayIsolatedMargin': false,
@@ -826,6 +827,7 @@ class hyperliquid extends hyperliquid$1 {
826
827
  await this.loadMarkets();
827
828
  const market = this.market(symbol);
828
829
  const until = this.safeInteger(params, 'until', this.milliseconds());
830
+ const useTail = (since === undefined);
829
831
  if (since === undefined) {
830
832
  since = 0;
831
833
  }
@@ -856,7 +858,7 @@ class hyperliquid extends hyperliquid$1 {
856
858
  // }
857
859
  // ]
858
860
  //
859
- return this.parseOHLCVs(response, market, timeframe, since, limit);
861
+ return this.parseOHLCVs(response, market, timeframe, since, limit, useTail);
860
862
  }
861
863
  parseOHLCV(ohlcv, market = undefined) {
862
864
  //
@@ -1731,7 +1733,16 @@ class hyperliquid extends hyperliquid$1 {
1731
1733
  // }
1732
1734
  // ]
1733
1735
  //
1734
- return this.parseOrders(response, market, since, limit);
1736
+ const orderWithStatus = [];
1737
+ for (let i = 0; i < response.length; i++) {
1738
+ const order = response[i];
1739
+ const extendOrder = {};
1740
+ if (this.safeString(order, 'status') === undefined) {
1741
+ extendOrder['ccxtStatus'] = 'open';
1742
+ }
1743
+ orderWithStatus.push(this.extend(order, extendOrder));
1744
+ }
1745
+ return this.parseOrders(orderWithStatus, market, since, limit);
1735
1746
  }
1736
1747
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1737
1748
  /**
@@ -1745,8 +1756,59 @@ class hyperliquid extends hyperliquid$1 {
1745
1756
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
1746
1757
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1747
1758
  */
1759
+ await this.loadMarkets();
1760
+ const orders = await this.fetchOrders(symbol, undefined, undefined, params); // don't filter here because we don't want to catch open orders
1761
+ const closedOrders = this.filterByArray(orders, 'status', ['closed'], false);
1762
+ return this.filterBySymbolSinceLimit(closedOrders, symbol, since, limit);
1763
+ }
1764
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1765
+ /**
1766
+ * @method
1767
+ * @name hyperliquid#fetchCanceledOrders
1768
+ * @description fetch all canceled orders
1769
+ * @param {string} symbol unified market symbol
1770
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1771
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
1772
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1773
+ * @param {string} [params.user] user address, will default to this.walletAddress if not provided
1774
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1775
+ */
1776
+ await this.loadMarkets();
1777
+ const orders = await this.fetchOrders(symbol, undefined, undefined, params); // don't filter here because we don't want to catch open orders
1778
+ const closedOrders = this.filterByArray(orders, 'status', ['canceled'], false);
1779
+ return this.filterBySymbolSinceLimit(closedOrders, symbol, since, limit);
1780
+ }
1781
+ async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1782
+ /**
1783
+ * @method
1784
+ * @name hyperliquid#fetchCanceledAndClosedOrders
1785
+ * @description fetch all closed and canceled orders
1786
+ * @param {string} symbol unified market symbol
1787
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1788
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
1789
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1790
+ * @param {string} [params.user] user address, will default to this.walletAddress if not provided
1791
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1792
+ */
1793
+ await this.loadMarkets();
1794
+ const orders = await this.fetchOrders(symbol, undefined, undefined, params); // don't filter here because we don't want to catch open orders
1795
+ const closedOrders = this.filterByArray(orders, 'status', ['canceled', 'closed', 'rejected'], false);
1796
+ return this.filterBySymbolSinceLimit(closedOrders, symbol, since, limit);
1797
+ }
1798
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1799
+ /**
1800
+ * @method
1801
+ * @name hyperliquid#fetchOrders
1802
+ * @description fetch all orders
1803
+ * @param {string} symbol unified market symbol
1804
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1805
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
1806
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1807
+ * @param {string} [params.user] user address, will default to this.walletAddress if not provided
1808
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1809
+ */
1748
1810
  let userAddress = undefined;
1749
- [userAddress, params] = this.handlePublicAddress('fetchClosedOrders', params);
1811
+ [userAddress, params] = this.handlePublicAddress('fetchOrders', params);
1750
1812
  await this.loadMarkets();
1751
1813
  const market = this.safeMarket(symbol);
1752
1814
  const request = {
@@ -1920,12 +1982,7 @@ class hyperliquid extends hyperliquid$1 {
1920
1982
  const coin = this.safeString(entry, 'coin');
1921
1983
  let marketId = undefined;
1922
1984
  if (coin !== undefined) {
1923
- if (coin.indexOf('/') > -1) {
1924
- marketId = coin;
1925
- }
1926
- else {
1927
- marketId = coin + '/USDC:USDC';
1928
- }
1985
+ marketId = this.coinToMarketId(coin);
1929
1986
  }
1930
1987
  if (this.safeString(entry, 'id') === undefined) {
1931
1988
  market = this.safeMarket(marketId, undefined);
@@ -1935,11 +1992,14 @@ class hyperliquid extends hyperliquid$1 {
1935
1992
  }
1936
1993
  const symbol = market['symbol'];
1937
1994
  const timestamp = this.safeInteger2(order, 'timestamp', 'statusTimestamp');
1938
- const status = this.safeString(order, 'status');
1995
+ const status = this.safeString2(order, 'status', 'ccxtStatus');
1996
+ order = this.omit(order, ['ccxtStatus']);
1939
1997
  let side = this.safeString(entry, 'side');
1940
1998
  if (side !== undefined) {
1941
1999
  side = (side === 'A') ? 'sell' : 'buy';
1942
2000
  }
2001
+ const totalAmount = this.safeString2(entry, 'origSz', 'totalSz');
2002
+ const remaining = this.safeString(entry, 'sz');
1943
2003
  return this.safeOrder({
1944
2004
  'info': order,
1945
2005
  'id': this.safeString(entry, 'oid'),
@@ -1954,13 +2014,13 @@ class hyperliquid extends hyperliquid$1 {
1954
2014
  'postOnly': undefined,
1955
2015
  'reduceOnly': this.safeBool(entry, 'reduceOnly'),
1956
2016
  'side': side,
1957
- 'price': this.safeNumber(entry, 'limitPx'),
2017
+ 'price': this.safeString(entry, 'limitPx'),
1958
2018
  'triggerPrice': this.safeBool(entry, 'isTrigger') ? this.safeNumber(entry, 'triggerPx') : undefined,
1959
- 'amount': this.safeNumber2(entry, 'sz', 'totalSz'),
2019
+ 'amount': totalAmount,
1960
2020
  'cost': undefined,
1961
- 'average': this.safeNumber(entry, 'avgPx'),
1962
- 'filled': undefined,
1963
- 'remaining': undefined,
2021
+ 'average': this.safeString(entry, 'avgPx'),
2022
+ 'filled': Precise["default"].stringSub(totalAmount, remaining),
2023
+ 'remaining': remaining,
1964
2024
  'status': this.parseOrderStatus(status),
1965
2025
  'fee': undefined,
1966
2026
  'trades': undefined,
@@ -2059,7 +2119,7 @@ class hyperliquid extends hyperliquid$1 {
2059
2119
  const price = this.safeString(trade, 'px');
2060
2120
  const amount = this.safeString(trade, 'sz');
2061
2121
  const coin = this.safeString(trade, 'coin');
2062
- const marketId = coin + '/USDC:USDC';
2122
+ const marketId = this.coinToMarketId(coin);
2063
2123
  market = this.safeMarket(marketId, undefined);
2064
2124
  const symbol = market['symbol'];
2065
2125
  const id = this.safeString(trade, 'tid');
@@ -2199,7 +2259,7 @@ class hyperliquid extends hyperliquid$1 {
2199
2259
  //
2200
2260
  const entry = this.safeDict(position, 'position', {});
2201
2261
  const coin = this.safeString(entry, 'coin');
2202
- const marketId = coin + '/USDC:USDC';
2262
+ const marketId = this.coinToMarketId(coin);
2203
2263
  market = this.safeMarket(marketId, undefined);
2204
2264
  const symbol = market['symbol'];
2205
2265
  const leverage = this.safeDict(entry, 'leverage', {});
@@ -2512,11 +2572,13 @@ class hyperliquid extends hyperliquid$1 {
2512
2572
  * @name hyperliquid#withdraw
2513
2573
  * @description make a withdrawal (only support USDC)
2514
2574
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#initiate-a-withdrawal-request
2575
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-a-vault
2515
2576
  * @param {string} code unified currency code
2516
2577
  * @param {float} amount the amount to withdraw
2517
2578
  * @param {string} address the address to withdraw to
2518
2579
  * @param {string} tag
2519
2580
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2581
+ * @param {string} [params.vaultAddress] vault address withdraw from
2520
2582
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2521
2583
  */
2522
2584
  this.checkRequiredCredentials();
@@ -2528,24 +2590,40 @@ class hyperliquid extends hyperliquid$1 {
2528
2590
  throw new errors.NotSupported(this.id + 'withdraw() only support USDC');
2529
2591
  }
2530
2592
  }
2531
- const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2593
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
2594
+ params = this.omit(params, 'vaultAddress');
2532
2595
  const nonce = this.milliseconds();
2533
- const payload = {
2534
- 'hyperliquidChain': isSandboxMode ? 'Testnet' : 'Mainnet',
2535
- 'destination': address,
2536
- 'amount': amount.toString(),
2537
- 'time': nonce,
2538
- };
2539
- const sig = this.buildWithdrawSig(payload);
2540
- const request = {
2541
- 'action': {
2596
+ let action = {};
2597
+ let sig = undefined;
2598
+ if (vaultAddress !== undefined) {
2599
+ action = {
2600
+ 'type': 'vaultTransfer',
2601
+ 'vaultAddress': '0x' + vaultAddress,
2602
+ 'isDeposit': false,
2603
+ 'usd': amount,
2604
+ };
2605
+ sig = this.signL1Action(action, nonce);
2606
+ }
2607
+ else {
2608
+ const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2609
+ const payload = {
2610
+ 'hyperliquidChain': isSandboxMode ? 'Testnet' : 'Mainnet',
2611
+ 'destination': address,
2612
+ 'amount': amount.toString(),
2613
+ 'time': nonce,
2614
+ };
2615
+ sig = this.buildWithdrawSig(payload);
2616
+ action = {
2542
2617
  'hyperliquidChain': payload['hyperliquidChain'],
2543
2618
  'signatureChainId': '0x66eee',
2544
2619
  'destination': address,
2545
2620
  'amount': amount.toString(),
2546
2621
  'time': nonce,
2547
2622
  'type': 'withdraw3',
2548
- },
2623
+ };
2624
+ }
2625
+ const request = {
2626
+ 'action': action,
2549
2627
  'nonce': nonce,
2550
2628
  'signature': sig,
2551
2629
  };
@@ -2556,27 +2634,53 @@ class hyperliquid extends hyperliquid$1 {
2556
2634
  //
2557
2635
  // { status: 'ok', response: { type: 'default' } }
2558
2636
  //
2637
+ // fetchDeposits / fetchWithdrawals
2638
+ // {
2639
+ // "time":1724762307531,
2640
+ // "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
2641
+ // "delta":{
2642
+ // "type":"accountClassTransfer",
2643
+ // "usdc":"50.0",
2644
+ // "toPerp":false
2645
+ // }
2646
+ // }
2647
+ //
2648
+ const timestamp = this.safeInteger(transaction, 'time');
2649
+ const delta = this.safeDict(transaction, 'delta', {});
2650
+ let fee = undefined;
2651
+ const feeCost = this.safeInteger(delta, 'fee');
2652
+ if (feeCost !== undefined) {
2653
+ fee = {
2654
+ 'currency': 'USDC',
2655
+ 'cost': feeCost,
2656
+ };
2657
+ }
2658
+ let internal = undefined;
2659
+ const type = this.safeString(delta, 'type');
2660
+ if (type !== undefined) {
2661
+ internal = (type === 'internalTransfer');
2662
+ }
2559
2663
  return {
2560
2664
  'info': transaction,
2561
2665
  'id': undefined,
2562
- 'txid': undefined,
2563
- 'timestamp': undefined,
2564
- 'datetime': undefined,
2666
+ 'txid': this.safeString(transaction, 'hash'),
2667
+ 'timestamp': timestamp,
2668
+ 'datetime': this.iso8601(timestamp),
2565
2669
  'network': undefined,
2566
2670
  'address': undefined,
2567
- 'addressTo': undefined,
2568
- 'addressFrom': undefined,
2671
+ 'addressTo': this.safeString(delta, 'destination'),
2672
+ 'addressFrom': this.safeString(delta, 'user'),
2569
2673
  'tag': undefined,
2570
2674
  'tagTo': undefined,
2571
2675
  'tagFrom': undefined,
2572
2676
  'type': undefined,
2573
- 'amount': undefined,
2677
+ 'amount': this.safeInteger(delta, 'usdc'),
2574
2678
  'currency': undefined,
2575
2679
  'status': this.safeString(transaction, 'status'),
2576
2680
  'updated': undefined,
2577
2681
  'comment': undefined,
2578
- 'internal': undefined,
2579
- 'fee': undefined,
2682
+ 'internal': internal,
2683
+ 'fee': fee,
2580
2684
  };
2581
2685
  }
2582
2686
  async fetchTradingFee(symbol, params = {}) {
@@ -2685,6 +2789,197 @@ class hyperliquid extends hyperliquid$1 {
2685
2789
  'tierBased': undefined,
2686
2790
  };
2687
2791
  }
2792
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2793
+ /**
2794
+ * @method
2795
+ * @name hyperliquid#fetchLedger
2796
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2797
+ * @param {string} code unified currency code
2798
+ * @param {int} [since] timestamp in ms of the earliest ledger entry
2799
+ * @param {int} [limit] max number of ledger entrys to return
2800
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2801
+ * @param {int} [params.until] timestamp in ms of the latest ledger entry
2802
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2803
+ */
2804
+ await this.loadMarkets();
2805
+ let userAddress = undefined;
2806
+ [userAddress, params] = this.handlePublicAddress('fetchLedger', params);
2807
+ const request = {
2808
+ 'type': 'userNonFundingLedgerUpdates',
2809
+ 'user': userAddress,
2810
+ };
2811
+ if (since !== undefined) {
2812
+ request['startTime'] = since;
2813
+ }
2814
+ const until = this.safeInteger(params, 'until');
2815
+ if (until !== undefined) {
2816
+ request['endTime'] = until;
2817
+ params = this.omit(params, ['until']);
2818
+ }
2819
+ const response = await this.publicPostInfo(this.extend(request, params));
2820
+ //
2821
+ // [
2822
+ // {
2823
+ // "time":1724762307531,
2824
+ // "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
2825
+ // "delta":{
2826
+ // "type":"accountClassTransfer",
2827
+ // "usdc":"50.0",
2828
+ // "toPerp":false
2829
+ // }
2830
+ // }
2831
+ // ]
2832
+ //
2833
+ return this.parseLedger(response, undefined, since, limit);
2834
+ }
2835
+ parseLedgerEntry(item, currency = undefined) {
2836
+ //
2837
+ // {
2838
+ // "time":1724762307531,
2839
+ // "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
2840
+ // "delta":{
2841
+ // "type":"accountClassTransfer",
2842
+ // "usdc":"50.0",
2843
+ // "toPerp":false
2844
+ // }
2845
+ // }
2846
+ //
2847
+ const timestamp = this.safeInteger(item, 'time');
2848
+ const delta = this.safeDict(item, 'delta', {});
2849
+ let fee = undefined;
2850
+ const feeCost = this.safeInteger(delta, 'fee');
2851
+ if (feeCost !== undefined) {
2852
+ fee = {
2853
+ 'currency': 'USDC',
2854
+ 'cost': feeCost,
2855
+ };
2856
+ }
2857
+ const type = this.safeString(delta, 'type');
2858
+ const amount = this.safeString(delta, 'usdc');
2859
+ return {
2860
+ 'id': this.safeString(item, 'hash'),
2861
+ 'direction': undefined,
2862
+ 'account': undefined,
2863
+ 'referenceAccount': this.safeString(delta, 'user'),
2864
+ 'referenceId': this.safeString(item, 'hash'),
2865
+ 'type': this.parseLedgerEntryType(type),
2866
+ 'currency': undefined,
2867
+ 'amount': this.parseNumber(amount),
2868
+ 'timestamp': timestamp,
2869
+ 'datetime': this.iso8601(timestamp),
2870
+ 'before': undefined,
2871
+ 'after': undefined,
2872
+ 'status': undefined,
2873
+ 'fee': fee,
2874
+ 'info': item,
2875
+ };
2876
+ }
2877
+ parseLedgerEntryType(type) {
2878
+ const ledgerType = {
2879
+ 'internalTransfer': 'transfer',
2880
+ 'accountClassTransfer': 'transfer',
2881
+ };
2882
+ return this.safeString(ledgerType, type, type);
2883
+ }
2884
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
2885
+ /**
2886
+ * @method
2887
+ * @name hyperliquid#fetchDeposits
2888
+ * @description fetch all deposits made to an account
2889
+ * @param {string} code unified currency code
2890
+ * @param {int} [since] the earliest time in ms to fetch deposits for
2891
+ * @param {int} [limit] the maximum number of deposits structures to retrieve
2892
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2893
+ * @param {int} [params.until] the latest time in ms to fetch withdrawals for
2894
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2895
+ */
2896
+ await this.loadMarkets();
2897
+ let userAddress = undefined;
2898
+ [userAddress, params] = this.handlePublicAddress('fetchDepositsWithdrawals', params);
2899
+ const request = {
2900
+ 'type': 'userNonFundingLedgerUpdates',
2901
+ 'user': userAddress,
2902
+ };
2903
+ if (since !== undefined) {
2904
+ request['startTime'] = since;
2905
+ }
2906
+ const until = this.safeInteger(params, 'until');
2907
+ if (until !== undefined) {
2908
+ request['endTime'] = until;
2909
+ params = this.omit(params, ['until']);
2910
+ }
2911
+ const response = await this.publicPostInfo(this.extend(request, params));
2912
+ //
2913
+ // [
2914
+ // {
2915
+ // "time":1724762307531,
2916
+ // "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
2917
+ // "delta":{
2918
+ // "type":"accountClassTransfer",
2919
+ // "usdc":"50.0",
2920
+ // "toPerp":false
2921
+ // }
2922
+ // }
2923
+ // ]
2924
+ //
2925
+ const records = this.extractTypeFromDelta(response);
2926
+ const deposits = this.filterByArray(records, 'type', ['deposit'], false);
2927
+ return this.parseTransactions(deposits, undefined, since, limit);
2928
+ }
2929
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
2930
+ /**
2931
+ * @method
2932
+ * @name hyperliquid#fetchWithdrawals
2933
+ * @description fetch all withdrawals made from an account
2934
+ * @param {string} code unified currency code
2935
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
2936
+ * @param {int} [limit] the maximum number of withdrawals structures to retrieve
2937
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2938
+ * @param {int} [params.until] the latest time in ms to fetch withdrawals for
2939
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2940
+ */
2941
+ await this.loadMarkets();
2942
+ let userAddress = undefined;
2943
+ [userAddress, params] = this.handlePublicAddress('fetchDepositsWithdrawals', params);
2944
+ const request = {
2945
+ 'type': 'userNonFundingLedgerUpdates',
2946
+ 'user': userAddress,
2947
+ };
2948
+ if (since !== undefined) {
2949
+ request['startTime'] = since;
2950
+ }
2951
+ const until = this.safeInteger(params, 'until');
2952
+ if (until !== undefined) {
2953
+ request['endTime'] = until;
2954
+ params = this.omit(params, ['until']);
2955
+ }
2956
+ const response = await this.publicPostInfo(this.extend(request, params));
2957
+ //
2958
+ // [
2959
+ // {
2960
+ // "time":1724762307531,
2961
+ // "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
2962
+ // "delta":{
2963
+ // "type":"accountClassTransfer",
2964
+ // "usdc":"50.0",
2965
+ // "toPerp":false
2966
+ // }
2967
+ // }
2968
+ // ]
2969
+ //
2970
+ const records = this.extractTypeFromDelta(response);
2971
+ const withdrawals = this.filterByArray(records, 'type', ['withdraw'], false);
2972
+ return this.parseTransactions(withdrawals, undefined, since, limit);
2973
+ }
2974
+ extractTypeFromDelta(data = []) {
2975
+ const records = [];
2976
+ for (let i = 0; i < data.length; i++) {
2977
+ const record = data[i];
2978
+ record['type'] = record['delta']['type'];
2979
+ records.push(record);
2980
+ }
2981
+ return records;
2982
+ }
2688
2983
  formatVaultAddress(address = undefined) {
2689
2984
  if (address === undefined) {
2690
2985
  return undefined;
@@ -2708,7 +3003,7 @@ class hyperliquid extends hyperliquid$1 {
2708
3003
  throw new errors.ArgumentsRequired(this.id + ' ' + methodName + '() requires a user parameter inside \'params\' or the wallet address set');
2709
3004
  }
2710
3005
  coinToMarketId(coin) {
2711
- if (coin.indexOf('/') > -1) {
3006
+ if (coin.indexOf('/') > -1 || coin.indexOf('@') > -1) {
2712
3007
  return coin; // spot
2713
3008
  }
2714
3009
  return coin + '/USDC:USDC';
@@ -154,11 +154,12 @@ class independentreserve extends independentreserve$1 {
154
154
  * @param {object} [params] extra parameters specific to the exchange API endpoint
155
155
  * @returns {object[]} an array of objects representing market data
156
156
  */
157
- const baseCurrencies = await this.publicGetGetValidPrimaryCurrencyCodes(params);
157
+ const baseCurrenciesPromise = this.publicGetGetValidPrimaryCurrencyCodes(params);
158
158
  // ['Xbt', 'Eth', 'Usdt', ...]
159
- const quoteCurrencies = await this.publicGetGetValidSecondaryCurrencyCodes(params);
159
+ const quoteCurrenciesPromise = this.publicGetGetValidSecondaryCurrencyCodes(params);
160
160
  // ['Aud', 'Usd', 'Nzd', 'Sgd']
161
- const limits = await this.publicGetGetOrderMinimumVolumes(params);
161
+ const limitsPromise = this.publicGetGetOrderMinimumVolumes(params);
162
+ const [baseCurrencies, quoteCurrencies, limits] = await Promise.all([baseCurrenciesPromise, quoteCurrenciesPromise, limitsPromise]);
162
163
  //
163
164
  // {
164
165
  // "Xbt": 0.0001,
@@ -868,6 +868,9 @@ class indodax extends indodax$1 {
868
868
  else if (type === 'limit') {
869
869
  priceIsRequired = true;
870
870
  quantityIsRequired = true;
871
+ if (side === 'buy') {
872
+ request[market['quoteId']] = this.parseToNumeric(Precise["default"].stringMul(this.numberToString(amount), this.numberToString(price)));
873
+ }
871
874
  }
872
875
  if (priceIsRequired) {
873
876
  if (price === undefined) {
@@ -625,6 +625,7 @@ class kucoin extends kucoin$1 {
625
625
  'KALT': 'ALT', // ALTLAYER
626
626
  },
627
627
  'options': {
628
+ 'hf': false,
628
629
  'version': 'v1',
629
630
  'symbolSeparator': '-',
630
631
  'fetchMyTradesMethod': 'private_get_fills',
@@ -1218,9 +1219,8 @@ class kucoin extends kucoin$1 {
1218
1219
  this.options['hfMigrated'] = (status === 2);
1219
1220
  }
1220
1221
  }
1221
- async handleHfAndParams(params = {}) {
1222
- await this.loadMigrationStatus();
1223
- const migrated = this.safeBool(this.options, 'hfMigrated');
1222
+ handleHfAndParams(params = {}) {
1223
+ const migrated = this.safeBool2(this.options, 'hfMigrated', 'hf', false);
1224
1224
  let loadedHf = undefined;
1225
1225
  if (migrated !== undefined) {
1226
1226
  if (migrated) {
@@ -2119,7 +2119,7 @@ class kucoin extends kucoin$1 {
2119
2119
  const testOrder = this.safeBool(params, 'test', false);
2120
2120
  params = this.omit(params, 'test');
2121
2121
  let hf = undefined;
2122
- [hf, params] = await this.handleHfAndParams(params);
2122
+ [hf, params] = this.handleHfAndParams(params);
2123
2123
  let useSync = false;
2124
2124
  [useSync, params] = this.handleOptionAndParams(params, 'createOrder', 'sync', false);
2125
2125
  const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
@@ -2257,7 +2257,7 @@ class kucoin extends kucoin$1 {
2257
2257
  'orderList': ordersRequests,
2258
2258
  };
2259
2259
  let hf = undefined;
2260
- [hf, params] = await this.handleHfAndParams(params);
2260
+ [hf, params] = this.handleHfAndParams(params);
2261
2261
  let useSync = false;
2262
2262
  [useSync, params] = this.handleOptionAndParams(params, 'createOrders', 'sync', false);
2263
2263
  let response = undefined;
@@ -2455,7 +2455,7 @@ class kucoin extends kucoin$1 {
2455
2455
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
2456
2456
  const stop = this.safeBool2(params, 'stop', 'trigger', false);
2457
2457
  let hf = undefined;
2458
- [hf, params] = await this.handleHfAndParams(params);
2458
+ [hf, params] = this.handleHfAndParams(params);
2459
2459
  let useSync = false;
2460
2460
  [useSync, params] = this.handleOptionAndParams(params, 'cancelOrder', 'sync', false);
2461
2461
  if (hf || useSync) {
@@ -2577,7 +2577,7 @@ class kucoin extends kucoin$1 {
2577
2577
  const request = {};
2578
2578
  const stop = this.safeBool(params, 'stop', false);
2579
2579
  let hf = undefined;
2580
- [hf, params] = await this.handleHfAndParams(params);
2580
+ [hf, params] = this.handleHfAndParams(params);
2581
2581
  params = this.omit(params, 'stop');
2582
2582
  const [marginMode, query] = this.handleMarginModeAndParams('cancelAllOrders', params);
2583
2583
  if (symbol !== undefined) {
@@ -2636,7 +2636,7 @@ class kucoin extends kucoin$1 {
2636
2636
  const until = this.safeInteger(params, 'until');
2637
2637
  const stop = this.safeBool2(params, 'stop', 'trigger', false);
2638
2638
  let hf = undefined;
2639
- [hf, params] = await this.handleHfAndParams(params);
2639
+ [hf, params] = this.handleHfAndParams(params);
2640
2640
  if (hf && (symbol === undefined)) {
2641
2641
  throw new errors.ArgumentsRequired(this.id + ' fetchOrdersByStatus() requires a symbol parameter for hf orders');
2642
2642
  }
@@ -2819,7 +2819,7 @@ class kucoin extends kucoin$1 {
2819
2819
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
2820
2820
  const stop = this.safeBool2(params, 'stop', 'trigger', false);
2821
2821
  let hf = undefined;
2822
- [hf, params] = await this.handleHfAndParams(params);
2822
+ [hf, params] = this.handleHfAndParams(params);
2823
2823
  let market = undefined;
2824
2824
  if (symbol !== undefined) {
2825
2825
  market = this.market(symbol);
@@ -3097,7 +3097,7 @@ class kucoin extends kucoin$1 {
3097
3097
  }
3098
3098
  let request = {};
3099
3099
  let hf = undefined;
3100
- [hf, params] = await this.handleHfAndParams(params);
3100
+ [hf, params] = this.handleHfAndParams(params);
3101
3101
  if (hf && symbol === undefined) {
3102
3102
  throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol parameter for hf orders');
3103
3103
  }
@@ -3827,7 +3827,7 @@ class kucoin extends kucoin$1 {
3827
3827
  let type = this.safeString(accountsByType, requestedType, requestedType);
3828
3828
  params = this.omit(params, 'type');
3829
3829
  let hf = undefined;
3830
- [hf, params] = await this.handleHfAndParams(params);
3830
+ [hf, params] = this.handleHfAndParams(params);
3831
3831
  if (hf) {
3832
3832
  type = 'trade_hf';
3833
3833
  }
@@ -4287,7 +4287,7 @@ class kucoin extends kucoin$1 {
4287
4287
  let paginate = false;
4288
4288
  [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
4289
4289
  let hf = undefined;
4290
- [hf, params] = await this.handleHfAndParams(params);
4290
+ [hf, params] = this.handleHfAndParams(params);
4291
4291
  if (paginate) {
4292
4292
  return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params);
4293
4293
  }