ccxt 4.1.63 → 4.1.64

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/dist/cjs/ccxt.js CHANGED
@@ -173,7 +173,7 @@ var woo$1 = require('./src/pro/woo.js');
173
173
 
174
174
  //-----------------------------------------------------------------------------
175
175
  // this is updated by vss.js when building
176
- const version = '4.1.63';
176
+ const version = '4.1.64';
177
177
  Exchange["default"].ccxtVersion = version;
178
178
  const exchanges = {
179
179
  'ace': ace,
@@ -42,10 +42,39 @@ class binanceus extends binance {
42
42
  'has': {
43
43
  'CORS': undefined,
44
44
  'spot': true,
45
- 'margin': undefined,
46
- 'swap': undefined,
47
- 'future': undefined,
48
- 'option': undefined,
45
+ 'margin': false,
46
+ 'swap': false,
47
+ 'option': false,
48
+ 'addMargin': false,
49
+ 'borrowMargin': false,
50
+ 'createReduceOnlyOrder': false,
51
+ 'fetchBorrowInterest': false,
52
+ 'fetchBorrowRate': false,
53
+ 'fetchBorrowRateHistories': false,
54
+ 'fetchBorrowRateHistory': false,
55
+ 'fetchBorrowRates': false,
56
+ 'fetchBorrowRatesPerSymbol': false,
57
+ 'fetchFundingHistory': false,
58
+ 'fetchFundingRate': false,
59
+ 'fetchFundingRateHistory': false,
60
+ 'fetchFundingRates': false,
61
+ 'fetchIndexOHLCV': false,
62
+ 'fetchIsolatedPositions': false,
63
+ 'fetchLeverage': false,
64
+ 'fetchLeverageTiers': false,
65
+ 'fetchMarketLeverageTiers': false,
66
+ 'fetchMarkOHLCV': false,
67
+ 'fetchOpenInterestHistory': false,
68
+ 'fetchPosition': false,
69
+ 'fetchPositions': false,
70
+ 'fetchPositionsRisk': false,
71
+ 'fetchPremiumIndexOHLCV': false,
72
+ 'reduceMargin': false,
73
+ 'repayMargin': false,
74
+ 'setLeverage': false,
75
+ 'setMargin': false,
76
+ 'setMarginMode': false,
77
+ 'setPositionMode': false,
49
78
  },
50
79
  });
51
80
  }
