ccxt 4.4.86 → 4.4.88

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 (72) hide show
  1. package/README.md +17 -5
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +11 -1
  4. package/dist/cjs/src/abstract/modetrade.js +9 -0
  5. package/dist/cjs/src/base/Exchange.js +12 -8
  6. package/dist/cjs/src/binance.js +1 -1
  7. package/dist/cjs/src/bitteam.js +31 -0
  8. package/dist/cjs/src/bybit.js +19 -80
  9. package/dist/cjs/src/coinmetro.js +5 -1
  10. package/dist/cjs/src/derive.js +4 -5
  11. package/dist/cjs/src/ellipx.js +2 -3
  12. package/dist/cjs/src/gate.js +92 -76
  13. package/dist/cjs/src/htx.js +10 -8
  14. package/dist/cjs/src/hyperliquid.js +32 -16
  15. package/dist/cjs/src/kraken.js +5 -8
  16. package/dist/cjs/src/modetrade.js +2839 -0
  17. package/dist/cjs/src/okx.js +95 -2
  18. package/dist/cjs/src/okxus.js +53 -0
  19. package/dist/cjs/src/paradex.js +6 -1
  20. package/dist/cjs/src/phemex.js +4 -6
  21. package/dist/cjs/src/poloniex.js +181 -170
  22. package/dist/cjs/src/pro/modetrade.js +1334 -0
  23. package/dist/cjs/src/pro/okxus.js +38 -0
  24. package/dist/cjs/src/probit.js +18 -51
  25. package/dist/cjs/src/timex.js +5 -10
  26. package/dist/cjs/src/vertex.js +3 -4
  27. package/dist/cjs/src/whitebit.js +41 -11
  28. package/dist/cjs/src/woo.js +101 -77
  29. package/dist/cjs/src/woofipro.js +24 -21
  30. package/dist/cjs/src/xt.js +36 -44
  31. package/js/ccxt.d.ts +14 -2
  32. package/js/ccxt.js +10 -2
  33. package/js/src/abstract/modetrade.d.ts +122 -0
  34. package/js/src/abstract/modetrade.js +11 -0
  35. package/js/src/abstract/okxus.d.ts +352 -0
  36. package/js/src/abstract/okxus.js +11 -0
  37. package/js/src/base/Exchange.js +12 -8
  38. package/js/src/binance.js +1 -1
  39. package/js/src/bitteam.js +31 -0
  40. package/js/src/bybit.js +19 -80
  41. package/js/src/coinmetro.js +5 -1
  42. package/js/src/derive.js +4 -3
  43. package/js/src/ellipx.d.ts +1 -1
  44. package/js/src/ellipx.js +3 -5
  45. package/js/src/gate.js +92 -76
  46. package/js/src/htx.js +10 -8
  47. package/js/src/hyperliquid.js +32 -16
  48. package/js/src/kraken.js +5 -8
  49. package/js/src/modetrade.d.ts +475 -0
  50. package/js/src/modetrade.js +2840 -0
  51. package/js/src/okx.d.ts +24 -1
  52. package/js/src/okx.js +95 -2
  53. package/js/src/okxus.d.ts +4 -0
  54. package/js/src/okxus.js +54 -0
  55. package/js/src/paradex.js +6 -1
  56. package/js/src/phemex.js +4 -6
  57. package/js/src/poloniex.d.ts +2 -0
  58. package/js/src/poloniex.js +181 -170
  59. package/js/src/pro/modetrade.d.ts +155 -0
  60. package/js/src/pro/modetrade.js +1335 -0
  61. package/js/src/pro/okxus.d.ts +4 -0
  62. package/js/src/pro/okxus.js +39 -0
  63. package/js/src/probit.js +18 -51
  64. package/js/src/timex.js +5 -10
  65. package/js/src/vertex.js +3 -4
  66. package/js/src/whitebit.js +42 -11
  67. package/js/src/woo.d.ts +2 -0
  68. package/js/src/woo.js +101 -77
  69. package/js/src/woofipro.d.ts +2 -1
  70. package/js/src/woofipro.js +24 -21
  71. package/js/src/xt.js +36 -44
  72. package/package.json +1 -1
