ccxt 4.4.92 → 4.4.94

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 (62) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ascendex.js +9 -8
  5. package/dist/cjs/src/base/Exchange.js +118 -33
  6. package/dist/cjs/src/binance.js +44 -1
  7. package/dist/cjs/src/bitmex.js +3 -3
  8. package/dist/cjs/src/bybit.js +85 -10
  9. package/dist/cjs/src/coinbase.js +3 -1
  10. package/dist/cjs/src/coinbaseexchange.js +53 -0
  11. package/dist/cjs/src/coincheck.js +47 -4
  12. package/dist/cjs/src/coinex.js +19 -14
  13. package/dist/cjs/src/coinmetro.js +16 -3
  14. package/dist/cjs/src/cryptomus.js +30 -53
  15. package/dist/cjs/src/deribit.js +6 -6
  16. package/dist/cjs/src/exmo.js +66 -61
  17. package/dist/cjs/src/htx.js +7 -1
  18. package/dist/cjs/src/hyperliquid.js +134 -33
  19. package/dist/cjs/src/kucoin.js +13 -15
  20. package/dist/cjs/src/latoken.js +19 -74
  21. package/dist/cjs/src/lbank.js +2 -2
  22. package/dist/cjs/src/okx.js +169 -4
  23. package/dist/cjs/src/paradex.js +54 -0
  24. package/dist/cjs/src/phemex.js +3 -3
  25. package/dist/cjs/src/pro/bitstamp.js +55 -16
  26. package/dist/cjs/src/pro/bybit.js +2 -1
  27. package/dist/cjs/src/wavesexchange.js +15 -2
  28. package/js/ccxt.d.ts +1 -1
  29. package/js/ccxt.js +1 -1
  30. package/js/src/ascendex.js +9 -8
  31. package/js/src/base/Exchange.d.ts +3 -1
  32. package/js/src/base/Exchange.js +118 -33
  33. package/js/src/binance.d.ts +10 -0
  34. package/js/src/binance.js +44 -1
  35. package/js/src/bitmex.d.ts +1 -1
  36. package/js/src/bitmex.js +3 -3
  37. package/js/src/bybit.d.ts +12 -1
  38. package/js/src/bybit.js +85 -10
  39. package/js/src/coinbase.js +4 -2
  40. package/js/src/coinbaseexchange.js +53 -0
  41. package/js/src/coincheck.js +48 -5
  42. package/js/src/coinex.js +16 -13
  43. package/js/src/coinmetro.js +16 -3
  44. package/js/src/cryptomus.js +30 -53
  45. package/js/src/deribit.js +6 -6
  46. package/js/src/exmo.js +66 -61
  47. package/js/src/htx.js +7 -1
  48. package/js/src/hyperliquid.d.ts +31 -0
  49. package/js/src/hyperliquid.js +134 -33
  50. package/js/src/kucoin.js +13 -15
  51. package/js/src/latoken.d.ts +0 -1
  52. package/js/src/latoken.js +19 -74
  53. package/js/src/lbank.js +2 -2
  54. package/js/src/okx.d.ts +12 -0
  55. package/js/src/okx.js +169 -4
  56. package/js/src/paradex.d.ts +10 -0
  57. package/js/src/paradex.js +54 -0
  58. package/js/src/phemex.js +3 -3
  59. package/js/src/pro/bitstamp.js +55 -16
  60. package/js/src/pro/bybit.js +2 -1
  61. package/js/src/wavesexchange.js +15 -2
  62. package/package.json +1 -1
