ccxt 4.1.36 → 4.1.38

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 (143) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +1767 -446
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +19 -0
  6. package/dist/cjs/src/base/errors.js +6 -6
  7. package/dist/cjs/src/binance.js +2 -2
  8. package/dist/cjs/src/bingx.js +106 -0
  9. package/dist/cjs/src/bitforex.js +26 -1
  10. package/dist/cjs/src/bitget.js +2 -2
  11. package/dist/cjs/src/bitmart.js +2 -2
  12. package/dist/cjs/src/bitmex.js +3 -3
  13. package/dist/cjs/src/bybit.js +1 -0
  14. package/dist/cjs/src/deribit.js +2 -2
  15. package/dist/cjs/src/digifinex.js +204 -52
  16. package/dist/cjs/src/gate.js +2 -2
  17. package/dist/cjs/src/hollaex.js +7 -7
  18. package/dist/cjs/src/huobi.js +20 -4
  19. package/dist/cjs/src/kucoinfutures.js +0 -3
  20. package/dist/cjs/src/kuna.js +1284 -350
  21. package/dist/cjs/src/latoken.js +2 -2
  22. package/dist/cjs/src/pro/bitget.js +50 -7
  23. package/dist/cjs/src/wazirx.js +23 -1
  24. package/js/ccxt.d.ts +1 -1
  25. package/js/ccxt.js +1 -1
  26. package/js/src/abstract/bybit.d.ts +1 -0
  27. package/js/src/abstract/kuna.d.ts +29 -27
  28. package/js/src/ace.d.ts +7 -7
  29. package/js/src/alpaca.d.ts +7 -7
  30. package/js/src/ascendex.d.ts +3 -3
  31. package/js/src/base/Exchange.d.ts +3 -2
  32. package/js/src/base/Exchange.js +19 -0
  33. package/js/src/base/errorHierarchy.d.ts +1 -1
  34. package/js/src/base/errorHierarchy.js +1 -1
  35. package/js/src/base/errors.d.ts +3 -3
  36. package/js/src/base/errors.js +6 -6
  37. package/js/src/bigone.d.ts +10 -10
  38. package/js/src/binance.d.ts +48 -15
  39. package/js/src/binance.js +2 -2
  40. package/js/src/bingx.d.ts +10 -8
  41. package/js/src/bingx.js +106 -0
  42. package/js/src/bit2c.d.ts +5 -5
  43. package/js/src/bitbank.d.ts +7 -7
  44. package/js/src/bitbns.d.ts +6 -6
  45. package/js/src/bitfinex.d.ts +9 -9
  46. package/js/src/bitfinex2.d.ts +1 -1
  47. package/js/src/bitforex.d.ts +8 -8
  48. package/js/src/bitforex.js +26 -1
  49. package/js/src/bitget.d.ts +2 -12
  50. package/js/src/bitget.js +2 -2
  51. package/js/src/bithumb.d.ts +7 -7
  52. package/js/src/bitmart.d.ts +11 -21
  53. package/js/src/bitmart.js +2 -2
  54. package/js/src/bitmex.d.ts +2 -12
  55. package/js/src/bitmex.js +3 -3
  56. package/js/src/bitopro.d.ts +9 -9
  57. package/js/src/bitpanda.d.ts +8 -8
  58. package/js/src/bitrue.d.ts +9 -9
  59. package/js/src/bitso.d.ts +7 -7
  60. package/js/src/bitstamp.d.ts +7 -7
  61. package/js/src/bittrex.d.ts +9 -9
  62. package/js/src/bitvavo.d.ts +1 -1
  63. package/js/src/blockchaincom.d.ts +8 -8
  64. package/js/src/btcalpha.d.ts +9 -9
  65. package/js/src/btcbox.d.ts +8 -8
  66. package/js/src/btcmarkets.d.ts +3 -3
  67. package/js/src/btctradeua.d.ts +3 -3
  68. package/js/src/btcturk.d.ts +6 -6
  69. package/js/src/bybit.d.ts +1 -1
  70. package/js/src/bybit.js +1 -0
  71. package/js/src/cex.d.ts +3 -3
  72. package/js/src/coinbase.d.ts +1 -1
  73. package/js/src/coinbasepro.d.ts +1 -1
  74. package/js/src/coinex.d.ts +11 -11
  75. package/js/src/coinfalcon.d.ts +6 -6
  76. package/js/src/coinmate.d.ts +6 -6
  77. package/js/src/coinone.d.ts +5 -5
  78. package/js/src/coinsph.d.ts +10 -10
  79. package/js/src/cryptocom.d.ts +1 -1
  80. package/js/src/currencycom.d.ts +8 -8
  81. package/js/src/delta.d.ts +10 -10
  82. package/js/src/deribit.d.ts +9 -19
  83. package/js/src/deribit.js +2 -2
  84. package/js/src/digifinex.d.ts +10 -8
  85. package/js/src/digifinex.js +204 -52
  86. package/js/src/exmo.d.ts +3 -3
  87. package/js/src/gate.d.ts +2 -12
  88. package/js/src/gate.js +2 -2
  89. package/js/src/gemini.d.ts +6 -6
  90. package/js/src/hitbtc.d.ts +1 -1
  91. package/js/src/hollaex.d.ts +12 -12
  92. package/js/src/hollaex.js +7 -7
  93. package/js/src/huobi.d.ts +2 -12
  94. package/js/src/huobi.js +20 -4
  95. package/js/src/huobijp.d.ts +3 -3
  96. package/js/src/idex.d.ts +3 -3
  97. package/js/src/independentreserve.d.ts +6 -6
  98. package/js/src/kraken.d.ts +8 -8
  99. package/js/src/krakenfutures.d.ts +8 -8
  100. package/js/src/kucoin.d.ts +1 -1
  101. package/js/src/kucoinfutures.d.ts +4 -5
  102. package/js/src/kucoinfutures.js +0 -3
  103. package/js/src/kuna.d.ts +155 -7
  104. package/js/src/kuna.js +1290 -351
  105. package/js/src/latoken.d.ts +7 -7
  106. package/js/src/latoken.js +2 -2
  107. package/js/src/lbank.d.ts +3 -3
  108. package/js/src/lbank2.d.ts +10 -10
  109. package/js/src/luno.d.ts +8 -8
  110. package/js/src/lykke.d.ts +6 -6
  111. package/js/src/mercado.d.ts +9 -9
  112. package/js/src/mexc.d.ts +17 -17
  113. package/js/src/ndax.d.ts +9 -9
  114. package/js/src/novadax.d.ts +10 -10
  115. package/js/src/oceanex.d.ts +3 -3
  116. package/js/src/okcoin.d.ts +9 -9
  117. package/js/src/okx.d.ts +1 -1
  118. package/js/src/phemex.d.ts +13 -13
  119. package/js/src/poloniex.d.ts +9 -9
  120. package/js/src/poloniexfutures.d.ts +8 -8
  121. package/js/src/pro/bingx.d.ts +2 -2
  122. package/js/src/pro/bitget.d.ts +3 -3
  123. package/js/src/pro/bitget.js +50 -7
  124. package/js/src/pro/bybit.d.ts +3 -3
  125. package/js/src/pro/hitbtc.d.ts +2 -2
  126. package/js/src/pro/mexc.d.ts +2 -2
  127. package/js/src/pro/poloniex.d.ts +2 -2
  128. package/js/src/pro/wazirx.d.ts +2 -2
  129. package/js/src/probit.d.ts +9 -9
  130. package/js/src/tidex.d.ts +5 -5
  131. package/js/src/timex.d.ts +9 -9
  132. package/js/src/tokocrypto.d.ts +10 -10
  133. package/js/src/upbit.d.ts +11 -11
  134. package/js/src/wavesexchange.d.ts +9 -9
  135. package/js/src/wazirx.d.ts +8 -8
  136. package/js/src/wazirx.js +23 -1
  137. package/js/src/whitebit.d.ts +3 -3
  138. package/js/src/woo.d.ts +8 -8
  139. package/js/src/yobit.d.ts +6 -6
  140. package/js/src/zaif.d.ts +5 -5
  141. package/js/src/zonda.d.ts +6 -6
  142. package/package.json +1 -1
  143. package/skip-tests.json +6 -1
@@ -8710,6 +8710,25 @@ class Exchange {
8710
8710
  'cost': this.parseNumber(cost),
8711
8711
  };
8712
8712
  }
8713
+ safeLiquidation(liquidation, market = undefined) {
8714
+ const contracts = this.safeString(liquidation, 'contracts');
8715
+ const contractSize = this.safeString(market, 'contractSize');
8716
+ const price = this.safeString(liquidation, 'price');
8717
+ let baseValue = this.safeString(liquidation, 'baseValue');
8718
+ let quoteValue = this.safeString(liquidation, 'quoteValue');
8719
+ if ((baseValue === undefined) && (contracts !== undefined) && (contractSize !== undefined) && (price !== undefined)) {
8720
+ baseValue = _Precise_js__WEBPACK_IMPORTED_MODULE_8__/* .Precise.stringMul */ .O.stringMul(contracts, contractSize);
8721
+ }
8722
+ if ((quoteValue === undefined) && (baseValue !== undefined) && (price !== undefined)) {
8723
+ quoteValue = _Precise_js__WEBPACK_IMPORTED_MODULE_8__/* .Precise.stringMul */ .O.stringMul(baseValue, price);
8724
+ }
8725
+ liquidation['contracts'] = this.parseNumber(contracts);
8726
+ liquidation['contractSize'] = this.parseNumber(contractSize);
8727
+ liquidation['price'] = this.parseNumber(price);
8728
+ liquidation['baseValue'] = this.parseNumber(baseValue);
8729
+ liquidation['quoteValue'] = this.parseNumber(quoteValue);
8730
+ return liquidation;
8731
+ }
8713
8732
  safeTrade(trade, market = undefined) {
8714
8733
  const amount = this.safeString(trade, 'amount');
8715
8734
  const price = this.safeString(trade, 'price');
@@ -11525,12 +11544,6 @@ class ExchangeError extends Error {
11525
11544
  this.name = 'ExchangeError';
11526
11545
  }
11527
11546
  }
11528
- class OperationFailed extends ExchangeError {
11529
- constructor(message) {
11530
- super(message);
11531
- this.name = 'OperationFailed';
11532
- }
11533
- }
11534
11547
  class AuthenticationError extends ExchangeError {
11535
11548
  constructor(message) {
11536
11549
  super(message);
@@ -11718,6 +11731,12 @@ class RequestTimeout extends NetworkError {
11718
11731
  this.name = 'RequestTimeout';
11719
11732
  }
11720
11733
  }
11734
+ class OperationFailed extends NetworkError {
11735
+ constructor(message) {
11736
+ super(message);
11737
+ this.name = 'OperationFailed';
11738
+ }
11739
+ }
11721
11740
  /* ------------------------------------------------------------------------ */
11722
11741
  // export default subclass (
11723
11742
  // // Root class
@@ -25797,7 +25816,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25797
25816
  //
25798
25817
  const marketId = this.safeString(liquidation, 'symbol');
25799
25818
  const timestamp = this.safeInteger2(liquidation, 'updatedTime', 'updateTime');
25800
- return {
25819
+ return this.safeLiquidation({
25801
25820
  'info': liquidation,
25802
25821
  'symbol': this.safeSymbol(marketId, market),
25803
25822
  'contracts': this.safeNumber(liquidation, 'executedQty'),
@@ -25807,7 +25826,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25807
25826
  'quoteValue': this.safeNumber(liquidation, 'cumQuote'),
25808
25827
  'timestamp': timestamp,
25809
25828
  'datetime': this.iso8601(timestamp),
25810
- };
25829
+ });
25811
25830
  }
25812
25831
  }
25813
25832
 
@@ -26040,7 +26059,9 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26040
26059
  'fetchFundingRate': true,
26041
26060
  'fetchFundingRateHistory': true,
26042
26061
  'fetchLeverage': true,
26062
+ 'fetchLiquidations': false,
26043
26063
  'fetchMarkets': true,
26064
+ 'fetchMyLiquidations': true,
26044
26065
  'fetchOHLCV': true,
26045
26066
  'fetchOpenInterest': true,
26046
26067
  'fetchOpenOrders': true,
@@ -29077,6 +29098,110 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
29077
29098
  }
29078
29099
  return sortedParams;
29079
29100
  }
29101
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
29102
+ /**
29103
+ * @method
29104
+ * @name bingx#fetchMyLiquidations
29105
+ * @description retrieves the users liquidated positions
29106
+ * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#User's%20Force%20Orders
29107
+ * @param {string} [symbol] unified CCXT market symbol
29108
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
29109
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
29110
+ * @param {object} [params] exchange specific parameters for the bingx api endpoint
29111
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
29112
+ * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
29113
+ */
29114
+ await this.loadMarkets();
29115
+ let request = {
29116
+ 'autoCloseType': 'LIQUIDATION',
29117
+ };
29118
+ [request, params] = this.handleUntilOption('endTime', request, params);
29119
+ let market = undefined;
29120
+ if (symbol !== undefined) {
29121
+ market = this.market(symbol);
29122
+ request['symbol'] = symbol;
29123
+ }
29124
+ if (since !== undefined) {
29125
+ request['startTime'] = since;
29126
+ }
29127
+ if (limit !== undefined) {
29128
+ request['limit'] = limit;
29129
+ }
29130
+ const response = await this.swapV2PrivateGetTradeForceOrders(this.extend(request, params));
29131
+ //
29132
+ // {
29133
+ // "code": 0,
29134
+ // "msg": "",
29135
+ // "data": {
29136
+ // "orders": [
29137
+ // {
29138
+ // "time": "int64",
29139
+ // "symbol": "string",
29140
+ // "side": "string",
29141
+ // "type": "string",
29142
+ // "positionSide": "string",
29143
+ // "cumQuote": "string",
29144
+ // "status": "string",
29145
+ // "stopPrice": "string",
29146
+ // "price": "string",
29147
+ // "origQty": "string",
29148
+ // "avgPrice": "string",
29149
+ // "executedQty": "string",
29150
+ // "orderId": "int64",
29151
+ // "profit": "string",
29152
+ // "commission": "string",
29153
+ // "workingType": "string",
29154
+ // "updateTime": "int64"
29155
+ // },
29156
+ // ]
29157
+ // }
29158
+ // }
29159
+ //
29160
+ const data = this.safeValue(response, 'data', {});
29161
+ const liquidations = this.safeValue(data, 'orders', []);
29162
+ return this.parseLiquidations(liquidations, market, since, limit);
29163
+ }
29164
+ parseLiquidation(liquidation, market = undefined) {
29165
+ //
29166
+ // {
29167
+ // "time": "int64",
29168
+ // "symbol": "string",
29169
+ // "side": "string",
29170
+ // "type": "string",
29171
+ // "positionSide": "string",
29172
+ // "cumQuote": "string",
29173
+ // "status": "string",
29174
+ // "stopPrice": "string",
29175
+ // "price": "string",
29176
+ // "origQty": "string",
29177
+ // "avgPrice": "string",
29178
+ // "executedQty": "string",
29179
+ // "orderId": "int64",
29180
+ // "profit": "string",
29181
+ // "commission": "string",
29182
+ // "workingType": "string",
29183
+ // "updateTime": "int64"
29184
+ // }
29185
+ //
29186
+ const marketId = this.safeString(liquidation, 'symbol');
29187
+ const timestamp = this.safeInteger(liquidation, 'time');
29188
+ const contractsString = this.safeString(liquidation, 'executedQty');
29189
+ const contractSizeString = this.safeString(market, 'contractSize');
29190
+ const priceString = this.safeString(liquidation, 'avgPrice');
29191
+ const baseValueString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(contractsString, contractSizeString);
29192
+ const quoteValueString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(baseValueString, priceString);
29193
+ return this.safeLiquidation({
29194
+ 'info': liquidation,
29195
+ 'symbol': this.safeSymbol(marketId, market),
29196
+ 'contracts': this.parseNumber(contractsString),
29197
+ 'contractSize': this.parseNumber(contractSizeString),
29198
+ 'price': this.parseNumber(priceString),
29199
+ 'baseValue': this.parseNumber(baseValueString),
29200
+ 'quoteValue': this.parseNumber(quoteValueString),
29201
+ 'timestamp': timestamp,
29202
+ 'datetime': this.iso8601(timestamp),
29203
+ });
29204
+ }
29080
29205
  sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
29081
29206
  const type = section[0];
29082
29207
  const version = section[1];
@@ -38114,29 +38239,48 @@ class bitforex extends _abstract_bitforex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
38114
38239
  'CORS': undefined,
38115
38240
  'spot': true,
38116
38241
  'margin': false,
38117
- 'swap': undefined,
38242
+ 'swap': false,
38118
38243
  'future': false,
38119
38244
  'option': false,
38245
+ 'addMargin': false,
38246
+ 'borrowMargin': false,
38120
38247
  'cancelOrder': true,
38121
38248
  'createOrder': true,
38249
+ 'createReduceOnlyOrder': false,
38122
38250
  'createStopLimitOrder': false,
38123
38251
  'createStopMarketOrder': false,
38124
38252
  'createStopOrder': false,
38125
38253
  'fetchBalance': true,
38254
+ 'fetchBorrowInterest': false,
38126
38255
  'fetchBorrowRate': false,
38127
38256
  'fetchBorrowRateHistories': false,
38128
38257
  'fetchBorrowRateHistory': false,
38129
38258
  'fetchBorrowRates': false,
38130
38259
  'fetchBorrowRatesPerSymbol': false,
38131
38260
  'fetchClosedOrders': true,
38261
+ 'fetchFundingHistory': false,
38262
+ 'fetchFundingRate': false,
38263
+ 'fetchFundingRateHistory': false,
38264
+ 'fetchFundingRates': false,
38265
+ 'fetchIndexOHLCV': false,
38266
+ 'fetchIsolatedPositions': false,
38267
+ 'fetchLeverage': false,
38268
+ 'fetchLeverageTiers': false,
38132
38269
  'fetchMarginMode': false,
