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.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +9 -8
- package/dist/cjs/src/base/Exchange.js +118 -33
- package/dist/cjs/src/binance.js +44 -1
- package/dist/cjs/src/bitmex.js +3 -3
- package/dist/cjs/src/bybit.js +85 -10
- package/dist/cjs/src/coinbase.js +3 -1
- package/dist/cjs/src/coinbaseexchange.js +53 -0
- package/dist/cjs/src/coincheck.js +47 -4
- package/dist/cjs/src/coinex.js +19 -14
- package/dist/cjs/src/coinmetro.js +16 -3
- package/dist/cjs/src/cryptomus.js +30 -53
- package/dist/cjs/src/deribit.js +6 -6
- package/dist/cjs/src/exmo.js +66 -61
- package/dist/cjs/src/htx.js +7 -1
- package/dist/cjs/src/hyperliquid.js +134 -33
- package/dist/cjs/src/kucoin.js +13 -15
- package/dist/cjs/src/latoken.js +19 -74
- package/dist/cjs/src/lbank.js +2 -2
- package/dist/cjs/src/okx.js +169 -4
- package/dist/cjs/src/paradex.js +54 -0
- package/dist/cjs/src/phemex.js +3 -3
- package/dist/cjs/src/pro/bitstamp.js +55 -16
- package/dist/cjs/src/pro/bybit.js +2 -1
- package/dist/cjs/src/wavesexchange.js +15 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/ascendex.js +9 -8
- package/js/src/base/Exchange.d.ts +3 -1
- package/js/src/base/Exchange.js +118 -33
- package/js/src/binance.d.ts +10 -0
- package/js/src/binance.js +44 -1
- package/js/src/bitmex.d.ts +1 -1
- package/js/src/bitmex.js +3 -3
- package/js/src/bybit.d.ts +12 -1
- package/js/src/bybit.js +85 -10
- package/js/src/coinbase.js +4 -2
- package/js/src/coinbaseexchange.js +53 -0
- package/js/src/coincheck.js +48 -5
- package/js/src/coinex.js +16 -13
- package/js/src/coinmetro.js +16 -3
- package/js/src/cryptomus.js +30 -53
- package/js/src/deribit.js +6 -6
- package/js/src/exmo.js +66 -61
- package/js/src/htx.js +7 -1
- package/js/src/hyperliquid.d.ts +31 -0
- package/js/src/hyperliquid.js +134 -33
- package/js/src/kucoin.js +13 -15
- package/js/src/latoken.d.ts +0 -1
- package/js/src/latoken.js +19 -74
- package/js/src/lbank.js +2 -2
- package/js/src/okx.d.ts +12 -0
- package/js/src/okx.js +169 -4
- package/js/src/paradex.d.ts +10 -0
- package/js/src/paradex.js +54 -0
- package/js/src/phemex.js +3 -3
- package/js/src/pro/bitstamp.js +55 -16
- package/js/src/pro/bybit.js +2 -1
- package/js/src/wavesexchange.js +15 -2
- package/package.json +1 -1
|
@@ -342,6 +342,9 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
342
342
|
* @returns {object} an associative dictionary of currencies
|
|
343
343
|
*/
|
|
344
344
|
async fetchCurrencies(params = {}) {
|
|
345
|
+
if (this.checkRequiredCredentials(false)) {
|
|
346
|
+
await this.handleBuilderFeeApproval();
|
|
347
|
+
}
|
|
345
348
|
const request = {
|
|
346
349
|
'type': 'meta',
|
|
347
350
|
};
|
|
@@ -622,6 +625,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
622
625
|
'quote': quote,
|
|
623
626
|
'settle': undefined,
|
|
624
627
|
'baseId': baseId,
|
|
628
|
+
'baseName': baseName,
|
|
625
629
|
'quoteId': quoteId,
|
|
626
630
|
'settleId': undefined,
|
|
627
631
|
'type': 'spot',
|
|
@@ -692,7 +696,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
692
696
|
// }
|
|
693
697
|
//
|
|
694
698
|
const quoteId = 'USDC';
|
|
695
|
-
const
|
|
699
|
+
const baseName = this.safeString(market, 'name');
|
|
700
|
+
const base = this.safeCurrencyCode(baseName);
|
|
696
701
|
const quote = this.safeCurrencyCode(quoteId);
|
|
697
702
|
const baseId = this.safeString(market, 'baseId');
|
|
698
703
|
const settleId = 'USDC';
|
|
@@ -728,6 +733,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
728
733
|
'quote': quote,
|
|
729
734
|
'settle': settle,
|
|
730
735
|
'baseId': baseId,
|
|
736
|
+
'baseName': baseName,
|
|
731
737
|
'quoteId': quoteId,
|
|
732
738
|
'settleId': settleId,
|
|
733
739
|
'type': 'swap',
|
|
@@ -783,6 +789,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
783
789
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
784
790
|
* @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap
|
|
785
791
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
|
|
792
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
786
793
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
787
794
|
*/
|
|
788
795
|
async fetchBalance(params = {}) {
|
|
@@ -793,9 +800,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
793
800
|
let marginMode = undefined;
|
|
794
801
|
[marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
795
802
|
const isSpot = (type === 'spot');
|
|
796
|
-
const reqType = (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState';
|
|
797
803
|
const request = {
|
|
798
|
-
'type':
|
|
804
|
+
'type': (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState',
|
|
799
805
|
'user': userAddress,
|
|
800
806
|
};
|
|
801
807
|
const response = await this.publicPostInfo(this.extend(request, params));
|
|
@@ -883,7 +889,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
883
889
|
const market = this.market(symbol);
|
|
884
890
|
const request = {
|
|
885
891
|
'type': 'l2Book',
|
|
886
|
-
'coin': market['swap'] ? market['
|
|
892
|
+
'coin': market['swap'] ? market['baseName'] : market['id'],
|
|
887
893
|
};
|
|
888
894
|
const response = await this.publicPostInfo(this.extend(request, params));
|
|
889
895
|
//
|
|
@@ -1121,7 +1127,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1121
1127
|
const request = {
|
|
1122
1128
|
'type': 'candleSnapshot',
|
|
1123
1129
|
'req': {
|
|
1124
|
-
'coin': market['swap'] ? market['
|
|
1130
|
+
'coin': market['swap'] ? market['baseName'] : market['id'],
|
|
1125
1131
|
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
|
1126
1132
|
'startTime': since,
|
|
1127
1133
|
'endTime': until,
|
|
@@ -1183,6 +1189,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1183
1189
|
* @param {int} [params.until] timestamp in ms of the latest trade
|
|
1184
1190
|
* @param {string} [params.address] wallet address that made trades
|
|
1185
1191
|
* @param {string} [params.user] wallet address that made trades
|
|
1192
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1186
1193
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1187
1194
|
*/
|
|
1188
1195
|
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
@@ -1367,6 +1374,71 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1367
1374
|
};
|
|
1368
1375
|
return this.signUserSignedAction(messageTypes, message);
|
|
1369
1376
|
}
|
|
1377
|
+
buildApproveBuilderFeeSig(message) {
|
|
1378
|
+
const messageTypes = {
|
|
1379
|
+
'HyperliquidTransaction:ApproveBuilderFee': [
|
|
1380
|
+
{ 'name': 'hyperliquidChain', 'type': 'string' },
|
|
1381
|
+
{ 'name': 'maxFeeRate', 'type': 'string' },
|
|
1382
|
+
{ 'name': 'builder', 'type': 'address' },
|
|
1383
|
+
{ 'name': 'nonce', 'type': 'uint64' },
|
|
1384
|
+
],
|
|
1385
|
+
};
|
|
1386
|
+
return this.signUserSignedAction(messageTypes, message);
|
|
1387
|
+
}
|
|
1388
|
+
async approveBuilderFee(builder, maxFeeRate) {
|
|
1389
|
+
const nonce = this.milliseconds();
|
|
1390
|
+
const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
1391
|
+
const payload = {
|
|
1392
|
+
'hyperliquidChain': isSandboxMode ? 'Testnet' : 'Mainnet',
|
|
1393
|
+
'maxFeeRate': maxFeeRate,
|
|
1394
|
+
'builder': builder,
|
|
1395
|
+
'nonce': nonce,
|
|
1396
|
+
};
|
|
1397
|
+
const sig = this.buildApproveBuilderFeeSig(payload);
|
|
1398
|
+
const action = {
|
|
1399
|
+
'hyperliquidChain': payload['hyperliquidChain'],
|
|
1400
|
+
'signatureChainId': '0x66eee',
|
|
1401
|
+
'maxFeeRate': payload['maxFeeRate'],
|
|
1402
|
+
'builder': payload['builder'],
|
|
1403
|
+
'nonce': nonce,
|
|
1404
|
+
'type': 'approveBuilderFee',
|
|
1405
|
+
};
|
|
1406
|
+
const request = {
|
|
1407
|
+
'action': action,
|
|
1408
|
+
'nonce': nonce,
|
|
1409
|
+
'signature': sig,
|
|
1410
|
+
'vaultAddress': undefined,
|
|
1411
|
+
};
|
|
1412
|
+
//
|
|
1413
|
+
// {
|
|
1414
|
+
// "status": "ok",
|
|
1415
|
+
// "response": {
|
|
1416
|
+
// "type": "default"
|
|
1417
|
+
// }
|
|
1418
|
+
// }
|
|
1419
|
+
//
|
|
1420
|
+
return await this.privatePostExchange(request);
|
|
1421
|
+
}
|
|
1422
|
+
async handleBuilderFeeApproval() {
|
|
1423
|
+
const buildFee = this.safeBool(this.options, 'builderFee', true);
|
|
1424
|
+
if (!buildFee) {
|
|
1425
|
+
return false; // skip if builder fee is not enabled
|
|
1426
|
+
}
|
|
1427
|
+
const approvedBuilderFee = this.safeBool(this.options, 'approvedBuilderFee', false);
|
|
1428
|
+
if (approvedBuilderFee) {
|
|
1429
|
+
return true; // skip if builder fee is already approved
|
|
1430
|
+
}
|
|
1431
|
+
try {
|
|
1432
|
+
const builder = this.safeString(this.options, 'builder', '0x6530512A6c89C7cfCEbC3BA7fcD9aDa5f30827a6');
|
|
1433
|
+
const maxFeeRate = this.safeString(this.options, 'feeRate', '0.01%');
|
|
1434
|
+
await this.approveBuilderFee(builder, maxFeeRate);
|
|
1435
|
+
this.options['approvedBuilderFee'] = true;
|
|
1436
|
+
}
|
|
1437
|
+
catch (e) {
|
|
1438
|
+
this.options['builderFee'] = false; // disable builder fee if an error occurs
|
|
1439
|
+
}
|
|
1440
|
+
return true;
|
|
1441
|
+
}
|
|
1370
1442
|
/**
|
|
1371
1443
|
* @method
|
|
1372
1444
|
* @name hyperliquid#createOrder
|
|
@@ -1385,6 +1457,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1385
1457
|
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1386
1458
|
* @param {string} [params.slippage] the slippage for market order
|
|
1387
1459
|
* @param {string} [params.vaultAddress] the vault address for order
|
|
1460
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1388
1461
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1389
1462
|
*/
|
|
1390
1463
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -1404,6 +1477,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1404
1477
|
*/
|
|
1405
1478
|
async createOrders(orders, params = {}) {
|
|
1406
1479
|
await this.loadMarkets();
|
|
1480
|
+
await this.handleBuilderFeeApproval();
|
|
1407
1481
|
const request = this.createOrdersRequest(orders, params);
|
|
1408
1482
|
const response = await this.privatePostExchange(request);
|
|
1409
1483
|
//
|
|
@@ -1589,10 +1663,10 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1589
1663
|
'type': 'order',
|
|
1590
1664
|
'orders': orderReq,
|
|
1591
1665
|
'grouping': grouping,
|
|
1592
|
-
// 'brokerCode': 1, // cant
|
|
1593
1666
|
};
|
|
1594
|
-
if (
|
|
1595
|
-
|
|
1667
|
+
if (this.safeBool(this.options, 'approvedBuilderFee', false)) {
|
|
1668
|
+
const wallet = this.safeStringLower(this.options, 'builder', '0x6530512A6c89C7cfCEbC3BA7fcD9aDa5f30827a6');
|
|
1669
|
+
orderAction['builder'] = { 'b': wallet, 'f': this.safeInteger(this.options, 'feeInt', 10) };
|
|
1596
1670
|
}
|
|
1597
1671
|
const signature = this.signL1Action(orderAction, nonce, vaultAddress);
|
|
1598
1672
|
const request = {
|
|
@@ -1618,6 +1692,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1618
1692
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1619
1693
|
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1620
1694
|
* @param {string} [params.vaultAddress] the vault address for order
|
|
1695
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1621
1696
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1622
1697
|
*/
|
|
1623
1698
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
@@ -1635,6 +1710,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1635
1710
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1636
1711
|
* @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1637
1712
|
* @param {string} [params.vaultAddress] the vault address
|
|
1713
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1638
1714
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1639
1715
|
*/
|
|
1640
1716
|
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
@@ -1680,7 +1756,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1680
1756
|
}
|
|
1681
1757
|
cancelAction['cancels'] = cancelReq;
|
|
1682
1758
|
let vaultAddress = undefined;
|
|
1683
|
-
[vaultAddress, params] = this.
|
|
1759
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelOrders', 'vaultAddress', 'subAccountAddress');
|
|
1684
1760
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
1685
1761
|
const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
|
|
1686
1762
|
request['action'] = cancelAction;
|
|
@@ -1725,6 +1801,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1725
1801
|
* @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"}]
|
|
1726
1802
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1727
1803
|
* @param {string} [params.vaultAddress] the vault address
|
|
1804
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1728
1805
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1729
1806
|
*/
|
|
1730
1807
|
async cancelOrdersForSymbols(orders, params = {}) {
|
|
@@ -1766,7 +1843,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1766
1843
|
cancelAction['type'] = cancelByCloid ? 'cancelByCloid' : 'cancel';
|
|
1767
1844
|
cancelAction['cancels'] = cancelReq;
|
|
1768
1845
|
let vaultAddress = undefined;
|
|
1769
|
-
[vaultAddress, params] = this.
|
|
1846
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelOrdersForSymbols', 'vaultAddress', 'subAccountAddress');
|
|
1770
1847
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
1771
1848
|
const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
|
|
1772
1849
|
request['action'] = cancelAction;
|
|
@@ -1798,6 +1875,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1798
1875
|
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
|
|
1799
1876
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1800
1877
|
* @param {string} [params.vaultAddress] the vault address
|
|
1878
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1801
1879
|
* @returns {object} the api result
|
|
1802
1880
|
*/
|
|
1803
1881
|
async cancelAllOrdersAfter(timeout, params = {}) {
|
|
@@ -1814,7 +1892,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1814
1892
|
'time': nonce + timeout,
|
|
1815
1893
|
};
|
|
1816
1894
|
let vaultAddress = undefined;
|
|
1817
|
-
[vaultAddress, params] = this.
|
|
1895
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelAllOrdersAfter', 'vaultAddress', 'subAccountAddress');
|
|
1818
1896
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
1819
1897
|
const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
|
|
1820
1898
|
request['action'] = cancelAction;
|
|
@@ -1973,6 +2051,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1973
2051
|
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
1974
2052
|
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1975
2053
|
* @param {string} [params.vaultAddress] the vault address for order
|
|
2054
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1976
2055
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1977
2056
|
*/
|
|
1978
2057
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
@@ -2097,7 +2176,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2097
2176
|
const market = this.market(symbol);
|
|
2098
2177
|
const request = {
|
|
2099
2178
|
'type': 'fundingHistory',
|
|
2100
|
-
'coin': market['
|
|
2179
|
+
'coin': market['baseName'],
|
|
2101
2180
|
};
|
|
2102
2181
|
if (since !== undefined) {
|
|
2103
2182
|
request['startTime'] = since;
|
|
@@ -2148,6 +2227,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2148
2227
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2149
2228
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
2150
2229
|
* @param {string} [params.method] 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders'
|
|
2230
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2151
2231
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2152
2232
|
*/
|
|
2153
2233
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2246,6 +2326,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2246
2326
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
2247
2327
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2248
2328
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
2329
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2249
2330
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2250
2331
|
*/
|
|
2251
2332
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2282,6 +2363,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2282
2363
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2283
2364
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2284
2365
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
2366
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2285
2367
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2286
2368
|
*/
|
|
2287
2369
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
@@ -2514,6 +2596,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2514
2596
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
2515
2597
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2516
2598
|
* @param {int} [params.until] timestamp in ms of the latest trade
|
|
2599
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2517
2600
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
2518
2601
|
*/
|
|
2519
2602
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2639,6 +2722,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2639
2722
|
* @param {string[]} [symbols] list of unified market symbols
|
|
2640
2723
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2641
2724
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
2725
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2642
2726
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
2643
2727
|
*/
|
|
2644
2728
|
async fetchPositions(symbols = undefined, params = {}) {
|
|
@@ -2783,6 +2867,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2783
2867
|
* @param {string} symbol unified market symbol of the market the position is held in, default is undefined
|
|
2784
2868
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2785
2869
|
* @param {string} [params.leverage] the rate of leverage, is required if setting trade mode (symbol)
|
|
2870
|
+
* @param {string} [params.vaultAddress] the vault address
|
|
2871
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2786
2872
|
* @returns {object} response from the exchange
|
|
2787
2873
|
*/
|
|
2788
2874
|
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
@@ -2806,7 +2892,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2806
2892
|
'leverage': leverage,
|
|
2807
2893
|
};
|
|
2808
2894
|
let vaultAddress = undefined;
|
|
2809
|
-
[vaultAddress, params] = this.
|
|
2895
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'setMarginMode', 'vaultAddress', 'subAccountAddress');
|
|
2810
2896
|
if (vaultAddress !== undefined) {
|
|
2811
2897
|
if (vaultAddress.startsWith('0x')) {
|
|
2812
2898
|
vaultAddress = vaultAddress.replace('0x', '');
|
|
@@ -2861,7 +2947,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2861
2947
|
'leverage': leverage,
|
|
2862
2948
|
};
|
|
2863
2949
|
let vaultAddress = undefined;
|
|
2864
|
-
[vaultAddress, params] = this.
|
|
2950
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'setLeverage', 'vaultAddress', 'subAccountAddress');
|
|
2865
2951
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
2866
2952
|
const signature = this.signL1Action(updateAction, nonce, vaultAddress);
|
|
2867
2953
|
const request = {
|
|
@@ -2893,6 +2979,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2893
2979
|
* @param {string} symbol unified market symbol
|
|
2894
2980
|
* @param {float} amount amount of margin to add
|
|
2895
2981
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2982
|
+
* @param {string} [params.vaultAddress] the vault address
|
|
2983
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2896
2984
|
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
|
|
2897
2985
|
*/
|
|
2898
2986
|
async addMargin(symbol, amount, params = {}) {
|
|
@@ -2906,6 +2994,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2906
2994
|
* @param {string} symbol unified market symbol
|
|
2907
2995
|
* @param {float} amount the amount of margin to remove
|
|
2908
2996
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2997
|
+
* @param {string} [params.vaultAddress] the vault address
|
|
2998
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2909
2999
|
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
|
|
2910
3000
|
*/
|
|
2911
3001
|
async reduceMargin(symbol, amount, params = {}) {
|
|
@@ -2927,7 +3017,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2927
3017
|
'ntli': sz,
|
|
2928
3018
|
};
|
|
2929
3019
|
let vaultAddress = undefined;
|
|
2930
|
-
[vaultAddress, params] = this.
|
|
3020
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'modifyMargin', 'vaultAddress', 'subAccountAddress');
|
|
2931
3021
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
2932
3022
|
const signature = this.signL1Action(updateAction, nonce, vaultAddress);
|
|
2933
3023
|
const request = {
|
|
@@ -3027,30 +3117,36 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3027
3117
|
const transferResponse = await this.privatePostExchange(transferRequest);
|
|
3028
3118
|
return transferResponse;
|
|
3029
3119
|
}
|
|
3030
|
-
//
|
|
3031
|
-
this.checkAddress(toAccount);
|
|
3120
|
+
// transfer between main account and subaccount
|
|
3032
3121
|
if (code !== undefined) {
|
|
3033
3122
|
code = code.toUpperCase();
|
|
3034
3123
|
if (code !== 'USDC') {
|
|
3035
3124
|
throw new errors.NotSupported(this.id + ' transfer() only support USDC');
|
|
3036
3125
|
}
|
|
3037
3126
|
}
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3127
|
+
let isDeposit = false;
|
|
3128
|
+
let subAccountAddress = undefined;
|
|
3129
|
+
if (fromAccount === 'main') {
|
|
3130
|
+
subAccountAddress = toAccount;
|
|
3131
|
+
isDeposit = true;
|
|
3132
|
+
}
|
|
3133
|
+
else if (toAccount === 'main') {
|
|
3134
|
+
subAccountAddress = fromAccount;
|
|
3135
|
+
}
|
|
3136
|
+
else {
|
|
3137
|
+
throw new errors.NotSupported(this.id + ' transfer() only support main <> subaccount transfer');
|
|
3138
|
+
}
|
|
3139
|
+
this.checkAddress(subAccountAddress);
|
|
3140
|
+
const usd = this.parseToInt(Precise["default"].stringMul(this.numberToString(amount), '1000000'));
|
|
3141
|
+
const action = {
|
|
3142
|
+
'type': 'subAccountTransfer',
|
|
3143
|
+
'subAccountUser': subAccountAddress,
|
|
3144
|
+
'isDeposit': isDeposit,
|
|
3145
|
+
'usd': usd,
|
|
3043
3146
|
};
|
|
3044
|
-
const sig = this.
|
|
3147
|
+
const sig = this.signL1Action(action, nonce);
|
|
3045
3148
|
const request = {
|
|
3046
|
-
'action':
|
|
3047
|
-
'hyperliquidChain': payload['hyperliquidChain'],
|
|
3048
|
-
'signatureChainId': '0x66eee',
|
|
3049
|
-
'destination': toAccount,
|
|
3050
|
-
'amount': amount.toString(),
|
|
3051
|
-
'time': nonce,
|
|
3052
|
-
'type': 'usdSend',
|
|
3053
|
-
},
|
|
3149
|
+
'action': action,
|
|
3054
3150
|
'nonce': nonce,
|
|
3055
3151
|
'signature': sig,
|
|
3056
3152
|
};
|
|
@@ -3202,6 +3298,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3202
3298
|
* @param {string} symbol unified market symbol
|
|
3203
3299
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3204
3300
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
3301
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3205
3302
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
3206
3303
|
*/
|
|
3207
3304
|
async fetchTradingFee(symbol, params = {}) {
|
|
@@ -3310,6 +3407,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3310
3407
|
* @param {int} [limit] max number of ledger entries to return
|
|
3311
3408
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3312
3409
|
* @param {int} [params.until] timestamp in ms of the latest ledger entry
|
|
3410
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3313
3411
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
|
|
3314
3412
|
*/
|
|
3315
3413
|
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3402,6 +3500,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3402
3500
|
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
3403
3501
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3404
3502
|
* @param {int} [params.until] the latest time in ms to fetch withdrawals for
|
|
3503
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3405
3504
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
3406
3505
|
*/
|
|
3407
3506
|
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3447,6 +3546,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3447
3546
|
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
3448
3547
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3449
3548
|
* @param {int} [params.until] the latest time in ms to fetch withdrawals for
|
|
3549
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3450
3550
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
3451
3551
|
*/
|
|
3452
3552
|
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3553,6 +3653,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3553
3653
|
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
3554
3654
|
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
|
3555
3655
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3656
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3556
3657
|
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
|
3557
3658
|
*/
|
|
3558
3659
|
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3650,7 +3751,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3650
3751
|
}
|
|
3651
3752
|
handlePublicAddress(methodName, params) {
|
|
3652
3753
|
let userAux = undefined;
|
|
3653
|
-
[userAux, params] = this.
|
|
3754
|
+
[userAux, params] = this.handleOptionAndParams2(params, methodName, 'user', 'subAccountAddress');
|
|
3654
3755
|
let user = userAux;
|
|
3655
3756
|
[user, params] = this.handleOptionAndParams(params, methodName, 'address', userAux);
|
|
3656
3757
|
if ((user !== undefined) && (user !== '')) {
|
|
@@ -3729,7 +3830,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3729
3830
|
parseCreateEditOrderArgs(id, symbol, type, side, amount, price = undefined, params = {}) {
|
|
3730
3831
|
const market = this.market(symbol);
|
|
3731
3832
|
let vaultAddress = undefined;
|
|
3732
|
-
[vaultAddress, params] = this.
|
|
3833
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'createOrder', 'vaultAddress', 'subAccountAddress');
|
|
3733
3834
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
3734
3835
|
symbol = market['symbol'];
|
|
3735
3836
|
const order = {
|
package/dist/cjs/src/kucoin.js
CHANGED
|
@@ -1386,36 +1386,32 @@ class kucoin extends kucoin$1 {
|
|
|
1386
1386
|
// }
|
|
1387
1387
|
//
|
|
1388
1388
|
const currenciesData = this.safeList(response, 'data', []);
|
|
1389
|
+
const brokenCurrencies = this.safeList(this.options, 'brokenCurrencies', ['00', 'OPEN_ERROR', 'HUF', 'BDT']);
|
|
1390
|
+
const otherFiats = this.safeList(this.options, 'fiats', ['KWD', 'IRR', 'PKR']);
|
|
1389
1391
|
const result = {};
|
|
1390
1392
|
for (let i = 0; i < currenciesData.length; i++) {
|
|
1391
1393
|
const entry = currenciesData[i];
|
|
1392
1394
|
const id = this.safeString(entry, 'currency');
|
|
1393
|
-
|
|
1395
|
+
if (this.inArray(id, brokenCurrencies)) {
|
|
1396
|
+
continue; // skip buggy entries: https://t.me/KuCoin_API/217798
|
|
1397
|
+
}
|
|
1394
1398
|
const code = this.safeCurrencyCode(id);
|
|
1395
1399
|
const networks = {};
|
|
1396
1400
|
const chains = this.safeList(entry, 'chains', []);
|
|
1397
|
-
const rawPrecision = this.safeString(entry, 'precision');
|
|
1398
|
-
const precision = this.parseNumber(this.parsePrecision(rawPrecision));
|
|
1399
1401
|
const chainsLength = chains.length;
|
|
1400
|
-
if (!chainsLength) {
|
|
1401
|
-
// one buggy coin, which doesn't contain info https://t.me/KuCoin_API/173118
|
|
1402
|
-
continue;
|
|
1403
|
-
}
|
|
1404
1402
|
for (let j = 0; j < chainsLength; j++) {
|
|
1405
1403
|
const chain = chains[j];
|
|
1406
1404
|
const chainId = this.safeString(chain, 'chainId');
|
|
1407
1405
|
const networkCode = this.networkIdToCode(chainId, code);
|
|
1408
|
-
const chainWithdrawEnabled = this.safeBool(chain, 'isWithdrawEnabled', false);
|
|
1409
|
-
const chainDepositEnabled = this.safeBool(chain, 'isDepositEnabled', false);
|
|
1410
1406
|
networks[networkCode] = {
|
|
1411
1407
|
'info': chain,
|
|
1412
1408
|
'id': chainId,
|
|
1413
1409
|
'name': this.safeString(chain, 'chainName'),
|
|
1414
1410
|
'code': networkCode,
|
|
1415
|
-
'active':
|
|
1411
|
+
'active': undefined,
|
|
1416
1412
|
'fee': this.safeNumber(chain, 'withdrawalMinFee'),
|
|
1417
|
-
'deposit':
|
|
1418
|
-
'withdraw':
|
|
1413
|
+
'deposit': this.safeBool(chain, 'isDepositEnabled'),
|
|
1414
|
+
'withdraw': this.safeBool(chain, 'isWithdrawEnabled'),
|
|
1419
1415
|
'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'withdrawPrecision'))),
|
|
1420
1416
|
'limits': {
|
|
1421
1417
|
'withdraw': {
|
|
@@ -1430,10 +1426,12 @@ class kucoin extends kucoin$1 {
|
|
|
1430
1426
|
};
|
|
1431
1427
|
}
|
|
1432
1428
|
// kucoin has determined 'fiat' currencies with below logic
|
|
1433
|
-
const
|
|
1429
|
+
const rawPrecision = this.safeString(entry, 'precision');
|
|
1430
|
+
const precision = this.parseNumber(this.parsePrecision(rawPrecision));
|
|
1431
|
+
const isFiat = this.inArray(id, otherFiats) || ((rawPrecision === '2') && (chainsLength === 0));
|
|
1434
1432
|
result[code] = this.safeCurrencyStructure({
|
|
1435
1433
|
'id': id,
|
|
1436
|
-
'name':
|
|
1434
|
+
'name': this.safeString(entry, 'fullName'),
|
|
1437
1435
|
'code': code,
|
|
1438
1436
|
'type': isFiat ? 'fiat' : 'crypto',
|
|
1439
1437
|
'precision': precision,
|
|
@@ -2694,7 +2692,7 @@ class kucoin extends kucoin$1 {
|
|
|
2694
2692
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
2695
2693
|
await this.loadMarkets();
|
|
2696
2694
|
const request = {};
|
|
2697
|
-
const trigger = this.
|
|
2695
|
+
const trigger = this.safeBool2(params, 'trigger', 'stop', false);
|
|
2698
2696
|
let hf = undefined;
|
|
2699
2697
|
[hf, params] = this.handleHfAndParams(params);
|
|
2700
2698
|
params = this.omit(params, 'stop');
|