@@ -1526,8 +1526,8 @@ class kraken extends kraken$1 {
1526
1526
  //
1527
1527
  // market
1528
1528
  // limit (price = limit price)
1529
- // stop-loss (price = stop loss price)
1530
- // take-profit (price = take profit price)
1529
+ // stop-loss (price = stop loss trigger price)
1530
+ // take-profit (price = take profit trigger price)
1531
1531
  // stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price)
1532
1532
  // take-profit-limit (price = take profit trigger price, price2 = triggered limit price)
1533
1533
  // settle-position
@@ -1798,6 +1798,15 @@ class kraken extends kraken$1 {
1798
1798
  return result;
1799
1799
  }
1800
1800
  async fetchOrdersByIds(ids, symbol = undefined, params = {}) {
1801
+ /**
1802
+ * @method
1803
+ * @name kraken#fetchOrdersByIds
1804
+ * @description fetch orders by the list of order id
1805
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
1806
+ * @param {string[]|undefined} ids list of order id
1807
+ * @param {object} [params] extra parameters specific to the kraken api endpoint
1808
+ * @returns {object[]} a list of [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1809
+ */
1801
1810
  await this.loadMarkets();
1802
1811
  const response = await this.privatePostQueryOrders(this.extend({
1803
1812
  'trades': true,
@@ -2293,6 +2302,15 @@ class kraken extends kraken$1 {
2293
2302
  return await this.fetchDepositAddress(code, this.extend(request, params));
2294
2303
  }
2295
2304
  async fetchDepositMethods(code, params = {}) {
2305
+ /**
2306
+ * @method
2307
+ * @name kraken#fetchDepositMethods
2308
+ * @description fetch deposit methods for a currency associated with this account
2309
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositMethods
2310
+ * @param {string} code unified currency code
2311
+ * @param {object} [params] extra parameters specific to the kraken api endpoint
2312
+ * @returns {object} of deposit methods
2313
+ */
2296
2314
  await this.loadMarkets();
2297
2315
  const currency = this.currency(code);
2298
2316
  const request = {
@@ -86,7 +86,7 @@ class krakenfutures extends krakenfutures$1 {
86
86
  },
87
87
  'www': 'https://futures.kraken.com/',
88
88
  'doc': [
89
- 'https://support.kraken.com/hc/en-us/categories/360001806372-Futures-API',
89
+ 'https://docs.futures.kraken.com/#introduction',
90
90
  ],
91
91
  'fees': 'https://support.kraken.com/hc/en-us/articles/360022835771-Transaction-fees-and-rebates-for-Kraken-Futures',
92
92
  'referral': undefined,
@@ -2229,26 +2229,26 @@ class krakenfutures extends krakenfutures$1 {
2229
2229
  */
2230
2230
  await this.loadMarkets();
2231
2231
  const currency = this.currency(code);
2232
- let method = 'privatePostTransfer';
2233
- const request = {
2234
- 'amount': amount,
2235
- };
2236
2232
  if (fromAccount === 'spot') {
2237
2233
  throw new errors.BadRequest(this.id + ' transfer does not yet support transfers from spot');
2238
2234
  }
2235
+ const request = {
2236
+ 'amount': amount,
2237
+ };
2238
+ let response = undefined;
2239
2239
  if (toAccount === 'spot') {
2240
2240
  if (this.parseAccount(fromAccount) !== 'cash') {
2241
2241
  throw new errors.BadRequest(this.id + ' transfer cannot transfer from ' + fromAccount + ' to ' + toAccount);
2242
2242
  }
2243
- method = 'privatePostWithdrawal';
2244
2243
  request['currency'] = currency['id'];
2244
+ response = await this.privatePostWithdrawal(this.extend(request, params));
2245
2245
  }
2246
2246
  else {
2247
2247
  request['fromAccount'] = this.parseAccount(fromAccount);
2248
2248
  request['toAccount'] = this.parseAccount(toAccount);
2249
2249
  request['unit'] = currency['id'];
2250
+ response = await this.privatePostTransfer(this.extend(request, params));
2250
2251
  }
2251
- const response = await this[method](this.extend(request, params));
2252
2252
  //
2253
2253
  // {
2254
2254
  // "result": "success",
@@ -334,17 +334,17 @@ class luno extends luno$1 {
334
334
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
335
335
  */
336
336
  await this.loadMarkets();
337
- let method = 'publicGetOrderbook';
338
- if (limit !== undefined) {
339
- if (limit <= 100) {
340
- method += 'Top'; // get just the top of the orderbook when limit is low
341
- }
342
- }
343
337
  const market = this.market(symbol);
344
338
  const request = {
345
339
  'pair': market['id'],
346
340
  };
347
- const response = await this[method](this.extend(request, params));
341
+ let response = undefined;
342
+ if (limit !== undefined && limit <= 100) {
343
+ response = await this.publicGetOrderbookTop(this.extend(request, params));
344
+ }
345
+ else {
346
+ response = await this.publicGetOrderbook(this.extend(request, params));
347
+ }
348
348
  const timestamp = this.safeInteger(response, 'timestamp');
349
349
  return this.parseOrderBook(response, market['symbol'], timestamp, 'bids', 'asks', 'price', 'volume');
350
350
  }
@@ -812,13 +812,12 @@ class luno extends luno$1 {
812
812
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
813
813
  */
814
814
  await this.loadMarkets();
815
- let method = 'privatePost';
816
815
  const market = this.market(symbol);
817
816
  const request = {
818
817
  'pair': market['id'],
819
818
  };
819
+ let response = undefined;
820
820
  if (type === 'market') {
821
- method += 'Marketorder';
822
821
  request['type'] = side.toUpperCase();
823
822
  // todo add createMarketBuyOrderRequires price logic as it is implemented in the other exchanges
824
823
  if (side === 'buy') {
@@ -827,14 +826,14 @@ class luno extends luno$1 {
827
826
  else {
828
827
  request['base_volume'] = this.amountToPrecision(market['symbol'], amount);
829
828
  }
829
+ response = await this.privatePostMarketorder(this.extend(request, params));
830
830
  }
831
831
  else {
832
- method += 'Postorder';
833
832
  request['volume'] = this.amountToPrecision(market['symbol'], amount);
834
833
  request['price'] = this.priceToPrecision(market['symbol'], price);
835
834
  request['type'] = (side === 'buy') ? 'BID' : 'ASK';
835
+ response = await this.privatePostPostorder(this.extend(request, params));
836
836
  }
837
- const response = await this[method](this.extend(request, params));
838
837
  return this.safeOrder({
839
838
  'info': response,
840
839
  'id': response['order_id'],
@@ -986,11 +986,13 @@ class phemex extends phemex$1 {
986
986
  'symbol': market['id'],
987
987
  // 'id': 123456789, // optional request id
988
988
  };
989
- let method = 'v1GetMdOrderbook';
989
+ let response = undefined;
990
990
  if (market['linear'] && market['settle'] === 'USDT') {
991
- method = 'v2GetMdV2Orderbook';
991
+ response = await this.v2GetMdV2Orderbook(this.extend(request, params));
992
+ }
993
+ else {
994
+ response = await this.v1GetMdOrderbook(this.extend(request, params));
992
995
  }
993
- const response = await this[method](this.extend(request, params));
994
996
  //
995
997
  // {
996
998
  // "error": null,
@@ -1295,16 +1297,18 @@ class phemex extends phemex$1 {
1295
1297
  'symbol': market['id'],
1296
1298
  // 'id': 123456789, // optional request id
1297
1299
  };
1298
- let method = 'v1GetMdSpotTicker24hr';
1300
+ let response = undefined;
1299
1301
  if (market['swap']) {
1300
1302
  if (market['inverse'] || market['settle'] === 'USD') {
1301
- method = 'v1GetMdTicker24hr';
1303
+ response = await this.v1GetMdTicker24hr(this.extend(request, params));
1302
1304
  }
1303
1305
  else {
1304
- method = 'v2GetMdV2Ticker24hr';
1306
+ response = await this.v2GetMdV2Ticker24hr(this.extend(request, params));
1305
1307
  }
1306
1308
  }
1307
- const response = await this[method](this.extend(request, params));
1309
+ else {
1310
+ response = await this.v1GetMdSpotTicker24hr(this.extend(request, params));
1311
+ }
1308
1312
  //
1309
1313
  // spot
1310
1314
  //
@@ -1375,18 +1379,16 @@ class phemex extends phemex$1 {
1375
1379
  let subType = undefined;
1376
1380
  [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
1377
1381
  const query = this.omit(params, 'type');
1378
- let defaultMethod;
1382
+ let response = undefined;
1379
1383
  if (type === 'spot') {
1380
- defaultMethod = 'v1GetMdSpotTicker24hrAll';
1384
+ response = await this.v1GetMdSpotTicker24hrAll(query);
1381
1385
  }
1382
- else if (subType === 'inverse') {
1383
- defaultMethod = 'v1GetMdTicker24hrAll';
1386
+ else if (subType === 'inverse' || market['settle'] === 'USD') {
1387
+ response = await this.v1GetMdTicker24hrAll(query);
1384
1388
  }
1385
1389
  else {
1386
- defaultMethod = 'v2GetMdV2Ticker24hrAll';
1390
+ response = await this.v2GetMdV2Ticker24hrAll(query);
1387
1391
  }
1388
- const method = this.safeString(this.options, 'fetchTickersMethod', defaultMethod);
1389
- const response = await this[method](query);
1390
1392
  const result = this.safeValue(response, 'result', []);
1391
1393
  return this.parseTickers(result, symbols);
1392
1394
  }
@@ -1408,11 +1410,13 @@ class phemex extends phemex$1 {
1408
1410
  'symbol': market['id'],
1409
1411
  // 'id': 123456789, // optional request id
1410
1412
  };
1411
- let method = 'v1GetMdTrade';
1413
+ let response = undefined;
1412
1414
  if (market['linear'] && market['settle'] === 'USDT') {
1413
- method = 'v2GetMdV2Trade';
1415
+ response = await this.v2GetMdV2Trade(this.extend(request, params));
1416
+ }
1417
+ else {
1418
+ response = await this.v1GetMdTrade(this.extend(request, params));
1414
1419
  }
1415
- const response = await this[method](this.extend(request, params));
1416
1420
  //
1417
1421
  // {
1418
1422
  // "error": null,
@@ -1809,18 +1813,20 @@ class phemex extends phemex$1 {
1809
1813
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
1810
1814
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-account-positions
1811
1815
  * @param {object} [params] extra parameters specific to the phemex api endpoint
1816
+ * @param {string} [params.type] spot or swap
1812
1817
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1813
1818
  */
1814
1819
  await this.loadMarkets();
1815
1820
  let type = undefined;
1816
1821
  [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
1817
- let method = 'privateGetSpotWallets';
1822
+ const code = this.safeString(params, 'code');
1823
+ params = this.omit(params, ['type', 'code']);
1824
+ let response = undefined;
1818
1825
  const request = {};
1819
1826
  if ((type !== 'spot') && (type !== 'swap')) {
1820
1827
  throw new errors.BadRequest(this.id + ' does not support ' + type + ' markets, only spot and swap');
1821
1828
  }
1822
1829
  if (type === 'swap') {
1823
- const code = this.safeString(params, 'code');
1824
1830
  let settle = undefined;
1825
1831
  [settle, params] = this.handleOptionAndParams(params, 'fetchBalance', 'settle');
1826
1832
  if (code !== undefined || settle !== undefined) {
@@ -1834,10 +1840,10 @@ class phemex extends phemex$1 {
1834
1840
  const currency = this.currency(coin);
1835
1841
  request['currency'] = currency['id'];
1836
1842
  if (currency['id'] === 'USDT') {
1837
- method = 'privateGetGAccountsAccountPositions';
1843
+ response = await this.privateGetGAccountsAccountPositions(this.extend(request, params));
1838
1844
  }
1839
1845
  else {
1840
- method = 'privateGetAccountsAccountPositions';
1846
+ response = await this.privateGetAccountsAccountPositions(this.extend(request, params));
1841
1847
  }
1842
1848
  }
1843
1849
  else {
@@ -1845,10 +1851,12 @@ class phemex extends phemex$1 {
1845
1851
  if (currency === undefined) {
1846
1852
  throw new errors.ArgumentsRequired(this.id + ' fetchBalance() requires a code parameter or a currency or settle parameter for ' + type + ' type');
1847
1853
  }
1854
+ response = await this.privateGetSpotWallets(this.extend(request, params));
1848
1855
  }
1849
1856
  }
1850
- params = this.omit(params, ['type', 'code']);
1851
- const response = await this[method](this.extend(request, params));
1857
+ else {
1858
+ response = await this.privateGetSpotWallets(this.extend(request, params));
1859
+ }
1852
1860
  //
1853
1861
  // usdt
1854
1862
  // {
@@ -2375,7 +2383,7 @@ class phemex extends phemex$1 {
2375
2383
  request['clOrdID'] = clientOrderId;
2376
2384
  params = this.omit(params, ['clOrdID', 'clientOrderId']);
2377
2385
  }
2378
- const stopPrice = this.safeString2(params, 'stopPx', 'stopPrice');
2386
+ const stopPrice = this.safeStringN(params, ['stopPx', 'stopPrice', 'triggerPrice']);
2379
2387
  if (stopPrice !== undefined) {
2380
2388
  if (market['settle'] === 'USDT') {
2381
2389
  request['stopPxRp'] = this.priceToPrecision(symbol, stopPrice);
@@ -2384,7 +2392,7 @@ class phemex extends phemex$1 {
2384
2392
  request['stopPxEp'] = this.toEp(stopPrice, market);
2385
2393
  }
2386
2394
  }
2387
- params = this.omit(params, ['stopPx', 'stopPrice', 'stopLoss', 'takeProfit']);
2395
+ params = this.omit(params, ['stopPx', 'stopPrice', 'stopLoss', 'takeProfit', 'triggerPrice']);
2388
2396
  if (market['spot']) {
2389
2397
  let qtyType = this.safeValue(params, 'qtyType', 'ByBase');
2390
2398
  if ((type === 'Market') || (type === 'Stop') || (type === 'MarketIfTouched')) {
@@ -2520,15 +2528,17 @@ class phemex extends phemex$1 {
2520
2528
  }
2521
2529
  params = this.omit(params, 'stopLossPrice');
2522
2530
  }
2523
- let method = 'privatePostSpotOrders';
2531
+ params = this.omit(params, 'reduceOnly');
2532
+ let response = undefined;
2524
2533
  if (market['settle'] === 'USDT') {
2525
- method = 'privatePostGOrders';
2534
+ response = await this.privatePostGOrders(this.extend(request, params));
2526
2535
  }
2527
2536
  else if (market['contract']) {
2528
- method = 'privatePostOrders';
2537
+ response = await this.privatePostOrders(this.extend(request, params));
2538
+ }
2539
+ else {
2540
+ response = await this.privatePostSpotOrders(this.extend(request, params));
2529
2541
  }
2530
- params = this.omit(params, 'reduceOnly');
2531
- const response = await this[method](this.extend(request, params));
2532
2542
  //
2533
2543
  // spot
2534
2544
  //
@@ -2670,18 +2680,20 @@ class phemex extends phemex$1 {
2670
2680
  }
2671
2681
  }
2672
2682
  params = this.omit(params, ['stopPx', 'stopPrice']);
2673
- let method = 'privatePutSpotOrders';
2683
+ let response = undefined;
2674
2684
  if (isUSDTSettled) {
2675
- method = 'privatePutGOrdersReplace';
2676
2685
  const posSide = this.safeString(params, 'posSide');
2677
2686
  if (posSide === undefined) {
2678
2687
  request['posSide'] = 'Merged';
2679
2688
  }
2689
+ response = await this.privatePutGOrdersReplace(this.extend(request, params));
2680
2690
  }
2681
2691
  else if (market['swap']) {
2682
- method = 'privatePutOrdersReplace';
2692
+ response = await this.privatePutOrdersReplace(this.extend(request, params));
2693
+ }
2694
+ else {
2695
+ response = await this.privatePutSpotOrders(this.extend(request, params));
2683
2696
  }
2684
- const response = await this[method](this.extend(request, params));
2685
2697
  const data = this.safeValue(response, 'data', {});
2686
2698
  return this.parseOrder(data, market);
2687
2699
  }
@@ -2713,18 +2725,20 @@ class phemex extends phemex$1 {
2713
2725
  else {
2714
2726
  request['orderID'] = id;
2715
2727
  }
2716
- let method = 'privateDeleteSpotOrders';
2728
+ let response = undefined;
2717
2729
  if (market['settle'] === 'USDT') {
2718
- method = 'privateDeleteGOrdersCancel';
2719
2730
  const posSide = this.safeString(params, 'posSide');
2720
2731
  if (posSide === undefined) {
2721
2732
  request['posSide'] = 'Merged';
2722
2733
  }
2734
+ response = await this.privateDeleteGOrdersCancel(this.extend(request, params));
2723
2735
  }
2724
2736
  else if (market['swap']) {
2725
- method = 'privateDeleteOrdersCancel';
2737
+ response = await this.privateDeleteOrdersCancel(this.extend(request, params));
2738
+ }
2739
+ else {
2740
+ response = await this.privateDeleteSpotOrders(this.extend(request, params));
2726
2741
  }
2727
- const response = await this[method](this.extend(request, params));
2728
2742
  const data = this.safeValue(response, 'data', {});
2729
2743
  return this.parseOrder(data, market);
2730
2744
  }
@@ -2742,21 +2756,23 @@ class phemex extends phemex$1 {
2742
2756
  throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
2743
2757
  }
2744
2758
  await this.loadMarkets();
2759
+ const market = this.market(symbol);
2745
2760
  const request = {
2746
- // 'symbol': market['id'],
2747
- // 'untriggerred': false, // false to cancel non-conditional orders, true to cancel conditional orders
2748
- // 'text': 'up to 40 characters max',
2761
+ 'symbol': market['id'],
2762
+ // 'untriggerred': false, // false to cancel non-conditional orders, true to cancel conditional orders
2763
+ // 'text': 'up to 40 characters max',
2749
2764
  };
2750
- const market = this.market(symbol);
2751
- let method = 'privateDeleteSpotOrdersAll';
2765
+ let response = undefined;
2752
2766
  if (market['settle'] === 'USDT') {
2753
- method = 'privateDeleteGOrdersAll';
2767
+ response = await this.privateDeleteGOrdersAll(this.extend(request, params));
2754
2768
  }
2755
2769
  else if (market['swap']) {
2756
- method = 'privateDeleteOrdersAll';
2770
+ response = await this.privateDeleteOrdersAll(this.extend(request, params));
2757
2771
  }
2758
- request['symbol'] = market['id'];
2759
- return await this[method](this.extend(request, params));
2772
+ else {
2773
+ response = await this.privateDeleteSpotOrdersAll(this.extend(request, params));
2774
+ }
2775
+ return response;
2760
2776
  }
2761
2777
  async fetchOrder(id, symbol = undefined, params = {}) {
2762
2778
  /**
@@ -2775,7 +2791,6 @@ class phemex extends phemex$1 {
2775
2791
  if (market['settle'] === 'USDT') {
2776
2792
  throw new errors.NotSupported(this.id + 'fetchOrder() is not supported yet for USDT settled swap markets'); // https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-user-order-by-orderid-or-query-user-order-by-client-order-id
2777
2793
  }
2778
- const method = market['spot'] ? 'privateGetSpotOrdersActive' : 'privateGetExchangeOrder';
2779
2794
  const request = {
2780
2795
  'symbol': market['id'],
2781
2796
  };
@@ -2787,7 +2802,13 @@ class phemex extends phemex$1 {
2787
2802
  else {
2788
2803
  request['orderID'] = id;
2789
2804
  }
2790
- const response = await this[method](this.extend(request, params));
2805
+ let response = undefined;
2806
+ if (market['spot']) {
2807
+ response = await this.privateGetSpotOrdersActive(this.extend(request, params));
2808
+ }
2809
+ else {
2810
+ response = await this.privateGetExchangeOrder(this.extend(request, params));
2811
+ }
2791
2812
  const data = this.safeValue(response, 'data', {});
2792
2813
  let order = data;
2793
2814
  if (Array.isArray(data)) {
@@ -2824,21 +2845,23 @@ class phemex extends phemex$1 {
2824
2845
  const request = {
2825
2846
  'symbol': market['id'],
2826
2847
  };
2827
- let method = 'privateGetSpotOrders';
2828
- if (market['settle'] === 'USDT') {
2829
- request['currency'] = market['settle'];
2830
- method = 'privateGetExchangeOrderV2OrderList';
2831
- }
2832
- else if (market['swap']) {
2833
- method = 'privateGetExchangeOrderList';
2834
- }
2835
2848
  if (since !== undefined) {
2836
2849
  request['start'] = since;
2837
2850
  }
2838
2851
  if (limit !== undefined) {
2839
2852
  request['limit'] = limit;
2840
2853
  }
2841
- const response = await this[method](this.extend(request, params));
2854
+ let response = undefined;
2855
+ if (market['settle'] === 'USDT') {
2856
+ request['currency'] = market['settle'];
2857
+ response = await this.privateGetExchangeOrderV2OrderList(this.extend(request, params));
2858
+ }
2859
+ else if (market['swap']) {
2860
+ response = await this.privateGetExchangeOrderList(this.extend(request, params));
2861
+ }
2862
+ else {
2863
+ response = await this.privateGetSpotOrders(this.extend(request, params));
2864
+ }
2842
2865
  const data = this.safeValue(response, 'data', {});
2843
2866
  const rows = this.safeValue(data, 'rows', data);
2844
2867
  return this.parseOrders(rows, market, since, limit);
@@ -2861,19 +2884,20 @@ class phemex extends phemex$1 {
2861
2884
  }
2862
2885
  await this.loadMarkets();
2863
2886
  const market = this.market(symbol);
2864
- let method = 'privateGetSpotOrders';
2865
- if (market['settle'] === 'USDT') {
2866
- method = 'privateGetGOrdersActiveList';
2867
- }
2868
- else if (market['swap']) {
2869
- method = 'privateGetOrdersActiveList';
2870
- }
2871
2887
  const request = {
2872
2888
  'symbol': market['id'],
2873
2889
  };
2874
2890
  let response = undefined;
2875
2891
  try {
2876
- response = await this[method](this.extend(request, params));
2892
+ if (market['settle'] === 'USDT') {
2893
+ response = await this.privateGetGOrdersActiveList(this.extend(request, params));
2894
+ }
2895
+ else if (market['swap']) {
2896
+ response = await this.privateGetOrdersActiveList(this.extend(request, params));
2897
+ }
2898
+ else {
2899
+ response = await this.privateGetSpotOrders(this.extend(request, params));
2900
+ }
2877
2901
  }
2878
2902
  catch (e) {
2879
2903
  if (e instanceof errors.OrderNotFound) {
@@ -2910,21 +2934,23 @@ class phemex extends phemex$1 {
2910
2934
  const request = {
2911
2935
  'symbol': market['id'],
2912
2936
  };
2913
- let method = 'privateGetExchangeSpotOrder';
2914
- if (market['settle'] === 'USDT') {
2915
- request['currency'] = market['settle'];
2916
- method = 'privateGetExchangeOrderV2OrderList';
2917
- }
2918
- else if (market['swap']) {
2919
- method = 'privateGetExchangeOrderList';
2920
- }
2921
2937
  if (since !== undefined) {
2922
2938
  request['start'] = since;
2923
2939
  }
2924
2940
  if (limit !== undefined) {
2925
2941
  request['limit'] = limit;
2926
2942
  }
2927
- const response = await this[method](this.extend(request, params));
2943
+ let response = undefined;
2944
+ if (market['settle'] === 'USDT') {
2945
+ request['currency'] = market['settle'];
2946
+ response = await this.privateGetExchangeOrderV2OrderList(this.extend(request, params));
2947
+ }
2948
+ else if (market['swap']) {
2949
+ response = await this.privateGetExchangeOrderList(this.extend(request, params));
2950
+ }
2951
+ else {
2952
+ response = await this.privateGetExchangeSpotOrder(this.extend(request, params));
2953
+ }
2928
2954
  //
2929
2955
  // spot
2930
2956
  //
@@ -2988,13 +3014,6 @@ class phemex extends phemex$1 {
2988
3014
  }
2989
3015
  await this.loadMarkets();
2990
3016
  const market = this.market(symbol);
2991
- let method = 'privateGetExchangeSpotOrderTrades';
2992
- if (market['swap']) {
2993
- method = 'privateGetExchangeOrderTrade';
2994
- if (market['settle'] === 'USDT') {
2995
- method = 'privateGetExchangeOrderV2TradingList';
2996
- }
2997
- }
2998
3017
  const request = {};
2999
3018
  if (limit !== undefined) {
3000
3019
  limit = Math.min(200, limit);
@@ -3016,7 +3035,19 @@ class phemex extends phemex$1 {
3016
3035
  if (market['swap'] && (limit !== undefined)) {
3017
3036
  request['limit'] = limit;
3018
3037
  }
3019
- const response = await this[method](this.extend(request, params));
3038
+ const isUSDTSettled = market['settle'] === 'USDT';
3039
+ let response = undefined;
3040
+ if (market['swap']) {
3041
+ if (isUSDTSettled) {
3042
+ response = await this.privateGetExchangeOrderV2TradingList(this.extend(request, params));
3043
+ }
3044
+ else {
3045
+ response = await this.privateGetExchangeOrderTrade(this.extend(request, params));
3046
+ }
3047
+ }
3048
+ else {
3049
+ response = await this.privateGetExchangeSpotOrderTrades(this.extend(request, params));
3050
+ }
3020
3051
  //
3021
3052
  // spot
3022
3053
  //
@@ -3121,10 +3152,13 @@ class phemex extends phemex$1 {
3121
3152
  // }
3122
3153
  // }
3123
3154
  //
3124
- const data = this.safeValue(response, 'data', {});
3125
- if (method !== 'privateGetExchangeOrderV2TradingList') {
3126
- const rows = this.safeValue(data, 'rows', []);
3127
- return this.parseTrades(rows, market, since, limit);
3155
+ let data = undefined;
3156
+ if (isUSDTSettled) {
3157
+ data = this.safeValue(response, 'data', []);
3158
+ }
3159
+ else {
3160
+ data = this.safeValue(response, 'data', {});
3161
+ data = this.safeValue(data, 'rows', []);
3128
3162
  }
3129
3163
  return this.parseTrades(data, market, since, limit);
3130
3164
  }
@@ -3356,7 +3390,6 @@ class phemex extends phemex$1 {
3356
3390
  await this.loadMarkets();
3357
3391
  symbols = this.marketSymbols(symbols);
3358
3392
  let subType = undefined;
3359
- let method = 'privateGetAccountsAccountPositions';
3360
3393
  let code = this.safeString(params, 'currency');
3361
3394
  let settle = undefined;
3362
3395
  let market = undefined;
@@ -3370,9 +3403,9 @@ class phemex extends phemex$1 {
3370
3403
  [settle, params] = this.handleOptionAndParams(params, 'fetchPositions', 'settle', 'USD');
3371
3404
  }
3372
3405
  [subType, params] = this.handleSubTypeAndParams('fetchPositions', market, params);
3373
- if (settle === 'USDT') {
3406
+ const isUSDTSettled = settle === 'USDT';
3407
+ if (isUSDTSettled) {
3374
3408
  code = 'USDT';
3375
- method = 'privateGetGAccountsAccountPositions';
3376
3409
  }
3377
3410
  else if (code === undefined) {
3378
3411
  code = (subType === 'linear') ? 'USD' : 'BTC';
@@ -3384,7 +3417,13 @@ class phemex extends phemex$1 {
3384
3417
  const request = {
3385
3418
  'currency': currency['id'],
3386
3419
  };
3387
- const response = await this[method](this.extend(request, params));
3420
+ let response = undefined;
3421
+ if (isUSDTSettled) {
3422
+ response = await this.privateGetGAccountsAccountPositions(this.extend(request, params));
3423
+ }
3424
+ else {
3425
+ response = await this.privateGetAccountsAccountPositions(this.extend(request, params));
3426
+ }
3388
3427
  //
3389
3428
  // {
3390
3429
  // "code":0,"msg":"",