38270
+ 'fetchMarketLeverageTiers': false,
38133
38271
  'fetchMarkets': true,
38272
+ 'fetchMarkOHLCV': false,
38134
38273
  'fetchMyTrades': true,
38135
38274
  'fetchOHLCV': true,
38275
+ 'fetchOpenInterestHistory': false,
38136
38276
  'fetchOpenOrders': true,
38137
38277
  'fetchOrder': true,
38138
38278
  'fetchOrderBook': true,
38279
+ 'fetchPosition': false,
38139
38280
  'fetchPositionMode': false,
38281
+ 'fetchPositions': false,
38282
+ 'fetchPositionsRisk': false,
38283
+ 'fetchPremiumIndexOHLCV': false,
38140
38284
  'fetchTicker': true,
38141
38285
  'fetchTickers': false,
38142
38286
  'fetchTrades': true,
@@ -38145,6 +38289,12 @@ class bitforex extends _abstract_bitforex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
38145
38289
  'fetchTransfers': false,
38146
38290
  'fetchWithdrawal': false,
38147
38291
  'fetchWithdrawals': false,
38292
+ 'reduceMargin': false,
38293
+ 'repayMargin': false,
38294
+ 'setLeverage': false,
38295
+ 'setMargin': false,
38296
+ 'setMarginMode': false,
38297
+ 'setPositionMode': false,
38148
38298
  'transfer': false,
38149
38299
  'withdraw': false,
38150
38300
  },
@@ -45237,7 +45387,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45237
45387
  const liquidationFee = this.safeString(liquidation, 'LiqFee');
45238
45388
  const totalDebt = this.safeString(liquidation, 'totalDebt');
45239
45389
  const quoteValueString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(liquidationFee, totalDebt);
45240
- return {
45390
+ return this.safeLiquidation({
45241
45391
  'info': liquidation,
45242
45392
  'symbol': this.safeSymbol(marketId, market),
45243
45393
  'contracts': undefined,
@@ -45247,7 +45397,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45247
45397
  'quoteValue': this.parseNumber(quoteValueString),
45248
45398
  'timestamp': timestamp,
45249
45399
  'datetime': this.iso8601(timestamp),
45250
- };
45400
+ });
45251
45401
  }
45252
45402
  async fetchBorrowRate(code, params = {}) {
45253
45403
  /**
@@ -50830,7 +50980,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50830
50980
  const priceString = this.safeString(liquidation, 'deal_avg_price');
50831
50981
  const baseValueString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(contractsString, contractSizeString);
50832
50982
  const quoteValueString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(baseValueString, priceString);
50833
- return {
50983
+ return this.safeLiquidation({
50834
50984
  'info': liquidation,
50835
50985
  'symbol': this.safeSymbol(marketId, market),
50836
50986
  'contracts': this.parseNumber(contractsString),
@@ -50840,7 +50990,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50840
50990
  'quoteValue': this.parseNumber(quoteValueString),
50841
50991
  'timestamp': timestamp,
50842
50992
  'datetime': this.iso8601(timestamp),
50843
- };
50993
+ });
50844
50994
  }
50845
50995
  nonce() {
50846
50996
  return this.milliseconds();
@@ -51852,7 +52002,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51852
52002
  */
51853
52003
  // Bitmex barfs if you set 'open': false in the filter...
51854
52004
  const orders = await this.fetchOrders(symbol, since, limit, params);
51855
- return this.filterBy(orders, 'status', 'closed');
52005
+ return this.filterByArray(orders, 'status', ['closed', 'canceled'], false);
51856
52006
  }
51857
52007
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
51858
52008
  /**
@@ -53623,7 +53773,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
53623
53773
  // }
53624
53774
  //
53625
53775
  const marketId = this.safeString(liquidation, 'symbol');
53626
- return {
53776
+ return this.safeLiquidation({
53627
53777
  'info': liquidation,
53628
53778
  'symbol': this.safeSymbol(marketId, market),
53629
53779
  'contracts': undefined,
@@ -53633,7 +53783,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
53633
53783
  'quoteValue': undefined,
53634
53784
  'timestamp': undefined,
53635
53785
  'datetime': undefined,
53636
- };
53786
+ });
53637
53787
  }
53638
53788
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
53639
53789
  if (response === undefined) {
@@ -74514,6 +74664,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
74514
74664
  'v5/user/query-api': 5,
74515
74665
  'v5/user/get-member-type': 5,
74516
74666
  'v5/user/aff-customer-info': 5,
74667
+ 'v5/user/del-submember': 5,
74517
74668
  // spot leverage token
74518
74669
  'v5/spot-lever-token/order-record': 1,
74519
74670
  // spot margin trade
@@ -110982,7 +111133,7 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
110982
111133
  // }
110983
111134
  //
110984
111135
  const timestamp = this.safeInteger(liquidation, 'timestamp');
110985
- return {
111136
+ return this.safeLiquidation({
110986
111137
  'info': liquidation,
110987
111138
  'symbol': this.safeSymbol(undefined, market),
110988
111139
  'contracts': undefined,
@@ -110992,7 +111143,7 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
110992
111143
  'quoteValue': undefined,
110993
111144
  'timestamp': timestamp,
110994
111145
  'datetime': this.iso8601(timestamp),
110995
- };
111146
+ });
110996
111147
  }
110997
111148
  nonce() {
110998
111149
  return this.milliseconds();
@@ -111095,6 +111246,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
111095
111246
  'cancelOrder': true,
111096
111247
  'cancelOrders': true,
111097
111248
  'createOrder': true,
111249
+ 'createOrders': true,
111098
111250
  'createPostOnlyOrder': true,
111099
111251
  'createReduceOnlyOrder': true,
111100
111252
  'createStopLimitOrder': false,
@@ -111352,6 +111504,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
111352
111504
  'options': {
111353
111505
  'defaultType': 'spot',
111354
111506
  'types': ['spot', 'margin', 'otc'],
111507
+ 'createMarketBuyOrderRequiresPrice': true,
111355
111508
  'accountsByType': {
111356
111509
  'spot': '1',
111357
111510
  'margin': '2',
@@ -112615,28 +112768,173 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
112615
112768
  * @param {string} symbol unified symbol of the market to create an order in
112616
112769
  * @param {string} type 'market' or 'limit'
112617
112770
  * @param {string} side 'buy' or 'sell'
112618
- * @param {float} amount how much of currency you want to trade in units of base currency
112771
+ * @param {float} amount how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
112619
112772
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
112620
112773
  * @param {object} [params] extra parameters specific to the digifinex api endpoint
112621
112774
  * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
112622
112775
  * @param {bool} [params.postOnly] true or false
112623
112776
  * @param {bool} [params.reduceOnly] true or false
112777
+ * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
112624
112778
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
112625
112779
  */
112626
112780
  await this.loadMarkets();
112627
112781
  const market = this.market(symbol);
112628
- symbol = market['symbol'];
112782
+ const marginResult = this.handleMarginModeAndParams('createOrder', params);
112783
+ const marginMode = marginResult[0];
112784
+ const request = this.createOrderRequest(symbol, type, side, amount, price, params);
112785
+ let response = undefined;
112786
+ if (market['swap']) {
112787
+ response = await this.privateSwapPostTradeOrderPlace(request);
112788
+ }
112789
+ else {
112790
+ if (marginMode !== undefined) {
112791
+ response = await this.privateSpotPostMarginOrderNew(request);
112792
+ }
112793
+ else {
112794
+ response = await this.privateSpotPostSpotOrderNew(request);
112795
+ }
112796
+ }
112797
+ //
112798
+ // spot and margin
112799
+ //
112800
+ // {
112801
+ // "code": 0,
112802
+ // "order_id": "198361cecdc65f9c8c9bb2fa68faec40"
112803
+ // }
112804
+ //
112805
+ // swap
112806
+ //
112807
+ // {
112808
+ // "code": 0,
112809
+ // "data": "1590873693003714560"
112810
+ // }
112811
+ //
112812
+ const order = this.parseOrder(response, market);
112813
+ order['symbol'] = market['symbol'];
112814
+ order['type'] = type;
112815
+ order['side'] = side;
112816
+ order['amount'] = amount;
112817
+ order['price'] = price;
112818
+ return order;
112819
+ }
112820
+ async createOrders(orders, params = {}) {
112821
+ /**
112822
+ * @method
112823
+ * @name digifinex#createOrders
112824
+ * @description create a list of trade orders (all orders should be of the same symbol)
112825
+ * @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
112826
+ * @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#batchorder
112827
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
112828
+ * @param {object} [params] extra parameters specific to the digifinex api endpoint
112829
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
112830
+ */
112831
+ await this.loadMarkets();
112832
+ const ordersRequests = [];
112833
+ let symbol = undefined;
112834
+ let marginMode = undefined;
112835
+ for (let i = 0; i < orders.length; i++) {
112836
+ const rawOrder = orders[i];
112837
+ const marketId = this.safeString(rawOrder, 'symbol');
112838
+ if (symbol === undefined) {
112839
+ symbol = marketId;
112840
+ }
112841
+ else {
112842
+ if (symbol !== marketId) {
112843
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
112844
+ }
112845
+ }
112846
+ const type = this.safeString(rawOrder, 'type');
112847
+ const side = this.safeString(rawOrder, 'side');
112848
+ const amount = this.safeValue(rawOrder, 'amount');
112849
+ const price = this.safeValue(rawOrder, 'price');
112850
+ const orderParams = this.safeValue(rawOrder, 'params', {});
112851
+ const marginResult = this.handleMarginModeAndParams('createOrders', params);
112852
+ const currentMarginMode = marginResult[0];
112853
+ if (currentMarginMode !== undefined) {
112854
+ if (marginMode === undefined) {
112855
+ marginMode = currentMarginMode;
112856
+ }
112857
+ else {
112858
+ if (marginMode !== currentMarginMode) {
112859
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrders() requires all orders to have the same margin mode (isolated or cross)');
112860
+ }
112861
+ }
112862
+ }
112863
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
112864
+ ordersRequests.push(orderRequest);
112865
+ }
112866
+ const market = this.market(symbol);
112867
+ const request = {};
112868
+ let response = undefined;
112869
+ if (market['swap']) {
112870
+ response = await this.privateSwapPostTradeBatchOrder(ordersRequests);
112871
+ }
112872
+ else {
112873
+ request['market'] = (marginMode !== undefined) ? 'margin' : 'spot';
112874
+ request['symbol'] = market['id'];
112875
+ request['list'] = this.json(ordersRequests);
112876
+ response = await this.privateSpotPostMarketOrderBatchNew(request);
112877
+ }
112878
+ //
112879
+ // spot
112880
+ //
112881
+ // {
112882
+ // "code": 0,
112883
+ // "order_ids": [
112884
+ // "064290fbe2d26e7b28d7e6c0a5cf70a5",
112885
+ // "24c8f9b73d81e4d9d8d7e3280281c258"
112886
+ // ]
112887
+ // }
112888
+ //
112889
+ // swap
112890
+ //
112891
+ // {
112892
+ // "code": 0,
112893
+ // "data": [
112894
+ // "1720297963537829888",
112895
+ // "1720297963537829889"
112896
+ // ]
112897
+ // }
112898
+ //
112899
+ let data = [];
112900
+ if (market['swap']) {
112901
+ data = this.safeValue(response, 'data', []);
112902
+ }
112903
+ else {
112904
+ data = this.safeValue(response, 'order_ids', []);
112905
+ }
112906
+ const result = [];
112907
+ for (let i = 0; i < orders.length; i++) {
112908
+ const rawOrder = orders[i];
112909
+ const individualOrder = {};
112910
+ individualOrder['order_id'] = data[i];
112911
+ individualOrder['instrument_id'] = market['id'];
112912
+ individualOrder['amount'] = this.safeNumber(rawOrder, 'amount');
112913
+ individualOrder['price'] = this.safeNumber(rawOrder, 'price');
112914
+ result.push(individualOrder);
112915
+ }
112916
+ return this.parseOrders(result, market);
112917
+ }
112918
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
112919
+ /**
112920
+ * @method
112921
+ * @ignore
112922
+ * @name digifinex#createOrderRequest
112923
+ * @description helper function to build request
112924
+ * @param {string} symbol unified symbol of the market to create an order in
112925
+ * @param {string} type 'market' or 'limit'
112926
+ * @param {string} side 'buy' or 'sell'
112927
+ * @param {float} amount how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
112928
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
112929
+ * @param {object} [params] extra parameters specific to the digifinex api endpoint
112930
+ * @returns {object} request to be sent to the exchange
112931
+ */
112932
+ const market = this.market(symbol);
112629
112933
  let marketType = undefined;
112630
112934
  let marginMode = undefined;
112631
- [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
112632
- let method = this.getSupportedMapping(marketType, {
112633
- 'spot': 'privateSpotPostSpotOrderNew',
112634
- 'margin': 'privateSpotPostMarginOrderNew',
112635
- 'swap': 'privateSwapPostTradeOrderPlace',
112636
- });
112637
- [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
112935
+ [marketType, params] = this.handleMarketTypeAndParams('createOrderRequest', market, params);
112936
+ [marginMode, params] = this.handleMarginModeAndParams('createOrderRequest', params);
112638
112937
  if (marginMode !== undefined) {
112639
- method = 'privateSpotPostMarginOrderNew';
112640
112938
  marketType = 'margin';
112641
112939
  }
112642
112940
  const request = {};
@@ -112693,40 +112991,34 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
112693
112991
  }
112694
112992
  request['type'] = side + suffix;
112695
112993
  // limit orders require the amount in the base currency, market orders require the amount in the quote currency
112696
- request['amount'] = this.amountToPrecision(symbol, amount);
112994
+ let quantity = undefined;
112995
+ const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
112996
+ if (createMarketBuyOrderRequiresPrice && isMarketOrder && (side === 'buy')) {
112997
+ if (price === undefined) {
112998
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
112999
+ }
113000
+ else {
113001
+ const amountString = this.numberToString(amount);
113002
+ const priceString = this.numberToString(price);
113003
+ const cost = this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(amountString, priceString));
113004
+ quantity = this.priceToPrecision(symbol, cost);
113005
+ }
113006
+ }
113007
+ else {
113008
+ quantity = this.amountToPrecision(symbol, amount);
113009
+ }
113010
+ request['amount'] = quantity;
112697
113011
  }
112698
113012
  if (postOnly) {
112699
113013
  if (postOnlyParsed) {
112700
- request['postOnly'] = postOnlyParsed;
113014
+ request['post_only'] = postOnlyParsed;
112701
113015
  }
112702
113016
  else {
112703
- request['postOnly'] = postOnly;
113017
+ request['post_only'] = postOnly;
112704
113018
  }
112705
113019
  }
112706
- const query = this.omit(params, ['postOnly', 'post_only']);
112707
- const response = await this[method](this.extend(request, query));
112708
- //
112709
- // spot and margin
112710
- //
112711
- // {
112712
- // "code": 0,
112713
- // "order_id": "198361cecdc65f9c8c9bb2fa68faec40"
112714
- // }
112715
- //
112716
- // swap
112717
- //
112718
- // {
112719
- // "code": 0,
112720
- // "data": "1590873693003714560"
112721
- // }
112722
- //
112723
- const order = this.parseOrder(response, market);
112724
- order['symbol'] = symbol;
112725
- order['type'] = type;
112726
- order['side'] = side;
112727
- order['amount'] = amount;
112728
- order['price'] = price;
112729
- return order;
113020
+ params = this.omit(params, ['postOnly']);
113021
+ return this.extend(request, params);
112730
113022
  }
112731
113023
  async cancelOrder(id, symbol = undefined, params = {}) {
112732
113024
  /**
@@ -112863,6 +113155,15 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
112863
113155
  // "data": "1590873693003714560"
112864
113156
  // }
112865
113157
  //
113158
+ // spot and swap: createOrders
113159
+ //
113160
+ // {
113161
+ // "order_id": "d64d92a5e0a120f792f385485bc3d95b",
113162
+ // "instrument_id": "BTC_USDT",
113163
+ // "amount": 0.0001,
113164
+ // "price": 27000
113165
+ // }
113166
+ //
112866
113167
  // spot: fetchOrder, fetchOpenOrders, fetchOrders
112867
113168
  //
112868
113169
  // {
@@ -112908,24 +113209,26 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
112908
113209
  let type = undefined;
112909
113210
  let side = this.safeString(order, 'type');
112910
113211
  const marketId = this.safeString2(order, 'symbol', 'instrument_id');
112911
- const symbol = this.safeSymbol(marketId, market, '_');
113212
+ const symbol = this.safeSymbol(marketId, market);
112912
113213
  market = this.market(symbol);
112913
113214
  if (market['type'] === 'swap') {
112914
113215
  const orderType = this.safeInteger(order, 'order_type');
112915
- if ((orderType === 9) || (orderType === 10) || (orderType === 11) || (orderType === 12) || (orderType === 15)) {
112916
- timeInForce = 'FOK';
112917
- }
112918
- else if ((orderType === 1) || (orderType === 2) || (orderType === 3) || (orderType === 4) || (orderType === 13)) {
112919
- timeInForce = 'IOC';
112920
- }
112921
- else if ((orderType === 6) || (orderType === 7) || (orderType === 8) || (orderType === 14)) {
112922
- timeInForce = 'GTC';
112923
- }
112924
- if ((orderType === 0) || (orderType === 1) || (orderType === 4) || (orderType === 5) || (orderType === 9) || (orderType === 10)) {
112925
- type = 'limit';
112926
- }
112927
- else {
112928
- type = 'market';
113216
+ if (orderType !== undefined) {
113217
+ if ((orderType === 9) || (orderType === 10) || (orderType === 11) || (orderType === 12) || (orderType === 15)) {
113218
+ timeInForce = 'FOK';
113219
+ }
113220
+ else if ((orderType === 1) || (orderType === 2) || (orderType === 3) || (orderType === 4) || (orderType === 13)) {
113221
+ timeInForce = 'IOC';
113222
+ }
113223
+ else if ((orderType === 6) || (orderType === 7) || (orderType === 8) || (orderType === 14)) {
113224
+ timeInForce = 'GTC';
113225
+ }
113226
+ if ((orderType === 0) || (orderType === 1) || (orderType === 4) || (orderType === 5) || (orderType === 9) || (orderType === 10)) {
113227
+ type = 'limit';
113228
+ }
113229
+ else {
113230
+ type = 'market';
113231
+ }
112929
113232
  }
112930
113233
  if (side === '1') {
112931
113234
  side = 'open long';
@@ -124495,7 +124798,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124495
124798
  if (quoteValueString === undefined) {
124496
124799
  quoteValueString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(baseValueString, priceString);
124497
124800
  }
124498
- return {
124801
+ return this.safeLiquidation({
124499
124802
  'info': liquidation,
124500
124803
  'symbol': this.safeSymbol(marketId, market),
124501
124804
  'contracts': this.parseNumber(contractsString),
@@ -124505,7 +124808,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124505
124808
  'quoteValue': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAbs */ .O.stringAbs(quoteValueString)),
