ccxt 4.3.64 → 4.3.66

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.
package/dist/cjs/ccxt.js CHANGED
@@ -191,7 +191,7 @@ var xt$1 = require('./src/pro/xt.js');
191
191
 
192
192
  //-----------------------------------------------------------------------------
193
193
  // this is updated by vss.js when building
194
- const version = '4.3.64';
194
+ const version = '4.3.66';
195
195
  Exchange["default"].ccxtVersion = version;
196
196
  const exchanges = {
197
197
  'ace': ace,
@@ -800,7 +800,7 @@ class Exchange {
800
800
  // @ts-ignore
801
801
  this.httpProxyAgentModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'http-proxy-agent')); });
802
802
  // @ts-ignore
803
- this.httpProxyAgentModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'https-proxy-agent')); });
803
+ this.httpsProxyAgentModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'https-proxy-agent')); });
804
804
  }
805
805
  catch (e) { }
806
806
  }
@@ -3050,7 +3050,7 @@ class bybit extends bybit$1 {
3050
3050
  * @see https://bybit-exchange.github.io/docs/v5/asset/all-balance
3051
3051
  * @see https://bybit-exchange.github.io/docs/v5/account/wallet-balance
3052
3052
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3053
- * @param {string} [params.type] wallet type, ['spot', 'swap', 'fund']
3053
+ * @param {string} [params.type] wallet type, ['spot', 'swap', 'funding']
3054
3054
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
3055
3055
  */
3056
3056
  await this.loadMarkets();
@@ -3058,10 +3058,18 @@ class bybit extends bybit$1 {
3058
3058
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
3059
3059
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
3060
3060
  let type = undefined;
3061
- [type, params] = this.getBybitType('fetchBalance', undefined, params);
3061
+ // don't use getBybitType here
3062
+ [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
3063
+ let subType = undefined;
3064
+ [subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
3065
+ if ((type === 'swap') || (type === 'future')) {
3066
+ type = subType;
3067
+ }
3068
+ const lowercaseRawType = (type !== undefined) ? type.toLowerCase() : undefined;
3062
3069
  const isSpot = (type === 'spot');
3063
3070
  const isLinear = (type === 'linear');
3064
3071
  const isInverse = (type === 'inverse');
3072
+ const isFunding = (lowercaseRawType === 'fund') || (lowercaseRawType === 'funding');
3065
3073
  if (isUnifiedAccount) {
3066
3074
  if (isInverse) {
3067
3075
  type = 'contract';
@@ -3083,10 +3091,10 @@ class bybit extends bybit$1 {
3083
3091
  if (isSpot && (marginMode !== undefined)) {
3084
3092
  response = await this.privateGetV5SpotCrossMarginTradeAccount(this.extend(request, params));
3085
3093
  }
3086
- else if (unifiedType === 'FUND') {
3094
+ else if (isFunding) {
3087
3095
  // use this endpoint only we have no other choice
3088
3096
  // because it requires transfer permission
3089
- request['accountType'] = unifiedType;
3097
+ request['accountType'] = 'FUND';
3090
3098
  response = await this.privateGetV5AssetTransferQueryAccountCoinsBalance(this.extend(request, params));
3091
3099
  }
3092
3100
  else {
@@ -94,8 +94,8 @@ class hyperliquid extends hyperliquid$1 {
94
94
  'fetchPositions': true,
95
95
  'fetchPositionsRisk': false,
96
96
  'fetchPremiumIndexOHLCV': false,
97
- 'fetchTicker': false,
98
- 'fetchTickers': false,
97
+ 'fetchTicker': 'emulated',
98
+ 'fetchTickers': true,
99
99
  'fetchTime': false,
100
100
  'fetchTrades': true,
101
101
  'fetchTradingFee': true,
@@ -324,12 +324,12 @@ class hyperliquid extends hyperliquid$1 {
324
324
  // ]
325
325
  //
326
326
  //
327
- let meta = this.safeDict(response, 0, {});
328
- meta = this.safeList(meta, 'universe', []);
327
+ const meta = this.safeDict(response, 0, {});
328
+ const universe = this.safeList(meta, 'universe', []);
329
329
  const assetCtxs = this.safeDict(response, 1, {});
330
330
  const result = [];
331
- for (let i = 0; i < meta.length; i++) {
332
- const data = this.extend(this.safeDict(meta, i, {}), this.safeDict(assetCtxs, i, {}));
331
+ for (let i = 0; i < universe.length; i++) {
332
+ const data = this.extend(this.safeDict(universe, i, {}), this.safeDict(assetCtxs, i, {}));
333
333
  data['baseId'] = i;
334
334
  result.push(data);
335
335
  }
@@ -444,11 +444,13 @@ class hyperliquid extends hyperliquid$1 {
444
444
  //
445
445
  // response differs depending on the environment (mainnet vs sandbox)
446
446
  const first = this.safeDict(response, 0, {});
447
+ const second = this.safeList(response, 1, []);
447
448
  const meta = this.safeList2(first, 'universe', 'spot_infos', []);
448
449
  const tokens = this.safeList2(first, 'tokens', 'token_infos', []);
449
450
  const markets = [];
450
451
  for (let i = 0; i < meta.length; i++) {
451
452
  const market = this.safeDict(meta, i, {});
453
+ const extraData = this.safeDict(second, i, {});
452
454
  const marketName = this.safeString(market, 'name');
453
455
  // if (marketName.indexOf ('/') < 0) {
454
456
  // // there are some weird spot markets in testnet, eg @2
@@ -525,7 +527,7 @@ class hyperliquid extends hyperliquid$1 {
525
527
  },
526
528
  },
527
529
  'created': undefined,
528
- 'info': market,
530
+ 'info': this.extend(extraData, market),
529
531
  }));
530
532
  }
531
533
  return markets;
@@ -753,6 +755,60 @@ class hyperliquid extends hyperliquid$1 {
753
755
  const timestamp = this.safeInteger(response, 'time');
754
756
  return this.parseOrderBook(result, market['symbol'], timestamp, 'bids', 'asks', 'px', 'sz');
755
757
  }
758
+ async fetchTickers(symbols = undefined, params = {}) {
759
+ /**
760
+ * @method
761
+ * @name hyperliquid#fetchTickers
762
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
763
+ * @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActiveAndIndices
764
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
765
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
766
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
767
+ */
768
+ await this.loadMarkets();
769
+ symbols = this.marketSymbols(symbols);
770
+ // at this stage, to get tickers data, we use fetchMarkets endpoints
771
+ const response = await this.fetchMarkets(params);
772
+ // same response as under "fetchMarkets"
773
+ const result = {};
774
+ for (let i = 0; i < response.length; i++) {
775
+ const market = response[i];
776
+ const info = market['info'];
777
+ const ticker = this.parseTicker(info, market);
778
+ const symbol = this.safeString(ticker, 'symbol');
779
+ result[symbol] = ticker;
780
+ }
781
+ return this.filterByArrayTickers(result, 'symbol', symbols);
782
+ }
783
+ parseTicker(ticker, market = undefined) {
784
+ //
785
+ // {
786
+ // "prevDayPx": "3400.5",
787
+ // "dayNtlVlm": "511297257.47936022",
788
+ // "markPx": "3464.7",
789
+ // "midPx": "3465.05",
790
+ // "oraclePx": "3460.1", // only in swap
791
+ // "openInterest": "64638.1108", // only in swap
792
+ // "premium": "0.00141614", // only in swap
793
+ // "funding": "0.00008727", // only in swap
794
+ // "impactPxs": [ "3465.0", "3465.1" ], // only in swap
795
+ // "coin": "PURR", // only in spot
796
+ // "circulatingSupply": "998949190.03400207", // only in spot
797
+ // },
798
+ //
799
+ const bidAsk = this.safeList(ticker, 'impactPxs');
800
+ return this.safeTicker({
801
+ 'symbol': market['symbol'],
802
+ 'timestamp': undefined,
803
+ 'datetime': undefined,
804
+ 'previousClose': this.safeNumber(ticker, 'prevDayPx'),
805
+ 'close': this.safeNumber(ticker, 'midPx'),
806
+ 'bid': this.safeNumber(bidAsk, 0),
807
+ 'ask': this.safeNumber(bidAsk, 1),
808
+ 'quoteVolume': this.safeNumber(ticker, 'dayNtlVlm'),
809
+ 'info': ticker,
810
+ }, market);
811
+ }
756
812
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
757
813
  /**
758
814
  * @method
@@ -4,7 +4,6 @@ var independentreserve$1 = require('./abstract/independentreserve.js');
4
4
  var Precise = require('./base/Precise.js');
5
5
  var number = require('./base/functions/number.js');
6
6
  var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
7
- require('../ccxt.js');
8
7
  var errors = require('./base/errors.js');
9
8
 
10
9
  // ---------------------------------------------------------------------------
@@ -80,6 +80,7 @@ class kraken extends kraken$1 {
80
80
  'fetchOrderTrades': 'emulated',
81
81
  'fetchPositions': true,
82
82
  'fetchPremiumIndexOHLCV': false,
83
+ 'fetchStatus': true,
83
84
  'fetchTicker': true,
84
85
  'fetchTickers': true,
85
86
  'fetchTime': true,
@@ -637,6 +638,32 @@ class kraken extends kraken$1 {
637
638
  }
638
639
  return result;
639
640
  }
641
+ async fetchStatus(params = {}) {
642
+ /**
643
+ * @method
644
+ * @name kraken#fetchStatus
645
+ * @description the latest known information on the availability of the exchange API
646
+ * @see https://docs.kraken.com/api/docs/rest-api/get-system-status/
647
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
648
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
649
+ */
650
+ const response = await this.publicGetSystemStatus(params);
651
+ //
652
+ // {
653
+ // error: [],
654
+ // result: { status: 'online', timestamp: '2024-07-22T16:34:44Z' }
655
+ // }
656
+ //
657
+ const result = this.safeDict(response, 'result');
658
+ const statusRaw = this.safeString(result, 'status');
659
+ return {
660
+ 'status': (statusRaw === 'online') ? 'ok' : 'maintenance',
661
+ 'updated': undefined,
662
+ 'eta': undefined,
663
+ 'url': undefined,
664
+ 'info': response,
665
+ };
666
+ }
640
667
  async fetchCurrencies(params = {}) {
641
668
  /**
642
669
  * @method
@@ -17,7 +17,7 @@ class hyperliquid extends hyperliquid$1 {
17
17
  'watchOrderBook': true,
18
18
  'watchOrders': true,
19
19
  'watchTicker': false,
20
- 'watchTickers': false,
20
+ 'watchTickers': true,
21
21
  'watchTrades': true,
22
22
  'watchPosition': false,
23
23
  },
@@ -118,6 +118,32 @@ class hyperliquid extends hyperliquid$1 {
118
118
  const messageHash = 'orderbook:' + symbol;
119
119
  client.resolve(orderbook, messageHash);
120
120
  }
121
+ async watchTickers(symbols = undefined, params = {}) {
122
+ /**
123
+ * @method
124
+ * @name hyperliquid#watchTickers
125
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
126
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
127
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
128
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
129
+ */
130
+ await this.loadMarkets();
131
+ symbols = this.marketSymbols(symbols, undefined, true);
132
+ const messageHash = 'tickers';
133
+ const url = this.urls['api']['ws']['public'];
134
+ const request = {
135
+ 'method': 'subscribe',
136
+ 'subscription': {
137
+ 'type': 'webData2',
138
+ 'user': '0x0000000000000000000000000000000000000000',
139
+ },
140
+ };
141
+ const tickers = await this.watch(url, messageHash, this.extend(request, params), messageHash);
142
+ if (this.newUpdates) {
143
+ return this.filterByArrayTickers(tickers, 'symbol', symbols);
144
+ }
145
+ return this.tickers;
146
+ }
121
147
  async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
122
148
  /**
123
149
  * @method
@@ -153,6 +179,81 @@ class hyperliquid extends hyperliquid$1 {
153
179
  }
154
180
  return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
155
181
  }
182
+ handleWsTickers(client, message) {
183
+ //
184
+ // {
185
+ // "channel": "webData2",
186
+ // "data": {
187
+ // "meta": {
188
+ // "universe": [
189
+ // {
190
+ // "szDecimals": 5,
191
+ // "name": "BTC",
192
+ // "maxLeverage": 50,
193
+ // "onlyIsolated": false
194
+ // },
195
+ // ...
196
+ // ],
197
+ // },
198
+ // "assetCtxs": [
199
+ // {
200
+ // "funding": "0.00003005",
201
+ // "openInterest": "2311.50778",
202
+ // "prevDayPx": "63475.0",
203
+ // "dayNtlVlm": "468043329.64289033",
204
+ // "premium": "0.00094264",
205
+ // "oraclePx": "64712.0",
206
+ // "markPx": "64774.0",
207
+ // "midPx": "64773.5",
208
+ // "impactPxs": [
209
+ // "64773.0",
210
+ // "64774.0"
211
+ // ]
212
+ // },
213
+ // ...
214
+ // ],
215
+ // "spotAssetCtxs": [
216
+ // {
217
+ // "prevDayPx": "0.20937",
218
+ // "dayNtlVlm": "11188888.61984999",
219
+ // "markPx": "0.19722",
220
+ // "midPx": "0.197145",
221
+ // "circulatingSupply": "598760557.12072003",
222
+ // "coin": "PURR/USDC"
223
+ // },
224
+ // ...
225
+ // ],
226
+ // }
227
+ // }
228
+ //
229
+ // spot
230
+ const rawData = this.safeDict(message, 'data', {});
231
+ const spotAssets = this.safeList(rawData, 'spotAssetCtxs', []);
232
+ const parsedTickers = [];
233
+ for (let i = 0; i < spotAssets.length; i++) {
234
+ const assetObject = spotAssets[i];
235
+ const marketId = this.safeString(assetObject, 'coin');
236
+ const market = this.safeMarket(marketId, undefined, undefined, 'spot');
237
+ const ticker = this.parseWsTicker(assetObject, market);
238
+ parsedTickers.push(ticker);
239
+ }
240
+ // perpetuals
241
+ const meta = this.safeDict(rawData, 'meta', {});
242
+ const universe = this.safeList(meta, 'universe', []);
243
+ const assetCtxs = this.safeList(rawData, 'assetCtxs', []);
244
+ for (let i = 0; i < universe.length; i++) {
245
+ const data = this.extend(this.safeDict(universe, i, {}), this.safeDict(assetCtxs, i, {}));
246
+ const id = data['name'] + '/USDC:USDC';
247
+ const market = this.safeMarket(id, undefined, undefined, 'swap');
248
+ const ticker = this.parseWsTicker(data, market);
249
+ parsedTickers.push(ticker);
250
+ }
251
+ const tickers = this.indexBy(parsedTickers, 'symbol');
252
+ client.resolve(tickers, 'tickers');
253
+ }
254
+ parseWsTicker(rawTicker, market = undefined) {
255
+ return this.parseTicker(rawTicker, market);
256
+ }
156
257
  handleMyTrades(client, message) {
157
258
  //
158
259
  // {
@@ -522,6 +623,7 @@ class hyperliquid extends hyperliquid$1 {
522
623
  'candle': this.handleOHLCV,
523
624
  'orderUpdates': this.handleOrder,
524
625
  'userFills': this.handleMyTrades,
626
+ 'webData2': this.handleWsTickers,
525
627
  };
526
628
  const exacMethod = this.safeValue(methods, topic);
527
629
  if (exacMethod !== undefined) {
@@ -1637,7 +1637,7 @@ class okx extends okx$1 {
1637
1637
  await this.loadMarkets();
1638
1638
  await this.authenticate();
1639
1639
  const url = this.getUrl('private', 'private');
1640
- const messageHash = this.nonce().toString();
1640
+ const messageHash = this.milliseconds().toString();
1641
1641
  let op = undefined;
1642
1642
  [op, params] = this.handleOptionAndParams(params, 'createOrderWs', 'op', 'batch-orders');
1643
1643
  const args = this.createOrderRequest(symbol, type, side, amount, price, params);
@@ -1707,7 +1707,7 @@ class okx extends okx$1 {
1707
1707
  await this.loadMarkets();
1708
1708
  await this.authenticate();
1709
1709
  const url = this.getUrl('private', 'private');
1710
- const messageHash = this.nonce().toString();
1710
+ const messageHash = this.milliseconds().toString();
1711
1711
  let op = undefined;
1712
1712
  [op, params] = this.handleOptionAndParams(params, 'editOrderWs', 'op', 'amend-order');
1713
1713
  const args = this.editOrderRequest(id, symbol, type, side, amount, price, params);
@@ -1736,7 +1736,7 @@ class okx extends okx$1 {
1736
1736
  await this.loadMarkets();
1737
1737
  await this.authenticate();
1738
1738
  const url = this.getUrl('private', 'private');
1739
- const messageHash = this.nonce().toString();
1739
+ const messageHash = this.milliseconds().toString();
1740
1740
  const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
1741
1741
  params = this.omit(params, ['clientOrderId', 'clOrdId']);
1742
1742
  const arg = {
@@ -1776,7 +1776,7 @@ class okx extends okx$1 {
1776
1776
  await this.loadMarkets();
1777
1777
  await this.authenticate();
1778
1778
  const url = this.getUrl('private', 'private');
1779
- const messageHash = this.nonce().toString();
1779
+ const messageHash = this.milliseconds().toString();
1780
1780
  const args = [];
1781
1781
  for (let i = 0; i < idsLength; i++) {
1782
1782
  const arg = {
@@ -1812,7 +1812,7 @@ class okx extends okx$1 {
1812
1812
  throw new errors.BadRequest(this.id + 'cancelAllOrdersWs is only applicable to Option in Portfolio Margin mode, and MMP privilege is required.');
1813
1813
  }
1814
1814
  const url = this.getUrl('private', 'private');
1815
- const messageHash = this.nonce().toString();
1815
+ const messageHash = this.milliseconds().toString();
1816
1816
  const request = {
1817
1817
  'id': messageHash,
1818
1818
  'op': 'mass-cancel',
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, TransferEntries, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending } from './src/base/errors.js';
7
- declare const version = "4.3.63";
7
+ declare const version = "4.3.65";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.64';
41
+ const version = '4.3.66';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -785,7 +785,7 @@ export default class Exchange {
785
785
  // @ts-ignore
786
786
  this.httpProxyAgentModule = await import(/* webpackIgnore: true */ 'http-proxy-agent');
787
787
  // @ts-ignore
788
- this.httpProxyAgentModule = await import(/* webpackIgnore: true */ 'https-proxy-agent');
788
+ this.httpsProxyAgentModule = await import(/* webpackIgnore: true */ 'https-proxy-agent');
789
789
  }
790
790
  catch (e) { }
791
791
  }
package/js/src/bybit.js CHANGED
@@ -3053,7 +3053,7 @@ export default class bybit extends Exchange {
3053
3053
  * @see https://bybit-exchange.github.io/docs/v5/asset/all-balance
3054
3054
  * @see https://bybit-exchange.github.io/docs/v5/account/wallet-balance
3055
3055
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3056
- * @param {string} [params.type] wallet type, ['spot', 'swap', 'fund']
3056
+ * @param {string} [params.type] wallet type, ['spot', 'swap', 'funding']
3057
3057
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
3058
3058
  */
3059
3059
  await this.loadMarkets();
@@ -3061,10 +3061,18 @@ export default class bybit extends Exchange {
3061
3061
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
3062
3062
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
3063
3063
  let type = undefined;
3064
- [type, params] = this.getBybitType('fetchBalance', undefined, params);
3064
+ // don't use getBybitType here
3065
+ [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
3066
+ let subType = undefined;
3067
+ [subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
3068
+ if ((type === 'swap') || (type === 'future')) {
3069
+ type = subType;
3070
+ }
3071
+ const lowercaseRawType = (type !== undefined) ? type.toLowerCase() : undefined;
3065
3072
  const isSpot = (type === 'spot');
3066
3073
  const isLinear = (type === 'linear');
3067
3074
  const isInverse = (type === 'inverse');
3075
+ const isFunding = (lowercaseRawType === 'fund') || (lowercaseRawType === 'funding');
3068
3076
  if (isUnifiedAccount) {
3069
3077
  if (isInverse) {
3070
3078
  type = 'contract';
@@ -3086,10 +3094,10 @@ export default class bybit extends Exchange {
3086
3094
  if (isSpot && (marginMode !== undefined)) {
3087
3095
  response = await this.privateGetV5SpotCrossMarginTradeAccount(this.extend(request, params));
3088
3096
  }
3089
- else if (unifiedType === 'FUND') {
3097
+ else if (isFunding) {
3090
3098
  // use this endpoint only we have no other choice
3091
3099
  // because it requires transfer permission
3092
- request['accountType'] = unifiedType;
3100
+ request['accountType'] = 'FUND';
3093
3101
  response = await this.privateGetV5AssetTransferQueryAccountCoinsBalance(this.extend(request, params));
3094
3102
  }
3095
3103
  else {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/hyperliquid.js';
2
- import type { Market, TransferEntry, Balances, Int, OrderBook, OHLCV, Str, FundingRateHistory, Order, OrderType, OrderSide, Trade, Strings, Position, OrderRequest, Dict, Num, MarginModification, Currencies, CancellationRequest, int, Transaction, Currency, TradingFeeInterface } from './base/types.js';
2
+ import type { Market, TransferEntry, Balances, Int, OrderBook, OHLCV, Str, FundingRateHistory, Order, OrderType, OrderSide, Trade, Strings, Position, OrderRequest, Dict, Num, MarginModification, Currencies, CancellationRequest, int, Transaction, Currency, TradingFeeInterface, Ticker, Tickers } from './base/types.js';
3
3
  /**
4
4
  * @class hyperliquid
5
5
  * @augments Exchange
@@ -14,6 +14,8 @@ export default class hyperliquid extends Exchange {
14
14
  parseMarket(market: Dict): Market;
15
15
  fetchBalance(params?: {}): Promise<Balances>;
16
16
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
17
+ fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
18
+ parseTicker(ticker: Dict, market?: Market): Ticker;
17
19
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
18
20
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
19
21
  fetchTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
@@ -97,8 +97,8 @@ export default class hyperliquid extends Exchange {
97
97
  'fetchPositions': true,
98
98
  'fetchPositionsRisk': false,
99
99
  'fetchPremiumIndexOHLCV': false,
100
- 'fetchTicker': false,
101
- 'fetchTickers': false,
100
+ 'fetchTicker': 'emulated',
101
+ 'fetchTickers': true,
102
102
  'fetchTime': false,
103
103
  'fetchTrades': true,
104
104
  'fetchTradingFee': true,
@@ -327,12 +327,12 @@ export default class hyperliquid extends Exchange {
327
327
  // ]
328
328
  //
329
329
  //
330
- let meta = this.safeDict(response, 0, {});
331
- meta = this.safeList(meta, 'universe', []);
330
+ const meta = this.safeDict(response, 0, {});
331
+ const universe = this.safeList(meta, 'universe', []);
332
332
  const assetCtxs = this.safeDict(response, 1, {});
333
333
  const result = [];
334
- for (let i = 0; i < meta.length; i++) {
335
- const data = this.extend(this.safeDict(meta, i, {}), this.safeDict(assetCtxs, i, {}));
334
+ for (let i = 0; i < universe.length; i++) {
335
+ const data = this.extend(this.safeDict(universe, i, {}), this.safeDict(assetCtxs, i, {}));
336
336
  data['baseId'] = i;
337
337
  result.push(data);
338
338
  }
@@ -447,11 +447,13 @@ export default class hyperliquid extends Exchange {
447
447
  //
448
448
  // response differs depending on the environment (mainnet vs sandbox)
449
449
  const first = this.safeDict(response, 0, {});
450
+ const second = this.safeList(response, 1, []);
450
451
  const meta = this.safeList2(first, 'universe', 'spot_infos', []);
451
452
  const tokens = this.safeList2(first, 'tokens', 'token_infos', []);
452
453
  const markets = [];
453
454
  for (let i = 0; i < meta.length; i++) {
454
455
  const market = this.safeDict(meta, i, {});
456
+ const extraData = this.safeDict(second, i, {});
455
457
  const marketName = this.safeString(market, 'name');
456
458
  // if (marketName.indexOf ('/') < 0) {
457
459
  // // there are some weird spot markets in testnet, eg @2
@@ -528,7 +530,7 @@ export default class hyperliquid extends Exchange {
528
530
  },
529
531
  },
530
532
  'created': undefined,
531
- 'info': market,
533
+ 'info': this.extend(extraData, market),
532
534
  }));
533
535
  }
534
536
  return markets;
@@ -756,6 +758,60 @@ export default class hyperliquid extends Exchange {
756
758
  const timestamp = this.safeInteger(response, 'time');
757
759
  return this.parseOrderBook(result, market['symbol'], timestamp, 'bids', 'asks', 'px', 'sz');
758
760
  }
761
+ async fetchTickers(symbols = undefined, params = {}) {
762
+ /**
763
+ * @method
764
+ * @name hyperliquid#fetchTickers
765
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
766
+ * @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActiveAndIndices
767
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
768
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
769
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
770
+ */
771
+ await this.loadMarkets();
772
+ symbols = this.marketSymbols(symbols);
773
+ // at this stage, to get tickers data, we use fetchMarkets endpoints
774
+ const response = await this.fetchMarkets(params);
775
+ // same response as under "fetchMarkets"
776
+ const result = {};
777
+ for (let i = 0; i < response.length; i++) {
778
+ const market = response[i];
779
+ const info = market['info'];
780
+ const ticker = this.parseTicker(info, market);
781
+ const symbol = this.safeString(ticker, 'symbol');
782
+ result[symbol] = ticker;
783
+ }
784
+ return this.filterByArrayTickers(result, 'symbol', symbols);
785
+ }
786
+ parseTicker(ticker, market = undefined) {
787
+ //
788
+ // {
789
+ // "prevDayPx": "3400.5",
790
+ // "dayNtlVlm": "511297257.47936022",
791
+ // "markPx": "3464.7",
792
+ // "midPx": "3465.05",
793
+ // "oraclePx": "3460.1", // only in swap
794
+ // "openInterest": "64638.1108", // only in swap
795
+ // "premium": "0.00141614", // only in swap
796
+ // "funding": "0.00008727", // only in swap
797
+ // "impactPxs": [ "3465.0", "3465.1" ], // only in swap
798
+ // "coin": "PURR", // only in spot
799
+ // "circulatingSupply": "998949190.03400207", // only in spot
800
+ // },
801
+ //
802
+ const bidAsk = this.safeList(ticker, 'impactPxs');
803
+ return this.safeTicker({
804
+ 'symbol': market['symbol'],
805
+ 'timestamp': undefined,
806
+ 'datetime': undefined,
807
+ 'previousClose': this.safeNumber(ticker, 'prevDayPx'),
808
+ 'close': this.safeNumber(ticker, 'midPx'),
809
+ 'bid': this.safeNumber(bidAsk, 0),
810
+ 'ask': this.safeNumber(bidAsk, 1),
811
+ 'quoteVolume': this.safeNumber(ticker, 'dayNtlVlm'),
812
+ 'info': ticker,
813
+ }, market);
814
+ }
759
815
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
760
816
  /**
761
817
  * @method
@@ -9,7 +9,7 @@ import Exchange from './abstract/independentreserve.js';
9
9
  import { Precise } from './base/Precise.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
- import { BadRequest } from '../ccxt.js';
12
+ import { BadRequest } from './base/errors.js';
13
13
  // ---------------------------------------------------------------------------
14
14
  /**
15
15
  * @class independentreserve
@@ -11,6 +11,13 @@ export default class kraken extends Exchange {
11
11
  fetchMarkets(params?: {}): Promise<Market[]>;
12
12
  safeCurrency(currencyId: any, currency?: Currency): import("./base/types.js").CurrencyInterface;
13
13
  appendInactiveMarkets(result: any): any;
14
+ fetchStatus(params?: {}): Promise<{
15
+ status: string;
16
+ updated: any;
17
+ eta: any;
18
+ url: any;
19
+ info: any;
20
+ }>;
14
21
  fetchCurrencies(params?: {}): Promise<Currencies>;
15
22
  fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
16
23
  parseTradingFee(response: any, market: any): {