ccxt 4.2.28 → 4.2.30

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 (158) hide show
  1. package/CONTRIBUTING.md +4 -1
  2. package/README.md +6 -6
  3. package/dist/ccxt.browser.js +1865 -558
  4. package/dist/ccxt.browser.min.js +7 -7
  5. package/dist/cjs/ccxt.js +3 -1
  6. package/dist/cjs/src/ascendex.js +5 -5
  7. package/dist/cjs/src/base/Exchange.js +114 -21
  8. package/dist/cjs/src/base/errors.js +3 -3
  9. package/dist/cjs/src/base/functions/type.js +12 -0
  10. package/dist/cjs/src/bigone.js +2 -2
  11. package/dist/cjs/src/binance.js +896 -217
  12. package/dist/cjs/src/bingx.js +1 -1
  13. package/dist/cjs/src/bitfinex.js +1 -1
  14. package/dist/cjs/src/bitfinex2.js +52 -62
  15. package/dist/cjs/src/bitget.js +8 -4
  16. package/dist/cjs/src/bitmart.js +3 -3
  17. package/dist/cjs/src/bitmex.js +9 -6
  18. package/dist/cjs/src/bitrue.js +1 -1
  19. package/dist/cjs/src/bitso.js +1 -1
  20. package/dist/cjs/src/bitteam.js +2 -2
  21. package/dist/cjs/src/btcalpha.js +1 -1
  22. package/dist/cjs/src/bybit.js +28 -12
  23. package/dist/cjs/src/coinbase.js +12 -5
  24. package/dist/cjs/src/coincheck.js +1 -1
  25. package/dist/cjs/src/coinex.js +2 -2
  26. package/dist/cjs/src/coinlist.js +1 -1
  27. package/dist/cjs/src/coinmate.js +1 -1
  28. package/dist/cjs/src/coinmetro.js +12 -6
  29. package/dist/cjs/src/coinsph.js +1 -1
  30. package/dist/cjs/src/cryptocom.js +3 -3
  31. package/dist/cjs/src/digifinex.js +6 -4
  32. package/dist/cjs/src/exmo.js +2 -2
  33. package/dist/cjs/src/gate.js +5 -5
  34. package/dist/cjs/src/gemini.js +3 -3
  35. package/dist/cjs/src/hitbtc.js +14 -20
  36. package/dist/cjs/src/hollaex.js +2 -2
  37. package/dist/cjs/src/htx.js +5 -5
  38. package/dist/cjs/src/huobijp.js +1 -1
  39. package/dist/cjs/src/krakenfutures.js +1 -1
  40. package/dist/cjs/src/kucoin.js +17 -17
  41. package/dist/cjs/src/kucoinfutures.js +3 -3
  42. package/dist/cjs/src/lbank.js +1 -1
  43. package/dist/cjs/src/mexc.js +7 -7
  44. package/dist/cjs/src/novadax.js +1 -1
  45. package/dist/cjs/src/okcoin.js +2 -2
  46. package/dist/cjs/src/okx.js +24 -10
  47. package/dist/cjs/src/p2b.js +1 -0
  48. package/dist/cjs/src/phemex.js +3 -3
  49. package/dist/cjs/src/poloniexfutures.js +3 -3
  50. package/dist/cjs/src/pro/alpaca.js +1 -1
  51. package/dist/cjs/src/pro/binance.js +4 -4
  52. package/dist/cjs/src/pro/bitget.js +1 -1
  53. package/dist/cjs/src/pro/bitmart.js +1 -1
  54. package/dist/cjs/src/pro/bitmex.js +49 -6
  55. package/dist/cjs/src/pro/bitvavo.js +1 -1
  56. package/dist/cjs/src/pro/bybit.js +2 -2
  57. package/dist/cjs/src/pro/cex.js +2 -2
  58. package/dist/cjs/src/pro/coinbase.js +1 -1
  59. package/dist/cjs/src/pro/independentreserve.js +1 -1
  60. package/dist/cjs/src/pro/okx.js +1 -1
  61. package/dist/cjs/src/pro/onetrading.js +2 -2
  62. package/dist/cjs/src/pro/p2b.js +432 -0
  63. package/dist/cjs/src/pro/probit.js +5 -5
  64. package/dist/cjs/src/pro/whitebit.js +1 -1
  65. package/dist/cjs/src/probit.js +1 -1
  66. package/dist/cjs/src/timex.js +1 -1
  67. package/dist/cjs/src/tokocrypto.js +3 -3
  68. package/dist/cjs/src/wavesexchange.js +2 -2
  69. package/dist/cjs/src/whitebit.js +2 -2
  70. package/dist/cjs/src/woo.js +3 -3
  71. package/dist/cjs/src/yobit.js +1 -1
  72. package/dist/cjs/src/zaif.js +1 -1
  73. package/dist/cjs/src/zonda.js +3 -3
  74. package/js/ccxt.d.ts +4 -1
  75. package/js/ccxt.js +3 -1
  76. package/js/src/abstract/bybit.d.ts +2 -2
  77. package/js/src/abstract/okx.d.ts +1 -0
  78. package/js/src/ascendex.js +5 -5
  79. package/js/src/base/Exchange.d.ts +10 -1
  80. package/js/src/base/Exchange.js +114 -21
  81. package/js/src/base/errorHierarchy.d.ts +7 -6
  82. package/js/src/base/errorHierarchy.js +7 -6
  83. package/js/src/base/errors.d.ts +3 -3
  84. package/js/src/base/errors.js +3 -3
  85. package/js/src/base/functions/type.js +12 -0
  86. package/js/src/bigone.js +2 -2
  87. package/js/src/binance.d.ts +1 -0
  88. package/js/src/binance.js +897 -218
  89. package/js/src/bingx.js +1 -1
  90. package/js/src/bitfinex.js +1 -1
  91. package/js/src/bitfinex2.js +52 -62
  92. package/js/src/bitget.js +8 -4
  93. package/js/src/bitmart.js +3 -3
  94. package/js/src/bitmex.js +9 -6
  95. package/js/src/bitrue.js +1 -1
  96. package/js/src/bitso.d.ts +1 -1
  97. package/js/src/bitso.js +1 -1
  98. package/js/src/bitteam.js +2 -2
  99. package/js/src/btcalpha.js +1 -1
  100. package/js/src/bybit.js +28 -12
  101. package/js/src/coinbase.js +12 -5
  102. package/js/src/coincheck.js +1 -1
  103. package/js/src/coinex.js +2 -2
  104. package/js/src/coinlist.js +1 -1
  105. package/js/src/coinmate.js +1 -1
  106. package/js/src/coinmetro.d.ts +1 -1
  107. package/js/src/coinmetro.js +12 -6
  108. package/js/src/coinsph.js +1 -1
  109. package/js/src/cryptocom.js +3 -3
  110. package/js/src/digifinex.js +6 -4
  111. package/js/src/exmo.js +2 -2
  112. package/js/src/gate.js +5 -5
  113. package/js/src/gemini.d.ts +1 -1
  114. package/js/src/gemini.js +3 -3
  115. package/js/src/hitbtc.js +14 -20
  116. package/js/src/hollaex.js +2 -2
  117. package/js/src/htx.js +5 -5
  118. package/js/src/huobijp.js +1 -1
  119. package/js/src/krakenfutures.js +1 -1
  120. package/js/src/kucoin.js +17 -17
  121. package/js/src/kucoinfutures.js +3 -3
  122. package/js/src/lbank.js +1 -1
  123. package/js/src/mexc.js +7 -7
  124. package/js/src/novadax.js +1 -1
  125. package/js/src/okcoin.js +2 -2
  126. package/js/src/okx.js +24 -10
  127. package/js/src/p2b.js +1 -0
  128. package/js/src/phemex.js +3 -3
  129. package/js/src/poloniexfutures.js +3 -3
  130. package/js/src/pro/alpaca.js +1 -1
  131. package/js/src/pro/binance.js +4 -4
  132. package/js/src/pro/bitget.js +1 -1
  133. package/js/src/pro/bitmart.js +1 -1
  134. package/js/src/pro/bitmex.d.ts +2 -1
  135. package/js/src/pro/bitmex.js +49 -6
  136. package/js/src/pro/bitvavo.js +1 -1
  137. package/js/src/pro/bybit.js +2 -2
  138. package/js/src/pro/cex.js +2 -2
  139. package/js/src/pro/coinbase.js +2 -2
  140. package/js/src/pro/independentreserve.js +1 -1
  141. package/js/src/pro/okx.js +1 -1
  142. package/js/src/pro/onetrading.js +2 -2
  143. package/js/src/pro/p2b.d.ts +23 -0
  144. package/js/src/pro/p2b.js +433 -0
  145. package/js/src/pro/probit.js +5 -5
  146. package/js/src/pro/whitebit.js +1 -1
  147. package/js/src/probit.js +1 -1
  148. package/js/src/timex.js +1 -1
  149. package/js/src/tokocrypto.js +3 -3
  150. package/js/src/wavesexchange.js +2 -2
  151. package/js/src/whitebit.js +2 -2
  152. package/js/src/woo.js +3 -3
  153. package/js/src/yobit.js +1 -1
  154. package/js/src/zaif.js +1 -1
  155. package/js/src/zonda.d.ts +1 -1
  156. package/js/src/zonda.js +3 -3
  157. package/package.json +1 -1
  158. package/skip-tests.json +3 -10