124506
124809
  'timestamp': timestamp,
124507
124810
  'datetime': this.iso8601(timestamp),
124508
- };
124811
+ });
124509
124812
  }
124510
124813
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
124511
124814
  if (response === undefined) {
@@ -130332,7 +130635,7 @@ class hollaex extends _abstract_hollaex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
130332
130635
  //
130333
130636
  return this.parseOHLCVs(response, market, timeframe, since, limit);
130334
130637
  }
130335
- parseOHLCV(response, market = undefined) {
130638
+ parseOHLCV(ohlcv, market = undefined) {
130336
130639
  //
130337
130640
  // {
130338
130641
  // "time":"2020-03-02T20:00:00.000Z",
@@ -130345,12 +130648,12 @@ class hollaex extends _abstract_hollaex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
130345
130648
  // }
130346
130649
  //
130347
130650
  return [
130348
- this.parse8601(this.safeString(response, 'time')),
130349
- this.safeNumber(response, 'open'),
130350
- this.safeNumber(response, 'high'),
130351
- this.safeNumber(response, 'low'),
130352
- this.safeNumber(response, 'close'),
130353
- this.safeNumber(response, 'volume'),
130651
+ this.parse8601(this.safeString(ohlcv, 'time')),
130652
+ this.safeNumber(ohlcv, 'open'),
130653
+ this.safeNumber(ohlcv, 'high'),
130654
+ this.safeNumber(ohlcv, 'low'),
130655
+ this.safeNumber(ohlcv, 'close'),
130656
+ this.safeNumber(ohlcv, 'volume'),
130354
130657
  ];
130355
130658
  }
130356
130659
  parseBalance(response) {
@@ -136247,6 +136550,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
136247
136550
  * @param {string} [params.offset] *contract only* 'open', 'close', or 'both', required in hedge mode
136248
136551
  * @param {bool} [params.postOnly] *contract only* true or false
136249
136552
  * @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
136553
+ * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
136250
136554
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
136251
136555
  */
136252
136556
  await this.loadMarkets();
@@ -136319,6 +136623,13 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
136319
136623
  if (postOnly) {
136320
136624
  orderType = 'limit-maker';
136321
136625
  }
136626
+ const timeInForce = this.safeString(params, 'timeInForce', 'GTC');
136627
+ if (timeInForce === 'FOK') {
136628
+ orderType = orderType + '-fok';
136629
+ }
136630
+ else if (timeInForce === 'IOC') {
136631
+ orderType = 'ioc';
136632
+ }
136322
136633
  request['type'] = side + '-' + orderType;
136323
136634
  const clientOrderId = this.safeString2(params, 'clientOrderId', 'client-order-id'); // must be 64 chars max and unique within 24 hours
136324
136635
  if (clientOrderId === undefined) {
@@ -136366,7 +136677,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
136366
136677
  if (orderType in limitOrderTypes) {
136367
136678
  request['price'] = this.priceToPrecision(symbol, price);
136368
136679
  }
136369
- params = this.omit(params, ['stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator']);
136680
+ params = this.omit(params, ['stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce']);
136370
136681
  const response = await this.spotPrivatePostV1OrderOrdersPlace(this.extend(request, params));
136371
136682
  //
136372
136683
  // spot
@@ -136411,6 +136722,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
136411
136722
  * @param {float} amount how much of currency you want to trade in units of base currency
136412
136723
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
136413
136724
  * @param {object} params extra parameters specific to the huobi api endpoint
136725
+ * @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
136414
136726
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
136415
136727
  */
136416
136728
  const market = this.market(symbol);
@@ -136424,6 +136736,13 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
136424
136736
  if (postOnly) {
136425
136737
  type = 'post_only';
136426
136738
  }
136739
+ const timeInForce = this.safeString(params, 'timeInForce', 'GTC');
136740
+ if (timeInForce === 'FOK') {
136741
+ type = 'fok';
136742
+ }
136743
+ else if (timeInForce === 'IOC') {
136744
+ type = 'ioc';
136745
+ }
136427
136746
  const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
136428
136747
  const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
136429
136748
  const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
@@ -136476,7 +136795,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
136476
136795
  request['lever_rate'] = leverRate;
136477
136796
  request['order_price_type'] = type;
136478
136797
  }
136479
- params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate']);
136798
+ params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
136480
136799
  const broker = this.safeValue(this.options, 'broker', {});
136481
136800
  const brokerId = this.safeString(broker, 'id');
136482
136801
  request['channel_code'] = brokerId;
@@ -139918,7 +140237,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
139918
140237
  //
139919
140238
  const marketId = this.safeString(liquidation, 'contract_code');
139920
140239
  const timestamp = this.safeInteger(liquidation, 'created_at');
139921
- return {
140240
+ return this.safeLiquidation({
139922
140241
  'info': liquidation,
139923
140242
  'symbol': this.safeSymbol(marketId, market),
139924
140243
  'contracts': this.safeNumber(liquidation, 'volume'),
@@ -139928,7 +140247,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
139928
140247
  'quoteValue': this.safeNumber(liquidation, 'trade_turnover'),
139929
140248
  'timestamp': timestamp,
139930
140249
  'datetime': this.iso8601(timestamp),
139931
- };
140250
+ });
139932
140251
  }
139933
140252
  }
139934
140253
 
@@ -155657,9 +155976,6 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
155657
155976
  //
155658
155977
  return this.parseTicker(response['data'], market);
155659
155978
  }
155660
- async fetchTickers(symbols = undefined, params = {}) {
155661
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTickers() is not supported yet');
155662
- }
155663
155979
  parseTicker(ticker, market = undefined) {
155664
155980
  //
155665
155981
  // {
@@ -157327,14 +157643,16 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
157327
157643
  /* harmony import */ var _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4722);
157328
157644
  /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
157329
157645
  /* harmony import */ var _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9292);
157330
- /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1372);
157331
- /* harmony import */ var _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7110);
157646
+ /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1372);
157647
+ /* harmony import */ var _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7110);
157648
+ /* harmony import */ var _ccxt_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2194);
157332
157649
  // ---------------------------------------------------------------------------
157333
157650
 
157334
157651
 
157335
157652
 
157336
157653
 
157337
157654
 
157655
+
157338
157656
  // ---------------------------------------------------------------------------
157339
157657
  /**
157340
157658
  * @class kuna
@@ -157348,35 +157666,63 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157348
157666
  'name': 'Kuna',
157349
157667
  'countries': ['UA'],
157350
157668
  'rateLimit': 1000,
157351
- 'version': 'v2',
157669
+ 'version': 'v4',
157352
157670
  'has': {
157353
157671
  'CORS': undefined,
157354
157672
  'spot': true,
157355
- 'margin': undefined,
157673
+ 'margin': false,
157356
157674
  'swap': false,
157357
157675
  'future': false,
157358
157676
  'option': false,
157677
+ 'addMargin': false,
157678
+ 'borrowMargin': false,
157359
157679
  'cancelOrder': true,
157680
+ 'cancelOrders': true,
157681
+ 'createDepositAddress': true,
157360
157682
  'createOrder': true,
157683
+ 'createPostOnlyOrder': false,
157684
+ 'createReduceOnlyOrder': false,
157685
+ 'createStopLimitOrder': true,
157686
+ 'createStopMarketOrder': false,
157687
+ 'createStopOrder': true,
157361
157688
  'fetchBalance': true,
157689
+ 'fetchBorrowInterest': false,
157690
+ 'fetchBorrowRate': false,
157691
+ 'fetchBorrowRateHistories': false,
157692
+ 'fetchBorrowRateHistory': false,
157693
+ 'fetchBorrowRates': false,
157694
+ 'fetchBorrowRatesPerSymbol': false,
157695
+ 'fetchClosedOrders': true,
157696
+ 'fetchCurrencies': true,
157697
+ 'fetchDeposit': true,
157698
+ 'fetchDepositAddress': true,
157699
+ 'fetchDeposits': true,
157700
+ 'fetchDepositsWithdrawals': false,
157362
157701
  'fetchFundingHistory': false,
157363
157702
  'fetchFundingRate': false,
157364
157703
  'fetchFundingRateHistory': false,
157365
157704
  'fetchFundingRates': false,
157366
157705
  'fetchIndexOHLCV': false,
157706
+ 'fetchIsolatedPositions': false,
157367
157707
  'fetchL3OrderBook': true,
157368
157708
  'fetchLeverage': false,
157709
+ 'fetchLeverageTiers': false,
157369
157710
  'fetchMarginMode': false,
157711
+ 'fetchMarketLeverageTiers': false,
157370
157712
  'fetchMarkets': true,
157371
157713
  'fetchMarkOHLCV': false,
157372
157714
  'fetchMyTrades': true,
157373
157715
  'fetchOHLCV': 'emulated',
157716
+ 'fetchOpenInterest': false,
157374
157717
  'fetchOpenInterestHistory': false,
157375
157718
  'fetchOpenOrders': true,
157376
157719
  'fetchOrder': true,
157377
157720
  'fetchOrderBook': true,
157721
+ 'fetchOrdersByStatus': true,
157722
+ 'fetchPosition': false,
157378
157723
  'fetchPositionMode': false,
157379
157724
  'fetchPositions': false,
157725
+ 'fetchPositionsBySymbol': false,
157380
157726
  'fetchPositionsRisk': false,
157381
157727
  'fetchPremiumIndexOHLCV': false,
157382
157728
  'fetchTicker': true,
@@ -157385,9 +157731,20 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157385
157731
  'fetchTrades': true,
157386
157732
  'fetchTradingFee': false,
157387
157733
  'fetchTradingFees': false,
157734
+ 'fetchTransactions': false,
157735
+ 'fetchTransfers': false,
157736
+ 'fetchWithdrawAddresses': false,
157737
+ 'fetchWithdrawal': true,
157738
+ 'fetchWithdrawals': true,
157388
157739
  'reduceMargin': false,
157740
+ 'repayMargin': false,
157389
157741
  'setLeverage': false,
157742
+ 'setMargin': false,
157743
+ 'setMarginMode': false,
157390
157744
  'setPositionMode': false,
157745
+ 'signIn': false,
157746
+ 'transfer': false,
157747
+ 'withdraw': true,
157391
157748
  },
157392
157749
  'timeframes': undefined,
157393
157750
  'urls': {
@@ -157419,34 +157776,34 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157419
157776
  'v4': {
157420
157777
  'private': {
157421
157778
  'get': {
157422
- 'me': 1,
157423
- 'getBalance': 1,
157424
- 'active': 1,
157425
- 'order/history': 1,
157779
+ 'private/me': 1,
157780
+ 'private/getBalance': 1,
157781
+ 'order/private/active': 1,
157782
+ 'order/private/history': 1,
157426
157783
  'order/private/{id}/trades': 1,
157427
- 'order/details/{id}?withTrades={withTrades}': 1,
157428
- 'trade/history': 1,
157429
- 'transaction/{hash}': 1,
157430
- 'deposit/preRequest': 1,
157431
- 'deposit/crypto/address': 1,
157432
- 'deposit/crypto/getMerchantAddress': 1,
157433
- 'deposit/history': 1,
157434
- 'deposit/details/{depositId}': 1,
157435
- 'withdraw/preRequest': 1,
157436
- 'withdraw/history': 1,
157437
- 'withdraw/details/{withdrawId}': 1,
157784
+ 'order/private/details/{id}': 1,
157785
+ 'trade/private/history': 1,
157786
+ 'transaction/private/{hash}': 1,
157787
+ 'deposit/private/preRequest': 1,
157788
+ 'deposit/private/crypto/address': 1,
157789
+ 'deposit/private/crypto/getMerchantAddress': 1,
157790
+ 'deposit/private/history': 1,
157791
+ 'deposit/private/details/{depositId}': 1,
157792
+ 'withdraw/private/preRequest': 1,
157793
+ 'withdraw/private/history': 1,
157794
+ 'withdraw/private/details/{withdrawId}': 1,
157438
157795
  'kuna-code/{id}': 1,
157439
157796
  'kuna-code/{code}/check': 1,
157440
157797
  'kuna-code/issued-by-me': 1,
157441
157798
  'kuna-code/redeemed-by-me': 1,
157442
157799
  },
157443
157800
  'post': {
157444
- 'order/create': 1,
157445
- 'order/cancel': 1,
157446
- 'order/cancel/multi': 1,
157447
- 'deposit/crypto/generateAddress': 1,
157448
- 'deposit/crypto/generateMerchantAddress': 1,
157449
- 'withdraw/create': 1,
157801
+ 'order/private/create': 1,
157802
+ 'order/private/cancel': 1,
157803
+ 'order/private/cancel/multi': 1,
157804
+ 'deposit/private/crypto/generateAddress': 1,
157805
+ 'deposit/private/crypto/generateMerchantAddress': 1,
157806
+ 'withdraw/private/create': 1,
157450
157807
  'kuna-code': 1,
157451
157808
  },
157452
157809
  'put': {
@@ -157455,12 +157812,14 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157455
157812
  },
157456
157813
  'public': {
157457
157814
  'get': {
157458
- 'timestamp': 1,
157459
- 'fees': 1,
157460
- 'currencies?type={type}': 1,
157461
- 'markets/getAll': 1,
157462
- 'markets/tickers?pairs={pairs}': 1,
157463
- 'order/book/{pairs}': 1,
157815
+ 'public/timestamp': 1,
157816
+ 'public/fees': 1,
157817
+ 'public/currencies?type={type}': 1,
157818
+ 'public/currencies': 1,
157819
+ 'markets/public/getAll': 1,
157820
+ 'markets/public/tickers?pairs={pairs}': 1,
157821
+ 'order/public/book/{pairs}': 1,
157822
+ 'trade/public/book/{pairs}': 1,
157464
157823
  },
157465
157824
  },
157466
157825
  },
@@ -157668,6 +158027,12 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157668
158027
  },
157669
158028
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__/* .TICK_SIZE */ .sh,
157670
158029
  'exceptions': {
158030
+ 'ARGUMENT_VALIDATION_ERROR': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
158031
+ 'PAYMENT_METHOD_NOT_SUPPORTED': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
158032
+ 'NOT_FOUND': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
158033
+ 'INVALID:ORDER_SIZE': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
158034
+ 'WrongRequestException': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
158035
+ 'INSUFFICIENT_FUNDS': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
157671
158036
  '2002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
157672
158037
  '2003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
157673
158038
  },
@@ -157681,109 +158046,206 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157681
158046
  * @method
157682
158047
  * @name kuna#fetchTime
157683
158048
  * @description fetches the current integer timestamp in milliseconds from the exchange server
158049
+ * @see https://docs.kuna.io/docs/get-time-on-the-server
157684
158050
  * @param {object} [params] extra parameters specific to the kuna api endpoint
157685
158051
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
157686
158052
  */
157687
- const response = await this.publicGetTimestamp(params);
158053
+ const response = await this.v4PublicGetPublicTimestamp(params);
157688
158054
  //
157689
- // 1594911427
158055
+ // {
158056
+ // "data": {
158057
+ // "timestamp": 1686740531,
158058
+ // "timestamp_miliseconds": 1686740531725,
158059
+ // }
158060
+ // }
157690
158061
  //