@@ -345,6 +345,9 @@ export default class hyperliquid extends Exchange {
345
345
  * @returns {object} an associative dictionary of currencies
346
346
  */
347
347
  async fetchCurrencies(params = {}) {
348
+ if (this.checkRequiredCredentials(false)) {
349
+ await this.handleBuilderFeeApproval();
350
+ }
348
351
  const request = {
349
352
  'type': 'meta',
350
353
  };
@@ -625,6 +628,7 @@ export default class hyperliquid extends Exchange {
625
628
  'quote': quote,
626
629
  'settle': undefined,
627
630
  'baseId': baseId,
631
+ 'baseName': baseName,
628
632
  'quoteId': quoteId,
629
633
  'settleId': undefined,
630
634
  'type': 'spot',
@@ -695,7 +699,8 @@ export default class hyperliquid extends Exchange {
695
699
  // }
696
700
  //
697
701
  const quoteId = 'USDC';
698
- const base = this.safeString(market, 'name');
702
+ const baseName = this.safeString(market, 'name');
703
+ const base = this.safeCurrencyCode(baseName);
699
704
  const quote = this.safeCurrencyCode(quoteId);
700
705
  const baseId = this.safeString(market, 'baseId');
701
706
  const settleId = 'USDC';
@@ -731,6 +736,7 @@ export default class hyperliquid extends Exchange {
731
736
  'quote': quote,
732
737
  'settle': settle,
733
738
  'baseId': baseId,
739
+ 'baseName': baseName,
734
740
  'quoteId': quoteId,
735
741
  'settleId': settleId,
736
742
  'type': 'swap',
@@ -786,6 +792,7 @@ export default class hyperliquid extends Exchange {
786
792
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
787
793
  * @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap
788
794
  * @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
795
+ * @param {string} [params.subAccountAddress] sub account user address
789
796
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
790
797
  */
791
798
  async fetchBalance(params = {}) {
@@ -796,9 +803,8 @@ export default class hyperliquid extends Exchange {
796
803
  let marginMode = undefined;
797
804
  [marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
798
805
  const isSpot = (type === 'spot');
799
- const reqType = (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState';
800
806
  const request = {
801
- 'type': reqType,
807
+ 'type': (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState',
802
808
  'user': userAddress,
803
809
  };
804
810
  const response = await this.publicPostInfo(this.extend(request, params));
@@ -886,7 +892,7 @@ export default class hyperliquid extends Exchange {
886
892
  const market = this.market(symbol);
887
893
  const request = {
888
894
  'type': 'l2Book',
889
- 'coin': market['swap'] ? market['base'] : market['id'],
895
+ 'coin': market['swap'] ? market['baseName'] : market['id'],
890
896
  };
891
897
  const response = await this.publicPostInfo(this.extend(request, params));
892
898
  //
@@ -1124,7 +1130,7 @@ export default class hyperliquid extends Exchange {
1124
1130
  const request = {
1125
1131
  'type': 'candleSnapshot',
1126
1132
  'req': {
1127
- 'coin': market['swap'] ? market['base'] : market['id'],
1133
+ 'coin': market['swap'] ? market['baseName'] : market['id'],
1128
1134
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
1129
1135
  'startTime': since,
1130
1136
  'endTime': until,
@@ -1186,6 +1192,7 @@ export default class hyperliquid extends Exchange {
1186
1192
  * @param {int} [params.until] timestamp in ms of the latest trade
1187
1193
  * @param {string} [params.address] wallet address that made trades
1188
1194
  * @param {string} [params.user] wallet address that made trades
1195
+ * @param {string} [params.subAccountAddress] sub account user address
1189
1196
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1190
1197
  */
1191
1198
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -1370,6 +1377,71 @@ export default class hyperliquid extends Exchange {
1370
1377
  };
1371
1378
  return this.signUserSignedAction(messageTypes, message);
1372
1379
  }
1380
+ buildApproveBuilderFeeSig(message) {
1381
+ const messageTypes = {
1382
+ 'HyperliquidTransaction:ApproveBuilderFee': [
1383
+ { 'name': 'hyperliquidChain', 'type': 'string' },
1384
+ { 'name': 'maxFeeRate', 'type': 'string' },
1385
+ { 'name': 'builder', 'type': 'address' },
1386
+ { 'name': 'nonce', 'type': 'uint64' },
1387
+ ],
1388
+ };
1389
+ return this.signUserSignedAction(messageTypes, message);
1390
+ }
1391
+ async approveBuilderFee(builder, maxFeeRate) {
1392
+ const nonce = this.milliseconds();
1393
+ const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1394
+ const payload = {
1395
+ 'hyperliquidChain': isSandboxMode ? 'Testnet' : 'Mainnet',
1396
+ 'maxFeeRate': maxFeeRate,
1397
+ 'builder': builder,
1398
+ 'nonce': nonce,
1399
+ };
1400
+ const sig = this.buildApproveBuilderFeeSig(payload);
1401
+ const action = {
1402
+ 'hyperliquidChain': payload['hyperliquidChain'],
1403
+ 'signatureChainId': '0x66eee',
1404
+ 'maxFeeRate': payload['maxFeeRate'],
1405
+ 'builder': payload['builder'],
1406
+ 'nonce': nonce,
1407
+ 'type': 'approveBuilderFee',
1408
+ };
1409
+ const request = {
1410
+ 'action': action,
1411
+ 'nonce': nonce,
1412
+ 'signature': sig,
1413
+ 'vaultAddress': undefined,
1414
+ };
1415
+ //
1416
+ // {
1417
+ // "status": "ok",
1418
+ // "response": {
1419
+ // "type": "default"
1420
+ // }
1421
+ // }
1422
+ //
1423
+ return await this.privatePostExchange(request);
1424
+ }
1425
+ async handleBuilderFeeApproval() {
1426
+ const buildFee = this.safeBool(this.options, 'builderFee', true);
1427
+ if (!buildFee) {
1428
+ return false; // skip if builder fee is not enabled
1429
+ }
1430
+ const approvedBuilderFee = this.safeBool(this.options, 'approvedBuilderFee', false);
1431
+ if (approvedBuilderFee) {
1432
+ return true; // skip if builder fee is already approved
1433
+ }
1434
+ try {
1435
+ const builder = this.safeString(this.options, 'builder', '0x6530512A6c89C7cfCEbC3BA7fcD9aDa5f30827a6');
1436
+ const maxFeeRate = this.safeString(this.options, 'feeRate', '0.01%');
1437
+ await this.approveBuilderFee(builder, maxFeeRate);
1438
+ this.options['approvedBuilderFee'] = true;
1439
+ }
1440
+ catch (e) {
1441
+ this.options['builderFee'] = false; // disable builder fee if an error occurs
1442
+ }
1443
+ return true;
1444
+ }
1373
1445
  /**
1374
1446
  * @method
1375
1447
  * @name hyperliquid#createOrder
@@ -1388,6 +1460,7 @@ export default class hyperliquid extends Exchange {
1388
1460
  * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
1389
1461
  * @param {string} [params.slippage] the slippage for market order
1390
1462
  * @param {string} [params.vaultAddress] the vault address for order
1463
+ * @param {string} [params.subAccountAddress] sub account user address
1391
1464
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1392
1465
  */
1393
1466
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -1407,6 +1480,7 @@ export default class hyperliquid extends Exchange {
1407
1480
  */
1408
1481
  async createOrders(orders, params = {}) {
1409
1482
  await this.loadMarkets();
1483
+ await this.handleBuilderFeeApproval();
1410
1484
  const request = this.createOrdersRequest(orders, params);
1411
1485
  const response = await this.privatePostExchange(request);
1412
1486
  //
@@ -1592,10 +1666,10 @@ export default class hyperliquid extends Exchange {
1592
1666
  'type': 'order',
1593
1667
  'orders': orderReq,
1594
1668
  'grouping': grouping,
1595
- // 'brokerCode': 1, // cant
1596
1669
  };
1597
- if (vaultAddress === undefined) {
1598
- orderAction['brokerCode'] = 1;
1670
+ if (this.safeBool(this.options, 'approvedBuilderFee', false)) {
1671
+ const wallet = this.safeStringLower(this.options, 'builder', '0x6530512A6c89C7cfCEbC3BA7fcD9aDa5f30827a6');
1672
+ orderAction['builder'] = { 'b': wallet, 'f': this.safeInteger(this.options, 'feeInt', 10) };
1599
1673
  }
1600
1674
  const signature = this.signL1Action(orderAction, nonce, vaultAddress);
1601
1675
  const request = {
@@ -1621,6 +1695,7 @@ export default class hyperliquid extends Exchange {
1621
1695
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1622
1696
  * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
1623
1697
  * @param {string} [params.vaultAddress] the vault address for order
1698
+ * @param {string} [params.subAccountAddress] sub account user address
1624
1699
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1625
1700
  */
1626
1701
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -1638,6 +1713,7 @@ export default class hyperliquid extends Exchange {
1638
1713
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1639
1714
  * @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
1640
1715
  * @param {string} [params.vaultAddress] the vault address
1716
+ * @param {string} [params.subAccountAddress] sub account user address
1641
1717
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1642
1718
  */
1643
1719
  async cancelOrders(ids, symbol = undefined, params = {}) {
@@ -1683,7 +1759,7 @@ export default class hyperliquid extends Exchange {
1683
1759
  }
1684
1760
  cancelAction['cancels'] = cancelReq;
1685
1761
  let vaultAddress = undefined;
1686
- [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelOrders', 'vaultAddress');
1762
+ [vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelOrders', 'vaultAddress', 'subAccountAddress');
1687
1763
  vaultAddress = this.formatVaultAddress(vaultAddress);
1688
1764
  const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
1689
1765
  request['action'] = cancelAction;
@@ -1728,6 +1804,7 @@ export default class hyperliquid extends Exchange {
1728
1804
  * @param {CancellationRequest[]} orders each order should contain the parameters required by cancelOrder namely id and symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
1729
1805
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1730
1806
  * @param {string} [params.vaultAddress] the vault address
1807
+ * @param {string} [params.subAccountAddress] sub account user address
1731
1808
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1732
1809
  */
1733
1810
  async cancelOrdersForSymbols(orders, params = {}) {
@@ -1769,7 +1846,7 @@ export default class hyperliquid extends Exchange {
1769
1846
  cancelAction['type'] = cancelByCloid ? 'cancelByCloid' : 'cancel';
1770
1847
  cancelAction['cancels'] = cancelReq;
1771
1848
  let vaultAddress = undefined;
1772
- [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelOrdersForSymbols', 'vaultAddress');
1849
+ [vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelOrdersForSymbols', 'vaultAddress', 'subAccountAddress');
1773
1850
  vaultAddress = this.formatVaultAddress(vaultAddress);
1774
1851
  const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
1775
1852
  request['action'] = cancelAction;
@@ -1801,6 +1878,7 @@ export default class hyperliquid extends Exchange {
1801
1878
  * @param {number} timeout time in milliseconds, 0 represents cancel the timer
1802
1879
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1803
1880
  * @param {string} [params.vaultAddress] the vault address
1881
+ * @param {string} [params.subAccountAddress] sub account user address
1804
1882
  * @returns {object} the api result
1805
1883
  */
1806
1884
  async cancelAllOrdersAfter(timeout, params = {}) {
@@ -1817,7 +1895,7 @@ export default class hyperliquid extends Exchange {
1817
1895
  'time': nonce + timeout,
1818
1896
  };
1819
1897
  let vaultAddress = undefined;
1820
- [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelAllOrdersAfter', 'vaultAddress');
1898
+ [vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelAllOrdersAfter', 'vaultAddress', 'subAccountAddress');
1821
1899
  vaultAddress = this.formatVaultAddress(vaultAddress);
1822
1900
  const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
1823
1901
  request['action'] = cancelAction;
@@ -1976,6 +2054,7 @@ export default class hyperliquid extends Exchange {
1976
2054
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
1977
2055
  * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
1978
2056
  * @param {string} [params.vaultAddress] the vault address for order
2057
+ * @param {string} [params.subAccountAddress] sub account user address
1979
2058
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1980
2059
  */
1981
2060
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
@@ -2100,7 +2179,7 @@ export default class hyperliquid extends Exchange {
2100
2179
  const market = this.market(symbol);
2101
2180
  const request = {
2102
2181
  'type': 'fundingHistory',
2103
- 'coin': market['base'],
2182
+ 'coin': market['baseName'],
2104
2183
  };
2105
2184
  if (since !== undefined) {
2106
2185
  request['startTime'] = since;
@@ -2151,6 +2230,7 @@ export default class hyperliquid extends Exchange {
2151
2230
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2152
2231
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
2153
2232
  * @param {string} [params.method] 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders'
2233
+ * @param {string} [params.subAccountAddress] sub account user address
2154
2234
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2155
2235
  */
2156
2236
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2249,6 +2329,7 @@ export default class hyperliquid extends Exchange {
2249
2329
  * @param {int} [limit] the maximum number of open orders structures to retrieve
2250
2330
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2251
2331
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
2332
+ * @param {string} [params.subAccountAddress] sub account user address
2252
2333
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2253
2334
  */
2254
2335
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2285,6 +2366,7 @@ export default class hyperliquid extends Exchange {
2285
2366
  * @param {string} symbol unified symbol of the market the order was made in
2286
2367
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2287
2368
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
2369
+ * @param {string} [params.subAccountAddress] sub account user address
2288
2370
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2289
2371
  */
2290
2372
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -2517,6 +2599,7 @@ export default class hyperliquid extends Exchange {
2517
2599
  * @param {int} [limit] the maximum number of trades structures to retrieve
2518
2600
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2519
2601
  * @param {int} [params.until] timestamp in ms of the latest trade
2602
+ * @param {string} [params.subAccountAddress] sub account user address
2520
2603
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2521
2604
  */
2522
2605
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2642,6 +2725,7 @@ export default class hyperliquid extends Exchange {
2642
2725
  * @param {string[]} [symbols] list of unified market symbols
2643
2726
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2644
2727
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
2728
+ * @param {string} [params.subAccountAddress] sub account user address
2645
2729
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2646
2730
  */
2647
2731
  async fetchPositions(symbols = undefined, params = {}) {
@@ -2786,6 +2870,8 @@ export default class hyperliquid extends Exchange {
2786
2870
  * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
2787
2871
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2788
2872
  * @param {string} [params.leverage] the rate of leverage, is required if setting trade mode (symbol)
2873
+ * @param {string} [params.vaultAddress] the vault address
2874
+ * @param {string} [params.subAccountAddress] sub account user address
2789
2875
  * @returns {object} response from the exchange
2790
2876
  */
2791
2877
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -2809,7 +2895,7 @@ export default class hyperliquid extends Exchange {
2809
2895
  'leverage': leverage,
2810
2896
  };
2811
2897
  let vaultAddress = undefined;
2812
- [vaultAddress, params] = this.handleOptionAndParams(params, 'setMarginMode', 'vaultAddress');
2898
+ [vaultAddress, params] = this.handleOptionAndParams2(params, 'setMarginMode', 'vaultAddress', 'subAccountAddress');
2813
2899
  if (vaultAddress !== undefined) {
2814
2900
  if (vaultAddress.startsWith('0x')) {
2815
2901
  vaultAddress = vaultAddress.replace('0x', '');
@@ -2864,7 +2950,7 @@ export default class hyperliquid extends Exchange {
2864
2950
  'leverage': leverage,
2865
2951
  };
2866
2952
  let vaultAddress = undefined;
2867
- [vaultAddress, params] = this.handleOptionAndParams(params, 'setLeverage', 'vaultAddress');
2953
+ [vaultAddress, params] = this.handleOptionAndParams2(params, 'setLeverage', 'vaultAddress', 'subAccountAddress');
2868
2954
  vaultAddress = this.formatVaultAddress(vaultAddress);
2869
2955
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
2870
2956
  const request = {
@@ -2896,6 +2982,8 @@ export default class hyperliquid extends Exchange {
2896
2982
  * @param {string} symbol unified market symbol
2897
2983
  * @param {float} amount amount of margin to add
2898
2984
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2985
+ * @param {string} [params.vaultAddress] the vault address
2986
+ * @param {string} [params.subAccountAddress] sub account user address
2899
2987
  * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
2900
2988
  */
2901
2989
  async addMargin(symbol, amount, params = {}) {
@@ -2909,6 +2997,8 @@ export default class hyperliquid extends Exchange {
2909
2997
  * @param {string} symbol unified market symbol
2910
2998
  * @param {float} amount the amount of margin to remove
2911
2999
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3000
+ * @param {string} [params.vaultAddress] the vault address
3001
+ * @param {string} [params.subAccountAddress] sub account user address
2912
3002
  * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
2913
3003
  */
2914
3004
  async reduceMargin(symbol, amount, params = {}) {
@@ -2930,7 +3020,7 @@ export default class hyperliquid extends Exchange {
2930
3020
  'ntli': sz,
2931
3021
  };
2932
3022
  let vaultAddress = undefined;
2933
- [vaultAddress, params] = this.handleOptionAndParams(params, 'modifyMargin', 'vaultAddress');
3023
+ [vaultAddress, params] = this.handleOptionAndParams2(params, 'modifyMargin', 'vaultAddress', 'subAccountAddress');
2934
3024
  vaultAddress = this.formatVaultAddress(vaultAddress);
2935
3025
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
2936
3026
  const request = {
@@ -3030,30 +3120,36 @@ export default class hyperliquid extends Exchange {
3030
3120
  const transferResponse = await this.privatePostExchange(transferRequest);
3031
3121
  return transferResponse;
3032
3122
  }
3033
- // handle sub-account/different account transfer
3034
- this.checkAddress(toAccount);
3123
+ // transfer between main account and subaccount
3035
3124
  if (code !== undefined) {
3036
3125
  code = code.toUpperCase();
3037
3126
  if (code !== 'USDC') {
3038
3127
  throw new NotSupported(this.id + ' transfer() only support USDC');
3039
3128
  }
3040
3129
  }
3041
- const payload = {
3042
- 'hyperliquidChain': isSandboxMode ? 'Testnet' : 'Mainnet',
3043
- 'destination': toAccount,
3044
- 'amount': this.numberToString(amount),
3045
- 'time': nonce,
3130
+ let isDeposit = false;
3131
+ let subAccountAddress = undefined;
3132
+ if (fromAccount === 'main') {
3133
+ subAccountAddress = toAccount;
3134
+ isDeposit = true;
3135
+ }
3136
+ else if (toAccount === 'main') {
3137
+ subAccountAddress = fromAccount;
3138
+ }
3139
+ else {
3140
+ throw new NotSupported(this.id + ' transfer() only support main <> subaccount transfer');
3141
+ }
3142
+ this.checkAddress(subAccountAddress);
3143
+ const usd = this.parseToInt(Precise.stringMul(this.numberToString(amount), '1000000'));
3144
+ const action = {
3145
+ 'type': 'subAccountTransfer',
3146
+ 'subAccountUser': subAccountAddress,
3147
+ 'isDeposit': isDeposit,
3148
+ 'usd': usd,
3046
3149
  };
3047
- const sig = this.buildUsdSendSig(payload);
3150
+ const sig = this.signL1Action(action, nonce);
3048
3151
  const request = {
3049
- 'action': {
3050
- 'hyperliquidChain': payload['hyperliquidChain'],
3051
- 'signatureChainId': '0x66eee',
3052
- 'destination': toAccount,
3053
- 'amount': amount.toString(),
3054
- 'time': nonce,
3055
- 'type': 'usdSend',
3056
- },
3152
+ 'action': action,
3057
3153
  'nonce': nonce,
3058
3154
  'signature': sig,
3059
3155
  };
@@ -3205,6 +3301,7 @@ export default class hyperliquid extends Exchange {
3205
3301
  * @param {string} symbol unified market symbol
3206
3302
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3207
3303
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
3304
+ * @param {string} [params.subAccountAddress] sub account user address
3208
3305
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
3209
3306
  */
3210
3307
  async fetchTradingFee(symbol, params = {}) {
@@ -3313,6 +3410,7 @@ export default class hyperliquid extends Exchange {
3313
3410
  * @param {int} [limit] max number of ledger entries to return
3314
3411
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3315
3412
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
3413
+ * @param {string} [params.subAccountAddress] sub account user address
3316
3414
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
3317
3415
  */
3318
3416
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3405,6 +3503,7 @@ export default class hyperliquid extends Exchange {
3405
3503
  * @param {int} [limit] the maximum number of deposits structures to retrieve
3406
3504
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3407
3505
  * @param {int} [params.until] the latest time in ms to fetch withdrawals for
3506
+ * @param {string} [params.subAccountAddress] sub account user address
3408
3507
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3409
3508
  */
3410
3509
  async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3450,6 +3549,7 @@ export default class hyperliquid extends Exchange {
3450
3549
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
3451
3550
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3452
3551
  * @param {int} [params.until] the latest time in ms to fetch withdrawals for
3552
+ * @param {string} [params.subAccountAddress] sub account user address
3453
3553
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3454
3554
  */
3455
3555
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3556,6 +3656,7 @@ export default class hyperliquid extends Exchange {
3556
3656
  * @param {int} [since] the earliest time in ms to fetch funding history for
3557
3657
  * @param {int} [limit] the maximum number of funding history structures to retrieve
3558
3658
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3659
+ * @param {string} [params.subAccountAddress] sub account user address
3559
3660
  * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
3560
3661
  */
3561
3662
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3653,7 +3754,7 @@ export default class hyperliquid extends Exchange {
3653
3754
  }
3654
3755
  handlePublicAddress(methodName, params) {
3655
3756
  let userAux = undefined;
3656
- [userAux, params] = this.handleOptionAndParams(params, methodName, 'user');
3757
+ [userAux, params] = this.handleOptionAndParams2(params, methodName, 'user', 'subAccountAddress');
3657
3758
  let user = userAux;
3658
3759
  [user, params] = this.handleOptionAndParams(params, methodName, 'address', userAux);
3659
3760
  if ((user !== undefined) && (user !== '')) {
@@ -3732,7 +3833,7 @@ export default class hyperliquid extends Exchange {
3732
3833
  parseCreateEditOrderArgs(id, symbol, type, side, amount, price = undefined, params = {}) {
3733
3834
  const market = this.market(symbol);
3734
3835
  let vaultAddress = undefined;
3735
- [vaultAddress, params] = this.handleOptionAndParams(params, 'createOrder', 'vaultAddress');
3836
+ [vaultAddress, params] = this.handleOptionAndParams2(params, 'createOrder', 'vaultAddress', 'subAccountAddress');
3736
3837
  vaultAddress = this.formatVaultAddress(vaultAddress);
3737
3838
  symbol = market['symbol'];
3738
3839
  const order = {
package/js/src/kucoin.js CHANGED
@@ -1389,36 +1389,32 @@ export default class kucoin extends Exchange {
1389
1389
  // }
1390
1390
  //
1391
1391
  const currenciesData = this.safeList(response, 'data', []);
1392
+ const brokenCurrencies = this.safeList(this.options, 'brokenCurrencies', ['00', 'OPEN_ERROR', 'HUF', 'BDT']);
1393
+ const otherFiats = this.safeList(this.options, 'fiats', ['KWD', 'IRR', 'PKR']);
1392
1394
  const result = {};
1393
1395
  for (let i = 0; i < currenciesData.length; i++) {
1394
1396
  const entry = currenciesData[i];
1395
1397
  const id = this.safeString(entry, 'currency');
1396
- const name = this.safeString(entry, 'fullName');
1398
+ if (this.inArray(id, brokenCurrencies)) {
1399
+ continue; // skip buggy entries: https://t.me/KuCoin_API/217798
1400
+ }
1397
1401
  const code = this.safeCurrencyCode(id);
1398
1402
  const networks = {};
1399
1403
  const chains = this.safeList(entry, 'chains', []);
1400
- const rawPrecision = this.safeString(entry, 'precision');
1401
- const precision = this.parseNumber(this.parsePrecision(rawPrecision));
1402
1404
  const chainsLength = chains.length;
1403
- if (!chainsLength) {
1404
- // one buggy coin, which doesn't contain info https://t.me/KuCoin_API/173118
1405
- continue;
1406
- }
1407
1405
  for (let j = 0; j < chainsLength; j++) {
1408
1406
  const chain = chains[j];
1409
1407
  const chainId = this.safeString(chain, 'chainId');
1410
1408
  const networkCode = this.networkIdToCode(chainId, code);
1411
- const chainWithdrawEnabled = this.safeBool(chain, 'isWithdrawEnabled', false);
1412
- const chainDepositEnabled = this.safeBool(chain, 'isDepositEnabled', false);
1413
1409
  networks[networkCode] = {
1414
1410
  'info': chain,
1415
1411
  'id': chainId,
1416
1412
  'name': this.safeString(chain, 'chainName'),
1417
1413
  'code': networkCode,
1418
- 'active': chainWithdrawEnabled && chainDepositEnabled,
1414
+ 'active': undefined,
1419
1415
  'fee': this.safeNumber(chain, 'withdrawalMinFee'),
1420
- 'deposit': chainDepositEnabled,
1421
- 'withdraw': chainWithdrawEnabled,
1416
+ 'deposit': this.safeBool(chain, 'isDepositEnabled'),
1417
+ 'withdraw': this.safeBool(chain, 'isWithdrawEnabled'),
1422
1418
  'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'withdrawPrecision'))),
1423
1419
  'limits': {
1424
1420
  'withdraw': {
@@ -1433,10 +1429,12 @@ export default class kucoin extends Exchange {
1433
1429
  };
1434
1430
  }
1435
1431
  // kucoin has determined 'fiat' currencies with below logic
1436
- const isFiat = (rawPrecision === '2') && (chainsLength === 0);
1432
+ const rawPrecision = this.safeString(entry, 'precision');
1433
+ const precision = this.parseNumber(this.parsePrecision(rawPrecision));
1434
+ const isFiat = this.inArray(id, otherFiats) || ((rawPrecision === '2') && (chainsLength === 0));
1437
1435
  result[code] = this.safeCurrencyStructure({
1438
1436
  'id': id,
1439
- 'name': name,
1437
+ 'name': this.safeString(entry, 'fullName'),
1440
1438
  'code': code,
1441
1439
  'type': isFiat ? 'fiat' : 'crypto',
1442
1440
  'precision': precision,
@@ -2697,7 +2695,7 @@ export default class kucoin extends Exchange {
2697
2695
  async cancelAllOrders(symbol = undefined, params = {}) {
2698
2696
  await this.loadMarkets();
2699
2697
  const request = {};
2700
- const trigger = this.safeBool(params, 'stop', false);
2698
+ const trigger = this.safeBool2(params, 'trigger', 'stop', false);
2701
2699
  let hf = undefined;
2702
2700
  [hf, params] = this.handleHfAndParams(params);
2703
2701
  params = this.omit(params, 'stop');
@@ -25,7 +25,6 @@ export default class latoken extends Exchange {
25
25
  * @returns {object[]} an array of objects representing market data
26
26
  */
27
27
  fetchMarkets(params?: {}): Promise<Market[]>;
28
- fetchCurrenciesFromCache(params?: {}): Promise<any>;
29
28
  /**
30
29
  * @method
31
30
  * @name latoken#fetchCurrencies