package/js/src/bybit.js CHANGED
@@ -2349,20 +2349,9 @@ export default class bybit extends Exchange {
2349
2349
  // 'baseCoin': '', Base coin. For option only
2350
2350
  // 'expDate': '', Expiry date. e.g., 25DEC22. For option only
2351
2351
  };
2352
- if (market['spot']) {
2353
- request['category'] = 'spot';
2354
- }
2355
- else {
2356
- if (market['option']) {
2357
- request['category'] = 'option';
2358
- }
2359
- else if (market['linear']) {
2360
- request['category'] = 'linear';
2361
- }
2362
- else if (market['inverse']) {
2363
- request['category'] = 'inverse';
2364
- }
2365
- }
2352
+ let category = undefined;
2353
+ [category, params] = this.getBybitType('fetchTicker', market, params);
2354
+ request['category'] = category;
2366
2355
  const response = await this.publicGetV5MarketTickers(this.extend(request, params));
2367
2356
  //
2368
2357
  // {
@@ -2463,28 +2452,16 @@ export default class bybit extends Exchange {
2463
2452
  // 'baseCoin': '', // Base coin. For option only
2464
2453
  // 'expDate': '', // Expiry date. e.g., 25DEC22. For option only
2465
2454
  };
2466
- let type = undefined;
2467
- [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
2468
- // Calls like `.fetchTickers (undefined, {subType:'inverse'})` should be supported for this exchange, so
2469
- // as "options.defaultSubType" is also set in exchange options, we should consider `params.subType`
2470
- // with higher priority and only default to spot, if `subType` is not set in params
2471
- const passedSubType = this.safeString(params, 'subType');
2472
- let subType = undefined;
2473
- [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params, 'linear');
2474
- // only if passedSubType is undefined, then use spot
2475
- if (type === 'spot' && passedSubType === undefined) {
2476
- request['category'] = 'spot';
2477
- }
2478
- else if (type === 'option') {
2455
+ let category = undefined;
2456
+ [category, params] = this.getBybitType('fetchTickers', market, params);
2457
+ request['category'] = category;
2458
+ if (category === 'option') {
2479
2459
  request['category'] = 'option';
2480
2460
  if (code === undefined) {
2481
2461
  code = 'BTC';
2482
2462
  }
2483
2463
  request['baseCoin'] = code;
2484
2464
  }
2485
- else if (type === 'swap' || type === 'future' || subType !== undefined) {
2486
- request['category'] = subType;
2487
- }
2488
2465
  const response = await this.publicGetV5MarketTickers(this.extend(request, params));
2489
2466
  //
2490
2467
  // {
@@ -4085,18 +4062,9 @@ export default class bybit extends Exchange {
4085
4062
  request['price'] = priceString;
4086
4063
  }
4087
4064
  }
4088
- if (market['spot']) {
4089
- request['category'] = 'spot';
4090
- }
4091
- else if (market['option']) {
4092
- request['category'] = 'option';
4093
- }
4094
- else if (market['linear']) {
4095
- request['category'] = 'linear';
4096
- }
4097
- else if (market['inverse']) {
4098
- request['category'] = 'inverse';
4099
- }
4065
+ let category = undefined;
4066
+ [category, params] = this.getBybitType('createOrderRequest', market, params);
4067
+ request['category'] = category;
4100
4068
  const cost = this.safeString(params, 'cost');
4101
4069
  params = this.omit(params, 'cost');
4102
4070
  // if the cost is inferable, let's keep the old logic and ignore marketUnit, to minimize the impact of the changes
@@ -4325,18 +4293,9 @@ export default class bybit extends Exchange {
4325
4293
  // Valid for option only.
4326
4294
  // 'orderIv': '0', // Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
4327
4295
  };
4328
- if (market['spot']) {
4329
- request['category'] = 'spot';
4330
- }
4331
- else if (market['linear']) {
4332
- request['category'] = 'linear';
4333
- }
4334
- else if (market['inverse']) {
4335
- request['category'] = 'inverse';
4336
- }
4337
- else if (market['option']) {
4338
- request['category'] = 'option';
4339
- }
4296
+ let category = undefined;
4297
+ [category, params] = this.getBybitType('editOrderRequest', market, params);
4298
+ request['category'] = category;
4340
4299
  if (amount !== undefined) {
4341
4300
  request['qty'] = this.getAmount(symbol, amount);
4342
4301
  }
@@ -4542,18 +4501,9 @@ export default class bybit extends Exchange {
4542
4501
  if (id !== undefined) { // The user can also use argument params["orderLinkId"]
4543
4502
  request['orderId'] = id;
4544
4503
  }
4545
- if (market['spot']) {
4546
- request['category'] = 'spot';
4547
- }
4548
- else if (market['linear']) {
4549
- request['category'] = 'linear';
4550
- }
4551
- else if (market['inverse']) {
4552
- request['category'] = 'inverse';
4553
- }
4554
- else if (market['option']) {
4555
- request['category'] = 'option';
4556
- }
4504
+ let category = undefined;
4505
+ [category, params] = this.getBybitType('cancelOrderRequest', market, params);
4506
+ request['category'] = category;
4557
4507
  return this.extend(request, params);
4558
4508
  }
4559
4509
  /**
@@ -7607,18 +7557,7 @@ export default class bybit extends Exchange {
7607
7557
  'symbol': market['id'],
7608
7558
  };
7609
7559
  let category = undefined;
7610
- if (market['linear']) {
7611
- category = 'linear';
7612
- }
7613
- else if (market['inverse']) {
7614
- category = 'inverse';
7615
- }
7616
- else if (market['spot']) {
7617
- category = 'spot';
7618
- }
7619
- else {
7620
- category = 'option';
7621
- }
7560
+ [category, params] = this.getBybitType('fetchTradingFee', market, params);
7622
7561
  request['category'] = category;
7623
7562
  const response = await this.privateGetV5AccountFeeRate(this.extend(request, params));
7624
7563
  //
@@ -7866,10 +7805,10 @@ export default class bybit extends Exchange {
7866
7805
  }
7867
7806
  let type = undefined;
7868
7807
  [type, params] = this.getBybitType('fetchMySettlementHistory', market, params);
7869
- if (type === 'spot' || type === 'inverse') {
7808
+ if (type === 'spot') {
7870
7809
  throw new NotSupported(this.id + ' fetchMySettlementHistory() is not supported for spot market');
7871
7810
  }
7872
- request['category'] = 'linear';
7811
+ request['category'] = type;
7873
7812
  if (limit !== undefined) {
7874
7813
  request['limit'] = limit;
7875
7814
  }
@@ -388,7 +388,11 @@ export default class coinmetro extends Exchange {
388
388
  else if (typeRaw === 'fiat') {
389
389
  type = 'fiat';
390
390
  }
391
- const precisionDigits = this.safeString2(currency, 'digits', 'notabeneDecimals');
391
+ let precisionDigits = this.safeString2(currency, 'digits', 'notabeneDecimals');
392
+ if (code === 'RENDER') {
393
+ // RENDER is an exception (with broken info)
394
+ precisionDigits = '4';
395
+ }
392
396
  result[code] = this.safeCurrencyStructure({
393
397
  'id': id,
394
398
  'code': code,
package/js/src/derive.js CHANGED
@@ -5,12 +5,13 @@
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
- import { BadRequest, InvalidOrder, Precise, ExchangeError, OrderNotFound, ArgumentsRequired, InsufficientFunds, RateLimitExceeded, AuthenticationError } from '../ccxt.js';
9
8
  import Exchange from './abstract/derive.js';
10
- import { TICK_SIZE } from './base/functions/number.js';
9
+ import Precise from './base/Precise.js';
10
+ import { BadRequest, InvalidOrder, ExchangeError, OrderNotFound, ArgumentsRequired, InsufficientFunds, RateLimitExceeded, AuthenticationError } from './base/errors.js';
11
+ import { ecdsa } from './base/functions/crypto.js';
11
12
  import { keccak_256 as keccak } from './static_dependencies/noble-hashes/sha3.js';
12
13
  import { secp256k1 } from './static_dependencies/noble-curves/secp256k1.js';
13
- import { ecdsa } from './base/functions/crypto.js';
14
+ import { TICK_SIZE } from './base/functions/number.js';
14
15
  // ---------------------------------------------------------------------------
15
16
  /**
16
17
  * @class derive
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/ellipx.js';
2
- import { Str, Int, int, Dict, Num, Market, Ticker, OrderBook, OHLCV, Currencies, Trade, Balances, OrderType, OrderSide, Order, DepositAddress, TradingFeeInterface, Transaction } from '../ccxt.js';
2
+ import { Str, Int, int, Dict, Num, Market, Ticker, OrderBook, OHLCV, Currencies, Trade, Balances, OrderType, OrderSide, Order, DepositAddress, TradingFeeInterface, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class ellipx
5
5
  * @augments Exchange
package/js/src/ellipx.js CHANGED
@@ -7,13 +7,11 @@
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/ellipx.js';
9
9
  import { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, PermissionDenied, NotSupported, ArgumentsRequired } from './base/errors.js';
10
- // import { Precise } from './base/Precise.js';
11
- import { TICK_SIZE } from './base/functions/number.js';
12
- // import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
- import { Precise } from '../ccxt.js';
14
- import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
15
10
  import { ed25519 } from './static_dependencies/noble-curves/ed25519.js';
16
11
  import { eddsa } from './base/functions/crypto.js';
12
+ import { Precise } from './base/Precise.js';
13
+ import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
14
+ import { TICK_SIZE } from './base/functions/number.js';
17
15
  // ---------------------------------------------------------------------------
18
16
  /**
19
17
  * @class ellipx
package/js/src/gate.js CHANGED
@@ -111,7 +111,7 @@ export default class gate extends Exchange {
111
111
  'fetchCurrencies': true,
112
112
  'fetchDepositAddress': true,
113
113
  'fetchDepositAddresses': false,
114
- 'fetchDepositAddressesByNetwork': false,
114
+ 'fetchDepositAddressesByNetwork': true,
115
115
  'fetchDeposits': true,
116
116
  'fetchDepositWithdrawFee': 'emulated',
117
117
  'fetchDepositWithdrawFees': true,
@@ -720,6 +720,16 @@ export default class gate extends Exchange {
720
720
  },
721
721
  'networksById': {
722
722
  'OPETH': 'OP',
723
+ 'ETH': 'ERC20',
724
+ 'ERC20': 'ERC20',
725
+ 'TRX': 'TRC20',
726
+ 'TRC20': 'TRC20',
727
+ 'HT': 'HRC20',
728
+ 'HECO': 'HRC20',
729
+ 'BSC': 'BEP20',
730
+ 'BEP20': 'BEP20',
731
+ 'POLYGON': 'MATIC',
732
+ 'POL': 'MATIC',
723
733
  },
724
734
  'timeInForce': {
725
735
  'GTC': 'gtc',
@@ -1216,6 +1226,9 @@ export default class gate extends Exchange {
1216
1226
  if (this.options['adjustForTimeDifference']) {
1217
1227
  await this.loadTimeDifference();
1218
1228
  }
1229
+ if (this.checkRequiredCredentials(false)) {
1230
+ await this.loadUnifiedStatus();
1231
+ }
1219
1232
  const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1220
1233
  let rawPromises = [
1221
1234
  this.fetchContractMarkets(params),
@@ -1829,88 +1842,93 @@ export default class gate extends Exchange {
1829
1842
  if (apiBackup !== undefined) {
1830
1843
  return undefined;
1831
1844
  }
1832
- if (this.checkRequiredCredentials(false)) {
1833
- await this.loadUnifiedStatus();
1834
- }
1835
1845
  const response = await this.publicSpotGetCurrencies(params);
1836
1846
  //
1837
- // [
1838
- // {
1839
- // "currency": "USDT_ETH",
1840
- // "name": "Tether",
1841
- // "delisted": false,
1842
- // "withdraw_disabled": false,
1843
- // "withdraw_delayed": false,
1844
- // "deposit_disabled": false,
1845
- // "trade_disabled": true,
1846
- // "chain": "ETH"
1847
- // },
1848
- // ]
1847
+ // [
1848
+ // {
1849
+ // "currency": "USDT",
1850
+ // "name": "Tether",
1851
+ // "delisted": false,
1852
+ // "withdraw_disabled": false,
1853
+ // "withdraw_delayed": false,
1854
+ // "deposit_disabled": false,
1855
+ // "trade_disabled": false,
1856
+ // "fixed_rate": "",
1857
+ // "chain": "ETH",
1858
+ // "chains": [
1859
+ // {
1860
+ // "name": "ETH",
1861
+ // "addr": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
1862
+ // "withdraw_disabled": false,
1863
+ // "withdraw_delayed": false,
1864
+ // "deposit_disabled": false
1865
+ // },
1866
+ // {
1867
+ // "name": "ARBEVM",
1868
+ // "addr": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
1869
+ // "withdraw_disabled": false,
1870
+ // "withdraw_delayed": false,
1871
+ // "deposit_disabled": false
1872
+ // },
1873
+ // {
1874
+ // "name": "BSC",
1875
+ // "addr": "0x55d398326f99059fF775485246999027B3197955",
1876
+ // "withdraw_disabled": false,
1877
+ // "withdraw_delayed": false,
1878
+ // "deposit_disabled": false
1879
+ // },
1880
+ // ]
1881
+ // },
1882
+ // ]
1849
1883
  //
1850
1884
  const indexedCurrencies = this.indexBy(response, 'currency');
1851
1885
  const result = {};
1852
1886
  for (let i = 0; i < response.length; i++) {
1853
1887
  const entry = response[i];
1854
1888
  const currencyId = this.safeString(entry, 'currency');
1855
- const parts = currencyId.split('_');
1856
- const partFirst = this.safeString(parts, 0);
1857
- // if there's an underscore then the second part is always the chain name (except the _OLD suffix)
1858
- const currencyName = currencyId.endsWith('_OLD') ? currencyId : partFirst;
1859
- const withdrawDisabled = this.safeBool(entry, 'withdraw_disabled', false);
1860
- const depositDisabled = this.safeBool(entry, 'deposit_disabled', false);
1861
- const tradeDisabled = this.safeBool(entry, 'trade_disabled', false);
1862
- const precision = this.parseNumber('0.0001'); // temporary safe default, because no value provided from API
1863
- const code = this.safeCurrencyCode(currencyName);
1889
+ const code = this.safeCurrencyCode(currencyId);
1864
1890
  // check leveraged tokens (e.g. BTC3S, ETH5L)
1865
- let isLeveragedToken = false;
1866
- if (currencyId.endsWith('3S') || currencyId.endsWith('3L') || currencyId.endsWith('5S') || currencyId.endsWith('5L')) {
1867
- const realCurrencyId = currencyId.slice(0, -2);
1868
- if (realCurrencyId in indexedCurrencies) {
1869
- isLeveragedToken = true;
1870
- }
1871
- }
1872
- const type = isLeveragedToken ? 'leveraged' : 'crypto';
1873
- // some networks are null, they are mostly obsolete & unsupported dead tokens, so we can default their networkId to their tokenname
1874
- const networkId = this.safeString(entry, 'chain', currencyId);
1875
- const networkCode = this.networkIdToCode(networkId, code);
1876
- const networkEntry = {
1877
- 'info': entry,
1878
- 'id': networkId,
1879
- 'network': networkCode,
1880
- 'limits': {
1881
- 'deposit': {
1882
- 'min': undefined,
1883
- 'max': undefined,
1884
- },
1885
- 'withdraw': {
1886
- 'min': undefined,
1887
- 'max': undefined,
1891
+ const type = this.isLeveragedCurrency(currencyId, true, indexedCurrencies) ? 'leveraged' : 'crypto';
1892
+ const chains = this.safeList(entry, 'chains', []);
1893
+ const networks = {};
1894
+ for (let j = 0; j < chains.length; j++) {
1895
+ const chain = chains[j];
1896
+ const networkId = this.safeString(chain, 'name');
1897
+ const networkCode = this.networkIdToCode(networkId);
1898
+ networks[networkCode] = {
1899
+ 'info': chain,
1900
+ 'id': networkId,
1901
+ 'network': networkCode,
1902
+ 'active': undefined,
1903
+ 'deposit': !this.safeBool(chain, 'deposit_disabled'),
1904
+ 'withdraw': !this.safeBool(chain, 'withdraw_disabled'),
1905
+ 'fee': undefined,
1906
+ 'precision': this.parseNumber('0.0001'),
1907
+ 'limits': {
1908
+ 'deposit': {
1909
+ 'min': undefined,
1910
+ 'max': undefined,
1911
+ },
1912
+ 'withdraw': {
1913
+ 'min': undefined,
1914
+ 'max': undefined,
1915
+ },
1888
1916
  },
1889
- },
1890
- 'active': !tradeDisabled,
1891
- 'deposit': !depositDisabled,
1892
- 'withdraw': !withdrawDisabled,
1893
- 'fee': undefined,
1894
- 'precision': precision,
1895
- };
1896
- // check if first entry for the specific currency
1897
- if (!(code in result)) {
1898
- result[code] = {
1899
- 'id': currencyName,
1900
- 'lowerCaseId': currencyName.toLowerCase(),
1901
- 'code': code,
1902
- 'type': type,
1903
- 'precision': precision,
1904
- 'limits': undefined,
1905
- 'networks': {},
1906
- 'info': [], // will be filled below
1907
1917
  };
1908
1918
  }
1909
- result[code]['networks'][networkCode] = networkEntry;
1910
- const info = this.safeList(result[code], 'info', []);
1911
- info.push(entry);
1912
- result[code]['info'] = info;
1913
- result[code] = this.safeCurrencyStructure(result[code]); // this is needed after adding network entry
1919
+ result[code] = this.safeCurrencyStructure({
1920
+ 'id': currencyId,
1921
+ 'code': code,
1922
+ 'name': this.safeString(entry, 'name'),
1923
+ 'type': type,
1924
+ 'active': !this.safeBool(entry, 'delisted'),
1925
+ 'deposit': !this.safeBool(entry, 'deposit_disabled'),
1926
+ 'withdraw': !this.safeBool(entry, 'withdraw_disabled'),
1927
+ 'fee': undefined,
1928
+ 'networks': networks,
1929
+ 'precision': this.parseNumber('0.0001'),
1930
+ 'info': entry,
1931
+ });
1914
1932
  }
1915
1933
  return result;
1916
1934
  }
@@ -2182,9 +2200,7 @@ export default class gate extends Exchange {
2182
2200
  const chains = this.safeValue(response, 'multichain_addresses', []);
2183
2201
  const currencyId = this.safeString(response, 'currency');
2184
2202
  currency = this.safeCurrency(currencyId, currency);
2185
- const parsed = this.parseDepositAddresses(chains, [currency['code']], false, {
2186
- 'currency': currency['id'],
2187
- });
2203
+ const parsed = this.parseDepositAddresses(chains, undefined, false);
2188
2204
  return this.indexBy(parsed, 'network');
2189
2205
  }
2190
2206
  /**
@@ -2202,8 +2218,8 @@ export default class gate extends Exchange {
2202
2218
  let networkCode = undefined;
2203
2219
  [networkCode, params] = this.handleNetworkCodeAndParams(params);
2204
2220
  const chainsIndexedById = await this.fetchDepositAddressesByNetwork(code, params);
2205
- const selectedNetworkId = this.selectNetworkCodeFromUnifiedNetworks(code, networkCode, chainsIndexedById);
2206
- return chainsIndexedById[selectedNetworkId];
2221
+ const selectedNetworkIdOrCode = this.selectNetworkCodeFromUnifiedNetworks(code, networkCode, chainsIndexedById);
2222
+ return chainsIndexedById[selectedNetworkIdOrCode];
2207
2223
  }
2208
2224
  parseDepositAddress(depositAddress, currency = undefined) {
2209
2225
  //
package/js/src/htx.js CHANGED
@@ -4543,6 +4543,8 @@ export default class htx extends Exchange {
4543
4543
  const request = {};
4544
4544
  let marketType = undefined;
4545
4545
  [marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
4546
+ let subType = undefined;
4547
+ [subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params, 'linear');
4546
4548
  let response = undefined;
4547
4549
  if (marketType === 'spot') {
4548
4550
  if (symbol !== undefined) {
@@ -4571,18 +4573,18 @@ export default class htx extends Exchange {
4571
4573
  response = await this.spotPrivateGetV1OrderOpenOrders(this.extend(request, params));
4572
4574
  }
4573
4575
  else {
4574
- if (symbol === undefined) {
4575
- throw new ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
4576
+ if (symbol !== undefined) {
4577
+ // throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument');
4578
+ request['contract_code'] = market['id'];
4576
4579
  }
4577
4580
  if (limit !== undefined) {
4578
4581
  request['page_size'] = limit;
4579
4582
  }
4580
- request['contract_code'] = market['id'];
4581
4583
  const trigger = this.safeBool2(params, 'stop', 'trigger');
4582
4584
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
4583
4585
  const trailing = this.safeBool(params, 'trailing', false);
4584
4586
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger']);
4585
- if (market['linear']) {
4587
+ if (subType === 'linear') {
4586
4588
  let marginMode = undefined;
4587
4589
  [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
4588
4590
  marginMode = (marginMode === undefined) ? 'cross' : marginMode;
@@ -4615,8 +4617,8 @@ export default class htx extends Exchange {
4615
4617
  }
4616
4618
  }
4617
4619
  }
4618
- else if (market['inverse']) {
4619
- if (market['swap']) {
4620
+ else if (subType === 'inverse') {
4621
+ if (marketType === 'swap') {
4620
4622
  if (trigger) {
4621
4623
  response = await this.contractPrivatePostSwapApiV1SwapTriggerOpenorders(this.extend(request, params));
4622
4624
  }
@@ -4630,8 +4632,8 @@ export default class htx extends Exchange {
4630
4632
  response = await this.contractPrivatePostSwapApiV1SwapOpenorders(this.extend(request, params));
4631
4633
  }
4632
4634
  }
4633
- else if (market['future']) {
4634
- request['symbol'] = market['settleId'];
4635
+ else if (marketType === 'future') {
4636
+ request['symbol'] = this.safeString(market, 'settleId', 'usdt');
4635
4637
  if (trigger) {
4636
4638
  response = await this.contractPrivatePostApiV1ContractTriggerOpenorders(this.extend(request, params));
4637
4639
  }
@@ -1529,7 +1529,9 @@ export default class hyperliquid extends Exchange {
1529
1529
  }
1530
1530
  orderReq.push(orderObj);
1531
1531
  }
1532
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1532
+ let vaultAddress = undefined;
1533
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'createOrder', 'vaultAddress');
1534
+ vaultAddress = this.formatVaultAddress(vaultAddress);
1533
1535
  const orderAction = {
1534
1536
  'type': 'order',
1535
1537
  'orders': orderReq,
@@ -1624,7 +1626,9 @@ export default class hyperliquid extends Exchange {
1624
1626
  }
1625
1627
  }
1626
1628
  cancelAction['cancels'] = cancelReq;
1627
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1629
+ let vaultAddress = undefined;
1630
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelOrders', 'vaultAddress');
1631
+ vaultAddress = this.formatVaultAddress(vaultAddress);
1628
1632
  const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
1629
1633
  request['action'] = cancelAction;
1630
1634
  request['signature'] = signature;
@@ -1708,7 +1712,9 @@ export default class hyperliquid extends Exchange {
1708
1712
  }
1709
1713
  cancelAction['type'] = cancelByCloid ? 'cancelByCloid' : 'cancel';
1710
1714
  cancelAction['cancels'] = cancelReq;
1711
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1715
+ let vaultAddress = undefined;
1716
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelOrdersForSymbols', 'vaultAddress');
1717
+ vaultAddress = this.formatVaultAddress(vaultAddress);
1712
1718
  const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
1713
1719
  request['action'] = cancelAction;
1714
1720
  request['signature'] = signature;
@@ -1754,7 +1760,9 @@ export default class hyperliquid extends Exchange {
1754
1760
  'type': 'scheduleCancel',
1755
1761
  'time': nonce + timeout,
1756
1762
  };
1757
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1763
+ let vaultAddress = undefined;
1764
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelAllOrdersAfter', 'vaultAddress');
1765
+ vaultAddress = this.formatVaultAddress(vaultAddress);
1758
1766
  const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
1759
1767
  request['action'] = cancelAction;
1760
1768
  request['signature'] = signature;
@@ -1879,7 +1887,9 @@ export default class hyperliquid extends Exchange {
1879
1887
  'type': 'batchModify',
1880
1888
  'modifies': modifies,
1881
1889
  };
1882
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1890
+ let vaultAddress = undefined;
1891
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'editOrder', 'vaultAddress');
1892
+ vaultAddress = this.formatVaultAddress(vaultAddress);
1883
1893
  const signature = this.signL1Action(modifyAction, nonce, vaultAddress);
1884
1894
  const request = {
1885
1895
  'action': modifyAction,
@@ -1888,7 +1898,6 @@ export default class hyperliquid extends Exchange {
1888
1898
  // 'vaultAddress': vaultAddress,
1889
1899
  };
1890
1900
  if (vaultAddress !== undefined) {
1891
- params = this.omit(params, 'vaultAddress');
1892
1901
  request['vaultAddress'] = vaultAddress;
1893
1902
  }
1894
1903
  return request;
@@ -2743,9 +2752,9 @@ export default class hyperliquid extends Exchange {
2743
2752
  'isCross': isCross,
2744
2753
  'leverage': leverage,
2745
2754
  };
2746
- let vaultAddress = this.safeString(params, 'vaultAddress');
2755
+ let vaultAddress = undefined;
2756
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'setMarginMode', 'vaultAddress');
2747
2757
  if (vaultAddress !== undefined) {
2748
- params = this.omit(params, 'vaultAddress');
2749
2758
  if (vaultAddress.startsWith('0x')) {
2750
2759
  vaultAddress = vaultAddress.replace('0x', '');
2751
2760
  }
@@ -2798,7 +2807,9 @@ export default class hyperliquid extends Exchange {
2798
2807
  'isCross': isCross,
2799
2808
  'leverage': leverage,
2800
2809
  };
2801
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
2810
+ let vaultAddress = undefined;
2811
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'setLeverage', 'vaultAddress');
2812
+ vaultAddress = this.formatVaultAddress(vaultAddress);
2802
2813
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
2803
2814
  const request = {
2804
2815
  'action': updateAction,
@@ -2862,7 +2873,9 @@ export default class hyperliquid extends Exchange {
2862
2873
  'isBuy': true,
2863
2874
  'ntli': sz,
2864
2875
  };
2865
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
2876
+ let vaultAddress = undefined;
2877
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'modifyMargin', 'vaultAddress');
2878
+ vaultAddress = this.formatVaultAddress(vaultAddress);
2866
2879
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
2867
2880
  const request = {
2868
2881
  'action': updateAction,
@@ -2871,7 +2884,6 @@ export default class hyperliquid extends Exchange {
2871
2884
  // 'vaultAddress': vaultAddress,
2872
2885
  };
2873
2886
  if (vaultAddress !== undefined) {
2874
- params = this.omit(params, 'vaultAddress');
2875
2887
  request['vaultAddress'] = vaultAddress;
2876
2888
  }
2877
2889
  const response = await this.privatePostExchange(request);
@@ -2930,8 +2942,9 @@ export default class hyperliquid extends Exchange {
2930
2942
  throw new NotSupported(this.id + ' transfer() only support spot <> swap transfer');
2931
2943
  }
2932
2944
  let strAmount = this.numberToString(amount);
2933
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
2934
- params = this.omit(params, 'vaultAddress');
2945
+ let vaultAddress = undefined;
2946
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'transfer', 'vaultAddress');
2947
+ vaultAddress = this.formatVaultAddress(vaultAddress);
2935
2948
  if (vaultAddress !== undefined) {
2936
2949
  strAmount = strAmount + ' subaccount:' + vaultAddress;
2937
2950
  }
@@ -3034,7 +3047,9 @@ export default class hyperliquid extends Exchange {
3034
3047
  throw new NotSupported(this.id + ' withdraw() only support USDC');
3035
3048
  }
3036
3049
  }
3037
- const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
3050
+ let vaultAddress = undefined;
3051
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'withdraw', 'vaultAddress');
3052
+ vaultAddress = this.formatVaultAddress(vaultAddress);
3038
3053
  params = this.omit(params, 'vaultAddress');
3039
3054
  const nonce = this.milliseconds();
3040
3055
  let action = {};
@@ -3660,8 +3675,9 @@ export default class hyperliquid extends Exchange {
3660
3675
  }
3661
3676
  parseCreateEditOrderArgs(id, symbol, type, side, amount, price = undefined, params = {}) {
3662
3677
  const market = this.market(symbol);
3663
- const vaultAddress = this.safeString(params, 'vaultAddress');
3664
- params = this.omit(params, 'vaultAddress');
3678
+ let vaultAddress = undefined;
3679
+ [vaultAddress, params] = this.handleOptionAndParams(params, 'createOrder', 'vaultAddress');
3680
+ vaultAddress = this.formatVaultAddress(vaultAddress);
3665
3681
  symbol = market['symbol'];
3666
3682
  const order = {
3667
3683
  'symbol': symbol,