157691
- return response * 1000;
158062
+ const data = this.safeValue(response, 'data', {});
158063
+ return this.safeInteger(data, 'timestamp_miliseconds');
158064
+ }
158065
+ async fetchCurrencies(params = {}) {
158066
+ /**
158067
+ * @method
158068
+ * @name kuna#fetchCurrencies
158069
+ * @description fetches all available currencies on an exchange
158070
+ * @see https://docs.kuna.io/docs/get-information-about-available-currencies
158071
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
158072
+ * @returns {object} an associative dictionary of currencies
158073
+ */
158074
+ const response = await this.v4PublicGetPublicCurrencies(params);
158075
+ //
158076
+ // {
158077
+ // "data": [
158078
+ // {
158079
+ // "code": "BTC",
158080
+ // "name": "Bitcoin",
158081
+ // "payload": {
158082
+ // "chart": "https://kuna-pro.kuna.io/bitcoin-chart",
158083
+ // "icons": {
158084
+ // "svg": "https://kuna-pro.kuna.io/icon-btc-svg",
158085
+ // "png2x": "https://kuna-pro.kuna.io/icon-btc-png2x",
158086
+ // "png3x": "https://kuna-pro.kuna.io/icon-btc-png3x",
158087
+ // "svgXL": "https://kuna-pro.kuna.io/icon-btc-svg"
158088
+ // },
158089
+ // "pngChart": "https://kuna-pro.kuna.io/png-bitcoin-chart"
158090
+ // },
158091
+ // "position": 1,
158092
+ // "precision": 8,
158093
+ // "tradePrecision": 6,
158094
+ // "type": "Crypto"
158095
+ // }
158096
+ // ]
158097
+ // }
158098
+ //
158099
+ const data = this.safeValue(response, 'data', []);
158100
+ return this.parseCurrencies(data);
158101
+ }
158102
+ parseCurrencies(currencies, params = {}) {
158103
+ currencies = this.toArray(currencies);
158104
+ const result = {};
158105
+ for (let i = 0; i < currencies.length; i++) {
158106
+ const currency = this.parseCurrency(currencies[i]);
158107
+ result[currency['code']] = currency;
158108
+ }
158109
+ return result;
158110
+ }
158111
+ parseCurrency(currency) {
158112
+ //
158113
+ // {
158114
+ // "code": "BTC",
158115
+ // "name": "Bitcoin",
158116
+ // "payload": {
158117
+ // "chart": "https://kuna-pro.kuna.io/bitcoin-chart",
158118
+ // "icons": {
158119
+ // "svg": "https://kuna-pro.kuna.io/icon-btc-svg",
158120
+ // "png2x": "https://kuna-pro.kuna.io/icon-btc-png2x",
158121
+ // "png3x": "https://kuna-pro.kuna.io/icon-btc-png3x",
158122
+ // "svgXL": "https://kuna-pro.kuna.io/icon-btc-svg"
158123
+ // },
158124
+ // "pngChart": "https://kuna-pro.kuna.io/png-bitcoin-chart"
158125
+ // },
158126
+ // "position": 1,
158127
+ // "precision": 8,
158128
+ // "tradePrecision": 6,
158129
+ // "type": "Crypto"
158130
+ // }
158131
+ //
158132
+ const currencyId = this.safeString(currency, 'code');
158133
+ const precision = this.safeString(currency, 'precision');
158134
+ const tradePrecision = this.safeString(currency, 'tradePrecision');
158135
+ return {
158136
+ 'info': currency,
158137
+ 'id': currencyId,
158138
+ 'code': this.safeCurrencyCode(currencyId),
158139
+ 'type': undefined,
158140
+ 'margin': undefined,
158141
+ 'name': this.safeString(currency, 'name'),
158142
+ 'active': undefined,
158143
+ 'deposit': undefined,
158144
+ 'withdraw': undefined,
158145
+ 'fee': undefined,
158146
+ 'precision': _ccxt_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMin */ .O.stringMin(precision, tradePrecision),
158147
+ 'limits': {
158148
+ 'amount': {
158149
+ 'min': undefined,
158150
+ 'max': undefined,
158151
+ },
158152
+ 'withdraw': {
158153
+ 'min': undefined,
158154
+ 'max': undefined,
158155
+ },
158156
+ },
158157
+ 'networks': {},
158158
+ };
157692
158159
  }
157693
158160
  async fetchMarkets(params = {}) {
157694
158161
  /**
157695
158162
  * @method
157696
158163
  * @name kuna#fetchMarkets
157697
158164
  * @description retrieves data on all markets for kuna
158165
+ * @see https://docs.kuna.io/docs/get-all-traded-markets
157698
158166
  * @param {object} [params] extra parameters specific to the exchange api endpoint
157699
158167
  * @returns {object[]} an array of objects representing market data
157700
158168
  */
157701
- const quotes = ['btc', 'rub', 'uah', 'usd', 'usdt', 'usdc'];
157702
- const markets = [];
157703
- const response = await this.publicGetTickers(params);
158169
+ const response = await this.v4PublicGetMarketsPublicGetAll(params);
157704
158170
  //
157705
158171
  // {
157706
- // shibuah: {
157707
- // at: '1644463685',
157708
- // ticker: {
157709
- // buy: '0.000911',
157710
- // sell: '0.00092',
157711
- // low: '0.000872',
157712
- // high: '0.000963',
157713
- // last: '0.000911',
157714
- // vol: '1539278096.0',
157715
- // price: '1434244.211249'
158172
+ // "data": [
158173
+ // {
158174
+ // "pair": "BTC_USDT", // Traded pair of assets
158175
+ // "baseAsset": { // The base asset of the traded pair, the one to sell or buy as a result of the trade
158176
+ // "code": "BTC",
158177
+ // "precision": 6 // Maximum amount of digits for the decimal part of a number
158178
+ // },
158179
+ // "quoteAsset": { // The quoted asset of the traded pair, the one to use to sell or buy the base asset
158180
+ // "code": "USDT",
158181
+ // "precision": 2 // Maximum amount of digits for the decimal part of a number
158182
+ // },
158183
+ // "tickerPriceChange": "-0.07" // Relative change compared with the last tick
157716
158184
  // }
157717
- // }
158185
+ // ]
157718
158186
  // }
157719
158187
  //
157720
- const ids = Object.keys(response);
157721
- for (let i = 0; i < ids.length; i++) {
157722
- const id = ids[i];
157723
- for (let j = 0; j < quotes.length; j++) {
157724
- const quoteId = quotes[j];
157725
- // usd gets matched before usdt in usdtusd USDT/USD
157726
- // https://github.com/ccxt/ccxt/issues/9868
157727
- const slicedId = id.slice(1);
157728
- const index = slicedId.indexOf(quoteId);
157729
- const slicePart = slicedId.slice(index);
157730
- if ((index > 0) && (slicePart === quoteId)) {
157731
- // usd gets matched before usdt in usdtusd USDT/USD
157732
- // https://github.com/ccxt/ccxt/issues/9868
157733
- const baseId = id[0] + slicedId.replace(quoteId, '');
157734
- const base = this.safeCurrencyCode(baseId);
157735
- const quote = this.safeCurrencyCode(quoteId);
157736
- markets.push({
157737
- 'id': id,
157738
- 'symbol': base + '/' + quote,
157739
- 'base': base,
157740
- 'quote': quote,
157741
- 'settle': undefined,
157742
- 'baseId': baseId,
157743
- 'quoteId': quoteId,
157744
- 'settleId': undefined,
157745
- 'type': 'spot',
157746
- 'spot': true,
157747
- 'margin': false,
157748
- 'swap': false,
157749
- 'future': false,
157750
- 'option': false,
157751
- 'active': undefined,
157752
- 'contract': false,
157753
- 'linear': undefined,
157754
- 'inverse': undefined,
157755
- 'contractSize': undefined,
157756
- 'expiry': undefined,
157757
- 'expiryDatetime': undefined,
157758
- 'strike': undefined,
157759
- 'optionType': undefined,
157760
- 'precision': {
157761
- 'amount': undefined,
157762
- 'price': undefined,
157763
- },
157764
- 'limits': {
157765
- 'leverage': {
157766
- 'min': undefined,
157767
- 'max': undefined,
157768
- },
157769
- 'amount': {
157770
- 'min': undefined,
157771
- 'max': undefined,
157772
- },
157773
- 'price': {
157774
- 'min': undefined,
157775
- 'max': undefined,
157776
- },
157777
- 'cost': {
157778
- 'min': undefined,
157779
- 'max': undefined,
157780
- },
157781
- },
157782
- 'created': undefined,
157783
- 'info': undefined,
157784
- });
157785
- }
157786
- }
158188
+ const data = this.safeValue(response, 'data', []);
158189
+ const markets = [];
158190
+ for (let i = 0; i < data.length; i++) {
158191
+ const item = data[i];
158192
+ const marketId = this.safeString(item, 'pair');
158193
+ const baseAsset = this.safeValue(item, 'baseAsset');
158194
+ const quoteAsset = this.safeValue(item, 'quoteAsset');
158195
+ const baseId = this.safeString(baseAsset, 'code');
158196
+ const quoteId = this.safeString(quoteAsset, 'code');
158197
+ const base = this.safeCurrencyCode(baseId);
158198
+ const quote = this.safeCurrencyCode(quoteId);
158199
+ const basePrecision = this.safeString(baseAsset, 'precision');
158200
+ const quotePrecision = this.safeString(quoteAsset, 'precision');
158201
+ markets.push({
158202
+ 'id': marketId,
158203
+ 'symbol': base + '/' + quote,
158204
+ 'base': base,
158205
+ 'quote': quote,
158206
+ 'settle': undefined,
158207
+ 'baseId': baseId,
158208
+ 'quoteId': quoteId,
158209
+ 'settleId': undefined,
158210
+ 'type': 'spot',
158211
+ 'spot': true,
158212
+ 'margin': false,
158213
+ 'swap': false,
158214
+ 'future': false,
158215
+ 'option': false,
158216
+ 'active': undefined,
158217
+ 'contract': false,
158218
+ 'linear': undefined,
158219
+ 'inverse': undefined,
158220
+ 'contractSize': undefined,
158221
+ 'expiry': undefined,
158222
+ 'expiryDatetime': undefined,
158223
+ 'strike': undefined,
158224
+ 'optionType': undefined,
158225
+ 'precision': {
158226
+ 'amount': this.parseNumber(this.parsePrecision(basePrecision)),
158227
+ 'price': this.parseNumber(this.parsePrecision(quotePrecision)),
158228
+ },
158229
+ 'limits': {
158230
+ 'leverage': {
158231
+ 'min': undefined,
158232
+ 'max': undefined,
158233
+ },
158234
+ 'amount': {
158235
+ 'min': undefined,
158236
+ 'max': undefined,
158237
+ },
158238
+ 'price': {
158239
+ 'min': undefined,
158240
+ 'max': undefined,
158241
+ },
158242
+ 'cost': {
158243
+ 'min': undefined,
158244
+ 'max': undefined,
158245
+ },
158246
+ },
158247
+ 'info': item,
158248
+ });
157787
158249
  }
157788
158250
  return markets;
157789
158251
  }
@@ -157792,78 +158254,137 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157792
158254
  * @method
157793
158255
  * @name kuna#fetchOrderBook
157794
158256
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
158257
+ * @see https://docs.kuna.io/docs/get-public-orders-book
157795
158258
  * @param {string} symbol unified symbol of the market to fetch the order book for
157796
- * @param {int} [limit] the maximum amount of order book entries to return
158259
+ * @param {int} [limit] 5, 10, 20, 50, 100, 500, or 1000 (default)
157797
158260
  * @param {object} [params] extra parameters specific to the kuna api endpoint
157798
158261
  * @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
157799
158262
  */
157800
158263
  await this.loadMarkets();
157801
158264
  const market = this.market(symbol);
157802
158265
  const request = {
157803
- 'market': market['id'],
158266
+ 'pairs': market['id'],
157804
158267
  };
157805
158268
  if (limit !== undefined) {
157806
- request['limit'] = limit; // default = 300
158269
+ request['level'] = limit;
157807
158270
  }
157808
- const orderbook = await this.publicGetDepth(this.extend(request, params));
157809
- const timestamp = this.safeTimestamp(orderbook, 'timestamp');
157810
- return this.parseOrderBook(orderbook, market['symbol'], timestamp);
158271
+ const response = await this.v4PublicGetOrderPublicBookPairs(this.extend(request, params));
158272
+ //
158273
+ // {
158274
+ // "data": {
158275
+ // "asks": [ // An array of sell orders
158276
+ // [
158277
+ // "16950", // Sell price, level 1
158278
+ // "0.001" // Sell quantity, level 1
158279
+ // ],
158280
+ // [
158281
+ // "17000", // Sell price, level 2
158282
+ // "0.01" // Sell quantity, level 2
158283
+ // ]
158284
+ // ],
158285
+ // "bids": [ // An array of buy orders
158286
+ // [
158287
+ // "16700", // Sell price, level 1
158288
+ // "0.01" // Sell quantity, level 1
158289
+ // ],
158290
+ // [
158291
+ // "16000", // Sell price, level 2
158292
+ // "0.001" // Sell quantity, level 2
158293
+ // ]
158294
+ // ]
158295
+ // }
158296
+ // }
158297
+ //
158298
+ const data = this.safeValue(response, 'data', {});
158299
+ return this.parseOrderBook(data, market['symbol'], undefined, 'bids', 'asks', 0, 1);
157811
158300
  }
157812
158301
  parseTicker(ticker, market = undefined) {
157813
- const timestamp = this.safeTimestamp(ticker, 'at');
157814
- ticker = ticker['ticker'];
157815
- const symbol = this.safeSymbol(undefined, market);
157816
- const last = this.safeString(ticker, 'last');
158302
+ //
158303
+ // {
158304
+ // "pair": "BTC_USDT", // Traded pair
158305
+ // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
158306
+ // "price": "27900", // Current median price
158307
+ // "equivalentPrice": "", // TBD
158308
+ // "high": "29059.69", // Highest price
158309
+ // "low": "27900", // Lowest price
158310
+ // "baseVolume": "2.9008499999999993", // Traded volume as base
158311
+ // "quoteVolume": "82251.41477976", // Traded volume as quote
158312
+ // "bestBidPrice": "27926.91", // The best bid price now
158313
+ // "bestAskPrice": "27970.02", // The best ask price now
158314
+ // "priceChange": "-973.9700000000012" // Absolute price change
158315
+ // }
158316
+ //
158317
+ const marketId = this.safeString(ticker, 'pair');
157817
158318
  return this.safeTicker({
157818
- 'symbol': symbol,
157819
- 'timestamp': timestamp,
157820
- 'datetime': this.iso8601(timestamp),
158319
+ 'info': ticker,
158320
+ 'symbol': this.safeSymbol(marketId, market),
158321
+ 'timestamp': undefined,
158322
+ 'datetime': undefined,
157821
158323
  'high': this.safeString(ticker, 'high'),
157822
158324
  'low': this.safeString(ticker, 'low'),
157823
- 'bid': this.safeString(ticker, 'buy'),
157824
- 'bidVolume': undefined,
157825
- 'ask': this.safeString(ticker, 'sell'),
157826
- 'askVolume': undefined,
158325
+ 'bid': this.safeString(ticker, 'bestBidPrice'),
158326
+ 'ask': this.safeString(ticker, 'bestAskPrice'),
157827
158327
  'vwap': undefined,
157828
158328
  'open': this.safeString(ticker, 'open'),
157829
- 'close': last,
157830
- 'last': last,
158329
+ 'close': undefined,
158330
+ 'last': undefined,
157831
158331
  'previousClose': undefined,
157832
- 'change': undefined,
157833
- 'percentage': undefined,
158332
+ 'change': this.safeString(ticker, 'priceChange'),
158333
+ 'percentage': this.safeString(ticker, 'percentagePriceChange'),
157834
158334
  'average': undefined,
157835
- 'baseVolume': this.safeString(ticker, 'vol'),
157836
- 'quoteVolume': undefined,
157837
- 'info': ticker,
158335
+ 'baseVolume': this.safeString(ticker, 'baseVolume'),
158336
+ 'quoteVolume': this.safeString(ticker, 'quoteVolume'),
157838
158337
  }, market);
157839
158338
  }
