ccxt 4.4.93 → 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/base/Exchange.js +51 -22
- package/dist/cjs/src/bybit.js +2 -2
- package/dist/cjs/src/coinbase.js +3 -1
- package/dist/cjs/src/coinmetro.js +16 -3
- package/dist/cjs/src/htx.js +7 -1
- package/dist/cjs/src/hyperliquid.js +132 -32
- package/dist/cjs/src/okx.js +13 -4
- package/dist/cjs/src/paradex.js +1 -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/base/Exchange.js +51 -22
- package/js/src/bybit.js +2 -2
- package/js/src/coinbase.js +4 -2
- package/js/src/coinmetro.js +16 -3
- package/js/src/htx.js +7 -1
- package/js/src/hyperliquid.d.ts +31 -0
- package/js/src/hyperliquid.js +132 -32
- package/js/src/okx.js +13 -4
- package/js/src/paradex.js +1 -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',
|
|
@@ -729,6 +733,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
729
733
|
'quote': quote,
|
|
730
734
|
'settle': settle,
|
|
731
735
|
'baseId': baseId,
|
|
736
|
+
'baseName': baseName,
|
|
732
737
|
'quoteId': quoteId,
|
|
733
738
|
'settleId': settleId,
|
|
734
739
|
'type': 'swap',
|
|
@@ -784,6 +789,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
784
789
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
785
790
|
* @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap
|
|
786
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
|
|
787
793
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
788
794
|
*/
|
|
789
795
|
async fetchBalance(params = {}) {
|
|
@@ -794,9 +800,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
794
800
|
let marginMode = undefined;
|
|
795
801
|
[marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
796
802
|
const isSpot = (type === 'spot');
|
|
797
|
-
const reqType = (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState';
|
|
798
803
|
const request = {
|
|
799
|
-
'type':
|
|
804
|
+
'type': (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState',
|
|
800
805
|
'user': userAddress,
|
|
801
806
|
};
|
|
802
807
|
const response = await this.publicPostInfo(this.extend(request, params));
|
|
@@ -884,7 +889,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
884
889
|
const market = this.market(symbol);
|
|
885
890
|
const request = {
|
|
886
891
|
'type': 'l2Book',
|
|
887
|
-
'coin': market['swap'] ? market['
|
|
892
|
+
'coin': market['swap'] ? market['baseName'] : market['id'],
|
|
888
893
|
};
|
|
889
894
|
const response = await this.publicPostInfo(this.extend(request, params));
|
|
890
895
|
//
|
|
@@ -1122,7 +1127,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1122
1127
|
const request = {
|
|
1123
1128
|
'type': 'candleSnapshot',
|
|
1124
1129
|
'req': {
|
|
1125
|
-
'coin': market['swap'] ? market['
|
|
1130
|
+
'coin': market['swap'] ? market['baseName'] : market['id'],
|
|
1126
1131
|
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
|
1127
1132
|
'startTime': since,
|
|
1128
1133
|
'endTime': until,
|
|
@@ -1184,6 +1189,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1184
1189
|
* @param {int} [params.until] timestamp in ms of the latest trade
|
|
1185
1190
|
* @param {string} [params.address] wallet address that made trades
|
|
1186
1191
|
* @param {string} [params.user] wallet address that made trades
|
|
1192
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1187
1193
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1188
1194
|
*/
|
|
1189
1195
|
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
@@ -1368,6 +1374,71 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1368
1374
|
};
|
|
1369
1375
|
return this.signUserSignedAction(messageTypes, message);
|
|
1370
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
|
+
}
|
|
1371
1442
|
/**
|
|
1372
1443
|
* @method
|
|
1373
1444
|
* @name hyperliquid#createOrder
|
|
@@ -1386,6 +1457,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1386
1457
|
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1387
1458
|
* @param {string} [params.slippage] the slippage for market order
|
|
1388
1459
|
* @param {string} [params.vaultAddress] the vault address for order
|
|
1460
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1389
1461
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1390
1462
|
*/
|
|
1391
1463
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -1405,6 +1477,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1405
1477
|
*/
|
|
1406
1478
|
async createOrders(orders, params = {}) {
|
|
1407
1479
|
await this.loadMarkets();
|
|
1480
|
+
await this.handleBuilderFeeApproval();
|
|
1408
1481
|
const request = this.createOrdersRequest(orders, params);
|
|
1409
1482
|
const response = await this.privatePostExchange(request);
|
|
1410
1483
|
//
|
|
@@ -1590,10 +1663,10 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1590
1663
|
'type': 'order',
|
|
1591
1664
|
'orders': orderReq,
|
|
1592
1665
|
'grouping': grouping,
|
|
1593
|
-
// 'brokerCode': 1, // cant
|
|
1594
1666
|
};
|
|
1595
|
-
if (
|
|
1596
|
-
|
|
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) };
|
|
1597
1670
|
}
|
|
1598
1671
|
const signature = this.signL1Action(orderAction, nonce, vaultAddress);
|
|
1599
1672
|
const request = {
|
|
@@ -1619,6 +1692,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1619
1692
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1620
1693
|
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1621
1694
|
* @param {string} [params.vaultAddress] the vault address for order
|
|
1695
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1622
1696
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1623
1697
|
*/
|
|
1624
1698
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
@@ -1636,6 +1710,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1636
1710
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1637
1711
|
* @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1638
1712
|
* @param {string} [params.vaultAddress] the vault address
|
|
1713
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1639
1714
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1640
1715
|
*/
|
|
1641
1716
|
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
@@ -1681,7 +1756,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1681
1756
|
}
|
|
1682
1757
|
cancelAction['cancels'] = cancelReq;
|
|
1683
1758
|
let vaultAddress = undefined;
|
|
1684
|
-
[vaultAddress, params] = this.
|
|
1759
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelOrders', 'vaultAddress', 'subAccountAddress');
|
|
1685
1760
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
1686
1761
|
const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
|
|
1687
1762
|
request['action'] = cancelAction;
|
|
@@ -1726,6 +1801,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1726
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"}]
|
|
1727
1802
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1728
1803
|
* @param {string} [params.vaultAddress] the vault address
|
|
1804
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1729
1805
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1730
1806
|
*/
|
|
1731
1807
|
async cancelOrdersForSymbols(orders, params = {}) {
|
|
@@ -1767,7 +1843,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1767
1843
|
cancelAction['type'] = cancelByCloid ? 'cancelByCloid' : 'cancel';
|
|
1768
1844
|
cancelAction['cancels'] = cancelReq;
|
|
1769
1845
|
let vaultAddress = undefined;
|
|
1770
|
-
[vaultAddress, params] = this.
|
|
1846
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelOrdersForSymbols', 'vaultAddress', 'subAccountAddress');
|
|
1771
1847
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
1772
1848
|
const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
|
|
1773
1849
|
request['action'] = cancelAction;
|
|
@@ -1799,6 +1875,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1799
1875
|
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
|
|
1800
1876
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1801
1877
|
* @param {string} [params.vaultAddress] the vault address
|
|
1878
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1802
1879
|
* @returns {object} the api result
|
|
1803
1880
|
*/
|
|
1804
1881
|
async cancelAllOrdersAfter(timeout, params = {}) {
|
|
@@ -1815,7 +1892,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1815
1892
|
'time': nonce + timeout,
|
|
1816
1893
|
};
|
|
1817
1894
|
let vaultAddress = undefined;
|
|
1818
|
-
[vaultAddress, params] = this.
|
|
1895
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelAllOrdersAfter', 'vaultAddress', 'subAccountAddress');
|
|
1819
1896
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
1820
1897
|
const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
|
|
1821
1898
|
request['action'] = cancelAction;
|
|
@@ -1974,6 +2051,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1974
2051
|
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
1975
2052
|
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1976
2053
|
* @param {string} [params.vaultAddress] the vault address for order
|
|
2054
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
1977
2055
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1978
2056
|
*/
|
|
1979
2057
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
@@ -2098,7 +2176,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2098
2176
|
const market = this.market(symbol);
|
|
2099
2177
|
const request = {
|
|
2100
2178
|
'type': 'fundingHistory',
|
|
2101
|
-
'coin': market['
|
|
2179
|
+
'coin': market['baseName'],
|
|
2102
2180
|
};
|
|
2103
2181
|
if (since !== undefined) {
|
|
2104
2182
|
request['startTime'] = since;
|
|
@@ -2149,6 +2227,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2149
2227
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2150
2228
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
2151
2229
|
* @param {string} [params.method] 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders'
|
|
2230
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2152
2231
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2153
2232
|
*/
|
|
2154
2233
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2247,6 +2326,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2247
2326
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
2248
2327
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2249
2328
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
2329
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2250
2330
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2251
2331
|
*/
|
|
2252
2332
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2283,6 +2363,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2283
2363
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2284
2364
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2285
2365
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
2366
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2286
2367
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2287
2368
|
*/
|
|
2288
2369
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
@@ -2515,6 +2596,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2515
2596
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
2516
2597
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2517
2598
|
* @param {int} [params.until] timestamp in ms of the latest trade
|
|
2599
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2518
2600
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
2519
2601
|
*/
|
|
2520
2602
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2640,6 +2722,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2640
2722
|
* @param {string[]} [symbols] list of unified market symbols
|
|
2641
2723
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2642
2724
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
2725
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
2643
2726
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
2644
2727
|
*/
|
|
2645
2728
|
async fetchPositions(symbols = undefined, params = {}) {
|
|
@@ -2784,6 +2867,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2784
2867
|
* @param {string} symbol unified market symbol of the market the position is held in, default is undefined
|
|
2785
2868
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2786
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
|
|
2787
2872
|
* @returns {object} response from the exchange
|
|
2788
2873
|
*/
|
|
2789
2874
|
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
@@ -2807,7 +2892,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2807
2892
|
'leverage': leverage,
|
|
2808
2893
|
};
|
|
2809
2894
|
let vaultAddress = undefined;
|
|
2810
|
-
[vaultAddress, params] = this.
|
|
2895
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'setMarginMode', 'vaultAddress', 'subAccountAddress');
|
|
2811
2896
|
if (vaultAddress !== undefined) {
|
|
2812
2897
|
if (vaultAddress.startsWith('0x')) {
|
|
2813
2898
|
vaultAddress = vaultAddress.replace('0x', '');
|
|
@@ -2862,7 +2947,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2862
2947
|
'leverage': leverage,
|
|
2863
2948
|
};
|
|
2864
2949
|
let vaultAddress = undefined;
|
|
2865
|
-
[vaultAddress, params] = this.
|
|
2950
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'setLeverage', 'vaultAddress', 'subAccountAddress');
|
|
2866
2951
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
2867
2952
|
const signature = this.signL1Action(updateAction, nonce, vaultAddress);
|
|
2868
2953
|
const request = {
|
|
@@ -2894,6 +2979,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2894
2979
|
* @param {string} symbol unified market symbol
|
|
2895
2980
|
* @param {float} amount amount of margin to add
|
|
2896
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
|
|
2897
2984
|
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
|
|
2898
2985
|
*/
|
|
2899
2986
|
async addMargin(symbol, amount, params = {}) {
|
|
@@ -2907,6 +2994,8 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2907
2994
|
* @param {string} symbol unified market symbol
|
|
2908
2995
|
* @param {float} amount the amount of margin to remove
|
|
2909
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
|
|
2910
2999
|
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
|
|
2911
3000
|
*/
|
|
2912
3001
|
async reduceMargin(symbol, amount, params = {}) {
|
|
@@ -2928,7 +3017,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2928
3017
|
'ntli': sz,
|
|
2929
3018
|
};
|
|
2930
3019
|
let vaultAddress = undefined;
|
|
2931
|
-
[vaultAddress, params] = this.
|
|
3020
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'modifyMargin', 'vaultAddress', 'subAccountAddress');
|
|
2932
3021
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
2933
3022
|
const signature = this.signL1Action(updateAction, nonce, vaultAddress);
|
|
2934
3023
|
const request = {
|
|
@@ -3028,30 +3117,36 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3028
3117
|
const transferResponse = await this.privatePostExchange(transferRequest);
|
|
3029
3118
|
return transferResponse;
|
|
3030
3119
|
}
|
|
3031
|
-
//
|
|
3032
|
-
this.checkAddress(toAccount);
|
|
3120
|
+
// transfer between main account and subaccount
|
|
3033
3121
|
if (code !== undefined) {
|
|
3034
3122
|
code = code.toUpperCase();
|
|
3035
3123
|
if (code !== 'USDC') {
|
|
3036
3124
|
throw new errors.NotSupported(this.id + ' transfer() only support USDC');
|
|
3037
3125
|
}
|
|
3038
3126
|
}
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
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,
|
|
3044
3146
|
};
|
|
3045
|
-
const sig = this.
|
|
3147
|
+
const sig = this.signL1Action(action, nonce);
|
|
3046
3148
|
const request = {
|
|
3047
|
-
'action':
|
|
3048
|
-
'hyperliquidChain': payload['hyperliquidChain'],
|
|
3049
|
-
'signatureChainId': '0x66eee',
|
|
3050
|
-
'destination': toAccount,
|
|
3051
|
-
'amount': amount.toString(),
|
|
3052
|
-
'time': nonce,
|
|
3053
|
-
'type': 'usdSend',
|
|
3054
|
-
},
|
|
3149
|
+
'action': action,
|
|
3055
3150
|
'nonce': nonce,
|
|
3056
3151
|
'signature': sig,
|
|
3057
3152
|
};
|
|
@@ -3203,6 +3298,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3203
3298
|
* @param {string} symbol unified market symbol
|
|
3204
3299
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3205
3300
|
* @param {string} [params.user] user address, will default to this.walletAddress if not provided
|
|
3301
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3206
3302
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
3207
3303
|
*/
|
|
3208
3304
|
async fetchTradingFee(symbol, params = {}) {
|
|
@@ -3311,6 +3407,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3311
3407
|
* @param {int} [limit] max number of ledger entries to return
|
|
3312
3408
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3313
3409
|
* @param {int} [params.until] timestamp in ms of the latest ledger entry
|
|
3410
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3314
3411
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
|
|
3315
3412
|
*/
|
|
3316
3413
|
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3403,6 +3500,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3403
3500
|
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
3404
3501
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3405
3502
|
* @param {int} [params.until] the latest time in ms to fetch withdrawals for
|
|
3503
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3406
3504
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
3407
3505
|
*/
|
|
3408
3506
|
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3448,6 +3546,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3448
3546
|
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
3449
3547
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3450
3548
|
* @param {int} [params.until] the latest time in ms to fetch withdrawals for
|
|
3549
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3451
3550
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
3452
3551
|
*/
|
|
3453
3552
|
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3554,6 +3653,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3554
3653
|
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
3555
3654
|
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
|
3556
3655
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3656
|
+
* @param {string} [params.subAccountAddress] sub account user address
|
|
3557
3657
|
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
|
3558
3658
|
*/
|
|
3559
3659
|
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3651,7 +3751,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3651
3751
|
}
|
|
3652
3752
|
handlePublicAddress(methodName, params) {
|
|
3653
3753
|
let userAux = undefined;
|
|
3654
|
-
[userAux, params] = this.
|
|
3754
|
+
[userAux, params] = this.handleOptionAndParams2(params, methodName, 'user', 'subAccountAddress');
|
|
3655
3755
|
let user = userAux;
|
|
3656
3756
|
[user, params] = this.handleOptionAndParams(params, methodName, 'address', userAux);
|
|
3657
3757
|
if ((user !== undefined) && (user !== '')) {
|
|
@@ -3730,7 +3830,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
3730
3830
|
parseCreateEditOrderArgs(id, symbol, type, side, amount, price = undefined, params = {}) {
|
|
3731
3831
|
const market = this.market(symbol);
|
|
3732
3832
|
let vaultAddress = undefined;
|
|
3733
|
-
[vaultAddress, params] = this.
|
|
3833
|
+
[vaultAddress, params] = this.handleOptionAndParams2(params, 'createOrder', 'vaultAddress', 'subAccountAddress');
|
|
3734
3834
|
vaultAddress = this.formatVaultAddress(vaultAddress);
|
|
3735
3835
|
symbol = market['symbol'];
|
|
3736
3836
|
const order = {
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -2601,12 +2601,12 @@ class okx extends okx$1 {
|
|
|
2601
2601
|
// it may be incorrect to use total, free and used for swap accounts
|
|
2602
2602
|
const eq = this.safeString(balance, 'eq');
|
|
2603
2603
|
const availEq = this.safeString(balance, 'availEq');
|
|
2604
|
-
|
|
2604
|
+
account['total'] = eq;
|
|
2605
|
+
if (availEq === undefined) {
|
|
2605
2606
|
account['free'] = this.safeString(balance, 'availBal');
|
|
2606
2607
|
account['used'] = this.safeString(balance, 'frozenBal');
|
|
2607
2608
|
}
|
|
2608
2609
|
else {
|
|
2609
|
-
account['total'] = eq;
|
|
2610
2610
|
account['free'] = availEq;
|
|
2611
2611
|
}
|
|
2612
2612
|
result[code] = account;
|
|
@@ -2878,7 +2878,7 @@ class okx extends okx$1 {
|
|
|
2878
2878
|
}
|
|
2879
2879
|
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
2880
2880
|
const market = this.market(symbol);
|
|
2881
|
-
|
|
2881
|
+
let request = {
|
|
2882
2882
|
'instId': market['id'],
|
|
2883
2883
|
// 'ccy': currency['id'], // only applicable to cross MARGIN orders in single-currency margin
|
|
2884
2884
|
// 'clOrdId': clientOrderId, // up to 32 characters, must be unique
|
|
@@ -3043,7 +3043,8 @@ class okx extends okx$1 {
|
|
|
3043
3043
|
if (stopLossTriggerPrice === undefined) {
|
|
3044
3044
|
throw new errors.InvalidOrder(this.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"], or params["stopLoss"]["stopPrice"], or params["stopLoss"]["slTriggerPx"] for a stop loss order');
|
|
3045
3045
|
}
|
|
3046
|
-
|
|
3046
|
+
const slTriggerPx = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
3047
|
+
request['slTriggerPx'] = slTriggerPx;
|
|
3047
3048
|
const stopLossLimitPrice = this.safeValueN(stopLoss, ['price', 'stopLossPrice', 'slOrdPx']);
|
|
3048
3049
|
const stopLossOrderType = this.safeString(stopLoss, 'type');
|
|
3049
3050
|
if (stopLossOrderType !== undefined) {
|
|
@@ -3135,6 +3136,14 @@ class okx extends okx$1 {
|
|
|
3135
3136
|
if (twoWayCondition) {
|
|
3136
3137
|
request['ordType'] = 'oco';
|
|
3137
3138
|
}
|
|
3139
|
+
if (side === 'sell') {
|
|
3140
|
+
request = this.omit(request, 'tgtCcy');
|
|
3141
|
+
}
|
|
3142
|
+
if (this.safeString(request, 'tdMode') === 'cash') {
|
|
3143
|
+
// for some reason tdMode = cash throws
|
|
3144
|
+
// {"code":"1","data":[{"algoClOrdId":"","algoId":"","clOrdId":"","sCode":"51000","sMsg":"Parameter tdMode error ","tag":""}],"msg":""}
|
|
3145
|
+
request['tdMode'] = marginMode;
|
|
3146
|
+
}
|
|
3138
3147
|
if (takeProfitPrice !== undefined) {
|
|
3139
3148
|
request['tpTriggerPx'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
3140
3149
|
let tpOrdPxReq = '-1';
|
package/dist/cjs/src/paradex.js
CHANGED
|
@@ -54,6 +54,7 @@ class paradex extends paradex$1 {
|
|
|
54
54
|
'createTriggerOrder': true,
|
|
55
55
|
'editOrder': false,
|
|
56
56
|
'fetchAccounts': false,
|
|
57
|
+
'fetchAllGreeks': true,
|
|
57
58
|
'fetchBalance': true,
|
|
58
59
|
'fetchBorrowInterest': false,
|
|
59
60
|
'fetchBorrowRateHistories': false,
|
|
@@ -73,7 +74,6 @@ class paradex extends paradex$1 {
|
|
|
73
74
|
'fetchFundingRateHistory': false,
|
|
74
75
|
'fetchFundingRates': false,
|
|
75
76
|
'fetchGreeks': true,
|
|
76
|
-
'fetchAllGreeks': true,
|
|
77
77
|
'fetchIndexOHLCV': false,
|
|
78
78
|
'fetchIsolatedBorrowRate': false,
|
|
79
79
|
'fetchIsolatedBorrowRates': false,
|
|
@@ -2319,13 +2319,26 @@ class wavesexchange extends wavesexchange$1 {
|
|
|
2319
2319
|
const order1 = this.safeValue(data, 'order1');
|
|
2320
2320
|
const order2 = this.safeValue(data, 'order2');
|
|
2321
2321
|
let order = undefined;
|
|
2322
|
-
//
|
|
2322
|
+
// at first, detect if response is from `fetch_my_trades`
|
|
2323
2323
|
if (this.safeString(order1, 'senderPublicKey') === this.apiKey) {
|
|
2324
2324
|
order = order1;
|
|
2325
2325
|
}
|
|
2326
|
-
else {
|
|
2326
|
+
else if (this.safeString(order2, 'senderPublicKey') === this.apiKey) {
|
|
2327
2327
|
order = order2;
|
|
2328
2328
|
}
|
|
2329
|
+
else {
|
|
2330
|
+
// response is from `fetch_trades`, so find only taker order
|
|
2331
|
+
const date1 = this.safeString(order1, 'timestamp');
|
|
2332
|
+
const date2 = this.safeString(order2, 'timestamp');
|
|
2333
|
+
const ts1 = this.parse8601(date1);
|
|
2334
|
+
const ts2 = this.parse8601(date2);
|
|
2335
|
+
if (ts1 > ts2) {
|
|
2336
|
+
order = order1;
|
|
2337
|
+
}
|
|
2338
|
+
else {
|
|
2339
|
+
order = order2;
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2329
2342
|
let symbol = undefined;
|
|
2330
2343
|
const assetPair = this.safeValue(order, 'assetPair');
|
|
2331
2344
|
if (assetPair !== undefined) {
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OrderBooks, OpenInterests, ConstructorArgs } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.4.
|
|
7
|
+
declare const version = "4.4.93";
|
|
8
8
|
import alpaca from './src/alpaca.js';
|
|
9
9
|
import apex from './src/apex.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.4.
|
|
41
|
+
const version = '4.4.93';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import alpaca from './src/alpaca.js';
|