ccxt 4.1.63 → 4.1.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +2769 -2653
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ace.js +13 -13
  6. package/dist/cjs/src/alpaca.js +10 -10
  7. package/dist/cjs/src/ascendex.js +33 -33
  8. package/dist/cjs/src/base/Exchange.js +6 -6
  9. package/dist/cjs/src/bigone.js +23 -23
  10. package/dist/cjs/src/binance.js +68 -68
  11. package/dist/cjs/src/binanceus.js +33 -3
  12. package/dist/cjs/src/bingx.js +33 -33
  13. package/dist/cjs/src/bit2c.js +11 -11
  14. package/dist/cjs/src/bitbank.js +14 -14
  15. package/dist/cjs/src/bitbns.js +15 -15
  16. package/dist/cjs/src/bitfinex.js +24 -24
  17. package/dist/cjs/src/bitfinex2.js +30 -30
  18. package/dist/cjs/src/bitflyer.js +17 -17
  19. package/dist/cjs/src/bitforex.js +12 -12
  20. package/dist/cjs/src/bitget.js +50 -50
  21. package/dist/cjs/src/bithumb.js +13 -13
  22. package/dist/cjs/src/bitmart.js +74 -59
  23. package/dist/cjs/src/bitmex.js +29 -28
  24. package/dist/cjs/src/bitopro.js +23 -23
  25. package/dist/cjs/src/bitpanda.js +25 -25
  26. package/dist/cjs/src/bitrue.js +26 -26
  27. package/dist/cjs/src/bitso.js +22 -22
  28. package/dist/cjs/src/bitstamp.js +24 -24
  29. package/dist/cjs/src/bittrex.js +31 -31
  30. package/dist/cjs/src/bitvavo.js +23 -23
  31. package/dist/cjs/src/bl3p.js +7 -7
  32. package/dist/cjs/src/blockchaincom.js +23 -23
  33. package/dist/cjs/src/btcalpha.js +17 -17
  34. package/dist/cjs/src/btcbox.js +9 -9
  35. package/dist/cjs/src/btcmarkets.js +19 -19
  36. package/dist/cjs/src/btcturk.js +13 -13
  37. package/dist/cjs/src/bybit.js +71 -67
  38. package/dist/cjs/src/cex.js +17 -17
  39. package/dist/cjs/src/coinbase.js +28 -28
  40. package/dist/cjs/src/coinbasepro.js +27 -27
  41. package/dist/cjs/src/coincheck.js +11 -11
  42. package/dist/cjs/src/coinex.js +42 -42
  43. package/dist/cjs/src/coinlist.js +29 -29
  44. package/dist/cjs/src/coinmate.js +14 -14
  45. package/dist/cjs/src/coinone.js +13 -13
  46. package/dist/cjs/src/coinsph.js +25 -25
  47. package/dist/cjs/src/coinspot.js +9 -9
  48. package/dist/cjs/src/cryptocom.js +33 -32
  49. package/dist/cjs/src/currencycom.js +24 -24
  50. package/dist/cjs/src/delta.js +29 -29
  51. package/dist/cjs/src/deribit.js +35 -35
  52. package/dist/cjs/src/digifinex.js +43 -43
  53. package/dist/cjs/src/exmo.js +30 -30
  54. package/dist/cjs/src/gate.js +39 -39
  55. package/dist/cjs/src/gemini.js +18 -18
  56. package/dist/cjs/src/hitbtc.js +40 -40
  57. package/dist/cjs/src/hollaex.js +26 -26
  58. package/dist/cjs/src/htx.js +48 -48
  59. package/dist/cjs/src/huobijp.js +24 -24
  60. package/dist/cjs/src/idex.js +23 -23
  61. package/dist/cjs/src/independentreserve.js +12 -12
  62. package/dist/cjs/src/indodax.js +16 -16
  63. package/dist/cjs/src/kraken.js +48 -30
  64. package/dist/cjs/src/krakenfutures.js +16 -16
  65. package/dist/cjs/src/kucoin.js +39 -39
  66. package/dist/cjs/src/kucoinfutures.js +24 -24
  67. package/dist/cjs/src/kuna.js +25 -25
  68. package/dist/cjs/src/latoken.js +20 -20
  69. package/dist/cjs/src/lbank.js +24 -24
  70. package/dist/cjs/src/luno.js +27 -28
  71. package/dist/cjs/src/lykke.js +18 -18
  72. package/dist/cjs/src/mercado.js +13 -13
  73. package/dist/cjs/src/mexc.js +47 -45
  74. package/dist/cjs/src/ndax.js +23 -23
  75. package/dist/cjs/src/novadax.js +23 -23
  76. package/dist/cjs/src/oceanex.js +19 -19
  77. package/dist/cjs/src/okcoin.js +25 -25
  78. package/dist/cjs/src/okx.js +53 -53
  79. package/dist/cjs/src/p2b.js +14 -14
  80. package/dist/cjs/src/paymium.js +10 -10
  81. package/dist/cjs/src/phemex.js +162 -123
  82. package/dist/cjs/src/poloniex.js +27 -27
  83. package/dist/cjs/src/poloniexfutures.js +21 -21
  84. package/dist/cjs/src/pro/alpaca.js +6 -6
  85. package/dist/cjs/src/pro/ascendex.js +5 -5
  86. package/dist/cjs/src/pro/binance.js +21 -21
  87. package/dist/cjs/src/pro/bingx.js +6 -6
  88. package/dist/cjs/src/pro/bitfinex.js +4 -4
  89. package/dist/cjs/src/pro/bitfinex2.js +7 -7
  90. package/dist/cjs/src/pro/bitget.js +12 -12
  91. package/dist/cjs/src/pro/bitmart.js +5 -5
  92. package/dist/cjs/src/pro/bitmex.js +8 -8
  93. package/dist/cjs/src/pro/bitopro.js +4 -4
  94. package/dist/cjs/src/pro/bitpanda.js +7 -7
  95. package/dist/cjs/src/pro/bitrue.js +2 -2
  96. package/dist/cjs/src/pro/bitstamp.js +3 -3
  97. package/dist/cjs/src/pro/bittrex.js +7 -7
  98. package/dist/cjs/src/pro/bitvavo.js +6 -6
  99. package/dist/cjs/src/pro/blockchaincom.js +6 -6
  100. package/dist/cjs/src/pro/bybit.js +12 -12
  101. package/dist/cjs/src/pro/cex.js +9 -9
  102. package/dist/cjs/src/pro/coinbase.js +6 -6
  103. package/dist/cjs/src/pro/coinbasepro.js +10 -10
  104. package/dist/cjs/src/pro/coinex.js +7 -7
  105. package/dist/cjs/src/pro/cryptocom.js +13 -13
  106. package/dist/cjs/src/pro/currencycom.js +5 -5
  107. package/dist/cjs/src/pro/deribit.js +7 -7
  108. package/dist/cjs/src/pro/exmo.js +5 -5
  109. package/dist/cjs/src/pro/gate.js +10 -10
  110. package/dist/cjs/src/pro/gemini.js +4 -4
  111. package/dist/cjs/src/pro/hitbtc.js +11 -11
  112. package/dist/cjs/src/pro/hollaex.js +5 -5
  113. package/dist/cjs/src/pro/htx.js +8 -8
  114. package/dist/cjs/src/pro/huobijp.js +4 -4
  115. package/dist/cjs/src/pro/idex.js +5 -5
  116. package/dist/cjs/src/pro/independentreserve.js +2 -2
  117. package/dist/cjs/src/pro/kraken.js +11 -11
  118. package/dist/cjs/src/pro/krakenfutures.js +12 -9
  119. package/dist/cjs/src/pro/kucoin.js +10 -10
  120. package/dist/cjs/src/pro/kucoinfutures.js +8 -8
  121. package/dist/cjs/src/pro/luno.js +4 -4
  122. package/dist/cjs/src/pro/mexc.js +7 -7
  123. package/dist/cjs/src/pro/ndax.js +4 -4
  124. package/dist/cjs/src/pro/okcoin.js +6 -6
  125. package/dist/cjs/src/pro/okx.js +16 -16
  126. package/dist/cjs/src/pro/phemex.js +7 -7
  127. package/dist/cjs/src/pro/poloniex.js +7 -7
  128. package/dist/cjs/src/pro/poloniexfutures.js +5 -5
  129. package/dist/cjs/src/pro/probit.js +6 -6
  130. package/dist/cjs/src/pro/upbit.js +3 -3
  131. package/dist/cjs/src/pro/wazirx.js +7 -7
  132. package/dist/cjs/src/pro/whitebit.js +7 -7
  133. package/dist/cjs/src/pro/woo.js +1 -1
  134. package/dist/cjs/src/probit.js +24 -24
  135. package/dist/cjs/src/tidex.js +15 -15
  136. package/dist/cjs/src/timex.js +19 -19
  137. package/dist/cjs/src/tokocrypto.js +22 -24
  138. package/dist/cjs/src/upbit.js +22 -22
  139. package/dist/cjs/src/wavesexchange.js +19 -19
  140. package/dist/cjs/src/wazirx.js +22 -16
  141. package/dist/cjs/src/whitebit.js +29 -29
  142. package/dist/cjs/src/woo.js +26 -26
  143. package/dist/cjs/src/yobit.js +17 -17
  144. package/dist/cjs/src/zaif.js +10 -10
  145. package/dist/cjs/src/zonda.js +16 -16
  146. package/doc/manual.rst +1 -1
  147. package/doc/readme.rst +1 -1
  148. package/js/ccxt.d.ts +1 -1
  149. package/js/ccxt.js +1 -1
  150. package/js/src/abstract/mexc.d.ts +2 -0
  151. package/js/src/ace.js +13 -13
  152. package/js/src/alpaca.js +10 -10
  153. package/js/src/ascendex.js +33 -33
  154. package/js/src/base/Exchange.js +6 -6
  155. package/js/src/bigone.js +23 -23
  156. package/js/src/binance.js +68 -68
  157. package/js/src/binanceus.js +33 -3
  158. package/js/src/bingx.js +33 -33
  159. package/js/src/bit2c.js +11 -11
  160. package/js/src/bitbank.js +14 -14
  161. package/js/src/bitbns.js +15 -15
  162. package/js/src/bitfinex.js +24 -24
  163. package/js/src/bitfinex2.js +30 -30
  164. package/js/src/bitflyer.js +17 -17
  165. package/js/src/bitforex.js +12 -12
  166. package/js/src/bitget.js +50 -50
  167. package/js/src/bithumb.js +13 -13
  168. package/js/src/bitmart.js +74 -59
  169. package/js/src/bitmex.js +29 -28
  170. package/js/src/bitopro.js +23 -23
  171. package/js/src/bitpanda.js +25 -25
  172. package/js/src/bitrue.js +26 -26
  173. package/js/src/bitso.js +22 -22
  174. package/js/src/bitstamp.js +24 -24
  175. package/js/src/bittrex.js +31 -31
  176. package/js/src/bitvavo.js +23 -23
  177. package/js/src/bl3p.js +7 -7
  178. package/js/src/blockchaincom.js +23 -23
  179. package/js/src/btcalpha.js +17 -17
  180. package/js/src/btcbox.js +9 -9
  181. package/js/src/btcmarkets.js +19 -19
  182. package/js/src/btcturk.js +13 -13
  183. package/js/src/bybit.js +71 -67
  184. package/js/src/cex.js +17 -17
  185. package/js/src/coinbase.js +28 -28
  186. package/js/src/coinbasepro.js +27 -27
  187. package/js/src/coincheck.js +11 -11
  188. package/js/src/coinex.js +42 -42
  189. package/js/src/coinlist.js +29 -29
  190. package/js/src/coinmate.js +14 -14
  191. package/js/src/coinone.js +13 -13
  192. package/js/src/coinsph.js +25 -25
  193. package/js/src/coinspot.js +9 -9
  194. package/js/src/cryptocom.js +33 -32
  195. package/js/src/currencycom.js +24 -24
  196. package/js/src/delta.js +29 -29
  197. package/js/src/deribit.js +35 -35
  198. package/js/src/digifinex.js +43 -43
  199. package/js/src/exmo.js +30 -30
  200. package/js/src/gate.js +39 -39
  201. package/js/src/gemini.js +18 -18
  202. package/js/src/hitbtc.js +40 -40
  203. package/js/src/hollaex.js +26 -26
  204. package/js/src/htx.js +48 -48
  205. package/js/src/huobijp.js +24 -24
  206. package/js/src/idex.js +23 -23
  207. package/js/src/independentreserve.js +12 -12
  208. package/js/src/indodax.js +16 -16
  209. package/js/src/kraken.js +48 -30
  210. package/js/src/krakenfutures.js +16 -16
  211. package/js/src/kucoin.js +39 -39
  212. package/js/src/kucoinfutures.js +24 -24
  213. package/js/src/kuna.js +25 -25
  214. package/js/src/latoken.js +20 -20
  215. package/js/src/lbank.js +24 -24
  216. package/js/src/luno.js +27 -28
  217. package/js/src/lykke.js +18 -18
  218. package/js/src/mercado.js +13 -13
  219. package/js/src/mexc.js +47 -45
  220. package/js/src/ndax.js +23 -23
  221. package/js/src/novadax.js +23 -23
  222. package/js/src/oceanex.js +19 -19
  223. package/js/src/okcoin.js +25 -25
  224. package/js/src/okx.js +53 -53
  225. package/js/src/p2b.js +14 -14
  226. package/js/src/paymium.js +10 -10
  227. package/js/src/phemex.js +162 -123
  228. package/js/src/poloniex.js +27 -27
  229. package/js/src/poloniexfutures.js +21 -21
  230. package/js/src/pro/alpaca.js +6 -6
  231. package/js/src/pro/ascendex.js +5 -5
  232. package/js/src/pro/binance.js +21 -21
  233. package/js/src/pro/bingx.js +6 -6
  234. package/js/src/pro/bitfinex.js +4 -4
  235. package/js/src/pro/bitfinex2.js +7 -7
  236. package/js/src/pro/bitget.js +12 -12
  237. package/js/src/pro/bitmart.js +5 -5
  238. package/js/src/pro/bitmex.js +8 -8
  239. package/js/src/pro/bitopro.js +4 -4
  240. package/js/src/pro/bitpanda.js +7 -7
  241. package/js/src/pro/bitrue.js +2 -2
  242. package/js/src/pro/bitstamp.js +3 -3
  243. package/js/src/pro/bittrex.js +7 -7
  244. package/js/src/pro/bitvavo.js +6 -6
  245. package/js/src/pro/blockchaincom.js +6 -6
  246. package/js/src/pro/bybit.js +12 -12
  247. package/js/src/pro/cex.js +9 -9
  248. package/js/src/pro/coinbase.js +6 -6
  249. package/js/src/pro/coinbasepro.js +10 -10
  250. package/js/src/pro/coinex.js +7 -7
  251. package/js/src/pro/cryptocom.js +13 -13
  252. package/js/src/pro/currencycom.js +5 -5
  253. package/js/src/pro/deribit.js +7 -7
  254. package/js/src/pro/exmo.js +5 -5
  255. package/js/src/pro/gate.js +10 -10
  256. package/js/src/pro/gemini.js +4 -4
  257. package/js/src/pro/hitbtc.js +11 -11
  258. package/js/src/pro/hollaex.js +5 -5
  259. package/js/src/pro/htx.js +8 -8
  260. package/js/src/pro/huobijp.js +4 -4
  261. package/js/src/pro/idex.js +5 -5
  262. package/js/src/pro/independentreserve.js +2 -2
  263. package/js/src/pro/kraken.js +11 -11
  264. package/js/src/pro/krakenfutures.js +12 -9
  265. package/js/src/pro/kucoin.js +10 -10
  266. package/js/src/pro/kucoinfutures.js +8 -8
  267. package/js/src/pro/luno.js +4 -4
  268. package/js/src/pro/mexc.js +7 -7
  269. package/js/src/pro/ndax.js +4 -4
  270. package/js/src/pro/okcoin.js +6 -6
  271. package/js/src/pro/okx.js +16 -16
  272. package/js/src/pro/phemex.js +7 -7
  273. package/js/src/pro/poloniex.js +7 -7
  274. package/js/src/pro/poloniexfutures.js +5 -5
  275. package/js/src/pro/probit.js +6 -6
  276. package/js/src/pro/upbit.js +3 -3
  277. package/js/src/pro/wazirx.js +7 -7
  278. package/js/src/pro/whitebit.js +7 -7
  279. package/js/src/pro/woo.js +1 -1
  280. package/js/src/probit.js +24 -24
  281. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  282. package/js/src/tidex.js +15 -15
  283. package/js/src/timex.js +19 -19
  284. package/js/src/tokocrypto.js +22 -24
  285. package/js/src/upbit.js +22 -22
  286. package/js/src/wavesexchange.js +19 -19
  287. package/js/src/wazirx.js +22 -16
  288. package/js/src/whitebit.js +29 -29
  289. package/js/src/woo.js +26 -26
  290. package/js/src/yobit.js +17 -17
  291. package/js/src/zaif.js +10 -10
  292. package/js/src/zonda.js +16 -16
  293. package/package.json +1 -1