157840
158339
  async fetchTickers(symbols = undefined, params = {}) {
157841
158340
  /**
157842
158341
  * @method
157843
158342
  * @name kuna#fetchTickers
157844
- * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
157845
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
158343
+ * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market. The average is not returned in the response, but the median can be accessed via response['info']['price']
158344
+ * @see https://docs.kuna.io/docs/get-market-info-by-tickers
158345
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
157846
158346
  * @param {object} [params] extra parameters specific to the kuna api endpoint
157847
158347
  * @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
157848
158348
  */
157849
158349
  await this.loadMarkets();
157850
- symbols = this.marketSymbols(symbols);
157851
- const response = await this.publicGetTickers(params);
157852
- const ids = Object.keys(response);
157853
- const result = {};
157854
- for (let i = 0; i < ids.length; i++) {
157855
- const id = ids[i];
157856
- const market = this.safeMarket(id);
157857
- const symbol = market['symbol'];
157858
- result[symbol] = this.parseTicker(response[id], market);
158350
+ if (symbols === undefined) {
158351
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchTickers () requires a symbols argument');
157859
158352
  }
157860
- return this.filterByArrayTickers(result, 'symbol', symbols);
158353
+ symbols = this.marketSymbols(symbols);
158354
+ const marketIds = this.marketIds(symbols);
158355
+ const request = {
158356
+ 'pairs': marketIds.join(','),
158357
+ };
158358
+ const response = await this.v4PublicGetMarketsPublicTickersPairsPairs(this.extend(request, params));
158359
+ //
158360
+ // {
158361
+ // "data": [
158362
+ // {
158363
+ // "pair": "BTC_USDT", // Traded pair
158364
+ // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
158365
+ // "price": "27900", // Current median price
158366
+ // "equivalentPrice": "", // TBD
158367
+ // "high": "29059.69", // Highest price
158368
+ // "low": "27900", // Lowest price
158369
+ // "baseVolume": "2.9008499999999993", // Traded volume as base
158370
+ // "quoteVolume": "82251.41477976", // Traded volume as quote
158371
+ // "bestBidPrice": "27926.91", // The best bid price now
158372
+ // "bestAskPrice": "27970.02", // The best ask price now
158373
+ // "priceChange": "-973.9700000000012" // Absolute price change
158374
+ // }
158375
+ // ...
158376
+ // ]
158377
+ // }
158378
+ //
158379
+ const data = this.safeValue(response, 'data', []);
158380
+ return this.parseTickers(data, symbols, params);
157861
158381
  }
157862
158382
  async fetchTicker(symbol, params = {}) {
157863
158383
  /**
157864
158384
  * @method
157865
158385
  * @name kuna#fetchTicker
157866
158386
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
158387
+ * @see https://docs.kuna.io/docs/get-market-info-by-tickers
157867
158388
  * @param {string} symbol unified symbol of the market to fetch the ticker for
157868
158389
  * @param {object} [params] extra parameters specific to the kuna api endpoint
157869
158390
  * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -157871,13 +158392,36 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157871
158392
  await this.loadMarkets();
157872
158393
  const market = this.market(symbol);
157873
158394
  const request = {
157874
- 'market': market['id'],
158395
+ 'pairs': market['id'],
157875
158396
  };
157876
- const response = await this.publicGetTickersMarket(this.extend(request, params));
157877
- return this.parseTicker(response, market);
158397
+ const response = await this.v4PublicGetMarketsPublicTickersPairsPairs(this.extend(request, params));
158398
+ //
158399
+ // {
158400
+ // "data": [
158401
+ // {
158402
+ // "pair": "BTC_USDT", // Traded pair
158403
+ // "percentagePriceChange": "-0.03490931899641581", // Relative price change, in percent
158404
+ // "price": "27900", // Current median price
158405
+ // "equivalentPrice": "", // TBD
158406
+ // "high": "29059.69", // Highest price
158407
+ // "low": "27900", // Lowest price
158408
+ // "baseVolume": "2.9008499999999993", // Traded volume as base
158409
+ // "quoteVolume": "82251.41477976", // Traded volume as quote
158410
+ // "bestBidPrice": "27926.91", // The best bid price now
158411
+ // "bestAskPrice": "27970.02", // The best ask price now
158412
+ // "priceChange": "-973.9700000000012" // Absolute price change
158413
+ // }
158414
+ // ...
158415
+ // ]
158416
+ // }
158417
+ //
158418
+ const data = this.safeValue(response, 'data', []);
158419
+ const ticker = this.safeValue(data, 0);
158420
+ return this.parseTicker(ticker, market);
157878
158421
  }
157879
158422
  async fetchL3OrderBook(symbol, limit = undefined, params = {}) {
157880
158423
  /**
158424
+ * TODO: double check
157881
158425
  * @method
157882
158426
  * @name kuna#fetchL3OrderBook
157883
158427
  * @description fetches level 3 information on open orders with bid (buy) and ask (sell) prices, volumes and other data
@@ -157893,136 +158437,115 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
157893
158437
  * @method
157894
158438
  * @name kuna#fetchTrades
157895
158439
  * @description get the list of most recent trades for a particular symbol
158440
+ * @see https://docs.kuna.io/docs/get-public-trades-book
157896
158441
  * @param {string} symbol unified symbol of the market to fetch trades for
157897
158442
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
157898
- * @param {int} [limit] the maximum amount of trades to fetch
158443
+ * @param {int} [limit] between 1 and 100, 25 by default
157899
158444
  * @param {object} [params] extra parameters specific to the kuna api endpoint
157900
158445
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
157901
158446
  */
157902
158447
  await this.loadMarkets();
157903
158448
  const market = this.market(symbol);
157904
158449
  const request = {
157905
- 'market': market['id'],
158450
+ 'pair': market['id'],
157906
158451
  };
157907
- const response = await this.publicGetTrades(this.extend(request, params));
158452
+ if (limit !== undefined) {
158453
+ request['limit'] = limit;
158454
+ }
158455
+ const response = await this.v4PublicGetTradePublicBookPairs(this.extend(request, params));
157908
158456
  //
157909
- // [
157910
- // {
157911
- // "id":11353466,
157912
- // "price":"3000.16",
157913
- // "volume":"0.000397",
157914
- // "funds":"1.19106352",
157915
- // "market":"ethusdt",
157916
- // "created_at":"2022-04-12T18:32:36Z",
157917
- // "side":null,
157918
- // "trend":"sell"
157919
- // },
157920
- // ]
158457
+ // {
158458
+ // "data": {
158459
+ // "id": "3e5591ba-2778-4d85-8851-54284045ea44", // Unique identifier of a trade
158460
+ // "pair": "BTC_USDT", // Market pair that is being traded
158461
+ // "quoteQuantity": "11528.8118", // Qty of the quote asset, USDT in this example
158462
+ // "matchPrice": "18649", // Exchange price at the moment of execution
158463
+ // "matchQuantity": "0.6182", // Qty of the base asset, BTC in this example
158464
+ // "createdAt": "2022-09-23T14:30:41.486Z", // Date-time of trade execution, UTC
158465
+ // "side": "Ask" // Trade type: `Ask` or `Bid`. Bid for buying base asset, Ask for selling base asset (e.g. for BTC_USDT trading pair, BTC is the base asset).
158466
+ // }
158467
+ // }
157921
158468
  //
157922
- return this.parseTrades(response, market, since, limit);
158469
+ const data = this.safeValue(response, 'data', {});
158470
+ return this.parseTrades(data, market, since, limit);
157923
158471
  }
157924
158472
  parseTrade(trade, market = undefined) {
157925
158473
  //
157926
158474
  // fetchTrades (public)
157927
158475
  //
157928
- // {
157929
- // "id":11353466,
157930
- // "price":"3000.16",
157931
- // "volume":"0.000397",
157932
- // "funds":"1.19106352",
157933
- // "market":"ethusdt",
157934
- // "created_at":"2022-04-12T18:32:36Z",
157935
- // "side":null,
157936
- // "trend":"sell"
157937
- // }
158476
+ // {
158477
+ // "id": "3e5591ba-2778-4d85-8851-54284045ea44", // Unique identifier of a trade
158478
+ // "pair": "BTC_USDT", // Market pair that is being traded
158479
+ // "quoteQuantity": "11528.8118", // Qty of the quote asset, USDT in this example
158480
+ // "matchPrice": "18649", // Exchange price at the moment of execution
158481
+ // "matchQuantity": "0.6182", // Qty of the base asset, BTC in this example
158482
+ // "createdAt": "2022-09-23T14:30:41.486Z", // Date-time of trade execution, UTC
158483
+ // "side": "Ask" // Trade type: `Ask` or `Bid`. Bid for buying base asset, Ask for selling base asset (e.g. for BTC_USDT trading pair, BTC is the base asset).
158484
+ // }
157938
158485
  //
157939
- // fetchMyTrades (private)
158486
+ // fetchMyTrades, fetchOrder (private)
157940
158487
  //
157941
- // {
157942
- // "id":11353719,
157943
- // "price":"0.13566",
157944
- // "volume":"99.0",
157945
- // "funds":"13.43034",
157946
- // "market":"dogeusdt",
157947
- // "created_at":"2022-04-12T18:58:44Z",
157948
- // "side":"ask",
157949
- // "order_id":1665670371,
157950
- // "trend":"buy"
157951
- // }
158488
+ // {
158489
+ // id: "edb17459-c9bf-4148-9ae6-7367d7f55d71", // Unique identifier of a trade
158490
+ // orderId: "a80bec3f-4ffa-45c1-9d78-f6301e9748fe", // Unique identifier of an order associated with the trade
158491
+ // pair: "BTC_USDT", // Traded pair, base asset first, followed by quoted asset
158492
+ // quantity: "1.5862", // Traded quantity of base asset
158493
+ // price: "19087", // Price of the trade
158494
+ // isTaker: true, // Various fees for Makers and Takers; "Market" orders are always `true`
158495
+ // fee: "0.0039655", // Exchange commission fee
158496
+ // feeCurrency: "BTC", // Currency of the commission
158497
+ // isBuyer: true, // Buy or sell the base asset
158498
+ // quoteQuantity: "30275.7994", // Quote asset quantity spent to fulfill the base amount
158499
+ // createdAt: "2022-09-29T13:43:53.824Z", // Date-time of trade execution, UTC
158500
+ // }
157952
158501
  //
157953
- const timestamp = this.parse8601(this.safeString(trade, 'created_at'));
157954
- let symbol = undefined;
157955
- if (market) {
157956
- symbol = market['symbol'];
157957
- }
157958
- let side = this.safeString2(trade, 'side', 'trend');
157959
- if (side !== undefined) {
157960
- const sideMap = {
157961
- 'ask': 'sell',
157962
- 'bid': 'buy',
157963
- };
157964
- side = this.safeString(sideMap, side, side);
158502
+ const datetime = this.safeString(trade, 'createdAt');
158503
+ const marketId = this.safeString(trade, 'pair');
158504
+ const isTaker = this.safeValue(trade, 'isMaker');
158505
+ let side = this.safeStringLower(trade, 'side');
158506
+ if (side === undefined) {
158507
+ const isBuyer = this.safeValue(trade, 'isBuyer');
158508
+ side = isBuyer ? 'buy' : 'sell';
157965
158509
  }
157966
- const priceString = this.safeString(trade, 'price');
157967
- const amountString = this.safeString(trade, 'volume');
157968
- const costString = this.safeNumber(trade, 'funds');
157969
- const orderId = this.safeString(trade, 'order_id');
157970
- const id = this.safeString(trade, 'id');
157971
158510
  return this.safeTrade({
157972
- 'id': id,
157973
158511
  'info': trade,
157974
- 'timestamp': timestamp,
157975
- 'datetime': this.iso8601(timestamp),
157976
- 'symbol': symbol,
158512
+ 'id': this.safeString(trade, 'id'),
158513
+ 'symbol': this.safeSymbol(marketId, market),
158514
+ 'timestamp': this.parse8601(datetime),
158515
+ 'datetime': datetime,
157977
158516
  'type': undefined,
157978
158517
  'side': side,
157979
- 'order': orderId,
157980
- 'takerOrMaker': undefined,
157981
- 'price': priceString,
157982
- 'amount': amountString,
157983
- 'cost': costString,
157984
- 'fee': undefined,
158518
+ 'order': this.safeString(trade, 'orderId'),
158519
+ 'takerOrMaker': isTaker ? 'taker' : 'maker',
158520
+ 'price': this.safeString2(trade, 'matchPrice', 'price'),
158521
+ 'amount': this.safeString2(trade, 'matchQuantity', 'quantity'),
158522
+ 'cost': this.safeString(trade, 'quoteQuantity'),
158523
+ 'fee': {
158524
+ 'cost': this.safeString(trade, 'fee'),
158525
+ 'currency': this.safeCurrencyCode(this.safeString(trade, 'feeCurrency')),
158526
+ 'rate': undefined,
158527
+ },
157985
158528
  }, market);
157986
158529
  }
157987
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
157988
- /**
157989
- * @method
157990
- * @name kuna#fetchOHLCV
157991
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
157992
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
157993
- * @param {string} timeframe the length of time each candle represents
157994
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
157995
- * @param {int} [limit] the maximum amount of candles to fetch
157996
- * @param {object} [params] extra parameters specific to the kuna api endpoint
157997
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
157998
- */
157999
- await this.loadMarkets();
158000
- const trades = await this.fetchTrades(symbol, since, limit, params);
158001
- const ohlcvc = this.buildOHLCVC(trades, timeframe, since, limit);
158002
- const result = [];
158003
- for (let i = 0; i < ohlcvc.length; i++) {
158004
- const ohlcv = ohlcvc[i];
158005
- result.push([
158006
- ohlcv[0],
158007
- ohlcv[1],
158008
- ohlcv[2],
158009
- ohlcv[3],
158010
- ohlcv[4],
158011
- ohlcv[5],
158012
- ]);
158013
- }
158014
- return result;
158015
- }
158016
158530
  parseBalance(response) {
158017
- const balances = this.safeValue(response, 'accounts', []);
158018
- const result = { 'info': balances };
158019
- for (let i = 0; i < balances.length; i++) {
158020
- const balance = balances[i];
158531
+ //
158532
+ // [
158533
+ // {
158534
+ // "currency": "UAH",
158535
+ // "balance": "7134.6",
158536
+ // "lockBalance": "100"
158537
+ // }
158538
+ // ...
158539
+ // ]
158540
+ //
158541
+ const result = { 'info': response };
158542
+ for (let i = 0; i < response.length; i++) {
158543
+ const balance = response[i];
158021
158544
  const currencyId = this.safeString(balance, 'currency');
158022
158545
  const code = this.safeCurrencyCode(currencyId);
158023
158546
  const account = this.account();
158024
158547
  account['free'] = this.safeString(balance, 'balance');
158025
- account['used'] = this.safeString(balance, 'locked');
158548
+ account['used'] = this.safeString(balance, 'lockBalance');
158026
158549
  result[code] = account;
158027
158550
  }
158028
158551
  return this.safeBalance(result);
@@ -158036,35 +158559,79 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
158036
158559
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
158037
158560
  */
158038
158561
  await this.loadMarkets();
158039
- const response = await this.privateGetMembersMe(params);
158040
- return this.parseBalance(response);
158562
+ const response = await this.v4PrivateGetPrivateGetBalance(params);
158563
+ //
158564
+ // {
158565
+ // "data": [{
158566
+ // "currency": "UAH", // Wallet currency
158567
+ // "balance": "7134.6", // Available balance, precision depends on the currency
158568
+ // "lockBalance": "100" // Minimum amount locked on the balance
158569
+ // }]
158570
+ // }
158571
+ //
158572
+ const data = this.safeValue(response, 'data', []);
158573
+ return this.parseBalance(data);
158041
158574
  }
158042
158575
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
158043
158576
  /**
158044
158577
  * @method
158045
158578
  * @name kuna#createOrder
158046
158579
  * @description create a trade order
158580
+ * @see https://docs.kuna.io/docs/create-a-new-order-private
158047
158581
  * @param {string} symbol unified symbol of the market to create an order in
158048
158582
  * @param {string} type 'market' or 'limit'
158049
158583
  * @param {string} side 'buy' or 'sell'
158050
158584
  * @param {float} amount how much of currency you want to trade in units of base currency
158051
158585
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
158052
158586
  * @param {object} [params] extra parameters specific to the kuna api endpoint
158587
+ * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
158588
+ *
158589
+ * EXCHANGE SPECIFIC PARAMETERS
158590
+ * @param {string} [params.id] id must be a UUID format, if you do not specify id, it will be generated automatically.
158591
+ * @param {float} [params.quoteQuantity] the max quantity of the quote asset to use for selling/buying
158053
158592
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
158054
158593
  */
158055
158594
  await this.loadMarkets();
158056
158595
  const market = this.market(symbol);
158596
+ const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
158597
+ params = this.omit(params, ['triggerPrice', 'stopPrice']);
158598
+ const capitalizedType = this.capitalize(type);
158057
158599
  const request = {
158058
- 'market': market['id'],
158059
- 'side': side,
158060
- 'volume': amount.toString(),
158061
- 'ord_type': type,
158600
+ 'pair': market['id'],
158601
+ 'orderSide': (side === 'buy') ? 'Bid' : 'Ask',
158602
+ 'quantity': amount.toString(),
158603
+ 'type': capitalizedType,
158062
158604
  };
158063
- if (type === 'limit') {
158064
- request['price'] = price.toString();
158605
+ if (capitalizedType === 'Limit') {
158606
+ request['price'] = this.priceToPrecision(market['symbol'], price);
158065
158607
  }
158066
- const response = await this.privatePostOrders(this.extend(request, params));
158067
- return this.parseOrder(response, market);
158608
+ if (triggerPrice !== undefined) {
158609
+ if (capitalizedType === 'Market') {
158610
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrder () cannot place trigger market orders, or trigger limit');
158611
+ }
158612
+ request['stopPrice'] = this.priceToPrecision(market['symbol'], triggerPrice);
158613
+ if (capitalizedType !== 'TakeProfitLimit') {
158614
+ request['type'] = 'StopLossLimit';
158615
+ }
158616
+ }
158617
+ const response = await this.v4PrivatePostOrderPrivateCreate(this.extend(request, params));
158618
+ //
158619
+ // {
158620
+ // "data": {
158621
+ // "id": "b0fcb54c-2278-4f16-a300-02765faad8b0", // ID of your newly created order
158622
+ // "type": "Limit", // Type of an order
158623
+ // "quantity": "0.06", // Original order quantity
158624
+ // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
158625
+ // "pair": "BTC_USDT", // Traded pair
158626
+ // "price": "26440.46", // Price of the trade
158627
+ // "status": "Open", // The status of the order
158628
+ // "createdAt": "2023-07-11T08:01:30.550Z", // Date-time of order creation, UTC
158629
+ // "updatedAt": "2023-07-11T08:01:30.550Z" // Date-time of the last update of the order, UTC
158630
+ // }
158631
+ // }
158632
+ //
158633
+ const data = this.safeValue(response, 'data', {});
158634
+ return this.parseOrder(data, market);
158068
158635
  }
158069
158636
  async cancelOrder(id, symbol = undefined, params = {}) {
158070
158637
  /**
@@ -158072,24 +158639,66 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
158072
158639
  * @name kuna#cancelOrder
158073
158640
  * @description cancels an open order
158074
158641
  * @param {string} id order id
158075
- * @param {string} symbol not used by kuna cancelOrder ()
158642
+ * @param {string} symbol unified market symbol
158076
158643
  * @param {object} [params] extra parameters specific to the kuna api endpoint
158077
158644
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
158078
158645
  */
158079
158646
  await this.loadMarkets();
158080
158647
  const request = {
158081
- 'id': id,
158648
+ 'orderId': id,
158082
158649
  };
158083
- const response = await this.privatePostOrderDelete(this.extend(request, params));
158084
- const order = this.parseOrder(response);
158085
- const status = order['status'];
158086
- if (status === 'closed' || status === 'canceled') {
158087
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound(this.id + ' ' + this.json(order));
158650
+ const response = await this.v4PrivatePostOrderPrivateCancel(this.extend(request, params));
158651
+ //
158652
+ // {
158653
+ // "data": {
158654
+ // "success": true
158655
+ // }
158656
+ // }
158657
+ //
158658
+ const data = this.safeValue(response, 'data', {});
158659
+ let market = undefined;
158660
+ if (symbol !== undefined) {
158661
+ market = this.market(symbol);
158088
158662
  }
158663
+ const order = this.parseOrder(data, market);
158664
+ order['id'] = id;
158089
158665
  return order;
158090
158666
  }
158667
+ async cancelOrders(ids, symbol = undefined, params = {}) {
158668
+ /**
158669
+ * @method
158670
+ * @name kuna#cancelOrder
158671
+ * @description cancels an open order
158672
+ * @param {string} ids order ids
158673
+ * @param {string} symbol not used by kuna cancelOrder
158674
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
158675
+ * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
158676
+ */
158677
+ await this.loadMarkets();
158678
+ const request = {
158679
+ 'orderIds': ids,
158680
+ };
158681
+ const response = await this.v4PrivatePostOrderPrivateCancelMulti(this.extend(request, params));
158682
+ //
158683
+ // {
158684
+ // "data": [
158685
+ // {
158686
+ // "id": "c7fc5b2b-bd9d-48c1-a458-a83412669fe2", // Unique identifier of a canceled order
158687
+ // "success": true // Status for this order
158688
+ // },
158689
+ // ...
158690
+ // ]
158691
+ // }
158692
+ //
158693
+ const data = this.safeValue(response, 'data', []);
158694
+ return this.parseOrders(data);
158695
+ }
158091
158696
  parseOrderStatus(status) {
158092
158697
  const statuses = {
158698
+ 'Canceled': 'canceled',
158699
+ 'Closed': 'filled',
158700
+ 'Pending': 'open',
158701
+ 'Open': 'open',
158093
158702
  'done': 'closed',
158094
158703
  'wait': 'open',
158095
158704
  'cancel': 'canceled',
@@ -158097,36 +158706,81 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
158097
158706
  return this.safeString(statuses, status, status);
158098
158707
  }
158099
158708
  parseOrder(order, market = undefined) {
158100
- const marketId = this.safeString(order, 'market');
158101
- const symbol = this.safeSymbol(marketId, market);
158102
- const timestamp = this.parse8601(this.safeString(order, 'created_at'));
158103
- const status = this.parseOrderStatus(this.safeString(order, 'state'));
158104
- const type = this.safeString(order, 'type');
158105
- const side = this.safeString(order, 'side');
158106
- const id = this.safeString(order, 'id');
158709
+ //
158710
+ // createOrder, fetchOrder, fetchOpenOrders, fetchOrdersByStatus
158711
+ //
158712
+ // {
158713
+ // "id": "5992a049-8612-409d-8599-2c3d7298b106", // Unique identifier of an order
158714
+ // "type": "Limit", // Type of an order
158715
+ // "quantity": "5", // Original order quantity
158716
+ // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
158717
+ // "cumulativeQuoteQty": "0", // *absent on createOrder* Traded quantity in money (>0 if traded)
158718
+ // "cost": "0.05", // Total amount
158719
+ // "side": "Bid", // *absent on createOrder* Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
158720
+ // "pair": "TRX_USDT", // Traded pair
158721
+ // "price": "0.01", // Price of the trade
158722
+ // "status": "Open", // The status of the order
158723
+ // "createdAt": "2023-07-11T07:04:20.131Z", // Date-time of order creation, UTC
158724
+ // "updatedAt": "2023-07-11T07:04:20.131Z" // Date-time of the last update of the order, UTC
158725
+ // "closedAt": "2023-05-08T08:53:58.333Z" // *absent on fetchOpenOrders/createOrder* Date-time of order finish time, UTC
158726
+ // "trades": [ // * fetchOrder only *
158727
+ // {
158728
+ // "id": "15ff497c-8d25-4155-8184-bb1f905cce1e", // Unique identifier of a trade
158729
+ // "orderId": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an associated order
158730
+ // "pair": "BTC_USDT", // Traded pair
158731
+ // "quantity": "0.00054", // Traded quantity
158732
+ // "price": "27770", // Traded price
158733
+ // "isTaker": false, // Various fees for Makers and Takers; "Market" orders are always `true`
158734
+ // "fee": "0.000001350", // Exchange commission fee
158735
+ // "feeCurrency": "BTC", // Currency of the commission
158736
+ // "isBuyer": true, // Buy or sell the base asset
158737
+ // "quoteQuantity": "14.9958", // Quote asset quantity
158738
+ // "createdAt": "2023-05-08T08:53:58.332Z" // Date-time of trade execution, UTC
158739
+ // }
158740
+ // ]
158741
+ // }
158742
+ //
158743
+ // cancelOrder, cancelOrders
158744
+ //
158745
+ // {
158746
+ // "id": "c7fc5b2b-bd9d-48c1-a458-a83412669fe2", // Unique identifier of a canceled order *absent on cancelOrder*
158747
+ // "success": true // Status for this order
158748
+ // }
158749
+ //
158750
+ const marketId = this.safeString(order, 'pair');
158751
+ const datetime = this.safeString(order, 'createdAt');
158752
+ const triggerPrice = this.safeString(order, 'stopPrice');
158753
+ let side = this.safeString(order, 'side');
158754
+ if (side === 'Bid') {
158755
+ side = 'buy';
158756
+ }
158757
+ else if (side === 'Ask') {
158758
+ side = 'sell';
158759
+ }
158760
+ const trades = this.safeValue(order, 'trades', []);
158107
158761
  return this.safeOrder({
158108
- 'id': id,
158762
+ 'info': order,
158763
+ 'id': this.safeString2(order, 'id', 'orderId'),
158109
158764
  'clientOrderId': undefined,
158110
- 'timestamp': timestamp,
158111
- 'datetime': this.iso8601(timestamp),
158112
- 'lastTradeTimestamp': undefined,
158113
- 'status': status,
158114
- 'symbol': symbol,
158115
- 'type': type,
158765
+ 'symbol': this.safeSymbol(marketId, market),
158766
+ 'timestamp': this.parse8601(datetime),
158767
+ 'datetime': datetime,
158768
+ 'lastTradeTimestamp': this.parse8601(this.safeString(order, 'updatedAt')),
158769
+ 'status': this.parseOrderStatus(this.safeString(order, 'status')),
158770
+ 'type': this.safeStringLower(order, 'type'),
158116
158771
  'timeInForce': undefined,
158117
158772
  'postOnly': undefined,
158118
158773
  'side': side,
158119
158774
  'price': this.safeString(order, 'price'),
158120
- 'stopPrice': undefined,
158121
- 'triggerPrice': undefined,
158122
- 'amount': this.safeString(order, 'volume'),
158123
- 'filled': this.safeString(order, 'executed_volume'),
158124
- 'remaining': this.safeString(order, 'remaining_volume'),
158125
- 'trades': undefined,
158126
- 'fee': undefined,
158127
- 'info': order,
158128
- 'cost': undefined,
158775
+ 'stopPrice': triggerPrice,
158776
+ 'triggerPrice': triggerPrice,
158777
+ 'amount': this.safeString(order, 'quantity'),
158778
+ 'filled': this.safeString(order, 'executedQuantity'),
158779
+ 'remaining': undefined,
158780
+ 'trades': this.parseTrades(trades),
158781
+ 'cost': this.safeString(order, 'cost'),
158129
158782
  'average': undefined,
158783
+ 'fee': undefined,
158130
158784
  }, market);
158131
158785
  }
158132
158786
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -158134,78 +158788,656 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
158134
158788
  * @method
158135
158789
  * @name kuna#fetchOrder
158136
158790
  * @description fetches information on an order made by the user
158791
+ * @see https://docs.kuna.io/docs/get-order-details-by-id
158137
158792
  * @param {string} symbol not used by kuna fetchOrder
158138
158793
  * @param {object} [params] extra parameters specific to the kuna api endpoint
158794
+ *
158795
+ * EXCHANGE SPECIFIC PARAMETERS
158796
+ * @param {boolean} [params.withTrades] default == true, specify if the response should include trades associated with the order
158139
158797
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
158140
158798
  */
158141
158799
  await this.loadMarkets();
158142
158800
  const request = {
158143
- 'id': parseInt(id),
158801
+ 'id': id,
158802
+ 'withTrades': true,
158144
158803
  };
158145
- const response = await this.privateGetOrder(this.extend(request, params));
158146
- return this.parseOrder(response);
158804
+ const response = await this.v4PrivateGetOrderPrivateDetailsId(this.extend(request, params));
158805
+ //
158806
+ // {
158807
+ // "data": {
158808
+ // "id": "4b9b9705-e85f-4180-bdec-219fbf025fa3",
158809
+ // "type": "Limit",
158810
+ // "quantity": "0.00054",
158811
+ // "executedQuantity": "0.00054",
158812
+ // "cumulativeQuoteQty": "14.99580",
158813
+ // "cost": "14.9958",
158814
+ // "side": "Bid",
158815
+ // "pair": "BTC_USDT",
158816
+ // "price": "27770",
158817
+ // "status": "Closed",
158818
+ // "createdAt": "2023-05-08T08:39:46.708Z",
158819
+ // "updatedAt": "2023-05-08T08:53:58.332Z",
158820
+ // "closedAt": "2023-05-08T08:53:58.333Z",
158821
+ // "trades": [
158822
+ // {
158823
+ // "id": "15ff497c-8d25-4155-8184-bb1f905cce1e", // Unique identifier of a trade
158824
+ // "orderId": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an associated order
158825
+ // "pair": "BTC_USDT", // Traded pair
158826
+ // "quantity": "0.00054", // Traded quantity
158827
+ // "price": "27770", // Traded price
158828
+ // "isTaker": false, // Various fees for Makers and Takers; "Market" orders are always `true`
158829
+ // "fee": "0.000001350", // Exchange commission fee
158830
+ // "feeCurrency": "BTC", // Currency of the commission
158831
+ // "isBuyer": true, // Buy or sell the base asset
158832
+ // "quoteQuantity": "14.9958", // Quote asset quantity
158833
+ // "createdAt": "2023-05-08T08:53:58.332Z" // Date-time of trade execution, UTC
158834
+ // }
158835
+ // ]
158836
+ // }
158837
+ // }
158838
+ //
158839
+ const data = this.safeValue(response, 'data', {});
158840
+ return this.parseOrder(data);
158147
158841
  }
158148
158842
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
158149
158843
  /**
158150
158844
  * @method
158151
158845
  * @name kuna#fetchOpenOrders
158152
158846
  * @description fetch all unfilled currently open orders
158847
+ * @see https://docs.kuna.io/docs/get-active-client-orders-private
158153
158848
  * @param {string} symbol unified market symbol
158154
158849
  * @param {int} [since] the earliest time in ms to fetch open orders for
158155
- * @param {int} [limit] the maximum number of open orders structures to retrieve
158850
+ * @param {int} [limit] 1-100, the maximum number of open orders structures to retrieve
158156
158851
  * @param {object} [params] extra parameters specific to the kuna api endpoint
158852
+ * @param {int} [params.until] the latest timestamp (ms) to fetch orders for
158853
+ *
158854
+ * EXCHANGE SPECIFIC PARAMETERS
158855
+ * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
158157
158856
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
158158
158857
  */
158159
- if (symbol === undefined) {
158160
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
158858
+ await this.loadMarkets();
158859
+ const until = this.safeInteger(params, 'until');
158860
+ params = this.omit(params, ['until']);
158861
+ let market = undefined;
158862
+ const request = {};
158863
+ if (symbol !== undefined) {
158864
+ market = this.market(symbol);
158865
+ request['pairs'] = market['id'];
158866
+ }
158867
+ if (since !== undefined) {
158868
+ request['start'] = this.iso8601(since);
158161
158869
  }
158870
+ if (limit !== undefined) {
158871
+ request['limit'] = limit;
158872
+ }
158873
+ if (until !== undefined) {
158874
+ request['end'] = this.iso8601(until);
158875
+ }
158876
+ const response = await this.v4PrivateGetOrderPrivateActive(this.extend(request, params));
158877
+ //
158878
+ // {
158879
+ // "data": [
158880
+ // {
158881
+ // "id": "5992a049-8612-409d-8599-2c3d7298b106", // Unique identifier of an order
158882
+ // "type": "Limit", // Type of an order
158883
+ // "quantity": "5", // Original order quantity
158884
+ // "executedQuantity": "0", // Traded quantity in stock (>0 if traded)
158885
+ // "cumulativeQuoteQty": "0", // Traded quantity in money (>0 if traded)
158886
+ // "cost": "0.05", // Total amount
158887
+ // "side": "Bid", // Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
158888
+ // "pair": "TRX_USDT", // Traded pair
158889
+ // "price": "0.01", // Price of the trade
158890
+ // "status": "Open", // The status of the order
158891
+ // "createdAt": "2023-07-11T07:04:20.131Z", // Date-time of order creation, UTC
158892
+ // "updatedAt": "2023-07-11T07:04:20.131Z" // Date-time of the last update of the order, UTC
158893
+ // }
158894
+ // ...
158895
+ // ]
158896
+ // }
158897
+ //
158898
+ const data = this.safeValue(response, 'data', []);
158899
+ return this.parseOrders(data, market, since, limit);
158900
+ }
158901
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
158902
+ /**
158903
+ * @method
158904
+ * @name kuna#fetchClosedOrders
158905
+ * @description fetches information on multiple closed orders made by the user
158906
+ * @see https://docs.kuna.io/docs/get-private-orders-history
158907
+ * @param {string} symbol unified market symbol of the market orders were made in
158908
+ * @param {int} [since] the earliest time in ms to fetch orders for
158909
+ * @param {int} [limit] the maximum number of orde structures to retrieve
158910
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
158911
+ * @param {int} [params.until] the latest time in ms to fetch orders for
158912
+ *
158913
+ * EXCHANGE SPECIFIC PARAMETERS
158914
+ * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
158915
+ * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
158916
+ */
158917
+ return await this.fetchOrdersByStatus('closed', symbol, since, limit, params);
158918
+ }
158919
+ async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
158920
+ /**
158921
+ * @method
158922
+ * @name kuna#fetchOrdersByStatus
158923
+ * @description fetch a list of orders
158924
+ * @see https://docs.kuna.io/docs/get-private-orders-history
158925
+ * @param {string} status canceled, closed, expired, open, pending, rejected, or waitStop
158926
+ * @param {string} symbol unified market symbol of the market orders were made in
158927
+ * @param {int} [since] the earliest time in ms to fetch orders for
158928
+ * @param {int} [limit] 1-100, the maximum number of open orders structures to retrieve
158929
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
158930
+ * @param {int} [params.until] the latest timestamp (ms) to fetch orders for
158931
+ *
158932
+ * EXCHANGE SPECIFIC PARAMETERS
158933
+ * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
158934
+ * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
158935
+ */
158162
158936
  await this.loadMarkets();
158163
- const market = this.market(symbol);
158937
+ if (status === 'open') {
158938
+ return this.fetchOpenOrders(symbol, since, limit, params);
158939
+ }
158940
+ const until = this.safeInteger(params, 'until');
158941
+ params = this.omit(params, ['until']);
158942
+ let market = undefined;
158164
158943
  const request = {
158165
- 'market': market['id'],
158944
+ 'status': this.capitalize(status),
158166
158945
  };
158167
- const response = await this.privateGetOrders(this.extend(request, params));
158168
- // todo emulation of fetchClosedOrders, fetchOrders, fetchOrder
158169
- // with order cache + fetchOpenOrders
158170
- // as in BTC-e, Liqui, Yobit, DSX, Tidex, WEX
158171
- return this.parseOrders(response, market, since, limit);
158946
+ if (symbol !== undefined) {
158947
+ market = this.market(symbol);
158948
+ request['pairs'] = market['id'];
158949
+ }
158950
+ if (since !== undefined) {
158951
+ request['start'] = this.iso8601(since);
158952
+ }
158953
+ if (limit !== undefined) {
158954
+ request['limit'] = limit;
158955
+ }
158956
+ if (until !== undefined) {
158957
+ request['end'] = this.iso8601(until);
158958
+ }
158959
+ const response = await this.v4PrivateGetOrderPrivateHistory(request);
158960
+ //
158961
+ // {
158962
+ // "data": [
158963
+ // {
158964
+ // "id": "4b9b9705-e85f-4180-bdec-219fbf025fa3", // Unique identifier of an order
158965
+ // "type": "Limit", // Type of an order
158966
+ // "quantity": "0.00054", // Original order quantity
158967
+ // "executedQuantity": "0.00054", // Traded quantity in stock (>0 if traded)
158968
+ // "cumulativeQuoteQty": "14.99580", // Traded quantity in money (>0 if traded)
158969
+ // "cost": "14.9958", // Total amount
158970
+ // "side": "Bid", // Bid for buying base asset, Ask for selling base asset. FYI: For BTC_USDT trading pair, BTC is the base asset
158971
+ // "pair": "BTC_USDT", // Traded pair
158972
+ // "price": "27770", // Price of the trade
158973
+ // "status": "Closed", // The status of the order
158974
+ // "createdAt": "2023-05-08T08:39:46.708Z", // Date-time of order creation, UTC
158975
+ // "updatedAt": "2023-05-08T08:53:58.332Z", // Date-time of the last update of the order, UTC
158976
+ // "closedAt": "2023-05-08T08:53:58.333Z" // Date-time of order finish time, UTC
158977
+ // },
158978
+ // ...
158979
+ // ]
158980
+ // }
158981
+ //
158982
+ const data = this.safeValue(response, 'data', []);
158983
+ return this.parseOrders(data, market, since, limit);
158172
158984
  }
158173
158985
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
158174
158986
  /**
158175
158987
  * @method
158176
158988
  * @name kuna#fetchMyTrades
158177
158989
  * @description fetch all trades made by the user
158990
+ * @see https://docs.kuna.io/docs/get-private-trades-history
158178
158991
  * @param {string} symbol unified market symbol
158179
- * @param {int} [since] the earliest time in ms to fetch trades for
158180
- * @param {int} [limit] the maximum number of trades structures to retrieve
158992
+ * @param {int} [since] not used by kuna fetchMyTrades
158993
+ * @param {int} [limit] not used by kuna fetchMyTrades
158181
158994
  * @param {object} [params] extra parameters specific to the kuna api endpoint
158995
+ *
158996
+ * EXCHANGE SPECIFIC PARAMETERS
158997
+ * @param {string} [params.orderId] UUID of an order, to receive trades for this order only
158998
+ * @param {string} [params.sort] asc (oldest-on-top) or desc (newest-on-top)
158182
158999
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
158183
159000
  */
158184
- if (symbol === undefined) {
158185
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
159001
+ await this.loadMarkets();
159002
+ let market = undefined;
159003
+ const request = {};
159004
+ if (symbol !== undefined) {
159005
+ market = this.market(symbol);
159006
+ request['pair'] = market['id'];
158186
159007
  }
159008
+ const response = await this.v4PrivateGetTradePrivateHistory(this.extend(request, params));
159009
+ //
159010
+ // {
159011
+ // "data": [
159012
+ // {
159013
+ // id: "edb17459-c9bf-4148-9ae6-7367d7f55d71", // Unique identifier of a trade
159014
+ // orderId: "a80bec3f-4ffa-45c1-9d78-f6301e9748fe", // Unique identifier of an order associated with the trade
159015
+ // pair: "BTC_USDT", // Traded pair, base asset first, followed by quoted asset
159016
+ // quantity: "1.5862", // Traded quantity of base asset
159017
+ // price: "19087", // Price of the trade
159018
+ // isTaker: true, // Various fees for Makers and Takers; "Market" orders are always `true`
159019
+ // fee: "0.0039655", // Exchange commission fee
159020
+ // feeCurrency: "BTC", // Currency of the commission
159021
+ // isBuyer: true, // Buy or sell the base asset
159022
+ // quoteQuantity: "30275.7994", // Quote asset quantity spent to fulfill the base amount
159023
+ // createdAt: "2022-09-29T13:43:53.824Z", // Date-time of trade execution, UTC
159024
+ // },
159025
+ // ]
159026
+ // }
159027
+ //
159028
+ const data = this.safeValue(response, 'data');
159029
+ return this.parseTrades(data, market, since, limit);
159030
+ }
159031
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
159032
+ /**
159033
+ * @method
159034
+ * @name kuna#withdraw
159035
+ * @description make a withdrawal
159036
+ * @see https://docs.kuna.io/docs/create-a-withdraw
159037
+ * @param {string} code unified currency code
159038
+ * @param {float} amount the amount to withdraw
159039
+ * @param {string} address the address to withdraw to
159040
+ * @param {string} tag
159041
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
159042
+ * @param {string} [params.chain] the chain to withdraw to
159043
+ *
159044
+ * EXCHANGE SPECIFIC PARAMETERS
159045
+ * @param {string} [params.id] id must be a uuid format, if you do not specify id, it will be generated automatically
159046
+ * @param {boolean} [params.withdrawAll] this field says that the amount should also include a fee
159047
+ * @returns {object} a [transaction structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
159048
+ */
159049
+ this.checkAddress(address);
159050
+ let chain = this.safeString2(params, 'chain', 'network');
159051
+ params = this.omit(params, ['chain', 'network']);
158187
159052
  await this.loadMarkets();
158188
- const market = this.market(symbol);
159053
+ const currency = this.currency(code);
159054
+ if (chain === undefined) {
159055
+ if (currency['code'].indexOf('USD') > 0) {
159056
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' withdraw () requires an extra parameter params["network"] to withdraw ' + currency['code']);
159057
+ }
159058
+ else {
159059
+ chain = currency['id'].toUpperCase();
159060
+ }
159061
+ }
159062
+ const networkId = this.networkCodeToId(chain);
158189
159063
  const request = {
158190
- 'market': market['id'],
159064
+ 'currency': networkId,
159065
+ 'amount': amount,
159066
+ 'address': address,
159067
+ 'paymentMethod': chain, // TODO: double check, Withdraw method for currency, should be taken from "Get info about withdrawal methods by currency name" endpoint (key field).
158191
159068
  };