@@ -135,7 +135,7 @@ class coinmetro extends coinmetro$1 {
135
135
  'private': 'https://api.coinmetro.com',
136
136
  },
137
137
  'test': {
138
- 'public': 'https://api.coinmetro.com',
138
+ 'public': 'https://api.coinmetro.com/open',
139
139
  'private': 'https://api.coinmetro.com/open',
140
140
  },
141
141
  'www': 'https://coinmetro.com/',
@@ -377,7 +377,7 @@ class coinmetro extends coinmetro$1 {
377
377
  const quote = this.safeCurrencyCode(quoteId);
378
378
  const basePrecisionAndLimits = this.parseMarketPrecisionAndLimits(baseId);
379
379
  const quotePrecisionAndLimits = this.parseMarketPrecisionAndLimits(quoteId);
380
- const margin = this.safeValue(market, 'margin', false);
380
+ const margin = this.safeBool(market, 'margin', false);
381
381
  const tradingFees = this.safeValue(this.fees, 'trading', {});
382
382
  return this.safeMarketStructure({
383
383
  'id': id,
@@ -1336,7 +1336,7 @@ class coinmetro extends coinmetro$1 {
1336
1336
  };
1337
1337
  const marginMode = undefined;
1338
1338
  [params, params] = this.handleMarginModeAndParams('cancelOrder', params);
1339
- const isMargin = this.safeValue(params, 'margin', false);
1339
+ const isMargin = this.safeBool(params, 'margin', false);
1340
1340
  params = this.omit(params, 'margin');
1341
1341
  let response = undefined;
1342
1342
  if (isMargin || (marginMode !== undefined)) {
@@ -1854,11 +1854,17 @@ class coinmetro extends coinmetro$1 {
1854
1854
  const endpoint = '/' + this.implodeParams(path, params);
1855
1855
  let url = this.urls['api'][api] + endpoint;
1856
1856
  const query = this.urlencode(request);
1857
+ if (headers === undefined) {
1858
+ headers = {};
1859
+ }
1860
+ headers['CCXT'] = 'true';
1857
1861
  if (api === 'private') {
1858
- if (headers === undefined) {
1859
- headers = {};
1862
+ if ((this.uid === undefined) && (this.apiKey !== undefined)) {
1863
+ this.uid = this.apiKey;
1864
+ }
1865
+ if ((this.token === undefined) && (this.secret !== undefined)) {
1866
+ this.token = this.secret;
1860
1867
  }
1861
- headers['CCXT'] = true;
1862
1868
  if (url === 'https://api.coinmetro.com/jwt') { // handle with headers for login endpoint
1863
1869
  headers['X-Device-Id'] = 'bypass';
1864
1870
  if (this.twofa !== undefined) {
@@ -1559,7 +1559,7 @@ class coinsph extends coinsph$1 {
1559
1559
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1560
1560
  */
1561
1561
  const options = this.safeValue(this.options, 'withdraw');
1562
- const warning = this.safeValue(options, 'warning', true);
1562
+ const warning = this.safeBool(options, 'warning', true);
1563
1563
  if (warning) {
1564
1564
  throw new errors.InvalidAddress(this.id + " withdraw() makes a withdrawals only to coins_ph account, add .options['withdraw']['warning'] = false to make a withdrawal to your coins_ph account");
1565
1565
  }
@@ -1054,7 +1054,7 @@ class cryptocom extends cryptocom$1 {
1054
1054
  request['time_in_force'] = timeInForce;
1055
1055
  }
1056
1056
  }
1057
- const postOnly = this.safeValue(params, 'postOnly', false);
1057
+ const postOnly = this.safeBool(params, 'postOnly', false);
1058
1058
  if ((postOnly) || (timeInForce === 'PO')) {
1059
1059
  request['exec_inst'] = ['POST_ONLY'];
1060
1060
  request['time_in_force'] = 'GOOD_TILL_CANCEL';
@@ -1275,7 +1275,7 @@ class cryptocom extends cryptocom$1 {
1275
1275
  request['time_in_force'] = timeInForce;
1276
1276
  }
1277
1277
  }
1278
- const postOnly = this.safeValue(params, 'postOnly', false);
1278
+ const postOnly = this.safeBool(params, 'postOnly', false);
1279
1279
  if ((postOnly) || (timeInForce === 'PO')) {
1280
1280
  request['exec_inst'] = ['POST_ONLY'];
1281
1281
  request['time_in_force'] = 'GOOD_TILL_CANCEL';
@@ -2246,7 +2246,7 @@ class cryptocom extends cryptocom$1 {
2246
2246
  * @returns {Array} the marginMode in lowercase
2247
2247
  */
2248
2248
  const defaultType = this.safeString(this.options, 'defaultType');
2249
- const isMargin = this.safeValue(params, 'margin', false);
2249
+ const isMargin = this.safeBool(params, 'margin', false);
2250
2250
  params = this.omit(params, 'margin');
2251
2251
  let marginMode = undefined;
2252
2252
  [marginMode, params] = this.handleMarginModeAndParams(methodName, params);
@@ -1159,9 +1159,11 @@ class digifinex extends digifinex$1 {
1159
1159
  // "timestamp": 1663221614998
1160
1160
  // }
1161
1161
  //
1162
+ const indexPrice = this.safeNumber(ticker, 'index_price');
1163
+ const marketType = (indexPrice !== undefined) ? 'contract' : 'spot';
1162
1164
  const marketId = this.safeStringUpper2(ticker, 'symbol', 'instrument_id');
1163
- const symbol = this.safeSymbol(marketId, market);
1164
- market = this.safeMarket(marketId);
1165
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
1166
+ market = this.safeMarket(marketId, market, undefined, marketType);
1165
1167
  let timestamp = this.safeTimestamp(ticker, 'date');
1166
1168
  if (market['swap']) {
1167
1169
  timestamp = this.safeInteger(ticker, 'timestamp');
@@ -1748,7 +1750,7 @@ class digifinex extends digifinex$1 {
1748
1750
  let postOnly = this.isPostOnly(isMarketOrder, false, params);
1749
1751
  let postOnlyParsed = undefined;
1750
1752
  if (swap) {
1751
- const reduceOnly = this.safeValue(params, 'reduceOnly', false);
1753
+ const reduceOnly = this.safeBool(params, 'reduceOnly', false);
1752
1754
  const timeInForce = this.safeString(params, 'timeInForce');
1753
1755
  let orderType = undefined;
1754
1756
  if (side === 'buy') {
@@ -3921,7 +3923,7 @@ class digifinex extends digifinex$1 {
3921
3923
  * @returns {Array} the marginMode in lowercase
3922
3924
  */
3923
3925
  const defaultType = this.safeString(this.options, 'defaultType');
3924
- const isMargin = this.safeValue(params, 'margin', false);
3926
+ const isMargin = this.safeBool(params, 'margin', false);
3925
3927
  let marginMode = undefined;
3926
3928
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
3927
3929
  if (marginMode !== undefined) {
@@ -249,7 +249,7 @@ class exmo extends exmo$1 {
249
249
  //
250
250
  const margin = this.parseMarginModification(response, market);
251
251
  const options = this.safeValue(this.options, 'margin', {});
252
- const fillResponseFromRequest = this.safeValue(options, 'fillResponseFromRequest', true);
252
+ const fillResponseFromRequest = this.safeBool(options, 'fillResponseFromRequest', true);
253
253
  if (fillResponseFromRequest) {
254
254
  margin['type'] = type;
255
255
  margin['amount'] = amount;
@@ -2613,7 +2613,7 @@ class exmo extends exmo$1 {
2613
2613
  // {"result":false,"error":"Error 50052: Insufficient funds"}
2614
2614
  // {"s":"error","errmsg":"strconv.ParseInt: parsing \"\": invalid syntax"}
2615
2615
  //
2616
- let success = this.safeValue(response, 'result', false);
2616
+ let success = this.safeBool(response, 'result', false);
2617
2617
  if (typeof success === 'string') {
2618
2618
  if ((success === 'true') || (success === '1')) {
2619
2619
  success = true;
@@ -1589,9 +1589,9 @@ class gate extends gate$1 {
1589
1589
  const networkId = this.safeString(entry, 'chain');
1590
1590
  const networkCode = this.networkIdToCode(networkId, code);
1591
1591
  const delisted = this.safeValue(entry, 'delisted');
1592
- const withdrawDisabled = this.safeValue(entry, 'withdraw_disabled', false);
1593
- const depositDisabled = this.safeValue(entry, 'deposit_disabled', false);
1594
- const tradeDisabled = this.safeValue(entry, 'trade_disabled', false);
1592
+ const withdrawDisabled = this.safeBool(entry, 'withdraw_disabled', false);
1593
+ const depositDisabled = this.safeBool(entry, 'deposit_disabled', false);
1594
+ const tradeDisabled = this.safeBool(entry, 'trade_disabled', false);
1595
1595
  const withdrawEnabled = !withdrawDisabled;
1596
1596
  const depositEnabled = !depositDisabled;
1597
1597
  const tradeEnabled = !tradeDisabled;
@@ -4048,7 +4048,7 @@ class gate extends gate$1 {
4048
4048
  }
4049
4049
  }
4050
4050
  let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
4051
- const textIsRequired = this.safeValue(params, 'textIsRequired', false);
4051
+ const textIsRequired = this.safeBool(params, 'textIsRequired', false);
4052
4052
  if (clientOrderId !== undefined) {
4053
4053
  // user-defined, must follow the rules if not empty
4054
4054
  // prefixed with t-
@@ -4420,7 +4420,7 @@ class gate extends gate$1 {
4420
4420
  // "message": "Not enough balance"
4421
4421
  // }
4422
4422
  //
4423
- const succeeded = this.safeValue(order, 'succeeded', true);
4423
+ const succeeded = this.safeBool(order, 'succeeded', true);
4424
4424
  if (!succeeded) {
4425
4425
  // cancelOrders response
4426
4426
  return this.safeOrder({
@@ -512,7 +512,7 @@ class gemini extends gemini$1 {
512
512
  'post_only': true,
513
513
  'limit_only': true,
514
514
  };
515
- return this.safeValue(statuses, status, true);
515
+ return this.safeBool(statuses, status, true);
516
516
  }
517
517
  async fetchUSDTMarkets(params = {}) {
518
518
  // these markets can't be scrapped and fetchMarketsFrom api does an extra call
@@ -551,7 +551,7 @@ class gemini extends gemini$1 {
551
551
  result[marketId] = this.parseMarket(market);
552
552
  }
553
553
  const options = this.safeValue(this.options, 'fetchMarketsFromAPI', {});
554
- const fetchDetailsForAllSymbols = this.safeValue(options, 'fetchDetailsForAllSymbols', false);
554
+ const fetchDetailsForAllSymbols = this.safeBool(options, 'fetchDetailsForAllSymbols', false);
555
555
  const fetchDetailsForMarketIds = this.safeValue(options, 'fetchDetailsForMarketIds', []);
556
556
  let promises = [];
557
557
  let marketIds = [];
@@ -1368,7 +1368,7 @@ class gemini extends gemini$1 {
1368
1368
  request['options'] = ['maker-or-cancel'];
1369
1369
  }
1370
1370
  }
1371
- const postOnly = this.safeValue(params, 'postOnly', false);
1371
+ const postOnly = this.safeBool(params, 'postOnly', false);
1372
1372
  params = this.omit(params, 'postOnly');
1373
1373
  if (postOnly) {
1374
1374
  request['options'] = ['maker-or-cancel'];
@@ -690,7 +690,7 @@ class hitbtc extends hitbtc$1 {
690
690
  const expiry = this.safeInteger(market, 'expiry');
691
691
  const contract = (marketType === 'futures');
692
692
  const spot = (marketType === 'spot');
693
- const marginTrading = this.safeValue(market, 'margin_trading', false);
693
+ const marginTrading = this.safeBool(market, 'margin_trading', false);
694
694
  const margin = spot && marginTrading;
695
695
  const future = (expiry !== undefined);
696
696
  const swap = (contract && !future);
@@ -825,9 +825,9 @@ class hitbtc extends hitbtc$1 {
825
825
  const entry = response[currencyId];
826
826
  const name = this.safeString(entry, 'full_name');
827
827
  const precision = this.safeNumber(entry, 'precision_transfer');
828
- const payinEnabled = this.safeValue(entry, 'payin_enabled', false);
829
- const payoutEnabled = this.safeValue(entry, 'payout_enabled', false);
830
- const transferEnabled = this.safeValue(entry, 'transfer_enabled', false);
828
+ const payinEnabled = this.safeBool(entry, 'payin_enabled', false);
829
+ const payoutEnabled = this.safeBool(entry, 'payout_enabled', false);
830
+ const transferEnabled = this.safeBool(entry, 'transfer_enabled', false);
831
831
  const active = payinEnabled && payoutEnabled && transferEnabled;
832
832
  const rawNetworks = this.safeValue(entry, 'networks', []);
833
833
  const networks = {};
@@ -840,8 +840,8 @@ class hitbtc extends hitbtc$1 {
840
840
  const network = this.safeNetwork(networkId);
841
841
  fee = this.safeNumber(rawNetwork, 'payout_fee');
842
842
  const networkPrecision = this.safeNumber(rawNetwork, 'precision_payout');
843
- const payinEnabledNetwork = this.safeValue(entry, 'payin_enabled', false);
844
- const payoutEnabledNetwork = this.safeValue(entry, 'payout_enabled', false);
843
+ const payinEnabledNetwork = this.safeBool(entry, 'payin_enabled', false);
844
+ const payoutEnabledNetwork = this.safeBool(entry, 'payout_enabled', false);
845
845
  const activeNetwork = payinEnabledNetwork && payoutEnabledNetwork;
846
846
  if (payinEnabledNetwork && !depositEnabled) {
847
847
  depositEnabled = true;
@@ -2705,7 +2705,7 @@ class hitbtc extends hitbtc$1 {
2705
2705
  params = this.omit(params, 'network');
2706
2706
  }
2707
2707
  const withdrawOptions = this.safeValue(this.options, 'withdraw', {});
2708
- const includeFee = this.safeValue(withdrawOptions, 'includeFee', false);
2708
+ const includeFee = this.safeBool(withdrawOptions, 'includeFee', false);
2709
2709
  if (includeFee) {
2710
2710
  request['include_fee'] = true;
2711
2711
  }
@@ -3227,7 +3227,7 @@ class hitbtc extends hitbtc$1 {
3227
3227
  await this.loadMarkets();
3228
3228
  const market = this.market(symbol);
3229
3229
  const leverage = this.safeString(params, 'leverage');
3230
- if (market['type'] === 'swap') {
3230
+ if (market['swap']) {
3231
3231
  if (leverage === undefined) {
3232
3232
  throw new errors.ArgumentsRequired(this.id + ' modifyMarginHelper() requires a leverage parameter for swap markets');
3233
3233
  }
@@ -3251,21 +3251,15 @@ class hitbtc extends hitbtc$1 {
3251
3251
  let marginMode = undefined;
3252
3252
  [marketType, params] = this.handleMarketTypeAndParams('modifyMarginHelper', market, params);
3253
3253
  [marginMode, params] = this.handleMarginModeAndParams('modifyMarginHelper', params);
3254
- params = this.omit(params, ['marginMode', 'margin']);
3255
3254
  let response = undefined;
3256
- if (marginMode !== undefined) {
3255
+ if (marketType === 'swap') {
3256
+ response = await this.privatePutFuturesAccountIsolatedSymbol(this.extend(request, params));
3257
+ }
3258
+ else if ((marketType === 'margin') || (marketType === 'spot') || (marginMode === 'isolated')) {
3257
3259
  response = await this.privatePutMarginAccountIsolatedSymbol(this.extend(request, params));
3258
3260
  }
3259
3261
  else {
3260
- if (marketType === 'swap') {
3261
- response = await this.privatePutFuturesAccountIsolatedSymbol(this.extend(request, params));
3262
- }
3263
- else if (marketType === 'margin') {
3264
- response = await this.privatePutMarginAccountIsolatedSymbol(this.extend(request, params));
3265
- }
3266
- else {
3267
- throw new errors.NotSupported(this.id + ' modifyMarginHelper() not support this market type');
3268
- }
3262
+ throw new errors.NotSupported(this.id + ' modifyMarginHelper() not support this market type');
3269
3263
  }
3270
3264
  //
3271
3265
  // {
@@ -3577,7 +3571,7 @@ class hitbtc extends hitbtc$1 {
3577
3571
  * @returns {Array} the marginMode in lowercase
3578
3572
  */
3579
3573
  const defaultType = this.safeString(this.options, 'defaultType');
3580
- const isMargin = this.safeValue(params, 'margin', false);
3574
+ const isMargin = this.safeBool(params, 'margin', false);
3581
3575
  let marginMode = undefined;
3582
3576
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
3583
3577
  if (marginMode === undefined) {
@@ -1091,7 +1091,7 @@ class hollaex extends hollaex$1 {
1091
1091
  const filled = this.safeString(order, 'filled');
1092
1092
  const status = this.parseOrderStatus(this.safeString(order, 'status'));
1093
1093
  const meta = this.safeValue(order, 'meta', {});
1094
- const postOnly = this.safeValue(meta, 'post_only', false);
1094
+ const postOnly = this.safeBool(meta, 'post_only', false);
1095
1095
  return this.safeOrder({
1096
1096
  'id': id,
1097
1097
  'clientOrderId': undefined,
@@ -1145,7 +1145,7 @@ class hollaex extends hollaex$1 {
1145
1145
  };
1146
1146
  const stopPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'stop']);
1147
1147
  const meta = this.safeValue(params, 'meta', {});
1148
- const exchangeSpecificParam = this.safeValue(meta, 'post_only', false);
1148
+ const exchangeSpecificParam = this.safeBool(meta, 'post_only', false);
1149
1149
  const isMarketOrder = type === 'market';
1150
1150
  const postOnly = this.isPostOnly(isMarketOrder, exchangeSpecificParam, params);
1151
1151
  if (!isMarketOrder) {
@@ -3981,7 +3981,7 @@ class htx extends htx$1 {
3981
3981
  let response = undefined;
3982
3982
  const stop = this.safeValue(params, 'stop');
3983
3983
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
3984
- const trailing = this.safeValue(params, 'trailing', false);
3984
+ const trailing = this.safeBool(params, 'trailing', false);
3985
3985
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
3986
3986
  if (stop || stopLossTakeProfit || trailing) {
3987
3987
  if (limit !== undefined) {
@@ -4356,7 +4356,7 @@ class htx extends htx$1 {
4356
4356
  request['contract_code'] = market['id'];
4357
4357
  const stop = this.safeValue(params, 'stop');
4358
4358
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
4359
- const trailing = this.safeValue(params, 'trailing', false);
4359
+ const trailing = this.safeBool(params, 'trailing', false);
4360
4360
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
4361
4361
  if (market['linear']) {
4362
4362
  let marginMode = undefined;
@@ -5735,7 +5735,7 @@ class htx extends htx$1 {
5735
5735
  }
5736
5736
  const stop = this.safeValue(params, 'stop');
5737
5737
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
5738
- const trailing = this.safeValue(params, 'trailing', false);
5738
+ const trailing = this.safeBool(params, 'trailing', false);
5739
5739
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
5740
5740
  if (market['linear']) {
5741
5741
  let marginMode = undefined;
@@ -6060,7 +6060,7 @@ class htx extends htx$1 {
6060
6060
  request['contract_code'] = market['id'];
6061
6061
  const stop = this.safeValue(params, 'stop');
6062
6062
  const stopLossTakeProfit = this.safeValue(params, 'stopLossTakeProfit');
6063
- const trailing = this.safeValue(params, 'trailing', false);
6063
+ const trailing = this.safeBool(params, 'trailing', false);
6064
6064
  params = this.omit(params, ['stop', 'stopLossTakeProfit', 'trailing']);
6065
6065
  if (market['linear']) {
6066
6066
  let marginMode = undefined;
@@ -6526,7 +6526,7 @@ class htx extends htx$1 {
6526
6526
  }
6527
6527
  amount = parseFloat(this.currencyToPrecision(code, amount, networkCode));
6528
6528
  const withdrawOptions = this.safeValue(this.options, 'withdraw', {});
6529
- if (this.safeValue(withdrawOptions, 'includeFee', false)) {
6529
+ if (this.safeBool(withdrawOptions, 'includeFee', false)) {
6530
6530
  let fee = this.safeNumber(params, 'fee');
6531
6531
  if (fee === undefined) {
6532
6532
  const currencies = await this.fetchCurrencies();
@@ -1043,7 +1043,7 @@ class huobijp extends huobijp$1 {
1043
1043
  const depositEnabled = this.safeValue(currency, 'deposit-enabled');
1044
1044
  const withdrawEnabled = this.safeValue(currency, 'withdraw-enabled');
1045
1045
  const countryDisabled = this.safeValue(currency, 'country-disabled');
1046
- const visible = this.safeValue(currency, 'visible', false);
1046
+ const visible = this.safeBool(currency, 'visible', false);
1047
1047
  const state = this.safeString(currency, 'state');
1048
1048
  const active = visible && depositEnabled && withdrawEnabled && (state === 'online') && !countryDisabled;
1049
1049
  const name = this.safeString(currency, 'display-name');
@@ -545,7 +545,7 @@ class krakenfutures extends krakenfutures$1 {
545
545
  const volume = this.safeString(ticker, 'vol24h');
546
546
  let baseVolume = undefined;
547
547
  let quoteVolume = undefined;
548
- const isIndex = this.safeValue(market, 'index', false);
548
+ const isIndex = this.safeBool(market, 'index', false);
549
549
  if (!isIndex) {
550
550
  if (market['linear']) {
551
551
  baseVolume = volume;
@@ -940,7 +940,7 @@ class kucoin extends kucoin$1 {
940
940
  //
941
941
  const data = this.safeValue(response, 'data');
942
942
  const options = this.safeValue(this.options, 'fetchMarkets', {});
943
- const fetchTickersFees = this.safeValue(options, 'fetchTickersFees', true);
943
+ const fetchTickersFees = this.safeBool(options, 'fetchTickersFees', true);
944
944
  let tickersResponse = {};
945
945
  if (fetchTickersFees) {
946
946
  tickersResponse = await this.publicGetMarketAllTickers(params);
@@ -1148,14 +1148,14 @@ class kucoin extends kucoin$1 {
1148
1148
  const chain = chains[j];
1149
1149
  const chainId = this.safeString(chain, 'chainId');
1150
1150
  const networkCode = this.networkIdToCode(chainId);
1151
- const chainWithdrawEnabled = this.safeValue(chain, 'isWithdrawEnabled', false);
1151
+ const chainWithdrawEnabled = this.safeBool(chain, 'isWithdrawEnabled', false);
1152
1152
  if (isWithdrawEnabled === undefined) {
1153
1153
  isWithdrawEnabled = chainWithdrawEnabled;
1154
1154
  }
1155
1155
  else {
1156
1156
  isWithdrawEnabled = isWithdrawEnabled || chainWithdrawEnabled;
1157
1157
  }
1158
- const chainDepositEnabled = this.safeValue(chain, 'isDepositEnabled', false);
1158
+ const chainDepositEnabled = this.safeBool(chain, 'isDepositEnabled', false);
1159
1159
  if (isDepositEnabled === undefined) {
1160
1160
  isDepositEnabled = chainDepositEnabled;
1161
1161
  }
@@ -1913,9 +1913,9 @@ class kucoin extends kucoin$1 {
1913
1913
  */
1914
1914
  await this.loadMarkets();
1915
1915
  const market = this.market(symbol);
1916
- const testOrder = this.safeValue(params, 'test', false);
1916
+ const testOrder = this.safeBool(params, 'test', false);
1917
1917
  params = this.omit(params, 'test');
1918
- const isHf = this.safeValue(params, 'hf', false);
1918
+ const isHf = this.safeBool(params, 'hf', false);
1919
1919
  const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
1920
1920
  const tradeType = this.safeString(params, 'tradeType'); // keep it for backward compatibility
1921
1921
  const isTriggerOrder = (triggerPrice || stopLossPrice || takeProfitPrice);
@@ -2042,7 +2042,7 @@ class kucoin extends kucoin$1 {
2042
2042
  'symbol': market['id'],
2043
2043
  'orderList': ordersRequests,
2044
2044
  };
2045
- const hf = this.safeValue(params, 'hf', false);
2045
+ const hf = this.safeBool(params, 'hf', false);
2046
2046
  params = this.omit(params, 'hf');
2047
2047
  let response = undefined;
2048
2048
  if (hf) {
@@ -2224,7 +2224,7 @@ class kucoin extends kucoin$1 {
2224
2224
  const request = {};
2225
2225
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
2226
2226
  const stop = this.safeValue2(params, 'stop', 'trigger', false);
2227
- const hf = this.safeValue(params, 'hf', false);
2227
+ const hf = this.safeBool(params, 'hf', false);
2228
2228
  if (hf) {
2229
2229
  if (symbol === undefined) {
2230
2230
  throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol parameter for hf orders');
@@ -2279,8 +2279,8 @@ class kucoin extends kucoin$1 {
2279
2279
  */
2280
2280
  await this.loadMarkets();
2281
2281
  const request = {};
2282
- const stop = this.safeValue(params, 'stop', false);
2283
- const hf = this.safeValue(params, 'hf', false);
2282
+ const stop = this.safeBool(params, 'stop', false);
2283
+ const hf = this.safeBool(params, 'hf', false);
2284
2284
  params = this.omit(params, ['stop', 'hf']);
2285
2285
  const [marginMode, query] = this.handleMarginModeAndParams('cancelAllOrders', params);
2286
2286
  if (symbol !== undefined) {
@@ -2337,8 +2337,8 @@ class kucoin extends kucoin$1 {
2337
2337
  await this.loadMarkets();
2338
2338
  let lowercaseStatus = status.toLowerCase();
2339
2339
  const until = this.safeInteger2(params, 'until', 'till');
2340
- const stop = this.safeValue(params, 'stop', false);
2341
- const hf = this.safeValue(params, 'hf', false);
2340
+ const stop = this.safeBool(params, 'stop', false);
2341
+ const hf = this.safeBool(params, 'hf', false);
2342
2342
  params = this.omit(params, ['stop', 'hf', 'till', 'until']);
2343
2343
  const [marginMode, query] = this.handleMarginModeAndParams('fetchOrdersByStatus', params);
2344
2344
  if (lowercaseStatus === 'open') {
@@ -2512,8 +2512,8 @@ class kucoin extends kucoin$1 {
2512
2512
  await this.loadMarkets();
2513
2513
  const request = {};
2514
2514
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
2515
- const stop = this.safeValue(params, 'stop', false);
2516
- const hf = this.safeValue(params, 'hf', false);
2515
+ const stop = this.safeBool(params, 'stop', false);
2516
+ const hf = this.safeBool(params, 'hf', false);
2517
2517
  let market = undefined;
2518
2518
  if (symbol !== undefined) {
2519
2519
  market = this.market(symbol);
@@ -2690,10 +2690,10 @@ class kucoin extends kucoin$1 {
2690
2690
  const marketId = this.safeString(order, 'symbol');
2691
2691
  const timestamp = this.safeInteger(order, 'createdAt');
2692
2692
  const feeCurrencyId = this.safeString(order, 'feeCurrency');
2693
- const cancelExist = this.safeValue(order, 'cancelExist', false);
2693
+ const cancelExist = this.safeBool(order, 'cancelExist', false);
2694
2694
  const responseStop = this.safeString(order, 'stop');
2695
2695
  const stop = responseStop !== undefined;
2696
- const stopTriggered = this.safeValue(order, 'stopTriggered', false);
2696
+ const stopTriggered = this.safeBool(order, 'stopTriggered', false);
2697
2697
  const isActive = this.safeValue2(order, 'isActive', 'active');
2698
2698
  const responseStatus = this.safeString(order, 'status');
2699
2699
  let status = undefined;
@@ -2790,7 +2790,7 @@ class kucoin extends kucoin$1 {
2790
2790
  return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
2791
2791
  }
2792
2792
  let request = {};
2793
- const hf = this.safeValue(params, 'hf', false);
2793
+ const hf = this.safeBool(params, 'hf', false);
2794
2794
  if (hf && symbol === undefined) {
2795
2795
  throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol parameter for hf orders');
2796
2796
  }
@@ -3469,7 +3469,7 @@ class kucoin extends kucoin$1 {
3469
3469
  const accountsByType = this.safeValue(this.options, 'accountsByType');
3470
3470
  let type = this.safeString(accountsByType, requestedType, requestedType);
3471
3471
  params = this.omit(params, 'type');
3472
- const isHf = this.safeValue(params, 'hf', false);
3472
+ const isHf = this.safeBool(params, 'hf', false);
3473
3473
  if (isHf) {
3474
3474
  type = 'trade_hf';
3475
3475
  }
@@ -1121,7 +1121,7 @@ class kucoinfutures extends kucoinfutures$1 {
1121
1121
  */
1122
1122
  await this.loadMarkets();
1123
1123
  const market = this.market(symbol);
1124
- const testOrder = this.safeValue(params, 'test', false);
1124
+ const testOrder = this.safeBool(params, 'test', false);
1125
1125
  params = this.omit(params, 'test');
1126
1126
  const orderRequest = this.createContractOrderRequest(symbol, type, side, amount, price, params);
1127
1127
  let response = undefined;
@@ -1784,7 +1784,7 @@ class kucoinfutures extends kucoinfutures$1 {
1784
1784
  // const average = Precise.stringDiv (cost, Precise.stringMul (filled, market['contractSize']));
1785
1785
  // bool
1786
1786
  const isActive = this.safeValue(order, 'isActive');
1787
- const cancelExist = this.safeValue(order, 'cancelExist', false);
1787
+ const cancelExist = this.safeBool(order, 'cancelExist', false);
1788
1788
  let status = undefined;
1789
1789
  if (isActive !== undefined) {
1790
1790
  status = isActive ? 'open' : 'closed';
@@ -2508,7 +2508,7 @@ class kucoinfutures extends kucoinfutures$1 {
2508
2508
  await this.loadMarkets();
2509
2509
  const market = this.market(symbol);
2510
2510
  let clientOrderId = this.safeString(params, 'clientOrderId');
2511
- const testOrder = this.safeValue(params, 'test', false);
2511
+ const testOrder = this.safeBool(params, 'test', false);
2512
2512
  params = this.omit(params, ['test', 'clientOrderId']);
2513
2513
  if (clientOrderId === undefined) {
2514
2514
  clientOrderId = this.numberToString(this.nonce());
@@ -1312,7 +1312,7 @@ class lbank extends lbank$1 {
1312
1312
  await this.loadMarkets();
1313
1313
  const market = this.market(symbol);
1314
1314
  const clientOrderId = this.safeString2(params, 'custom_id', 'clientOrderId');
1315
- const postOnly = this.safeValue(params, 'postOnly', false);
1315
+ const postOnly = this.safeBool(params, 'postOnly', false);
1316
1316
  const timeInForce = this.safeStringUpper(params, 'timeInForce');
1317
1317
  params = this.omit(params, ['custom_id', 'clientOrderId', 'timeInForce', 'postOnly']);
1318
1318
  const request = {
@@ -955,8 +955,8 @@ class mexc extends mexc$1 {
955
955
  const chain = chains[j];
956
956
  const networkId = this.safeString(chain, 'network');
957
957
  const network = this.safeNetwork(networkId);
958
- const isDepositEnabled = this.safeValue(chain, 'depositEnable', false);
959
- const isWithdrawEnabled = this.safeValue(chain, 'withdrawEnable', false);
958
+ const isDepositEnabled = this.safeBool(chain, 'depositEnable', false);
959
+ const isWithdrawEnabled = this.safeBool(chain, 'withdrawEnable', false);
960
960
  const active = (isDepositEnabled && isWithdrawEnabled);
961
961
  currencyActive = active || currencyActive;
962
962
  const withdrawMin = this.safeString(chain, 'withdrawMin');
@@ -2215,7 +2215,7 @@ class mexc extends mexc$1 {
2215
2215
  await this.loadMarkets();
2216
2216
  const symbol = market['symbol'];
2217
2217
  const unavailableContracts = this.safeValue(this.options, 'unavailableContracts', {});
2218
- const isContractUnavaiable = this.safeValue(unavailableContracts, symbol, false);
2218
+ const isContractUnavaiable = this.safeBool(unavailableContracts, symbol, false);
2219
2219
  if (isContractUnavaiable) {
2220
2220
  throw new errors.NotSupported(this.id + ' createSwapOrder() does not support yet this symbol:' + symbol);
2221
2221
  }
@@ -2283,7 +2283,7 @@ class mexc extends mexc$1 {
2283
2283
  throw new errors.ArgumentsRequired(this.id + ' createSwapOrder() requires a leverage parameter for isolated margin orders');
2284
2284
  }
2285
2285
  }
2286
- const reduceOnly = this.safeValue(params, 'reduceOnly', false);
2286
+ const reduceOnly = this.safeBool(params, 'reduceOnly', false);
2287
2287
  if (reduceOnly) {
2288
2288
  request['side'] = (side === 'buy') ? 2 : 4;
2289
2289
  }
@@ -3618,7 +3618,7 @@ class mexc extends mexc$1 {
3618
3618
  const request = {};
3619
3619
  [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
3620
3620
  const marginMode = this.safeString(params, 'marginMode');
3621
- const isMargin = this.safeValue(params, 'margin', false);
3621
+ const isMargin = this.safeBool(params, 'margin', false);
3622
3622
  params = this.omit(params, ['margin', 'marginMode']);
3623
3623
  let response = undefined;
3624
3624
  if ((marginMode !== undefined) || (isMargin) || (marketType === 'margin')) {
@@ -5296,7 +5296,7 @@ class mexc extends mexc$1 {
5296
5296
  * @returns {Array} the marginMode in lowercase
5297
5297
  */
5298
5298
  const defaultType = this.safeString(this.options, 'defaultType');
5299
- const isMargin = this.safeValue(params, 'margin', false);
5299
+ const isMargin = this.safeBool(params, 'margin', false);
5300
5300
  let marginMode = undefined;
5301
5301
  [marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
5302
5302
  if ((defaultType === 'margin') || (isMargin === true)) {
@@ -5388,7 +5388,7 @@ class mexc extends mexc$1 {
5388
5388
  // {"code":10216,"msg":"No available deposit address"}
5389
5389
  // {"success":true, "code":0, "data":1634095541710}
5390
5390
  //
5391
- const success = this.safeValue(response, 'success', false); // v1
5391
+ const success = this.safeBool(response, 'success', false); // v1
5392
5392
  if (success === true) {
5393
5393
  return undefined;
5394
5394
  }
@@ -1162,7 +1162,7 @@ class novadax extends novadax$1 {
1162
1162
  //
1163
1163
  const transfer = this.parseTransfer(response, currency);
1164
1164
  const transferOptions = this.safeValue(this.options, 'transfer', {});
1165
- const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
1165
+ const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
1166
1166
  if (fillResponseFromRequest) {
1167
1167
  transfer['fromAccount'] = fromAccount;
1168
1168
  transfer['toAccount'] = toAccount;
@@ -857,7 +857,7 @@ class okcoin extends okcoin$1 {
857
857
  const symbol = market['symbol'];
858
858
  const last = this.safeString(ticker, 'last');
859
859
  const open = this.safeString(ticker, 'open24h');
860
- const spot = this.safeValue(market, 'spot', false);
860
+ const spot = this.safeBool(market, 'spot', false);
861
861
  const quoteVolume = spot ? this.safeString(ticker, 'volCcy24h') : undefined;
862
862
  const baseVolume = this.safeString(ticker, 'vol24h');
863
863
  const high = this.safeString(ticker, 'high24h');
@@ -1401,7 +1401,7 @@ class okcoin extends okcoin$1 {
1401
1401
  }
1402
1402
  else {
1403
1403
  marginMode = defaultMarginMode;
1404
- margin = this.safeValue(params, 'margin', false);
1404
+ margin = this.safeBool(params, 'margin', false);
1405
1405
  }
1406
1406
  if (margin) {
1407
1407
  const defaultCurrency = (side === 'buy') ? market['quote'] : market['base'];