@@ -710,7 +710,7 @@ class phemex extends phemex$1 {
710
710
  * @method
711
711
  * @name phemex#fetchMarkets
712
712
  * @description retrieves data on all markets for phemex
713
- * @param {object} [params] extra parameters specific to the exchange api endpoint
713
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
714
714
  * @returns {object[]} an array of objects representing market data
715
715
  */
716
716
  const v2Products = await this.publicGetCfgV2Products(params);
@@ -870,7 +870,7 @@ class phemex extends phemex$1 {
870
870
  * @method
871
871
  * @name phemex#fetchCurrencies
872
872
  * @description fetches all available currencies on an exchange
873
- * @param {object} [params] extra parameters specific to the phemex api endpoint
873
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
874
874
  * @returns {object} an associative dictionary of currencies
875
875
  */
876
876
  const response = await this.publicGetCfgV2Products(params);
@@ -977,7 +977,7 @@ class phemex extends phemex$1 {
977
977
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#queryorderbook
978
978
  * @param {string} symbol unified symbol of the market to fetch the order book for
979
979
  * @param {int} [limit] the maximum amount of order book entries to return
980
- * @param {object} [params] extra parameters specific to the phemex api endpoint
980
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
981
981
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
982
982
  */
983
983
  await this.loadMarkets();
@@ -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,
@@ -1111,7 +1113,7 @@ class phemex extends phemex$1 {
1111
1113
  * @param {string} timeframe the length of time each candle represents
1112
1114
  * @param {int} [since] *only used for USDT settled contracts, otherwise is emulated and not supported by the exchange* timestamp in ms of the earliest candle to fetch
1113
1115
  * @param {int} [limit] the maximum amount of candles to fetch
1114
- * @param {object} [params] extra parameters specific to the phemex api endpoint
1116
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1115
1117
  * @param {int} [params.until] *USDT settled/ linear swaps only* end time in ms
1116
1118
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1117
1119
  */
@@ -1286,7 +1288,7 @@ class phemex extends phemex$1 {
1286
1288
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1287
1289
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query24hrsticker
1288
1290
  * @param {string} symbol unified symbol of the market to fetch the ticker for
1289
- * @param {object} [params] extra parameters specific to the phemex api endpoint
1291
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1290
1292
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1291
1293
  */
1292
1294
  await this.loadMarkets();
@@ -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
  //
@@ -1356,12 +1360,12 @@ class phemex extends phemex$1 {
1356
1360
  /**
1357
1361
  * @method
1358
1362
  * @name phemex#fetchTickers
1359
- * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1363
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1360
1364
  * @see https://phemex-docs.github.io/#query-24-hours-ticker-for-all-symbols-2 // spot
1361
1365
  * @see https://phemex-docs.github.io/#query-24-ticker-for-all-symbols // linear
1362
1366
  * @see https://phemex-docs.github.io/#query-24-hours-ticker-for-all-symbols // inverse
1363
1367
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1364
- * @param {object} [params] extra parameters specific to the phemex api endpoint
1368
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1365
1369
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1366
1370
  */
1367
1371
  await this.loadMarkets();
@@ -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
  }
@@ -1399,7 +1401,7 @@ class phemex extends phemex$1 {
1399
1401
  * @param {string} symbol unified symbol of the market to fetch trades for
1400
1402
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1401
1403
  * @param {int} [limit] the maximum amount of trades to fetch
1402
- * @param {object} [params] extra parameters specific to the phemex api endpoint
1404
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1403
1405
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1404
1406
  */
1405
1407
  await this.loadMarkets();
@@ -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,
@@ -1808,19 +1812,21 @@ class phemex extends phemex$1 {
1808
1812
  * @name phemex#fetchBalance
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
- * @param {object} [params] extra parameters specific to the phemex api endpoint
1815
+ * @param {object} [params] extra parameters specific to the exchange 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
  // {
@@ -2320,7 +2328,7 @@ class phemex extends phemex$1 {
2320
2328
  * @param {string} side 'buy' or 'sell'
2321
2329
  * @param {float} amount how much of currency you want to trade in units of base currency
2322
2330
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2323
- * @param {object} [params] extra parameters specific to the phemex api endpoint
2331
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2324
2332
  * @param {object} [params.takeProfit] *swap only* *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
2325
2333
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
2326
2334
  * @param {object} [params.stopLoss] *swap only* *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
@@ -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
  //
@@ -2620,7 +2630,7 @@ class phemex extends phemex$1 {
2620
2630
  * @param {string} side 'buy' or 'sell'
2621
2631
  * @param {float} amount how much of currency you want to trade in units of base currency
2622
2632
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
2623
- * @param {object} [params] extra parameters specific to the phemex api endpoint
2633
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2624
2634
  * @param {string} [params.posSide] either 'Merged' or 'Long' or 'Short'
2625
2635
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2626
2636
  */
@@ -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
  }
@@ -2693,7 +2705,7 @@ class phemex extends phemex$1 {
2693
2705
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#cancel-single-order-by-orderid
2694
2706
  * @param {string} id order id
2695
2707
  * @param {string} symbol unified symbol of the market the order was made in
2696
- * @param {object} [params] extra parameters specific to the phemex api endpoint
2708
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2697
2709
  * @param {string} [params.posSide] either 'Merged' or 'Long' or 'Short'
2698
2710
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2699
2711
  */
@@ -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
  }
@@ -2735,28 +2749,30 @@ class phemex extends phemex$1 {
2735
2749
  * @description cancel all open orders in a market
2736
2750
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#cancelall
2737
2751
  * @param {string} symbol unified market symbol of the market to cancel orders in
2738
- * @param {object} [params] extra parameters specific to the phemex api endpoint
2752
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2739
2753
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2740
2754
  */
2741
2755
  if (symbol === undefined) {
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
  /**
@@ -2764,7 +2780,7 @@ class phemex extends phemex$1 {
2764
2780
  * @name phemex#fetchOrder
2765
2781
  * @description fetches information on an order made by the user
2766
2782
  * @param {string} symbol unified symbol of the market the order was made in
2767
- * @param {object} [params] extra parameters specific to the phemex api endpoint
2783
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2768
2784
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2769
2785
  */
2770
2786
  if (symbol === undefined) {
@@ -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)) {
@@ -2813,7 +2834,7 @@ class phemex extends phemex$1 {
2813
2834
  * @param {string} symbol unified market symbol of the market orders were made in
2814
2835
  * @param {int} [since] the earliest time in ms to fetch orders for
2815
2836
  * @param {int} [limit] the maximum number of order structures to retrieve
2816
- * @param {object} [params] extra parameters specific to the phemex api endpoint
2837
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2817
2838
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2818
2839
  */
2819
2840
  if (symbol === undefined) {
@@ -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);
@@ -2853,7 +2876,7 @@ class phemex extends phemex$1 {
2853
2876
  * @param {string} symbol unified market symbol
2854
2877
  * @param {int} [since] the earliest time in ms to fetch open orders for
2855
2878
  * @param {int} [limit] the maximum number of open order structures to retrieve
2856
- * @param {object} [params] extra parameters specific to the phemex api endpoint
2879
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2857
2880
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2858
2881
  */
2859
2882
  if (symbol === undefined) {
@@ -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) {
@@ -2899,7 +2923,7 @@ class phemex extends phemex$1 {
2899
2923
  * @param {string} symbol unified market symbol of the market orders were made in
2900
2924
  * @param {int} [since] the earliest time in ms to fetch orders for
2901
2925
  * @param {int} [limit] the maximum number of order structures to retrieve
2902
- * @param {object} [params] extra parameters specific to the phemex api endpoint
2926
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2903
2927
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2904
2928
  */
2905
2929
  if (symbol === undefined) {
@@ -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
  //
@@ -2980,7 +3006,7 @@ class phemex extends phemex$1 {
2980
3006
  * @param {string} symbol unified market symbol
2981
3007
  * @param {int} [since] the earliest time in ms to fetch trades for
2982
3008
  * @param {int} [limit] the maximum number of trades structures to retrieve
2983
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3009
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2984
3010
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2985
3011
  */
2986
3012
  if (symbol === undefined) {
@@ -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
  }
@@ -3134,7 +3168,7 @@ class phemex extends phemex$1 {
3134
3168
  * @name phemex#fetchDepositAddress
3135
3169
  * @description fetch the deposit address for a currency associated with this account
3136
3170
  * @param {string} code unified currency code
3137
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3171
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3138
3172
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3139
3173
  */
3140
3174
  await this.loadMarkets();
@@ -3184,7 +3218,7 @@ class phemex extends phemex$1 {
3184
3218
  * @param {string} code unified currency code
3185
3219
  * @param {int} [since] the earliest time in ms to fetch deposits for
3186
3220
  * @param {int} [limit] the maximum number of deposits structures to retrieve
3187
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3221
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3188
3222
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3189
3223
  */
3190
3224
  await this.loadMarkets();
@@ -3224,7 +3258,7 @@ class phemex extends phemex$1 {
3224
3258
  * @param {string} code unified currency code
3225
3259
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
3226
3260
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
3227
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3261
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3228
3262
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
3229
3263
  */
3230
3264
  await this.loadMarkets();
@@ -3350,13 +3384,12 @@ class phemex extends phemex$1 {
3350
3384
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#query-trading-account-and-positions
3351
3385
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-account-positions
3352
3386
  * @param {string[]|undefined} symbols list of unified market symbols
3353
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3387
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3354
3388
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
3355
3389
  */
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":"",
@@ -3624,7 +3663,7 @@ class phemex extends phemex$1 {
3624
3663
  * @param {string} symbol unified market symbol
3625
3664
  * @param {int} [since] the earliest time in ms to fetch funding history for
3626
3665
  * @param {int} [limit] the maximum number of funding history structures to retrieve
3627
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3666
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3628
3667
  * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
3629
3668
  */
3630
3669
  if (symbol === undefined) {
@@ -3696,7 +3735,7 @@ class phemex extends phemex$1 {
3696
3735
  * @name phemex#fetchFundingRate
3697
3736
  * @description fetch the current funding rate
3698
3737
  * @param {string} symbol unified market symbol
3699
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3738
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3700
3739
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3701
3740
  */
3702
3741
  await this.loadMarkets();
@@ -3809,7 +3848,7 @@ class phemex extends phemex$1 {
3809
3848
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#assign-position-balance-in-isolated-marign-mode
3810
3849
  * @param {string} symbol unified market symbol of the market to set margin in
3811
3850
  * @param {float} amount the amount to set the margin to
3812
- * @param {object} [params] parameters specific to the phemex api endpoint
3851
+ * @param {object} [params] parameters specific to the exchange API endpoint
3813
3852
  * @returns {object} A [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
3814
3853
  */
3815
3854
  await this.loadMarkets();
@@ -3864,7 +3903,7 @@ class phemex extends phemex$1 {
3864
3903
  * @description set margin mode to 'cross' or 'isolated'
3865
3904
  * @param {string} marginMode 'cross' or 'isolated'
3866
3905
  * @param {string} symbol unified market symbol
3867
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3906
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3868
3907
  * @returns {object} response from the exchange
3869
3908
  */
3870
3909
  if (symbol === undefined) {
@@ -3900,7 +3939,7 @@ class phemex extends phemex$1 {
3900
3939
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#switch-position-mode-synchronously
3901
3940
  * @param {bool} hedged set to true to use dualSidePosition
3902
3941
  * @param {string} symbol not used by binance setPositionMode ()
3903
- * @param {object} [params] extra parameters specific to the binance api endpoint
3942
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3904
3943
  * @returns {object} response from the exchange
3905
3944
  */
3906
3945
  this.checkRequiredArgument('setPositionMode', symbol, 'symbol');
@@ -3926,7 +3965,7 @@ class phemex extends phemex$1 {
3926
3965
  * @name phemex#fetchLeverageTiers
3927
3966
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
3928
3967
  * @param {string[]|undefined} symbols list of unified market symbols
3929
- * @param {object} [params] extra parameters specific to the phemex api endpoint
3968
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3930
3969
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
3931
3970
  */
3932
3971
  await this.loadMarkets();
@@ -4097,7 +4136,7 @@ class phemex extends phemex$1 {
4097
4136
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#set-leverage
4098
4137
  * @param {float} leverage the rate of leverage
4099
4138
  * @param {string} symbol unified market symbol
4100
- * @param {object} [params] extra parameters specific to the phemex api endpoint
4139
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4101
4140
  * @param {bool} [params.hedged] set to true if hedged position mode is enabled (by default long and short leverage are set to the same value)
4102
4141
  * @param {float} [params.longLeverageRr] *hedged mode only* set the leverage for long positions
4103
4142
  * @param {float} [params.shortLeverageRr] *hedged mode only* set the leverage for short positions
@@ -4147,7 +4186,7 @@ class phemex extends phemex$1 {
4147
4186
  * @param {float} amount amount to transfer
4148
4187
  * @param {string} fromAccount account to transfer from
4149
4188
  * @param {string} toAccount account to transfer to
4150
- * @param {object} [params] extra parameters specific to the phemex api endpoint
4189
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4151
4190
  * @param {string} [params.bizType] for transferring between main and sub-acounts either 'SPOT' or 'PERPETUAL' default is 'SPOT'
4152
4191
  * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
4153
4192
  */
@@ -4233,7 +4272,7 @@ class phemex extends phemex$1 {
4233
4272
  * @param {string} code unified currency code of the currency transferred
4234
4273
  * @param {int} [since] the earliest time in ms to fetch transfers for
4235
4274
  * @param {int} [limit] the maximum number of transfers structures to retrieve
4236
- * @param {object} [params] extra parameters specific to the phemex api endpoint
4275
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4237
4276
  * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
4238
4277
  */
4239
4278
  await this.loadMarkets();
@@ -4349,7 +4388,7 @@ class phemex extends phemex$1 {
4349
4388
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
4350
4389
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
4351
4390
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
4352
- * @param {object} [params] extra parameters specific to the phemex api endpoint
4391
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4353
4392
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4354
4393
  * @param {int} [params.until] timestamp in ms of the latest funding rate
4355
4394
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}