158192
- const response = await this.privateGetTradesMy(this.extend(request, params));
159069
+ if (tag !== undefined) {
159070
+ request['paymentId'] = tag;
159071
+ }
159072
+ const response = await this.v4PrivatePostWithdrawPrivateCreate(this.extend(request, params));
158193
159073
  //
158194
- // [
158195
- // {
158196
- // "id":11353719,
158197
- // "price":"0.13566",
158198
- // "volume":"99.0",
158199
- // "funds":"13.43034",
158200
- // "market":"dogeusdt",
158201
- // "created_at":"2022-04-12T18:58:44Z",
158202
- // "side":"ask",
158203
- // "order_id":1665670371,
158204
- // "trend":"buy"
158205
- // },
158206
- // ]
159074
+ // {
159075
+ // "data": {
159076
+ // "id": "edb17459-c9bf-4148-9ae6-7367d7f55d71", // unique identifier of a withdraw
159077
+ // "status": "waitingForConfirmation" // status of a withdraw, if you turn off withdrawal confirmation by email, it will return "processing" status, which means that the transaction is already being processed on our side
159078
+ // }
159079
+ // }
158207
159080
  //
158208
- return this.parseTrades(response, market, since, limit);
159081
+ const data = this.safeValue(response, 'data', {});
159082
+ return this.parseTransaction(data, currency);
159083
+ }
159084
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
159085
+ /**
159086
+ * @method
159087
+ * @name kuna#fetchWithdrawals
159088
+ * @description fetch all withdrawals made to an account
159089
+ * @see https://docs.kuna.io/docs/get-withdraw-history
159090
+ * @param {string} code unified currency code
159091
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
159092
+ * @param {int} [limit] the maximum number of withdrawals structures to retrieve
159093
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
159094
+ * @param {int} [params.until] the latest time in ms to fetch deposits for
159095
+ *
159096
+ * EXCHANGE SPECIFIC PARAMETERS
159097
+ * @param {string} [params.status] Created, Canceled, PartiallyProcessed, Processing, Processed, WaitForConfirmation, Pending, AmlChecking
159098
+ * @param {string} [params.sortField] amount (sorting by time), createdAt (sorting by date)
159099
+ * @param {string} [params.sortOrder] asc (oldest-on-top), or desc (newest-on-top, default)
159100
+ * @param {int} [params.skip] 0 - ... Select the number of transactions to skip
159101
+ * @param {string} [params.address]
159102
+ * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
159103
+ */
159104
+ await this.loadMarkets();
159105
+ const until = this.safeInteger(params, 'until');
159106
+ params = this.omit(params, 'until');
159107
+ let currency = undefined;
159108
+ if (currency !== undefined) {
159109
+ currency = this.currency(code);
159110
+ }
159111
+ const request = {};
159112
+ if (code !== undefined) {
159113
+ request['currency'] = code;
159114
+ }
159115
+ if (since !== undefined) {
159116
+ request['dateFrom'] = this.iso8601(since);
159117
+ }
159118
+ if (limit !== undefined) {
159119
+ request['take'] = limit;
159120
+ }
159121
+ if (until !== undefined) {
159122
+ request['dateTo'] = this.iso8601(until);
159123
+ }
159124
+ const response = await this.v4PrivateGetWithdrawPrivateHistory(this.extend(request, params));
159125
+ //
159126
+ // {
159127
+ // "data": [
159128
+ // {
159129
+ // "id": "e9aa15b8-9c19-42eb-800a-026a7a153990", // Unique identifier of withdrawal
159130
+ // "amount": "10.75", // Amount deducted from your account
159131
+ // "asset": "USDT", // Withdrawal currency
159132
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
159133
+ // "paymentCode": "TRX", // Blockchain name
159134
+ // "status": "Processed", // Withdrawal status
159135
+ // "type": "Withdraw", // Transaction type
159136
+ // "reason": [], // Reason for manual transaction processing
159137
+ // "address": "TL3CWAwviQQYSnzHT4RotCWYnarnunQM46", // Withdrawal address
159138
+ // "memo": "", // Withdrawal memo
159139
+ // "txId": "5ecc4e559b528c57be6723ac960a38211fbd3101ef4b59008452b3bd88c84621", // Withdrawal transaction hash
159140
+ // "fee": "0.75", // Withdrawal fee
159141
+ // "processedAmount": "10", // Withdrawal amount
159142
+ // "createdAt": "2023-06-09T11:33:02.383Z", // Withdrawal creation date
159143
+ // "updatedAt": "2023-06-09T11:34:25.317Z" // Date of final withdrawal status
159144
+ // },
159145
+ // ...
159146
+ // ]
159147
+ // }
159148
+ //
159149
+ const data = this.safeValue(response, 'data', []);
159150
+ return this.parseTransactions(data, currency);
159151
+ }
159152
+ async fetchWithdrawal(id, code = undefined, params = {}) {
159153
+ /**
159154
+ * @method
159155
+ * @name kuna#fetchWithdrawal
159156
+ * @description fetch data on a currency withdrawal via the withdrawal id
159157
+ * @see https://docs.kuna.io/docs/get-withdraw-details-by-id
159158
+ * @param {string} id withdrawal id
159159
+ * @param {string} code not used by kuna.fetchWithdrawal
159160
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
159161
+ * @returns {object} a [transaction structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
159162
+ */
159163
+ await this.loadMarkets();
159164
+ const request = {
159165
+ 'withdrawId': id,
159166
+ };
159167
+ const response = await this.v4PrivateGetWithdrawPrivateDetailsWithdrawId(this.extend(request, params));
159168
+ //
159169
+ // {
159170
+ // "data": {
159171
+ // "id": "e9aa15b8-9c19-42eb-800a-026a7a153990", // Unique identifier of withdrawal
159172
+ // "amount": "10.75", // Amount deducted from your account
159173
+ // "asset": "USDT", // Withdrawal currency
159174
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
159175
+ // "paymentCode": "TRX", // Blockchain name
159176
+ // "status": "Processed", // Withdrawal status
159177
+ // "type": "Withdraw", // Transaction type
159178
+ // "reason": [], // Reason for manual transaction processing
159179
+ // "address": "TL3CWAwviQQYSnzHT4RotCWYnarnunQM46", // Withdrawal address
159180
+ // "memo": "", // Withdrawal memo
159181
+ // "txId": "5ecc4e559b528c57be6723ac960a38211fbd3101ef4b59008452b3bd88c84621", // Withdrawal transaction hash
159182
+ // "fee": "0.75", // Withdrawal fee
159183
+ // "processedAmount": "10", // Withdrawal amount
159184
+ // "createdAt": "2023-06-09T11:33:02.383Z", // Withdrawal creation date
159185
+ // "updatedAt": "2023-06-09T11:34:25.317Z" // Date of final withdrawal status
159186
+ // }
159187
+ // }
159188
+ //
159189
+ const data = this.safeValue(response, 'data', {});
159190
+ return this.parseTransaction(data);
159191
+ }
159192
+ async createDepositAddress(code, params = {}) {
159193
+ /**
159194
+ * @method
159195
+ * @name kuna#createDepositAddress
159196
+ * @description create a currency deposit address
159197
+ * @see https://docs.kuna.io/docs/generate-a-constant-crypto-address-for-deposit
159198
+ * @param {string} code unified currency code of the currency for the deposit address
159199
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
159200
+ * @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
159201
+ */
159202
+ await this.loadMarkets();
159203
+ const currency = this.currency(code);
159204
+ const request = {
159205
+ 'source': currency['id'],
159206
+ };
159207
+ const response = await this.v4PrivatePostDepositPrivateCryptoGenerateAddress(this.extend(request, params));
159208
+ //
159209
+ // {
159210
+ // "data": {
159211
+ // "id": "1300c2b6-ree4-4f1e-2a9d-e0f7ed0991a7", // ID of your address
159212
+ // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account
159213
+ // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
159214
+ // }
159215
+ // }
159216
+ //
159217
+ const data = this.safeValue(response, 'data', {});
159218
+ return this.parseDepositAddress(data, currency);
159219
+ }
159220
+ async fetchDepositAddress(code, params = {}) {
159221
+ /**
159222
+ * @method
159223
+ * @name kuna#fetchDepositAddress
159224
+ * @description fetch the deposit address for a currency associated with this account
159225
+ * @see https://docs.kuna.io/docs/find-crypto-address-for-deposit
159226
+ * @param {string} code unified currency code
159227
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
159228
+ * @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
159229
+ */
159230
+ await this.loadMarkets();
159231
+ const currency = this.currency(code);
159232
+ const request = {
159233
+ 'source': currency['id'].toUpperCase(),
159234
+ };
159235
+ const response = await this.v4PrivateGetDepositPrivateCryptoAddress(this.extend(request, params));
159236
+ //
159237
+ // {
159238
+ // "data": {
159239
+ // "id": "c52b6646-fb91-4760-b147-a4f952e8652c", // ID of the address.
159240
+ // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account.
159241
+ // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
159242
+ // }
159243
+ // }
159244
+ //
159245
+ const data = this.safeValue(response, 'data', {});
159246
+ return this.parseDepositAddress(data, currency);
159247
+ }
159248
+ parseDepositAddress(depositAddress, currency = undefined) {
159249
+ //
159250
+ // {
159251
+ // "id": "c52b6646-fb91-4760-b147-a4f952e8652c", // ID of the address.
159252
+ // "source": "BTC", // Blockchain name for which you want to get the address to deposit into the account.
159253
+ // "address": "bc1qm6xfv0qsaaanx0egn6hca5vgsd4r7ak9ttha2a" // Your deposit address
159254
+ // }
159255
+ //
159256
+ const currencyId = this.safeString(depositAddress, 'source');
159257
+ return {
159258
+ 'info': this.safeString(depositAddress, ''),
159259
+ 'currency': this.safeCurrencyCode(currencyId, currency),
159260
+ 'network': undefined,
159261
+ 'address': this.safeString(depositAddress, 'address'),
159262
+ 'tag': undefined,
159263
+ };
159264
+ }
159265
+ parseTransactionStatus(status) {
159266
+ const statuses = {
159267
+ 'Created': 'pending',
159268
+ 'Canceled': 'canceled',
159269
+ 'PartiallyProcessed': 'pending',
159270
+ 'Processing': 'pending',
159271
+ 'Processed': 'ok',
159272
+ 'WaitForConfirmation': 'pending',
159273
+ 'Pending': 'pending',
159274
+ 'AmlChecking': 'pending',
159275
+ };
159276
+ return this.safeString(statuses, status, status);
159277
+ }
159278
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
159279
+ /**
159280
+ * @method
159281
+ * @name kuna#fetchDeposits
159282
+ * @description fetch all deposits made to an account
159283
+ * @see https://docs.kuna.io/docs/get-deposit-history
159284
+ * @param {string} code unified currency code
159285
+ * @param {int} [since] the earliest time in ms to fetch deposits for
159286
+ * @param {int} [limit] the maximum number of deposits structures to retrieve
159287
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
159288
+ * @param {int} [params.until] the latest time in ms to fetch deposits for
159289
+ *
159290
+ * EXCHANGE SPECIFIC PARAMETERS
159291
+ * @param {string} [params.status] Created, Canceled, PartiallyProcessed, Processing, Processed, WaitForConfirmation, Pending, AmlChecking
159292
+ * @param {string} [params.sortField] amount (sorting by time), createdAt (sorting by date)
159293
+ * @param {string} [params.sortOrder] asc (oldest-on-top), or desc (newest-on-top, default)
159294
+ * @param {int} [params.skip] 0 - ... Select the number of transactions to skip
159295
+ * @param {string} [params.address]
159296
+ * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
159297
+ */
159298
+ await this.loadMarkets();
159299
+ const until = this.safeInteger(params, 'until');
159300
+ params = this.omit(params, 'until');
159301
+ let currency = undefined;
159302
+ if (currency !== undefined) {
159303
+ currency = this.currency(code);
159304
+ }
159305
+ const request = {};
159306
+ if (code !== undefined) {
159307
+ request['currency'] = code;
159308
+ }
159309
+ if (since !== undefined) {
159310
+ request['dateFrom'] = this.iso8601(since);
159311
+ }
159312
+ if (limit !== undefined) {
159313
+ request['take'] = limit;
159314
+ }
159315
+ if (until !== undefined) {
159316
+ request['dateTo'] = this.iso8601(until);
159317
+ }
159318
+ const response = await this.v4PrivateGetDepositPrivateHistory(this.extend(request, params));
159319
+ //
159320
+ // {
159321
+ // "data": [
159322
+ // {
159323
+ // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
159324
+ // "amount": "9.9", // Amount credited to your account
159325
+ // "asset": "USDT", // Deposit currency
159326
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
159327
+ // "paymentCode": "TRX", // Blockchain name
159328
+ // "status": "Processed", // Transactions status
159329
+ // "type": "Deposit", // Transaction type
159330
+ // "reason": [], // Reason for manual transaction processing
159331
+ // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
159332
+ // "memo": "", // Deposit memo
159333
+ // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
159334
+ // "fee": "0.1", // Deposit fee
159335
+ // "processedAmount": "10", // Amount of deposit
159336
+ // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
159337
+ // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
159338
+ // },
159339
+ // ...
159340
+ // ]
159341
+ // }
159342
+ //
159343
+ const data = this.safeValue(response, 'data', []);
159344
+ return this.parseTransactions(data, currency);
159345
+ }
159346
+ async fetchDeposit(id, code = undefined, params = {}) {
159347
+ /**
159348
+ * @method
159349
+ * @name kuna#fetchDeposit
159350
+ * @description fetch data on a currency deposit via the deposit id
159351
+ * @see https://docs.kuna.io/docs/get-deposit-details-by-id
159352
+ * @param {string} id deposit id
159353
+ * @param {string} code filter by currency code
159354
+ * @param {object} [params] extra parameters specific to the kuna api endpoint
159355
+ * @returns {object} a [transaction structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
159356
+ */
159357
+ await this.loadMarkets();
159358
+ let currency = undefined;
159359
+ if (code !== undefined) {
159360
+ currency = this.currency(code);
159361
+ }
159362
+ const request = {
159363
+ 'depositId': id,
159364
+ };
159365
+ const response = await this.v4PrivateGetDepositPrivateDetailsDepositId(this.extend(request, params));
159366
+ //
159367
+ // {
159368
+ // "data": {
159369
+ // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
159370
+ // "amount": "9.9", // Amount credited to your account
159371
+ // "asset": "USDT", // Deposit currency
159372
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
159373
+ // "paymentCode": "TRX", // Blockchain name
159374
+ // "status": "Processed", // Transactions status
159375
+ // "type": "Deposit", // Transaction type
159376
+ // "reason": [], // Reason for manual transaction processing
159377
+ // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
159378
+ // "memo": "", // Deposit memo
159379
+ // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
159380
+ // "fee": "0.1", // Deposit fee
159381
+ // "processedAmount": "10", // Amount of deposit
159382
+ // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
159383
+ // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
159384
+ // }
159385
+ // }
159386
+ //
159387
+ const data = this.safeValue(response, 'data', {});
159388
+ return this.parseTransaction(data, currency);
159389
+ }
159390
+ parseTransaction(transaction, currency = undefined) {
159391
+ //
159392
+ // {
159393
+ // "id": "a201cb3c-5830-57ac-ad2c-f6a588dd55eb", // Unique ID of deposit
159394
+ // "amount": "9.9", // Amount credited to your account
159395
+ // "asset": "USDT", // Deposit currency
159396
+ // "merchantId": "16214228-5c0c-5abc-be6a-c90259b21d4e", // Internal ID (not for use)
159397
+ // "paymentCode": "TRX", // Blockchain name
159398
+ // "status": "Processed", // Transactions status
159399
+ // "type": "Deposit", // Transaction type
159400
+ // "reason": [], // Reason for manual transaction processing
159401
+ // "address": "TNeBQz8RyGGiAYAR7r8G6QGxtTWDkpH4dV", // Deposit address
159402
+ // "memo": "", // Deposit memo
159403
+ // "txId": "8a0b0c5a2ac5679879b71b2fa63b0a5c39f90bc8ff6c41e708906b398ac3d4ef", // Deposit transaction hash
159404
+ // "fee": "0.1", // Deposit fee
159405
+ // "processedAmount": "10", // Amount of deposit
159406
+ // "createdAt": "2023-06-13T12:55:01.256Z", // Deposit receipt date
159407
+ // "updatedAt": "2023-06-13T12:55:01.696Z" // Deposit credit date
159408
+ // }
159409
+ //
159410
+ const datetime = this.safeString(transaction, 'createdAt');
159411
+ const currencyId = this.safeString(transaction, 'asset');
159412
+ const code = this.safeCurrencyCode(currencyId, currency);
159413
+ const networkId = this.safeString(transaction, 'paymentCode');
159414
+ const type = this.safeStringLower(transaction, 'type');
159415
+ const address = this.safeString(transaction, 'address');
159416
+ const isDeposit = (type === 'deposit');
159417
+ return {
159418
+ 'info': transaction,
159419
+ 'id': this.safeString(transaction, 'id'),
159420
+ 'txid': this.safeString(transaction, 'txId'),
159421
+ 'currency': code,
159422
+ 'timestamp': this.parse8601(datetime),
159423
+ 'datetime': datetime,
159424
+ 'network': this.networkIdToCode(networkId),
159425
+ 'addressFrom': undefined,
159426
+ 'address': address,
159427
+ 'addressTo': address,
159428
+ 'amount': this.safeNumber(transaction, 'amount'),
159429
+ 'type': !isDeposit ? 'withdrawal' : type,
159430
+ 'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
159431
+ 'updated': this.parse8601(this.safeString(transaction, 'updatedAt')),
159432
+ 'tagFrom': undefined,
159433
+ 'tag': undefined,
159434
+ 'tagTo': undefined,
159435
+ 'comment': this.safeString(transaction, 'memo'),
159436
+ 'fee': {
159437
+ 'cost': this.safeString(transaction, 'fee'),
159438
+ 'currency': code,
159439
+ },
159440
+ };
158209
159441
  }
