ccxt 4.2.70 → 4.2.71
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 +4 -4
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +785 -180
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +3 -1
- package/dist/cjs/src/bitget.js +14 -6
- package/dist/cjs/src/coinbase.js +108 -89
- package/dist/cjs/src/digifinex.js +2 -1
- package/dist/cjs/src/hyperliquid.js +1 -1
- package/dist/cjs/src/kraken.js +1 -0
- package/dist/cjs/src/mexc.js +9 -0
- package/dist/cjs/src/pro/hyperliquid.js +556 -0
- package/js/ccxt.d.ts +4 -1
- package/js/ccxt.js +3 -1
- package/js/src/abstract/coinbase.d.ts +2 -0
- package/js/src/base/types.d.ts +48 -48
- package/js/src/bitget.js +14 -6
- package/js/src/coinbase.d.ts +1 -1
- package/js/src/coinbase.js +108 -89
- package/js/src/digifinex.js +2 -1
- package/js/src/hyperliquid.js +1 -1
- package/js/src/kraken.js +1 -0
- package/js/src/mexc.js +9 -0
- package/js/src/pro/hyperliquid.d.ts +23 -0
- package/js/src/pro/hyperliquid.js +557 -0
- package/package.json +1 -1
- package/skip-tests.json +33 -58
package/js/src/coinbase.js
CHANGED
|
@@ -229,6 +229,8 @@ export default class coinbase extends Exchange {
|
|
|
229
229
|
'brokerage/intx/portfolio/{portfolio_uuid}': 1,
|
|
230
230
|
'brokerage/intx/positions/{portfolio_uuid}': 1,
|
|
231
231
|
'brokerage/intx/positions/{portfolio_uuid}/{symbol}': 1,
|
|
232
|
+
'brokerage/payment_methods': 1,
|
|
233
|
+
'brokerage/payment_methods/{payment_method_id}': 1,
|
|
232
234
|
},
|
|
233
235
|
'post': {
|
|
234
236
|
'brokerage/orders': 1,
|
|
@@ -381,7 +383,7 @@ export default class coinbase extends Exchange {
|
|
|
381
383
|
// }
|
|
382
384
|
// }
|
|
383
385
|
//
|
|
384
|
-
response = this.
|
|
386
|
+
response = this.safeDict(response, 'data', {});
|
|
385
387
|
}
|
|
386
388
|
else {
|
|
387
389
|
response = await this.v3PublicGetBrokerageTime(params);
|
|
@@ -473,7 +475,7 @@ export default class coinbase extends Exchange {
|
|
|
473
475
|
const accounts = this.safeList(response, 'data', []);
|
|
474
476
|
const length = accounts.length;
|
|
475
477
|
const lastIndex = length - 1;
|
|
476
|
-
const last = this.
|
|
478
|
+
const last = this.safeDict(accounts, lastIndex);
|
|
477
479
|
if ((cursor !== undefined) && (cursor !== '')) {
|
|
478
480
|
last['next_starting_after'] = cursor;
|
|
479
481
|
accounts[lastIndex] = last;
|
|
@@ -524,7 +526,7 @@ export default class coinbase extends Exchange {
|
|
|
524
526
|
const accounts = this.safeList(response, 'accounts', []);
|
|
525
527
|
const length = accounts.length;
|
|
526
528
|
const lastIndex = length - 1;
|
|
527
|
-
const last = this.
|
|
529
|
+
const last = this.safeDict(accounts, lastIndex);
|
|
528
530
|
const cursor = this.safeString(response, 'cursor');
|
|
529
531
|
if ((cursor !== undefined) && (cursor !== '')) {
|
|
530
532
|
last['cursor'] = cursor;
|
|
@@ -588,9 +590,9 @@ export default class coinbase extends Exchange {
|
|
|
588
590
|
// }
|
|
589
591
|
// }
|
|
590
592
|
//
|
|
591
|
-
const active = this.
|
|
593
|
+
const active = this.safeBool(account, 'active');
|
|
592
594
|
const currencyIdV3 = this.safeString(account, 'currency');
|
|
593
|
-
const currency = this.
|
|
595
|
+
const currency = this.safeDict(account, 'currency', {});
|
|
594
596
|
const currencyId = this.safeString(currency, 'code', currencyIdV3);
|
|
595
597
|
const typeV3 = this.safeString(account, 'name');
|
|
596
598
|
const typeV2 = this.safeString(account, 'type');
|
|
@@ -667,7 +669,7 @@ export default class coinbase extends Exchange {
|
|
|
667
669
|
// }
|
|
668
670
|
// }
|
|
669
671
|
//
|
|
670
|
-
const data = this.
|
|
672
|
+
const data = this.safeDict(response, 'data', {});
|
|
671
673
|
const tag = this.safeString(data, 'destination_tag');
|
|
672
674
|
const address = this.safeString(data, 'address');
|
|
673
675
|
return {
|
|
@@ -881,24 +883,24 @@ export default class coinbase extends Exchange {
|
|
|
881
883
|
let amountAndCurrencyObject = undefined;
|
|
882
884
|
let feeObject = undefined;
|
|
883
885
|
if (transactionType === 'send') {
|
|
884
|
-
const network = this.
|
|
885
|
-
amountAndCurrencyObject = this.
|
|
886
|
-
feeObject = this.
|
|
886
|
+
const network = this.safeDict(transaction, 'network', {});
|
|
887
|
+
amountAndCurrencyObject = this.safeDict(network, 'transaction_amount', {});
|
|
888
|
+
feeObject = this.safeDict(network, 'transaction_fee', {});
|
|
887
889
|
}
|
|
888
890
|
else {
|
|
889
|
-
amountAndCurrencyObject = this.
|
|
890
|
-
feeObject = this.
|
|
891
|
+
amountAndCurrencyObject = this.safeDict(transaction, 'subtotal', {});
|
|
892
|
+
feeObject = this.safeDict(transaction, 'fee', {});
|
|
891
893
|
}
|
|
892
894
|
let status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
|
|
893
895
|
if (status === undefined) {
|
|
894
|
-
const committed = this.
|
|
896
|
+
const committed = this.safeBool(transaction, 'committed');
|
|
895
897
|
status = committed ? 'ok' : 'pending';
|
|
896
898
|
}
|
|
897
899
|
const id = this.safeString(transaction, 'id');
|
|
898
900
|
const currencyId = this.safeString(amountAndCurrencyObject, 'currency');
|
|
899
901
|
const feeCurrencyId = this.safeString(feeObject, 'currency');
|
|
900
|
-
const datetime = this.
|
|
901
|
-
const toObject = this.
|
|
902
|
+
const datetime = this.safeString(transaction, 'created_at');
|
|
903
|
+
const toObject = this.safeDict(transaction, 'to', {});
|
|
902
904
|
const toAddress = this.safeString(toObject, 'address');
|
|
903
905
|
return {
|
|
904
906
|
'info': transaction,
|
|
@@ -917,7 +919,7 @@ export default class coinbase extends Exchange {
|
|
|
917
919
|
'amount': this.safeNumber(amountAndCurrencyObject, 'amount'),
|
|
918
920
|
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
919
921
|
'status': status,
|
|
920
|
-
'updated': this.parse8601(this.
|
|
922
|
+
'updated': this.parse8601(this.safeString(transaction, 'updated_at')),
|
|
921
923
|
'fee': {
|
|
922
924
|
'cost': this.safeNumber(feeObject, 'amount'),
|
|
923
925
|
'currency': this.safeCurrencyCode(feeCurrencyId),
|
|
@@ -987,10 +989,10 @@ export default class coinbase extends Exchange {
|
|
|
987
989
|
// }
|
|
988
990
|
//
|
|
989
991
|
let symbol = undefined;
|
|
990
|
-
const totalObject = this.
|
|
991
|
-
const amountObject = this.
|
|
992
|
-
const subtotalObject = this.
|
|
993
|
-
const feeObject = this.
|
|
992
|
+
const totalObject = this.safeDict(trade, 'total', {});
|
|
993
|
+
const amountObject = this.safeDict(trade, 'amount', {});
|
|
994
|
+
const subtotalObject = this.safeDict(trade, 'subtotal', {});
|
|
995
|
+
const feeObject = this.safeDict(trade, 'fee', {});
|
|
994
996
|
const marketId = this.safeString(trade, 'product_id');
|
|
995
997
|
market = this.safeMarket(marketId, market, '-');
|
|
996
998
|
if (market !== undefined) {
|
|
@@ -1005,7 +1007,7 @@ export default class coinbase extends Exchange {
|
|
|
1005
1007
|
symbol = base + '/' + quote;
|
|
1006
1008
|
}
|
|
1007
1009
|
}
|
|
1008
|
-
const sizeInQuote = this.
|
|
1010
|
+
const sizeInQuote = this.safeBool(trade, 'size_in_quote');
|
|
1009
1011
|
const v3Price = this.safeString(trade, 'price');
|
|
1010
1012
|
let v3Cost = undefined;
|
|
1011
1013
|
let v3Amount = this.safeString(trade, 'size');
|
|
@@ -1074,11 +1076,11 @@ export default class coinbase extends Exchange {
|
|
|
1074
1076
|
}
|
|
1075
1077
|
async fetchMarketsV2(params = {}) {
|
|
1076
1078
|
const response = await this.fetchCurrenciesFromCache(params);
|
|
1077
|
-
const currencies = this.
|
|
1078
|
-
const exchangeRates = this.
|
|
1079
|
-
const data = this.
|
|
1079
|
+
const currencies = this.safeDict(response, 'currencies', {});
|
|
1080
|
+
const exchangeRates = this.safeDict(response, 'exchangeRates', {});
|
|
1081
|
+
const data = this.safeList(currencies, 'data', []);
|
|
1080
1082
|
const dataById = this.indexBy(data, 'id');
|
|
1081
|
-
const rates = this.
|
|
1083
|
+
const rates = this.safeDict(this.safeDict(exchangeRates, 'data', {}), 'rates', {});
|
|
1082
1084
|
const baseIds = Object.keys(rates);
|
|
1083
1085
|
const result = [];
|
|
1084
1086
|
for (let i = 0; i < baseIds.length; i++) {
|
|
@@ -1200,8 +1202,8 @@ export default class coinbase extends Exchange {
|
|
|
1200
1202
|
// "coinbase_pro_fees": 0
|
|
1201
1203
|
// }
|
|
1202
1204
|
//
|
|
1203
|
-
const feeTier = this.
|
|
1204
|
-
const data = this.
|
|
1205
|
+
const feeTier = this.safeDict(fees, 'fee_tier', {});
|
|
1206
|
+
const data = this.safeList(response, 'products', []);
|
|
1205
1207
|
const result = [];
|
|
1206
1208
|
for (let i = 0; i < data.length; i++) {
|
|
1207
1209
|
const market = data[i];
|
|
@@ -1211,8 +1213,8 @@ export default class coinbase extends Exchange {
|
|
|
1211
1213
|
const base = this.safeCurrencyCode(baseId);
|
|
1212
1214
|
const quote = this.safeCurrencyCode(quoteId);
|
|
1213
1215
|
const marketType = this.safeStringLower(market, 'product_type');
|
|
1214
|
-
const tradingDisabled = this.
|
|
1215
|
-
const stablePairs = this.
|
|
1216
|
+
const tradingDisabled = this.safeBool(market, 'trading_disabled');
|
|
1217
|
+
const stablePairs = this.safeList(this.options, 'stablePairs', []);
|
|
1216
1218
|
result.push({
|
|
1217
1219
|
'id': id,
|
|
1218
1220
|
'symbol': base + '/' + quote,
|
|
@@ -1268,7 +1270,7 @@ export default class coinbase extends Exchange {
|
|
|
1268
1270
|
return result;
|
|
1269
1271
|
}
|
|
1270
1272
|
async fetchCurrenciesFromCache(params = {}) {
|
|
1271
|
-
const options = this.
|
|
1273
|
+
const options = this.safeDict(this.options, 'fetchCurrencies', {});
|
|
1272
1274
|
const timestamp = this.safeInteger(options, 'timestamp');
|
|
1273
1275
|
const expires = this.safeInteger(options, 'expires', 1000);
|
|
1274
1276
|
const now = this.milliseconds();
|
|
@@ -1324,7 +1326,7 @@ export default class coinbase extends Exchange {
|
|
|
1324
1326
|
* @returns {object} an associative dictionary of currencies
|
|
1325
1327
|
*/
|
|
1326
1328
|
const response = await this.fetchCurrenciesFromCache(params);
|
|
1327
|
-
const currencies = this.
|
|
1329
|
+
const currencies = this.safeDict(response, 'currencies', {});
|
|
1328
1330
|
//
|
|
1329
1331
|
// fiat
|
|
1330
1332
|
//
|
|
@@ -1441,8 +1443,8 @@ export default class coinbase extends Exchange {
|
|
|
1441
1443
|
// }
|
|
1442
1444
|
// }
|
|
1443
1445
|
//
|
|
1444
|
-
const data = this.
|
|
1445
|
-
const rates = this.
|
|
1446
|
+
const data = this.safeDict(response, 'data', {});
|
|
1447
|
+
const rates = this.safeDict(data, 'rates', {});
|
|
1446
1448
|
const quoteId = this.safeString(data, 'currency');
|
|
1447
1449
|
const result = {};
|
|
1448
1450
|
const baseIds = Object.keys(rates);
|
|
@@ -1501,7 +1503,7 @@ export default class coinbase extends Exchange {
|
|
|
1501
1503
|
// "num_products": 549
|
|
1502
1504
|
// }
|
|
1503
1505
|
//
|
|
1504
|
-
const data = this.
|
|
1506
|
+
const data = this.safeList(response, 'products', []);
|
|
1505
1507
|
const result = {};
|
|
1506
1508
|
for (let i = 0; i < data.length; i++) {
|
|
1507
1509
|
const entry = data[i];
|
|
@@ -1549,9 +1551,9 @@ export default class coinbase extends Exchange {
|
|
|
1549
1551
|
//
|
|
1550
1552
|
// {"data":{"base":"BTC","currency":"USD","amount":"48691.23"}}
|
|
1551
1553
|
//
|
|
1552
|
-
const spotData = this.
|
|
1553
|
-
const askData = this.
|
|
1554
|
-
const bidData = this.
|
|
1554
|
+
const spotData = this.safeDict(spot, 'data', {});
|
|
1555
|
+
const askData = this.safeDict(ask, 'data', {});
|
|
1556
|
+
const bidData = this.safeDict(bid, 'data', {});
|
|
1555
1557
|
const bidAskLast = {
|
|
1556
1558
|
'bid': this.safeNumber(bidData, 'amount'),
|
|
1557
1559
|
'ask': this.safeNumber(askData, 'amount'),
|
|
@@ -1585,7 +1587,7 @@ export default class coinbase extends Exchange {
|
|
|
1585
1587
|
// "best_ask": "28208.62"
|
|
1586
1588
|
// }
|
|
1587
1589
|
//
|
|
1588
|
-
const data = this.
|
|
1590
|
+
const data = this.safeList(response, 'trades', []);
|
|
1589
1591
|
const ticker = this.parseTicker(data[0], market);
|
|
1590
1592
|
ticker['bid'] = this.safeNumber(response, 'best_bid');
|
|
1591
1593
|
ticker['ask'] = this.safeNumber(response, 'best_ask');
|
|
@@ -1677,8 +1679,8 @@ export default class coinbase extends Exchange {
|
|
|
1677
1679
|
let bidVolume = undefined;
|
|
1678
1680
|
let askVolume = undefined;
|
|
1679
1681
|
if (('bids' in ticker)) {
|
|
1680
|
-
const bids = this.
|
|
1681
|
-
const asks = this.
|
|
1682
|
+
const bids = this.safeList(ticker, 'bids', []);
|
|
1683
|
+
const asks = this.safeList(ticker, 'asks', []);
|
|
1682
1684
|
bid = this.safeNumber(bids[0], 'price');
|
|
1683
1685
|
bidVolume = this.safeNumber(bids[0], 'size');
|
|
1684
1686
|
ask = this.safeNumber(asks[0], 'price');
|
|
@@ -1711,21 +1713,21 @@ export default class coinbase extends Exchange {
|
|
|
1711
1713
|
}, market);
|
|
1712
1714
|
}
|
|
1713
1715
|
parseCustomBalance(response, params = {}) {
|
|
1714
|
-
const balances = this.
|
|
1715
|
-
const accounts = this.
|
|
1716
|
-
const v3Accounts = this.
|
|
1716
|
+
const balances = this.safeList2(response, 'data', 'accounts', []);
|
|
1717
|
+
const accounts = this.safeList(params, 'type', this.options['accounts']);
|
|
1718
|
+
const v3Accounts = this.safeList(params, 'type', this.options['v3Accounts']);
|
|
1717
1719
|
const result = { 'info': response };
|
|
1718
1720
|
for (let b = 0; b < balances.length; b++) {
|
|
1719
1721
|
const balance = balances[b];
|
|
1720
1722
|
const type = this.safeString(balance, 'type');
|
|
1721
1723
|
if (this.inArray(type, accounts)) {
|
|
1722
|
-
const value = this.
|
|
1724
|
+
const value = this.safeDict(balance, 'balance');
|
|
1723
1725
|
if (value !== undefined) {
|
|
1724
1726
|
const currencyId = this.safeString(value, 'currency');
|
|
1725
1727
|
const code = this.safeCurrencyCode(currencyId);
|
|
1726
1728
|
const total = this.safeString(value, 'amount');
|
|
1727
1729
|
const free = total;
|
|
1728
|
-
let account = this.
|
|
1730
|
+
let account = this.safeDict(result, code);
|
|
1729
1731
|
if (account === undefined) {
|
|
1730
1732
|
account = this.account();
|
|
1731
1733
|
account['free'] = free;
|
|
@@ -1739,15 +1741,15 @@ export default class coinbase extends Exchange {
|
|
|
1739
1741
|
}
|
|
1740
1742
|
}
|
|
1741
1743
|
else if (this.inArray(type, v3Accounts)) {
|
|
1742
|
-
const available = this.
|
|
1743
|
-
const hold = this.
|
|
1744
|
+
const available = this.safeDict(balance, 'available_balance');
|
|
1745
|
+
const hold = this.safeDict(balance, 'hold');
|
|
1744
1746
|
if (available !== undefined && hold !== undefined) {
|
|
1745
1747
|
const currencyId = this.safeString(available, 'currency');
|
|
1746
1748
|
const code = this.safeCurrencyCode(currencyId);
|
|
1747
1749
|
const used = this.safeString(hold, 'value');
|
|
1748
1750
|
const free = this.safeString(available, 'value');
|
|
1749
1751
|
const total = Precise.stringAdd(used, free);
|
|
1750
|
-
let account = this.
|
|
1752
|
+
let account = this.safeDict(result, code);
|
|
1751
1753
|
if (account === undefined) {
|
|
1752
1754
|
account = this.account();
|
|
1753
1755
|
account['free'] = free;
|
|
@@ -2155,7 +2157,7 @@ export default class coinbase extends Exchange {
|
|
|
2155
2157
|
// }
|
|
2156
2158
|
// }
|
|
2157
2159
|
//
|
|
2158
|
-
const amountInfo = this.
|
|
2160
|
+
const amountInfo = this.safeDict(item, 'amount', {});
|
|
2159
2161
|
let amount = this.safeString(amountInfo, 'amount');
|
|
2160
2162
|
let direction = undefined;
|
|
2161
2163
|
if (Precise.stringLt(amount, '0')) {
|
|
@@ -2177,9 +2179,9 @@ export default class coinbase extends Exchange {
|
|
|
2177
2179
|
// let txid = undefined;
|
|
2178
2180
|
//
|
|
2179
2181
|
let fee = undefined;
|
|
2180
|
-
const networkInfo = this.
|
|
2182
|
+
const networkInfo = this.safeDict(item, 'network', {});
|
|
2181
2183
|
// txid = network['hash']; // txid does not belong to the unified ledger structure
|
|
2182
|
-
const feeInfo = this.
|
|
2184
|
+
const feeInfo = this.safeDict(networkInfo, 'transaction_fee');
|
|
2183
2185
|
if (feeInfo !== undefined) {
|
|
2184
2186
|
const feeCurrencyId = this.safeString(feeInfo, 'currency');
|
|
2185
2187
|
const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId, currency);
|
|
@@ -2189,7 +2191,7 @@ export default class coinbase extends Exchange {
|
|
|
2189
2191
|
'currency': feeCurrencyCode,
|
|
2190
2192
|
};
|
|
2191
2193
|
}
|
|
2192
|
-
const timestamp = this.parse8601(this.
|
|
2194
|
+
const timestamp = this.parse8601(this.safeString(item, 'created_at'));
|
|
2193
2195
|
const id = this.safeString(item, 'id');
|
|
2194
2196
|
const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
|
|
2195
2197
|
const status = this.parseLedgerEntryStatus(this.safeString(item, 'status'));
|
|
@@ -2321,7 +2323,7 @@ export default class coinbase extends Exchange {
|
|
|
2321
2323
|
const isStopLoss = stopLossPrice !== undefined;
|
|
2322
2324
|
const isTakeProfit = takeProfitPrice !== undefined;
|
|
2323
2325
|
const timeInForce = this.safeString(params, 'timeInForce');
|
|
2324
|
-
const postOnly = (timeInForce === 'PO') ? true : this.
|
|
2326
|
+
const postOnly = (timeInForce === 'PO') ? true : this.safeBool2(params, 'postOnly', 'post_only', false);
|
|
2325
2327
|
const endTime = this.safeString(params, 'end_time');
|
|
2326
2328
|
let stopDirection = this.safeString(params, 'stop_direction');
|
|
2327
2329
|
if (type === 'limit') {
|
|
@@ -2391,6 +2393,14 @@ export default class coinbase extends Exchange {
|
|
|
2391
2393
|
},
|
|
2392
2394
|
};
|
|
2393
2395
|
}
|
|
2396
|
+
else if (timeInForce === 'IOC') {
|
|
2397
|
+
request['order_configuration'] = {
|
|
2398
|
+
'sor_limit_ioc': {
|
|
2399
|
+
'base_size': this.amountToPrecision(symbol, amount),
|
|
2400
|
+
'limit_price': this.priceToPrecision(symbol, price),
|
|
2401
|
+
},
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2394
2404
|
else {
|
|
2395
2405
|
request['order_configuration'] = {
|
|
2396
2406
|
'limit_limit_gtc': {
|
|
@@ -2444,7 +2454,7 @@ export default class coinbase extends Exchange {
|
|
|
2444
2454
|
}
|
|
2445
2455
|
}
|
|
2446
2456
|
params = this.omit(params, ['timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'stop_price', 'stopDirection', 'stop_direction', 'clientOrderId', 'postOnly', 'post_only', 'end_time']);
|
|
2447
|
-
const preview = this.
|
|
2457
|
+
const preview = this.safeBool2(params, 'preview', 'test', false);
|
|
2448
2458
|
let response = undefined;
|
|
2449
2459
|
if (preview) {
|
|
2450
2460
|
params = this.omit(params, ['preview', 'test']);
|
|
@@ -2491,9 +2501,9 @@ export default class coinbase extends Exchange {
|
|
|
2491
2501
|
// }
|
|
2492
2502
|
// }
|
|
2493
2503
|
//
|
|
2494
|
-
const success = this.
|
|
2504
|
+
const success = this.safeBool(response, 'success');
|
|
2495
2505
|
if (success !== true) {
|
|
2496
|
-
const errorResponse = this.
|
|
2506
|
+
const errorResponse = this.safeDict(response, 'error_response');
|
|
2497
2507
|
const errorTitle = this.safeString(errorResponse, 'error');
|
|
2498
2508
|
const errorMessage = this.safeString(errorResponse, 'message');
|
|
2499
2509
|
if (errorResponse !== undefined) {
|
|
@@ -2502,7 +2512,7 @@ export default class coinbase extends Exchange {
|
|
|
2502
2512
|
throw new ExchangeError(errorMessage);
|
|
2503
2513
|
}
|
|
2504
2514
|
}
|
|
2505
|
-
const data = this.
|
|
2515
|
+
const data = this.safeDict(response, 'success_response', {});
|
|
2506
2516
|
return this.parseOrder(data, market);
|
|
2507
2517
|
}
|
|
2508
2518
|
parseOrder(order, market = undefined) {
|
|
@@ -2573,29 +2583,39 @@ export default class coinbase extends Exchange {
|
|
|
2573
2583
|
if (symbol !== undefined) {
|
|
2574
2584
|
market = this.market(symbol);
|
|
2575
2585
|
}
|
|
2576
|
-
const orderConfiguration = this.
|
|
2577
|
-
const limitGTC = this.
|
|
2578
|
-
const limitGTD = this.
|
|
2579
|
-
const
|
|
2580
|
-
const
|
|
2581
|
-
const
|
|
2582
|
-
const
|
|
2586
|
+
const orderConfiguration = this.safeDict(order, 'order_configuration', {});
|
|
2587
|
+
const limitGTC = this.safeDict(orderConfiguration, 'limit_limit_gtc');
|
|
2588
|
+
const limitGTD = this.safeDict(orderConfiguration, 'limit_limit_gtd');
|
|
2589
|
+
const limitIOC = this.safeDict(orderConfiguration, 'sor_limit_ioc');
|
|
2590
|
+
const stopLimitGTC = this.safeDict(orderConfiguration, 'stop_limit_stop_limit_gtc');
|
|
2591
|
+
const stopLimitGTD = this.safeDict(orderConfiguration, 'stop_limit_stop_limit_gtd');
|
|
2592
|
+
const marketIOC = this.safeDict(orderConfiguration, 'market_market_ioc');
|
|
2593
|
+
const isLimit = ((limitGTC !== undefined) || (limitGTD !== undefined) || (limitIOC !== undefined));
|
|
2583
2594
|
const isStop = ((stopLimitGTC !== undefined) || (stopLimitGTD !== undefined));
|
|
2584
2595
|
let price = undefined;
|
|
2585
2596
|
let amount = undefined;
|
|
2586
2597
|
let postOnly = undefined;
|
|
2587
2598
|
let triggerPrice = undefined;
|
|
2588
2599
|
if (isLimit) {
|
|
2589
|
-
|
|
2600
|
+
let target = undefined;
|
|
2601
|
+
if (limitGTC !== undefined) {
|
|
2602
|
+
target = limitGTC;
|
|
2603
|
+
}
|
|
2604
|
+
else if (limitGTD !== undefined) {
|
|
2605
|
+
target = limitGTD;
|
|
2606
|
+
}
|
|
2607
|
+
else {
|
|
2608
|
+
target = limitIOC;
|
|
2609
|
+
}
|
|
2590
2610
|
price = this.safeString(target, 'limit_price');
|
|
2591
2611
|
amount = this.safeString(target, 'base_size');
|
|
2592
|
-
postOnly = this.
|
|
2612
|
+
postOnly = this.safeBool(target, 'post_only');
|
|
2593
2613
|
}
|
|
2594
2614
|
else if (isStop) {
|
|
2595
2615
|
const stopTarget = (stopLimitGTC !== undefined) ? stopLimitGTC : stopLimitGTD;
|
|
2596
2616
|
price = this.safeString(stopTarget, 'limit_price');
|
|
2597
2617
|
amount = this.safeString(stopTarget, 'base_size');
|
|
2598
|
-
postOnly = this.
|
|
2618
|
+
postOnly = this.safeBool(stopTarget, 'post_only');
|
|
2599
2619
|
triggerPrice = this.safeString(stopTarget, 'stop_price');
|
|
2600
2620
|
}
|
|
2601
2621
|
else {
|
|
@@ -2681,7 +2701,7 @@ export default class coinbase extends Exchange {
|
|
|
2681
2701
|
*/
|
|
2682
2702
|
await this.loadMarkets();
|
|
2683
2703
|
const orders = await this.cancelOrders([id], symbol, params);
|
|
2684
|
-
return this.
|
|
2704
|
+
return this.safeDict(orders, 0, {});
|
|
2685
2705
|
}
|
|
2686
2706
|
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
2687
2707
|
/**
|
|
@@ -2714,9 +2734,9 @@ export default class coinbase extends Exchange {
|
|
|
2714
2734
|
// ]
|
|
2715
2735
|
// }
|
|
2716
2736
|
//
|
|
2717
|
-
const orders = this.
|
|
2737
|
+
const orders = this.safeList(response, 'results', []);
|
|
2718
2738
|
for (let i = 0; i < orders.length; i++) {
|
|
2719
|
-
const success = this.
|
|
2739
|
+
const success = this.safeBool(orders[i], 'success');
|
|
2720
2740
|
if (success !== true) {
|
|
2721
2741
|
throw new BadRequest(this.id + ' cancelOrders() has failed, check your arguments and parameters');
|
|
2722
2742
|
}
|
|
@@ -2750,7 +2770,7 @@ export default class coinbase extends Exchange {
|
|
|
2750
2770
|
if (price !== undefined) {
|
|
2751
2771
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
2752
2772
|
}
|
|
2753
|
-
const preview = this.
|
|
2773
|
+
const preview = this.safeBool2(params, 'preview', 'test', false);
|
|
2754
2774
|
let response = undefined;
|
|
2755
2775
|
if (preview) {
|
|
2756
2776
|
params = this.omit(params, ['preview', 'test']);
|
|
@@ -2829,7 +2849,7 @@ export default class coinbase extends Exchange {
|
|
|
2829
2849
|
// }
|
|
2830
2850
|
// }
|
|
2831
2851
|
//
|
|
2832
|
-
const order = this.
|
|
2852
|
+
const order = this.safeDict(response, 'order', {});
|
|
2833
2853
|
return this.parseOrder(order, market);
|
|
2834
2854
|
}
|
|
2835
2855
|
async fetchOrders(symbol = undefined, since = undefined, limit = 100, params = {}) {
|
|
@@ -2866,7 +2886,7 @@ export default class coinbase extends Exchange {
|
|
|
2866
2886
|
if (since !== undefined) {
|
|
2867
2887
|
request['start_date'] = this.iso8601(since);
|
|
2868
2888
|
}
|
|
2869
|
-
const until = this.
|
|
2889
|
+
const until = this.safeIntegerN(params, ['until', 'till']);
|
|
2870
2890
|
if (until !== undefined) {
|
|
2871
2891
|
params = this.omit(params, ['until', 'till']);
|
|
2872
2892
|
request['end_date'] = this.iso8601(until);
|
|
@@ -2914,8 +2934,8 @@ export default class coinbase extends Exchange {
|
|
|
2914
2934
|
// "cursor": ""
|
|
2915
2935
|
// }
|
|
2916
2936
|
//
|
|
2917
|
-
const orders = this.
|
|
2918
|
-
const first = this.
|
|
2937
|
+
const orders = this.safeList(response, 'orders', []);
|
|
2938
|
+
const first = this.safeDict(orders, 0);
|
|
2919
2939
|
const cursor = this.safeString(response, 'cursor');
|
|
2920
2940
|
if ((cursor !== undefined) && (cursor !== '')) {
|
|
2921
2941
|
first['cursor'] = cursor;
|
|
@@ -2942,7 +2962,7 @@ export default class coinbase extends Exchange {
|
|
|
2942
2962
|
if (since !== undefined) {
|
|
2943
2963
|
request['start_date'] = this.iso8601(since);
|
|
2944
2964
|
}
|
|
2945
|
-
const until = this.
|
|
2965
|
+
const until = this.safeIntegerN(params, ['until', 'till']);
|
|
2946
2966
|
if (until !== undefined) {
|
|
2947
2967
|
params = this.omit(params, ['until', 'till']);
|
|
2948
2968
|
request['end_date'] = this.iso8601(until);
|
|
@@ -2990,8 +3010,8 @@ export default class coinbase extends Exchange {
|
|
|
2990
3010
|
// "cursor": ""
|
|
2991
3011
|
// }
|
|
2992
3012
|
//
|
|
2993
|
-
const orders = this.
|
|
2994
|
-
const first = this.
|
|
3013
|
+
const orders = this.safeList(response, 'orders', []);
|
|
3014
|
+
const first = this.safeDict(orders, 0);
|
|
2995
3015
|
const cursor = this.safeString(response, 'cursor');
|
|
2996
3016
|
if ((cursor !== undefined) && (cursor !== '')) {
|
|
2997
3017
|
first['cursor'] = cursor;
|
|
@@ -3085,7 +3105,7 @@ export default class coinbase extends Exchange {
|
|
|
3085
3105
|
'product_id': market['id'],
|
|
3086
3106
|
'granularity': this.safeString(this.timeframes, timeframe, timeframe),
|
|
3087
3107
|
};
|
|
3088
|
-
const until = this.
|
|
3108
|
+
const until = this.safeIntegerN(params, ['until', 'till', 'end']);
|
|
3089
3109
|
params = this.omit(params, ['until', 'till']);
|
|
3090
3110
|
const duration = this.parseTimeframe(timeframe);
|
|
3091
3111
|
const requestedDuration = limit * duration;
|
|
@@ -3119,7 +3139,7 @@ export default class coinbase extends Exchange {
|
|
|
3119
3139
|
// ]
|
|
3120
3140
|
// }
|
|
3121
3141
|
//
|
|
3122
|
-
const candles = this.
|
|
3142
|
+
const candles = this.safeList(response, 'candles', []);
|
|
3123
3143
|
return this.parseOHLCVs(candles, market, timeframe, since, limit);
|
|
3124
3144
|
}
|
|
3125
3145
|
parseOHLCV(ohlcv, market = undefined) {
|
|
@@ -3192,7 +3212,7 @@ export default class coinbase extends Exchange {
|
|
|
3192
3212
|
// ]
|
|
3193
3213
|
// }
|
|
3194
3214
|
//
|
|
3195
|
-
const trades = this.
|
|
3215
|
+
const trades = this.safeList(response, 'trades', []);
|
|
3196
3216
|
return this.parseTrades(trades, market, since, limit);
|
|
3197
3217
|
}
|
|
3198
3218
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3229,7 +3249,7 @@ export default class coinbase extends Exchange {
|
|
|
3229
3249
|
if (since !== undefined) {
|
|
3230
3250
|
request['start_sequence_timestamp'] = this.iso8601(since);
|
|
3231
3251
|
}
|
|
3232
|
-
const until = this.
|
|
3252
|
+
const until = this.safeIntegerN(params, ['until', 'till']);
|
|
3233
3253
|
if (until !== undefined) {
|
|
3234
3254
|
params = this.omit(params, ['until', 'till']);
|
|
3235
3255
|
request['end_sequence_timestamp'] = this.iso8601(until);
|
|
@@ -3258,8 +3278,8 @@ export default class coinbase extends Exchange {
|
|
|
3258
3278
|
// "cursor": ""
|
|
3259
3279
|
// }
|
|
3260
3280
|
//
|
|
3261
|
-
const trades = this.
|
|
3262
|
-
const first = this.
|
|
3281
|
+
const trades = this.safeList(response, 'fills', []);
|
|
3282
|
+
const first = this.safeDict(trades, 0);
|
|
3263
3283
|
const cursor = this.safeString(response, 'cursor');
|
|
3264
3284
|
if ((cursor !== undefined) && (cursor !== '')) {
|
|
3265
3285
|
first['cursor'] = cursor;
|
|
@@ -3351,7 +3371,7 @@ export default class coinbase extends Exchange {
|
|
|
3351
3371
|
// ]
|
|
3352
3372
|
// }
|
|
3353
3373
|
//
|
|
3354
|
-
const tickers = this.
|
|
3374
|
+
const tickers = this.safeList(response, 'pricebooks', []);
|
|
3355
3375
|
return this.parseTickers(tickers, symbols);
|
|
3356
3376
|
}
|
|
3357
3377
|
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
@@ -3445,7 +3465,7 @@ export default class coinbase extends Exchange {
|
|
|
3445
3465
|
// }
|
|
3446
3466
|
// }
|
|
3447
3467
|
//
|
|
3448
|
-
const data = this.
|
|
3468
|
+
const data = this.safeDict(response, 'data', {});
|
|
3449
3469
|
return this.parseTransaction(data, currency);
|
|
3450
3470
|
}
|
|
3451
3471
|
async fetchDepositAddressesByNetwork(code, params = {}) {
|
|
@@ -3718,7 +3738,7 @@ export default class coinbase extends Exchange {
|
|
|
3718
3738
|
// }
|
|
3719
3739
|
// }
|
|
3720
3740
|
//
|
|
3721
|
-
const data = this.
|
|
3741
|
+
const data = this.safeDict(response, 'data', {});
|
|
3722
3742
|
return this.parseTransaction(data);
|
|
3723
3743
|
}
|
|
3724
3744
|
sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
@@ -3818,7 +3838,7 @@ export default class coinbase extends Exchange {
|
|
|
3818
3838
|
this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
|
|
3819
3839
|
throw new ExchangeError(feedback);
|
|
3820
3840
|
}
|
|
3821
|
-
const errors = this.
|
|
3841
|
+
const errors = this.safeList(response, 'errors');
|
|
3822
3842
|
if (errors !== undefined) {
|
|
3823
3843
|
if (Array.isArray(errors)) {
|
|
3824
3844
|
const numErrors = errors.length;
|
|
@@ -3834,8 +3854,7 @@ export default class coinbase extends Exchange {
|
|
|
3834
3854
|
}
|
|
3835
3855
|
}
|
|
3836
3856
|
const advancedTrade = this.options['advanced'];
|
|
3837
|
-
|
|
3838
|
-
if ((data === undefined) && (!advancedTrade)) {
|
|
3857
|
+
if (!('data' in response) && (!advancedTrade)) {
|
|
3839
3858
|
throw new ExchangeError(this.id + ' failed due to a malformed response ' + this.json(response));
|
|
3840
3859
|
}
|
|
3841
3860
|
return undefined;
|
package/js/src/digifinex.js
CHANGED
|
@@ -1526,7 +1526,8 @@ export default class digifinex extends Exchange {
|
|
|
1526
1526
|
else if (limit !== undefined) {
|
|
1527
1527
|
const endTime = this.seconds();
|
|
1528
1528
|
const duration = this.parseTimeframe(timeframe);
|
|
1529
|
-
|
|
1529
|
+
const auxLimit = limit; // in c# -limit is mutating the arg
|
|
1530
|
+
request['start_time'] = this.sum(endTime, -auxLimit * duration);
|
|
1530
1531
|
}
|
|
1531
1532
|
response = await this.publicSpotGetKline(this.extend(request, params));
|
|
1532
1533
|
}
|
package/js/src/hyperliquid.js
CHANGED
package/js/src/kraken.js
CHANGED
|
@@ -1298,6 +1298,7 @@ export default class kraken extends Exchange {
|
|
|
1298
1298
|
const lastTrade = trades[length - 1];
|
|
1299
1299
|
const lastTradeId = this.safeString(result, 'last');
|
|
1300
1300
|
lastTrade.push(lastTradeId);
|
|
1301
|
+
trades[length - 1] = lastTrade;
|
|
1301
1302
|
return this.parseTrades(trades, market, since, limit);
|
|
1302
1303
|
}
|
|
1303
1304
|
parseBalance(response) {
|
package/js/src/mexc.js
CHANGED
|
@@ -44,6 +44,7 @@ export default class mexc extends Exchange {
|
|
|
44
44
|
'createMarketSellOrderWithCost': false,
|
|
45
45
|
'createOrder': true,
|
|
46
46
|
'createOrders': true,
|
|
47
|
+
'createPostOnlyOrder': true,
|
|
47
48
|
'createReduceOnlyOrder': true,
|
|
48
49
|
'deposit': undefined,
|
|
49
50
|
'editOrder': undefined,
|
|
@@ -2210,6 +2211,14 @@ export default class mexc extends Exchange {
|
|
|
2210
2211
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2211
2212
|
* @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
|
|
2212
2213
|
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
2214
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
|
|
2215
|
+
* @param {bool} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
|
|
2216
|
+
*
|
|
2217
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
2218
|
+
* @param {int} [params.leverage] *contract only* leverage is necessary on isolated margin
|
|
2219
|
+
* @param {long} [params.positionId] *contract only* it is recommended to fill in this parameter when closing a position
|
|
2220
|
+
* @param {string} [params.externalOid] *contract only* external order ID
|
|
2221
|
+
* @param {int} [params.positionMode] *contract only* 1:hedge, 2:one-way, default: the user's current config
|
|
2213
2222
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2214
2223
|
*/
|
|
2215
2224
|
await this.loadMarkets();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import hyperliquidRest from '../hyperliquid.js';
|
|
2
|
+
import Client from '../base/ws/Client.js';
|
|
3
|
+
import { Int, Str, Market, OrderBook, Trade, OHLCV, Order } from '../base/types.js';
|
|
4
|
+
export default class hyperliquid extends hyperliquidRest {
|
|
5
|
+
describe(): any;
|
|
6
|
+
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
7
|
+
handleOrderBook(client: any, message: any): void;
|
|
8
|
+
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
9
|
+
handleMyTrades(client: Client, message: any): void;
|
|
10
|
+
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
11
|
+
handleTrades(client: Client, message: any): void;
|
|
12
|
+
parseWsTrade(trade: any, market?: Market): Trade;
|
|
13
|
+
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
14
|
+
handleOHLCV(client: Client, message: any): void;
|
|
15
|
+
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
16
|
+
handleOrder(client: Client, message: any): void;
|
|
17
|
+
handleErrorMessage(client: Client, message: any): boolean;
|
|
18
|
+
handleMessage(client: Client, message: any): void;
|
|
19
|
+
ping(client: any): {
|
|
20
|
+
method: string;
|
|
21
|
+
};
|
|
22
|
+
handlePong(client: Client, message: any): any;
|
|
23
|
+
}
|