158210
159442
  nonce() {
158211
159443
  return this.milliseconds();
@@ -158230,11 +159462,12 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
158230
159462
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
158231
159463
  let url = undefined;
158232
159464
  if (Array.isArray(api)) {
159465
+ const isGet = method === 'GET';
158233
159466
  const [version, access] = api;
158234
159467
  if (version === 'v3') {
158235
159468
  url = this.urls['api'][version] + '/' + version + '/' + this.implodeParams(path, params);
158236
159469
  if (access === 'public') {
158237
- if (method === 'GET') {
159470
+ if (isGet) {
158238
159471
  if (Object.keys(params).length) {
158239
159472
  url += '?' + this.urlencode(params);
158240
159473
  }
@@ -158249,35 +159482,39 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
158249
159482
  }
158250
159483
  }
158251
159484
  else if (version === 'v4') {
158252
- const splitPath = path.split('/');
158253
- const splitPathLength = splitPath.length;
158254
- let urlPath = '';
158255
- if ((splitPathLength > 1) && (splitPath[0] !== 'kuna-code')) {
158256
- let pathTail = '';
158257
- for (let i = 1; i < splitPathLength; i++) {
158258
- pathTail += splitPath[i];
159485
+ const extractedParams = this.extractParams(path);
159486
+ let urlPath = '/' + version + '/' + this.implodeParams(path, params);
159487
+ params = this.omit(params, extractedParams);
159488
+ if (isGet) {
159489
+ const paramsList = Object.keys(params);
159490
+ const numParams = paramsList.length;
159491
+ if (numParams > 0) {
159492
+ urlPath += '?' + this.urlencode(params);
158259
159493
  }
158260
- urlPath = '/' + version + '/' + splitPath[0] + '/' + access + '/' + this.implodeParams(pathTail, params);
158261
- }
158262
- else {
158263
- urlPath = '/' + version + '/' + access + '/' + this.implodeParams(path, params);
158264
159494
  }
158265
- url = this.urls['api'][version] + urlPath;
158266
159495
  if (access === 'private') {
158267
- const nonce = this.nonce();
158268
- const auth = urlPath + nonce + this.json(params);
159496
+ const nonce = this.nonce().toString();
159497
+ let auth = urlPath + nonce;
159498
+ if (isGet) {
159499
+ auth = auth + this.json({});
159500
+ }
159501
+ else {
159502
+ auth = auth + this.json(params);
159503
+ body = params;
159504
+ }
158269
159505
  headers = {
158270
- 'content-type': 'application/json',
159506
+ 'Content-Type': 'application/json',
158271
159507
  'accept': 'application/json',
158272
159508
  'nonce': nonce,
158273
159509
  'public-key': this.apiKey,
158274
- 'signature': this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_3__/* .sha384 */ .iC, 'hex'),
159510
+ 'signature': this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__/* .sha384 */ .iC, 'hex'),
158275
159511
  };
158276
159512
  const account = this.safeString(this.options, 'account');
158277
159513
  if (account === 'pro') {
158278
159514
  headers['account'] = 'pro';
158279
159515
  }
158280
159516
  }
159517
+ url = this.urls['api'][version] + urlPath;
158281
159518
  }
158282
159519
  }
158283
159520
  else {
@@ -158300,7 +159537,7 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
158300
159537
  'tonce': nonce,
158301
159538
  }, params));
158302
159539
  const auth = method + '|' + request + '|' + queryInner;
158303
- const signed = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J);
159540
+ const signed = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J);
158304
159541
  const suffix = query + '&signature=' + signed;
158305
159542
  if (method === 'GET') {
158306
159543
  url += '?' + suffix;
@@ -158311,18 +159548,37 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
158311
159548
  }
158312
159549
  }
158313
159550
  }
159551
+ if (body !== undefined) {
159552
+ body = JSON.stringify(body);
159553
+ }
158314
159554
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
158315
159555
  }
158316
159556
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
158317
- if (response === undefined) {
159557
+ //
159558
+ // {
159559
+ // "errors": [
159560
+ // {
159561
+ // "extensions": {
159562
+ // "code": "IP_NOT_IN_WHITE_LIST"
159563
+ // },
159564
+ // "code": "IP_NOT_IN_WHITE_LIST"
159565
+ // }
159566
+ // ]
159567
+ // }
159568
+ //
159569
+ const errors = this.safeValue(response, 'errors');
159570
+ if ((response === undefined) && (errors === undefined)) {
158318
159571
  return undefined;
158319
159572
  }
158320
- if (code === 400) {
158321
- const error = this.safeValue(response, 'error');
159573
+ if ((errors !== undefined) || (code === 400)) {
159574
+ let error = this.safeValue(errors, 0);
159575
+ if (error === undefined) {
159576
+ error = this.safeValue(response, 'error');
159577
+ }
158322
159578
  const errorCode = this.safeString(error, 'code');
158323
159579
  const feedback = this.id + ' ' + this.json(response);
158324
159580
  this.throwExactlyMatchedException(this.exceptions, errorCode, feedback);
158325
- // fallback to default error handler
159581
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(feedback);
158326
159582
  }
158327
159583
  return undefined;
158328
159584
  }
@@ -158363,8 +159619,8 @@ class latoken extends _abstract_latoken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
158363
159619
  'CORS': undefined,
158364
159620
  'spot': true,
158365
159621
  'margin': false,
158366
- 'swap': undefined,
158367
- 'future': undefined,
159622
+ 'swap': false,
159623
+ 'future': false,
158368
159624
  'option': false,
158369
159625
  'cancelAllOrders': true,
158370
159626
  'cancelOrder': true,
@@ -204744,6 +206000,9 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
204744
206000
  /**
204745
206001
  * @method
204746
206002
  * @name bitget#watchOrders
206003
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#order-channel
206004
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#order-channel
206005
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#plan-order-channel
204747
206006
  * @description watches information on multiple orders made by the user
204748
206007
  * @param {string} symbol unified market symbol of the market orders were made in
204749
206008
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -204754,7 +206013,9 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
204754
206013
  await this.loadMarkets();
204755
206014
  let market = undefined;
204756
206015
  let marketId = undefined;
204757
- let messageHash = 'order';
206016
+ const isStop = this.safeValue(params, 'stop', false);
206017
+ params = this.omit(params, 'stop');
206018
+ let messageHash = (isStop) ? 'triggerOrder' : 'order';
204758
206019
  let subscriptionHash = 'order:trades';
204759
206020
  if (symbol !== undefined) {
204760
206021
  market = this.market(symbol);
@@ -204762,8 +206023,6 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
204762
206023
  marketId = market['id'];
204763
206024
  messageHash = messageHash + ':' + symbol;
204764
206025
  }
204765
- const isStop = this.safeValue(params, 'stop', false);
204766
- params = this.omit(params, 'stop');
204767
206026
  let type = undefined;
204768
206027
  [type, params] = this.handleMarketTypeAndParams('watchOrders', market, params);
204769
206028
  if ((type === 'spot') && (symbol === undefined)) {
@@ -204786,6 +206045,9 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
204786
206045
  instType = 'SUMCBL';
204787
206046
  }
204788
206047
  }
206048
+ if (isStop) {
206049
+ subscriptionHash = subscriptionHash + ':stop'; // we don't want to re-use the same subscription hash for stop orders
206050
+ }
204789
206051
  const instId = (type === 'spot') ? marketId : 'default'; // different from other streams here the 'rest' id is required for spot markets, contract markets require default here
204790
206052
  const channel = isStop ? 'ordersAlgo' : 'orders';
204791
206053
  const args = {
@@ -204827,7 +206089,42 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
204827
206089
  // ]
204828
206090
  // }
204829
206091
  //
206092
+ // {
206093
+ // action: 'snapshot',
206094
+ // arg: { instType: 'umcbl', channel: 'ordersAlgo', instId: 'default' },
206095
+ // data: [
206096
+ // {
206097
+ // actualPx: '55.000000000',
206098
+ // actualSz: '0.000000000',
206099
+ // cOid: '1104372235724890112',
206100
+ // cTime: '1699028779917',
206101
+ // eps: 'web',
206102
+ // hM: 'double_hold',
206103
+ // id: '1104372235724890113',
206104
+ // instId: 'BTCUSDT_UMCBL',
206105
+ // key: '1104372235724890113',
206106
+ // ordPx: '55.000000000',
206107
+ // ordType: 'limit',
206108
+ // planType: 'pl',
206109
+ // posSide: 'long',
206110
+ // side: 'buy',
206111
+ // state: 'not_trigger',
206112
+ // sz: '3.557000000',
206113
+ // tS: 'open_long',
206114
+ // tgtCcy: 'USDT',
206115
+ // triggerPx: '55.000000000',
206116
+ // triggerPxType: 'last',
206117
+ // triggerTime: '1699028779917',
206118
+ // uTime: '1699028779917',
206119
+ // userId: '3704614084',
206120
+ // version: 1104372235586478100
206121
+ // }
206122
+ // ],
206123
+ // ts: 1699028780327
206124
+ // }
206125
+ //
204830
206126
  const arg = this.safeValue(message, 'arg', {});
206127
+ const channel = this.safeString(arg, 'channel');
204831
206128
  const instType = this.safeString(arg, 'instType');
204832
206129
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
204833
206130
  const isContractUpdate = (!sandboxMode) ? (instType === 'umcbl') : (instType === 'sumcbl');
@@ -204835,8 +206132,10 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
204835
206132
  if (this.orders === undefined) {
204836
206133
  const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
204837
206134
  this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
206135
+ this.triggerOrders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
204838
206136
  }
204839
- const stored = this.orders;
206137
+ const stored = (channel === 'ordersAlgo') ? this.triggerOrders : this.orders;
206138
+ const messageHash = (channel === 'ordersAlgo') ? 'triggerOrder' : 'order';
204840
206139
  const marketSymbols = {};
204841
206140
  for (let i = 0; i < data.length; i++) {
204842
206141
  const order = data[i];
@@ -204853,10 +206152,10 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
204853
206152
  const keys = Object.keys(marketSymbols);
204854
206153
  for (let i = 0; i < keys.length; i++) {
204855
206154
  const symbol = keys[i];
204856
- const messageHash = 'order:' + symbol;
204857
- client.resolve(stored, messageHash);
206155
+ const innerMessageHash = messageHash + ':' + symbol;
206156
+ client.resolve(stored, innerMessageHash);
204858
206157
  }
204859
- client.resolve(stored, 'order');
206158
+ client.resolve(stored, messageHash);
204860
206159
  }
204861
206160
  parseWsOrder(order, market = undefined) {
204862
206161
  //
@@ -264891,18 +266190,27 @@ class wazirx extends _abstract_wazirx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
264891
266190
  'has': {
264892
266191
  'CORS': false,
264893
266192
  'spot': true,
264894
- 'margin': undefined,
266193
+ 'margin': false,
264895
266194
  'swap': false,
264896
266195
  'future': false,
264897
266196
  'option': false,
266197
+ 'addMargin': false,
266198
+ 'borrowMargin': false,
264898
266199
  'cancelAllOrders': true,
264899
266200
  'cancelOrder': true,
264900
266201
  'createOrder': true,
266202
+ 'createReduceOnlyOrder': false,
264901
266203
  'createStopLimitOrder': true,
264902
266204
  'createStopMarketOrder': true,
264903
266205
  'createStopOrder': true,
264904
266206
  'fetchBalance': true,
264905
266207
  'fetchBidsAsks': false,
266208
+ 'fetchBorrowInterest': false,
266209
+ 'fetchBorrowRate': false,
266210
+ 'fetchBorrowRateHistories': false,
266211
+ 'fetchBorrowRateHistory': false,
266212
+ 'fetchBorrowRates': false,
266213
+ 'fetchBorrowRatesPerSymbol': false,
264906
266214
  'fetchClosedOrders': false,
264907
266215
  'fetchCurrencies': false,
264908
266216
  'fetchDepositAddress': false,
@@ -264914,7 +266222,11 @@ class wazirx extends _abstract_wazirx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
264914
266222
  'fetchFundingRateHistory': false,
264915
266223
  'fetchFundingRates': false,
264916
266224
  'fetchIndexOHLCV': false,
266225
+ 'fetchIsolatedPositions': false,
266226
+ 'fetchLeverage': false,
266227
+ 'fetchLeverageTiers': false,
264917
266228
  'fetchMarginMode': false,
266229
+ 'fetchMarketLeverageTiers': false,
264918
266230
  'fetchMarkets': true,
264919
266231
  'fetchMarkOHLCV': false,
264920
266232
  'fetchMyTrades': false,
@@ -264924,7 +266236,10 @@ class wazirx extends _abstract_wazirx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
264924
266236
  'fetchOrder': false,
264925
266237
  'fetchOrderBook': true,
264926
266238
  'fetchOrders': true,
266239
+ 'fetchPosition': false,
264927
266240
  'fetchPositionMode': false,
266241
+ 'fetchPositions': false,
266242
+ 'fetchPositionsRisk': false,
264928
266243
  'fetchPremiumIndexOHLCV': false,
264929
266244
  'fetchStatus': true,
264930
266245
  'fetchTicker': true,
@@ -264937,6 +266252,12 @@ class wazirx extends _abstract_wazirx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
264937
266252
  'fetchTransactions': false,
264938
266253
  'fetchTransfers': false,
264939
266254
  'fetchWithdrawals': false,
266255
+ 'reduceMargin': false,
266256
+ 'repayMargin': false,
266257
+ 'setLeverage': false,
266258
+ 'setMargin': false,
266259
+ 'setMarginMode': false,
266260
+ 'setPositionMode': false,
264940
266261
  'transfer': false,
264941
266262
  'withdraw': false,
264942
266263
  },
@@ -280256,7 +281577,7 @@ SOFTWARE.
280256
281577
 
280257
281578
  //-----------------------------------------------------------------------------
280258
281579
  // this is updated by vss.js when building
280259
- const version = '4.1.36';
281580
+ const version = '4.1.38';
280260
281581
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
280261
281582
  //-----------------------------------------------------------------------------
280262
281583