ccxt 4.1.90 → 4.1.94

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 (52) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +3 -3
  3. package/dist/ccxt.browser.js +921 -308
  4. package/dist/ccxt.browser.min.js +7 -7
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/binance.js +72 -9
  7. package/dist/cjs/src/bingx.js +11 -6
  8. package/dist/cjs/src/bitget.js +120 -79
  9. package/dist/cjs/src/bitrue.js +2 -11
  10. package/dist/cjs/src/bybit.js +1 -0
  11. package/dist/cjs/src/coinbase.js +44 -2
  12. package/dist/cjs/src/coinone.js +394 -143
  13. package/dist/cjs/src/hitbtc.js +41 -0
  14. package/dist/cjs/src/kucoin.js +1 -0
  15. package/dist/cjs/src/kucoinfutures.js +57 -4
  16. package/dist/cjs/src/okx.js +2 -0
  17. package/dist/cjs/src/phemex.js +108 -27
  18. package/dist/cjs/src/pro/bingx.js +44 -5
  19. package/dist/cjs/src/pro/bitmart.js +19 -18
  20. package/dist/cjs/src/zaif.js +2 -3
  21. package/js/ccxt.d.ts +1 -1
  22. package/js/ccxt.js +1 -1
  23. package/js/src/abstract/bybit.d.ts +1 -0
  24. package/js/src/abstract/coinbase.d.ts +6 -0
  25. package/js/src/abstract/coinone.d.ts +44 -2
  26. package/js/src/abstract/kucoinfutures.d.ts +2 -0
  27. package/js/src/abstract/okx.d.ts +2 -0
  28. package/js/src/binance.d.ts +3 -0
  29. package/js/src/binance.js +72 -9
  30. package/js/src/bingx.js +11 -6
  31. package/js/src/bitget.d.ts +1 -0
  32. package/js/src/bitget.js +120 -79
  33. package/js/src/bitrue.js +2 -11
  34. package/js/src/bybit.js +1 -0
  35. package/js/src/coinbase.js +44 -2
  36. package/js/src/coinone.d.ts +1 -0
  37. package/js/src/coinone.js +394 -143
  38. package/js/src/hitbtc.d.ts +1 -0
  39. package/js/src/hitbtc.js +41 -0
  40. package/js/src/kucoin.js +1 -0
  41. package/js/src/kucoinfutures.d.ts +1 -0
  42. package/js/src/kucoinfutures.js +57 -4
  43. package/js/src/okx.js +2 -0
  44. package/js/src/phemex.js +108 -27
  45. package/js/src/pro/bingx.d.ts +2 -0
  46. package/js/src/pro/bingx.js +44 -5
  47. package/js/src/pro/bitmart.d.ts +1 -1
  48. package/js/src/pro/bitmart.js +19 -18
  49. package/js/src/zaif.js +2 -3
  50. package/package.json +1 -1
  51. package/skip-tests.json +7 -0
  52. package/changelog.js +0 -101
@@ -11912,7 +11912,8 @@ class Exchange {
11912
11912
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11913
11913
 
11914
11914
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11915
- /* harmony export */ O: () => (/* binding */ Precise)
11915
+ /* harmony export */ O: () => (/* binding */ Precise),
11916
+ /* harmony export */ Z: () => (__WEBPACK_DEFAULT_EXPORT__)
11916
11917
  /* harmony export */ });
11917
11918
  const zero = BigInt(0);
11918
11919
  const minusOne = BigInt(-1);
@@ -12170,7 +12171,7 @@ class Precise {
12170
12171
  return (new Precise(string1)).le(new Precise(string2));
12171
12172
  }
12172
12173
  }
12173
- /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = ((/* unused pure expression or super */ null && (Precise)));
12174
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Precise);
12174
12175
 
12175
12176
 
12176
12177
 
@@ -17122,6 +17123,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17122
17123
  'closeAllPositions': false,
17123
17124
  'closePosition': false,
17124
17125
  'createDepositAddress': false,
17126
+ 'createMarketBuyOrderWithCost': true,
17127
+ 'createMarketOrderWithCost': true,
17128
+ 'createMarketSellOrderWithCost': true,
17125
17129
  'createOrder': true,
17126
17130
  'createOrders': true,
17127
17131
  'createPostOnlyOrder': true,
@@ -20215,7 +20219,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20215
20219
  * @see https://binance-docs.github.io/apidocs/futures/en/#24hr-ticker-price-change-statistics // swap
20216
20220
  * @see https://binance-docs.github.io/apidocs/delivery/en/#24hr-ticker-price-change-statistics // future
20217
20221
  * @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics // option
20218
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
20222
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
20219
20223
  * @param {object} [params] extra parameters specific to the exchange API endpoint
20220
20224
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
20221
20225
  */
@@ -20230,22 +20234,24 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20230
20234
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
20231
20235
  let subType = undefined;
20232
20236
  [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
20233
- const query = this.omit(params, 'type');
20234
- let defaultMethod = undefined;
20237
+ let response = undefined;
20235
20238
  if (type === 'option') {
20236
- defaultMethod = 'eapiPublicGetTicker';
20239
+ response = await this.eapiPublicGetTicker(params);
20237
20240
  }
20238
20241
  else if (this.isLinear(type, subType)) {
20239
- defaultMethod = 'fapiPublicGetTicker24hr';
20242
+ response = await this.fapiPublicGetTicker24hr(params);
20240
20243
  }
20241
20244
  else if (this.isInverse(type, subType)) {
20242
- defaultMethod = 'dapiPublicGetTicker24hr';
20245
+ response = await this.dapiPublicGetTicker24hr(params);
20243
20246
  }
20244
20247
  else {
20245
- defaultMethod = 'publicGetTicker24hr';
20248
+ const request = {};
20249
+ if (symbols !== undefined) {
20250
+ const marketIds = this.marketIds(symbols);
20251
+ request['symbols'] = this.json(marketIds);
20252
+ }
20253
+ response = await this.publicGetTicker24hr(this.extend(request, params));
20246
20254
  }
20247
- const method = this.safeString(this.options, 'fetchTickersMethod', defaultMethod);
20248
- const response = await this[method](query);
20249
20255
  return this.parseTickers(response, symbols);
20250
20256
  }
20251
20257
  parseOHLCV(ohlcv, market = undefined) {
@@ -21735,6 +21741,64 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21735
21741
  const requestParams = this.omit(params, ['quoteOrderQty', 'cost', 'stopPrice', 'test', 'type', 'newClientOrderId', 'clientOrderId', 'postOnly']);
21736
21742
  return this.extend(request, requestParams);
21737
21743
  }
21744
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
21745
+ /**
21746
+ * @method
21747
+ * @name binance#createMarketOrderWithCost
21748
+ * @description create a market order by providing the symbol, side and cost
21749
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
21750
+ * @param {string} symbol unified symbol of the market to create an order in
21751
+ * @param {string} side 'buy' or 'sell'
21752
+ * @param {float} cost how much you want to trade in units of the quote currency
21753
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
21754
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
21755
+ */
21756
+ await this.loadMarkets();
21757
+ const market = this.market(symbol);
21758
+ if (!market['spot']) {
21759
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createMarketOrderWithCost() supports spot orders only');
21760
+ }
21761
+ params['quoteOrderQty'] = cost;
21762
+ return await this.createOrder(symbol, 'market', side, cost, undefined, params);
21763
+ }
21764
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
21765
+ /**
21766
+ * @method
21767
+ * @name binance#createMarketBuyOrderWithCost
21768
+ * @description create a market buy order by providing the symbol and cost
21769
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
21770
+ * @param {string} symbol unified symbol of the market to create an order in
21771
+ * @param {float} cost how much you want to trade in units of the quote currency
21772
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
21773
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
21774
+ */
21775
+ await this.loadMarkets();
21776
+ const market = this.market(symbol);
21777
+ if (!market['spot']) {
21778
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
21779
+ }
21780
+ params['quoteOrderQty'] = cost;
21781
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
21782
+ }
21783
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
21784
+ /**
21785
+ * @method
21786
+ * @name binance#createMarketSellOrderWithCost
21787
+ * @description create a market sell order by providing the symbol and cost
21788
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
21789
+ * @param {string} symbol unified symbol of the market to create an order in
21790
+ * @param {float} cost how much you want to trade in units of the quote currency
21791
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
21792
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
21793
+ */
21794
+ await this.loadMarkets();
21795
+ const market = this.market(symbol);
21796
+ if (!market['spot']) {
21797
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createMarketSellOrderWithCost() supports spot orders only');
21798
+ }
21799
+ params['quoteOrderQty'] = cost;
21800
+ return await this.createOrder(symbol, 'market', 'sell', cost, undefined, params);
21801
+ }
21738
21802
  async fetchOrder(id, symbol = undefined, params = {}) {
21739
21803
  /**
21740
21804
  * @method
@@ -27795,14 +27859,19 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27795
27859
  const type = (cost === undefined) ? 'spot' : 'swap';
27796
27860
  const currencyId = this.safeString2(trade, 'currency', 'N');
27797
27861
  const currencyCode = this.safeCurrencyCode(currencyId);
27798
- const m = this.safeValue(trade, 'm', false);
27862
+ const m = this.safeValue(trade, 'm');
27799
27863
  const marketId = this.safeString(trade, 's');
27800
27864
  const isBuyerMaker = this.safeValue2(trade, 'buyerMaker', 'isBuyerMaker');
27801
- let takeOrMaker = (isBuyerMaker || m) ? 'maker' : 'taker';
27865
+ let takeOrMaker = undefined;
27866
+ if ((isBuyerMaker !== undefined) || (m !== undefined)) {
27867
+ takeOrMaker = (isBuyerMaker || m) ? 'maker' : 'taker';
27868
+ }
27802
27869
  let side = this.safeStringLower2(trade, 'side', 'S');
27803
27870
  if (side === undefined) {
27804
- side = (isBuyerMaker || m) ? 'sell' : 'buy';
27805
- takeOrMaker = 'taker';
27871
+ if ((isBuyerMaker !== undefined) || (m !== undefined)) {
27872
+ side = (isBuyerMaker || m) ? 'sell' : 'buy';
27873
+ takeOrMaker = 'taker';
27874
+ }
27806
27875
  }
27807
27876
  return this.safeTrade({
27808
27877
  'id': this.safeStringN(trade, ['id', 't']),
@@ -27815,7 +27884,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27815
27884
  'side': this.parseOrderSide(side),
27816
27885
  'takerOrMaker': takeOrMaker,
27817
27886
  'price': this.safeString2(trade, 'price', 'p'),
27818
- 'amount': this.safeStringN(trade, ['qty', 'amount', 'q']),
27887
+ 'amount': this.safeStringN(trade, ['qty', 'volume', 'amount', 'q']),
27819
27888
  'cost': cost,
27820
27889
  'fee': {
27821
27890
  'cost': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(this.safeString2(trade, 'commission', 'n'))),
@@ -28251,7 +28320,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28251
28320
  async fetchBalance(params = {}) {
28252
28321
  /**
28253
28322
  * @method
28254
- * @name cryptocom#fetchBalance
28323
+ * @name bingx#fetchBalance
28255
28324
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
28256
28325
  * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
28257
28326
  * @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
@@ -40242,7 +40311,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
40242
40311
  'cancelOrder': true,
40243
40312
  'cancelOrders': true,
40244
40313
  'closeAllPositions': true,
40245
- 'closePosition': false,
40314
+ 'closePosition': true,
40246
40315
  'createMarketBuyOrderWithCost': true,
40247
40316
  'createMarketOrderWithCost': false,
40248
40317
  'createMarketSellOrderWithCost': false,
@@ -43773,7 +43842,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43773
43842
  }
43774
43843
  parseOrder(order, market = undefined) {
43775
43844
  //
43776
- // createOrder, editOrder
43845
+ // createOrder, editOrder, closePosition
43777
43846
  //
43778
43847
  // {
43779
43848
  // "clientOid": "abe95dbe-6081-4a6f-a2d3-ae49601cd479",
@@ -44051,8 +44120,13 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44051
44120
  'status': 'rejected',
44052
44121
  }, market);
44053
44122
  }
44123
+ const isContractOrder = ('posSide' in order);
44124
+ let marketType = isContractOrder ? 'contract' : 'spot';
44125
+ if (market !== undefined) {
44126
+ marketType = market['type'];
44127
+ }
44054
44128
  const marketId = this.safeString(order, 'symbol');
44055
- market = this.safeMarket(marketId, market);
44129
+ market = this.safeMarket(marketId, market, undefined, marketType);
44056
44130
  const timestamp = this.safeInteger2(order, 'cTime', 'ctime');
44057
44131
  const updateTimestamp = this.safeInteger(order, 'uTime');
44058
44132
  const rawStatus = this.safeString2(order, 'status', 'state');
@@ -45492,13 +45566,14 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45492
45566
  * @param {int} [params.until] the latest time in ms to fetch entries for
45493
45567
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
45494
45568
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45569
+ * @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
45495
45570
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45496
45571
  */
45497
- if (symbol === undefined) {
45498
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
45499
- }
45500
45572
  await this.loadMarkets();
45501
- const market = this.market(symbol);
45573
+ let market = undefined;
45574
+ if (symbol !== undefined) {
45575
+ market = this.market(symbol);
45576
+ }
45502
45577
  const response = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
45503
45578
  const result = [];
45504
45579
  for (let i = 0; i < response.length; i++) {
@@ -45528,13 +45603,14 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45528
45603
  * @param {int} [params.until] the latest time in ms to fetch entries for
45529
45604
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
45530
45605
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45606
+ * @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
45531
45607
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45532
45608
  */
45533
- if (symbol === undefined) {
45534
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchCanceledOrders() requires a symbol argument');
45535
- }
45536
45609
  await this.loadMarkets();
45537
- const market = this.market(symbol);
45610
+ let market = undefined;
45611
+ if (symbol !== undefined) {
45612
+ market = this.market(symbol);
45613
+ }
45538
45614
  const response = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
45539
45615
  const result = [];
45540
45616
  for (let i = 0; i < response.length; i++) {
@@ -45551,19 +45627,25 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45551
45627
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
45552
45628
  let market = undefined;
45553
45629
  if (sandboxMode) {
45554
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
45555
- market = this.market(sandboxSymbol);
45630
+ if (symbol !== undefined) {
45631
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
45632
+ symbol = sandboxSymbol;
45633
+ }
45556
45634
  }
45557
- else {
45635
+ let request = {};
45636
+ if (symbol !== undefined) {
45558
45637
  market = this.market(symbol);
45638
+ request['symbol'] = market['id'];
45559
45639
  }
45640
+ let marketType = undefined;
45641
+ [marketType, params] = this.handleMarketTypeAndParams('fetchCanceledAndClosedOrders', market, params);
45560
45642
  let marginMode = undefined;
45561
45643
  [marginMode, params] = this.handleMarginModeAndParams('fetchCanceledAndClosedOrders', params);
45562
45644
  let paginate = false;
45563
45645
  [paginate, params] = this.handleOptionAndParams(params, 'fetchCanceledAndClosedOrders', 'paginate');
45564
45646
  if (paginate) {
45565
45647
  let cursorReceived = undefined;
45566
- if (market['spot']) {
45648
+ if (marketType === 'spot') {
45567
45649
  if (marginMode !== undefined) {
45568
45650
  cursorReceived = 'minId';
45569
45651
  }
@@ -45573,9 +45655,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45573
45655
  }
45574
45656
  return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
45575
45657
  }
45576
- let request = {
45577
- 'symbol': market['id'],
45578
- };
45579
45658
  let response = undefined;
45580
45659
  const stop = this.safeValue2(params, 'stop', 'trigger');
45581
45660
  params = this.omit(params, ['stop', 'trigger']);
@@ -45586,7 +45665,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45586
45665
  if (limit !== undefined) {
45587
45666
  request['limit'] = limit;
45588
45667
  }
45589
- if ((market['swap']) || (market['future']) || (marginMode !== undefined)) {
45668
+ if ((marketType === 'swap') || (marketType === 'future') || (marginMode !== undefined)) {
45590
45669
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
45591
45670
  params = this.omit(params, 'clientOrderId');
45592
45671
  if (clientOrderId !== undefined) {
@@ -45594,7 +45673,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45594
45673
  }
45595
45674
  }
45596
45675
  const now = this.milliseconds();
45597
- if (market['spot']) {
45676
+ if (marketType === 'spot') {
45598
45677
  if (marginMode !== undefined) {
45599
45678
  if (since === undefined) {
45600
45679
  since = now - 7776000000;
@@ -45609,6 +45688,9 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45609
45688
  }
45610
45689
  else {
45611
45690
  if (stop) {
45691
+ if (symbol === undefined) {
45692
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchCanceledAndClosedOrders() requires a symbol argument');
45693
+ }
45612
45694
  const endTime = this.safeIntegerN(params, ['endTime', 'until', 'till']);
45613
45695
  params = this.omit(params, ['until', 'till']);
45614
45696
  if (since === undefined) {
@@ -45817,7 +45899,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45817
45899
  // }
45818
45900
  //
45819
45901
  const data = this.safeValue(response, 'data', {});
45820
- if (market['spot']) {
45902
+ if (marketType === 'spot') {
45821
45903
  if ((marginMode !== undefined) || stop) {
45822
45904
  return this.safeValue(data, 'orderList', []);
45823
45905
  }
@@ -46505,11 +46587,10 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46505
46587
  //
46506
46588
  // closeAllPositions
46507
46589
  //
46508
- // {
46509
- // "symbol": "XRPUSDT_UMCBL",
46510
- // "orderId": "1111861847410757635",
46511
- // "clientOid": "1111861847410757637"
46512
- // }
46590
+ // {
46591
+ // "orderId": "1120923953904893955",
46592
+ // "clientOid": "1120923953904893956"
46593
+ // }
46513
46594
  //
46514
46595
  const marketId = this.safeString(position, 'symbol');
46515
46596
  market = this.safeMarket(marketId, market, undefined, 'contract');
@@ -46578,7 +46659,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46578
46659
  const percentage = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(unrealizedPnl, initialMargin, 4), '100');
46579
46660
  return this.safePosition({
46580
46661
  'info': position,
46581
- 'id': undefined,
46662
+ 'id': this.safeString(position, 'orderId'),
46582
46663
  'symbol': symbol,
46583
46664
  'notional': this.parseNumber(notional),
46584
46665
  'marginMode': marginMode,
@@ -48198,65 +48279,94 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
48198
48279
  'info': info,
48199
48280
  };
48200
48281
  }
48201
- async closeAllPositions(params = {}) {
48282
+ async closePosition(symbol, side = undefined, params = {}) {
48202
48283
  /**
48203
48284
  * @method
48204
- * @name bitget#closePositions
48205
- * @description closes open positions for a market
48206
- * @see https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position
48207
- * @param {object} [params] extra parameters specific to the okx api endpoint
48208
- * @param {string} [params.subType] 'linear' or 'inverse'
48209
- * @param {string} [params.settle] *required and only valid when params.subType === "linear"* 'USDT' or 'USDC'
48210
- * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
48285
+ * @name bitget#closePosition
48286
+ * @description closes an open position for a market
48287
+ * @see https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
48288
+ * @param {string} symbol unified CCXT market symbol
48289
+ * @param {string} [side] one-way mode: 'buy' or 'sell', hedge-mode: 'long' or 'short'
48290
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
48291
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
48211
48292
  */
48212
48293
  await this.loadMarkets();
48213
- let subType = undefined;
48214
- let settle = undefined;
48215
- [subType, params] = this.handleSubTypeAndParams('closeAllPositions', undefined, params);
48216
- settle = this.safeString(params, 'settle', 'USDT');
48217
- params = this.omit(params, ['settle']);
48218
- const productType = this.safeString(params, 'productType');
48219
- const request = {};
48220
- if (productType === undefined) {
48221
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
48222
- let localProductType = undefined;
48223
- if (subType === 'inverse') {
48224
- localProductType = 'dmcbl';
48225
- }
48226
- else {
48227
- if (settle === 'USDT') {
48228
- localProductType = 'umcbl';
48229
- }
48230
- else if (settle === 'USDC') {
48231
- localProductType = 'cmcbl';
48232
- }
48233
- }
48234
- if (sandboxMode) {
48235
- localProductType = 's' + localProductType;
48236
- }
48237
- request['productType'] = localProductType;
48294
+ const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
48295
+ let market = undefined;
48296
+ if (sandboxMode) {
48297
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
48298
+ market = this.market(sandboxSymbol);
48238
48299
  }
48239
- const response = await this.privateMixPostMixV1OrderCloseAllPositions(this.extend(request, params));
48300
+ else {
48301
+ market = this.market(symbol);
48302
+ }
48303
+ let productType = undefined;
48304
+ [productType, params] = this.handleProductTypeAndParams(market, params);
48305
+ const request = {
48306
+ 'symbol': market['id'],
48307
+ 'productType': productType,
48308
+ };
48309
+ if (side !== undefined) {
48310
+ request['holdSide'] = side;
48311
+ }
48312
+ const response = await this.privateMixPostV2MixOrderClosePositions(this.extend(request, params));
48240
48313
  //
48241
- // {
48242
- // "code": "00000",
48243
- // "msg": "success",
48244
- // "requestTime": 1700814442466,
48245
- // "data": {
48246
- // "orderInfo": [
48247
- // {
48248
- // "symbol": "XRPUSDT_UMCBL",
48249
- // "orderId": "1111861847410757635",
48250
- // "clientOid": "1111861847410757637"
48251
- // },
48252
- // ],
48253
- // "failure": [],
48254
- // "result": true
48255
- // }
48256
- // }
48314
+ // {
48315
+ // "code": "00000",
48316
+ // "msg": "success",
48317
+ // "requestTime": 1702975017017,
48318
+ // "data": {
48319
+ // "successList": [
48320
+ // {
48321
+ // "orderId": "1120923953904893955",
48322
+ // "clientOid": "1120923953904893956"
48323
+ // }
48324
+ // ],
48325
+ // "failureList": [],
48326
+ // "result": false
48327
+ // }
48328
+ // }
48329
+ //
48330
+ const data = this.safeValue(response, 'data', {});
48331
+ const order = this.safeValue(data, 'successList', []);
48332
+ return this.parseOrder(order[0], market);
48333
+ }
48334
+ async closeAllPositions(params = {}) {
48335
+ /**
48336
+ * @method
48337
+ * @name bitget#closeAllPositions
48338
+ * @description closes all open positions for a market type
48339
+ * @see https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
48340
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
48341
+ * @param {string} [params.productType] 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
48342
+ * @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
48343
+ */
48344
+ await this.loadMarkets();
48345
+ let productType = undefined;
48346
+ [productType, params] = this.handleProductTypeAndParams(undefined, params);
48347
+ const request = {
48348
+ 'productType': productType,
48349
+ };
48350
+ const response = await this.privateMixPostV2MixOrderClosePositions(this.extend(request, params));
48351
+ //
48352
+ // {
48353
+ // "code": "00000",
48354
+ // "msg": "success",
48355
+ // "requestTime": 1702975017017,
48356
+ // "data": {
48357
+ // "successList": [
48358
+ // {
48359
+ // "orderId": "1120923953904893955",
48360
+ // "clientOid": "1120923953904893956"
48361
+ // }
48362
+ // ],
48363
+ // "failureList": [],
48364
+ // "result": false
48365
+ // }
48366
+ // }
48257
48367
  //
48258
48368
  const data = this.safeValue(response, 'data', {});
48259
- const orderInfo = this.safeValue(data, 'orderInfo', []);
48369
+ const orderInfo = this.safeValue(data, 'successList', []);
48260
48370
  return this.parsePositions(orderInfo, undefined, params);
48261
48371
  }
48262
48372
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
@@ -61902,18 +62012,9 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
61902
62012
  const first = this.safeString(symbols, 0);
61903
62013
  const market = this.market(first);
61904
62014
  if (market['swap']) {
61905
- request['contractName'] = market['id'];
61906
- if (market['linear']) {
61907
- response = await this.fapiV1PublicGetTicker(this.extend(request, params));
61908
- }
61909
- else if (market['inverse']) {
61910
- response = await this.dapiV1PublicGetTicker(this.extend(request, params));
61911
- }
61912
- response['symbol'] = market['id'];
61913
- data = [response];
62015
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTickers does not support swap markets, please use fetchTicker instead');
61914
62016
  }
61915
62017
  else if (market['spot']) {
61916
- request['symbol'] = market['id'];
61917
62018
  response = await this.spotV1PublicGetTicker24hr(this.extend(request, params));
61918
62019
  data = response;
61919
62020
  }
@@ -61924,7 +62025,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
61924
62025
  else {
61925
62026
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', undefined, params);
61926
62027
  if (type !== 'spot') {
61927
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTickers only support spot when symbols is not set');
62028
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTickers only support spot when symbols are not proved');
61928
62029
  }
61929
62030
  response = await this.spotV1PublicGetTicker24hr(this.extend(request, params));
61930
62031
  data = response;
@@ -75133,6 +75234,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75133
75234
  'v5/account/fee-rate': 10,
75134
75235
  'v5/account/info': 5,
75135
75236
  'v5/account/transaction-log': 1,
75237
+ 'v5/account/smp-group': 1,
75136
75238
  'v5/account/mmp-state': 5,
75137
75239
  // asset
75138
75240
  'v5/asset/exchange/order-record': 5,
@@ -84369,6 +84471,8 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
84369
84471
  'brokerage/products/{product_id}',
84370
84472
  'brokerage/products/{product_id}/candles',
84371
84473
  'brokerage/products/{product_id}/ticker',
84474
+ 'brokerage/portfolios',
84475
+ 'brokerage/portfolios/{portfolio_uuid}',
84372
84476
  'brokerage/transaction_summary',
84373
84477
  'brokerage/product_book',
84374
84478
  'brokerage/best_bid_ask',
@@ -84380,9 +84484,17 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
84380
84484
  'brokerage/orders/batch_cancel',
84381
84485
  'brokerage/orders/edit',
84382
84486
  'brokerage/orders/edit_preview',
84487
+ 'brokerage/portfolios',
84488
+ 'brokerage/portfolios/move_funds',
84383
84489
  'brokerage/convert/quote',
84384
84490
  'brokerage/convert/trade/{trade_id}',
84385
84491
  ],
84492
+ 'put': [
84493
+ 'brokerage/portfolios/{portfolio_uuid}',
84494
+ ],
84495
+ 'delete': [
84496
+ 'brokerage/portfolios/{portfolio_uuid}',
84497
+ ],
84386
84498
  },
84387
84499
  },
84388
84500
  },
@@ -84438,7 +84550,9 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
84438
84550
  'invalid_scope': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
84439
84551
  'not_found': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
84440
84552
  'rate_limit_exceeded': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded,
84441
- 'internal_server_error': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError, // 500 Internal server error
84553
+ 'internal_server_error': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
84554
+ 'UNSUPPORTED_ORDER_CONFIGURATION': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
84555
+ 'INSUFFICIENT_FUND': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
84442
84556
  },
84443
84557
  'broad': {
84444
84558
  'request timestamp expired': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidNonce,
@@ -86443,6 +86557,8 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
86443
86557
  params = this.omit(params, ['timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'stop_price', 'stopDirection', 'stop_direction', 'clientOrderId', 'postOnly', 'post_only', 'end_time']);
86444
86558
  const response = await this.v3PrivatePostBrokerageOrders(this.extend(request, params));
86445
86559
  //
86560
+ // successful order
86561
+ //
86446
86562
  // {
86447
86563
  // "success": true,
86448
86564
  // "failure_reason": "UNKNOWN_FAILURE_REASON",
@@ -86456,9 +86572,37 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
86456
86572
  // "order_configuration": null
86457
86573
  // }
86458
86574
  //
86575
+ // failed order
86576
+ //
86577
+ // {
86578
+ // "success": false,
86579
+ // "failure_reason": "UNKNOWN_FAILURE_REASON",
86580
+ // "order_id": "",
86581
+ // "error_response": {
86582
+ // "error": "UNSUPPORTED_ORDER_CONFIGURATION",
86583
+ // "message": "source is not enabled for trading",
86584
+ // "error_details": "",
86585
+ // "new_order_failure_reason": "UNSUPPORTED_ORDER_CONFIGURATION"
86586
+ // },
86587
+ // "order_configuration": {
86588
+ // "limit_limit_gtc": {
86589
+ // "base_size": "100",
86590
+ // "limit_price": "40000",
86591
+ // "post_only": false
86592
+ // }
86593
+ // }
86594
+ // }
86595
+ //
86459
86596
  const success = this.safeValue(response, 'success');
86460
86597
  if (success !== true) {
86461
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrder() has failed, check your arguments and parameters');
86598
+ const errorResponse = this.safeValue(response, 'error_response');
86599
+ const errorTitle = this.safeString(errorResponse, 'error');
86600
+ const errorMessage = this.safeString(errorResponse, 'message');
86601
+ if (errorResponse !== undefined) {
86602
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorTitle, errorMessage);
86603
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorTitle, errorMessage);
86604
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(errorMessage);
86605
+ }
86462
86606
  }
86463
86607
  const data = this.safeValue(response, 'success_response', {});
86464
86608
  return this.parseOrder(data, market);
@@ -98908,6 +99052,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
98908
99052
  'fetchClosedOrders': false,
98909
99053
  'fetchCrossBorrowRate': false,
98910
99054
  'fetchCrossBorrowRates': false,
99055
+ 'fetchCurrencies': true,
98911
99056
  'fetchDepositAddresses': true,
98912
99057
  'fetchFundingHistory': false,
98913
99058
  'fetchFundingRate': false,
@@ -98944,6 +99089,9 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
98944
99089
  'logo': 'https://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpg',
98945
99090
  'api': {
98946
99091
  'rest': 'https://api.coinone.co.kr',
99092
+ 'v2Public': 'https://api.coinone.co.kr/public/v2',
99093
+ 'v2Private': 'https://api.coinone.co.kr/v2',
99094
+ 'v2_1Private': 'https://api.coinone.co.kr/v2.1',
98947
99095
  },
98948
99096
  'www': 'https://coinone.co.kr',
98949
99097
  'doc': 'https://doc.coinone.co.kr',
@@ -98955,31 +99103,85 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
98955
99103
  'api': {
98956
99104
  'public': {
98957
99105
  'get': [
98958
- 'orderbook/',
98959
- 'trades/',
98960
- 'ticker/',
99106
+ 'orderbook',
99107
+ 'ticker',
99108
+ 'ticker_utc',
99109
+ 'trades',
99110
+ ],
99111
+ },
99112
+ 'v2Public': {
99113
+ 'get': [
99114
+ 'range_units',
99115
+ 'markets/{quote_currency}',
99116
+ 'markets/{quote_currency}/{target_currency}',
99117
+ 'orderbook/{quote_currency}/{target_currency}',
99118
+ 'trades/{quote_currency}/{target_currency}',
99119
+ 'ticker_new/{quote_currency}',
99120
+ 'ticker_new/{quote_currency}/{target_currency}',
99121
+ 'ticker_utc_new/{quote_currency}',
99122
+ 'ticker_utc_new/{quote_currency}/{target_currency}',
99123
+ 'currencies',
99124
+ 'currencies/{currency}',
99125
+ 'chart/{quote_currency}/{target_currency}',
98961
99126
  ],
98962
99127
  },
98963
99128
  'private': {
98964
99129
  'post': [
98965
- 'account/deposit_address/',
98966
- 'account/btc_deposit_address/',
98967
- 'account/balance/',
98968
- 'account/daily_balance/',
98969
- 'account/user_info/',
98970
- 'account/virtual_account/',
98971
- 'order/cancel_all/',
98972
- 'order/cancel/',
98973
- 'order/limit_buy/',
98974
- 'order/limit_sell/',
98975
- 'order/complete_orders/',
98976
- 'order/limit_orders/',
98977
- 'order/query_order/',
98978
- 'transaction/auth_number/',
98979
- 'transaction/history/',
98980
- 'transaction/krw/history/',
98981
- 'transaction/btc/',
98982
- 'transaction/coin/',
99130
+ 'account/deposit_address',
99131
+ 'account/btc_deposit_address',
99132
+ 'account/balance',
99133
+ 'account/daily_balance',
99134
+ 'account/user_info',
99135
+ 'account/virtual_account',
99136
+ 'order/cancel_all',
99137
+ 'order/cancel',
99138
+ 'order/limit_buy',
99139
+ 'order/limit_sell',
99140
+ 'order/complete_orders',
99141
+ 'order/limit_orders',
99142
+ 'order/order_info',
99143
+ 'transaction/auth_number',
99144
+ 'transaction/history',
99145
+ 'transaction/krw/history',
99146
+ 'transaction/btc',
99147
+ 'transaction/coin',
99148
+ ],
99149
+ },
99150
+ 'v2Private': {
99151
+ 'post': [
99152
+ 'account/balance',
99153
+ 'account/deposit_address',
99154
+ 'account/user_info',
99155
+ 'account/virtual_account',
99156
+ 'order/cancel',
99157
+ 'order/limit_buy',
99158
+ 'order/limit_sell',
99159
+ 'order/limit_orders',
99160
+ 'order/complete_orders',
99161
+ 'order/query_order',
99162
+ 'transaction/auth_number',
99163
+ 'transaction/btc',
99164
+ 'transaction/history',
99165
+ 'transaction/krw/history',
99166
+ ],
99167
+ },
99168
+ 'v2_1Private': {
99169
+ 'post': [
99170
+ 'account/balance/all',
99171
+ 'account/balance',
99172
+ 'account/trade_fee',
99173
+ 'account/trade_fee/{quote_currency}/{target_currency}',
99174
+ 'order/limit',
99175
+ 'order/cancel',
99176
+ 'order/cancel/all',
99177
+ 'order/open_orders',
99178
+ 'order/open_orders/all',
99179
+ 'order/complete_orders',
99180
+ 'order/complete_orders/all',
99181
+ 'order/info',
99182
+ 'transaction/krw/history',
99183
+ 'transaction/coin/history',
99184
+ 'transaction/coin/withdrawal/limit',
98983
99185
  ],
98984
99186
  },
98985
99187
  },
@@ -99003,53 +99205,129 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99003
99205
  },
99004
99206
  });
99005
99207
  }
99208
+ async fetchCurrencies(params = {}) {
99209
+ /**
99210
+ * @method
99211
+ * @name coinone#fetchCurrencies
99212
+ * @description fetches all available currencies on an exchange
99213
+ * @see https://docs.coinone.co.kr/reference/currencies
99214
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
99215
+ * @returns {object} an associative dictionary of currencies
99216
+ */
99217
+ const response = await this.v2PublicGetCurrencies(params);
99218
+ //
99219
+ // {
99220
+ // "result": "success",
99221
+ // "error_code": "0",
99222
+ // "server_time": 1701054555578,
99223
+ // "currencies": [
99224
+ // {
99225
+ // "name": "Polygon",
99226
+ // "symbol": "MATIC",
99227
+ // "deposit_status": "normal",
99228
+ // "withdraw_status": "normal",
99229
+ // "deposit_confirm_count": 150,
99230
+ // "max_precision": 8,
99231
+ // "deposit_fee": "0.0",
99232
+ // "withdrawal_min_amount": "1.0",
99233
+ // "withdrawal_fee": "3.0"
99234
+ // }
99235
+ // ]
99236
+ // }
99237
+ //
99238
+ const result = {};
99239
+ const currencies = this.safeValue(response, 'currencies', []);
99240
+ for (let i = 0; i < currencies.length; i++) {
99241
+ const entry = currencies[i];
99242
+ const id = this.safeString(entry, 'symbol');
99243
+ const name = this.safeString(entry, 'name');
99244
+ const code = this.safeCurrencyCode(id);
99245
+ const withdrawStatus = this.safeString(entry, 'withdraw_status', '');
99246
+ const depositStatus = this.safeString(entry, 'deposit_status', '');
99247
+ const isWithdrawEnabled = withdrawStatus === 'normal';
99248
+ const isDepositEnabled = depositStatus === 'normal';
99249
+ result[code] = {
99250
+ 'id': id,
99251
+ 'code': code,
99252
+ 'info': entry,
99253
+ 'name': name,
99254
+ 'active': isWithdrawEnabled && isDepositEnabled,
99255
+ 'deposit': isDepositEnabled,
99256
+ 'withdraw': isWithdrawEnabled,
99257
+ 'fee': this.safeNumber(entry, 'withdrawal_fee'),
99258
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(entry, 'max_precision'))),
99259
+ 'limits': {
99260
+ 'amount': {
99261
+ 'min': undefined,
99262
+ 'max': undefined,
99263
+ },
99264
+ 'withdraw': {
99265
+ 'min': this.safeNumber(entry, 'withdrawal_min_amount'),
99266
+ 'max': undefined,
99267
+ },
99268
+ },
99269
+ 'networks': {},
99270
+ };
99271
+ }
99272
+ return result;
99273
+ }
99006
99274
  async fetchMarkets(params = {}) {
99007
99275
  /**
99008
99276
  * @method
99009
99277
  * @name coinone#fetchMarkets
99010
99278
  * @description retrieves data on all markets for coinone
99279
+ * @see https://docs.coinone.co.kr/v1.0/reference/tickers
99011
99280
  * @param {object} [params] extra parameters specific to the exchange API endpoint
99012
99281
  * @returns {object[]} an array of objects representing market data
99013
99282
  */
99014
99283
  const request = {
99015
- 'currency': 'all',
99284
+ 'quote_currency': 'KRW',
99016
99285
  };
99017
- const response = await this.publicGetTicker(request);
99286
+ const response = await this.v2PublicGetTickerNewQuoteCurrency(request);
99018
99287
  //
99019
- // {
99020
- // "result": "success",
99021
- // "errorCode": "0",
99022
- // "timestamp": "1643676668",
99023
- // "xec": {
99024
- // "currency": "xec",
99025
- // "first": "0.0914",
99026
- // "low": "0.0894",
99027
- // "high": "0.096",
99028
- // "last": "0.0937",
99029
- // "volume": "1673283662.9797",
99030
- // "yesterday_first": "0.0929",
99031
- // "yesterday_low": "0.0913",
99032
- // "yesterday_high": "0.0978",
99033
- // "yesterday_last": "0.0913",
99034
- // "yesterday_volume": "1167285865.4571"
99035
- // },
99036
- // ...
99037
- // }
99288
+ // {
99289
+ // "result": "success",
99290
+ // "error_code": "0",
99291
+ // "server_time": 1701067923060,
99292
+ // "tickers": [
99293
+ // {
99294
+ // "quote_currency": "krw",
99295
+ // "target_currency": "stg",
99296
+ // "timestamp": 1701067920001,
99297
+ // "high": "667.5",
99298
+ // "low": "667.5",
99299
+ // "first": "667.5",
99300
+ // "last": "667.5",
99301
+ // "quote_volume": "0.0",
99302
+ // "target_volume": "0.0",
99303
+ // "best_asks": [
99304
+ // {
99305
+ // "price": "777.0",
99306
+ // "qty": "73.9098"
99307
+ // }
99308
+ // ],
99309
+ // "best_bids": [
99310
+ // {
99311
+ // "price": "690.8",
99312
+ // "qty": "40.7768"
99313
+ // }
99314
+ // ],
99315
+ // "id": "1701067920001001"
99316
+ // }
99317
+ // ]
99318
+ // }
99038
99319
  //
99320
+ const tickers = this.safeValue(response, 'tickers', []);
99039
99321
  const result = [];
99040
- const quoteId = 'krw';
99041
- const quote = this.safeCurrencyCode(quoteId);
99042
- const baseIds = Object.keys(response);
99043
- for (let i = 0; i < baseIds.length; i++) {
99044
- const baseId = baseIds[i];
99045
- const ticker = this.safeValue(response, baseId, {});
99046
- const currency = this.safeValue(ticker, 'currency');
99047
- if (currency === undefined) {
99048
- continue;
99049
- }
99322
+ for (let i = 0; i < tickers.length; i++) {
99323
+ const entry = this.safeValue(tickers, i);
99324
+ const id = this.safeString(entry, 'id');
99325
+ const baseId = this.safeStringUpper(entry, 'target_currency');
99326
+ const quoteId = this.safeStringUpper(entry, 'quote_currency');
99050
99327
  const base = this.safeCurrencyCode(baseId);
99328
+ const quote = this.safeCurrencyCode(quoteId);
99051
99329
  result.push({
99052
- 'id': baseId,
99330
+ 'id': id,
99053
99331
  'symbol': base + '/' + quote,
99054
99332
  'base': base,
99055
99333
  'quote': quote,
@@ -99096,7 +99374,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99096
99374
  },
99097
99375
  },
99098
99376
  'created': undefined,
99099
- 'info': ticker,
99377
+ 'info': entry,
99100
99378
  });
99101
99379
  }
99102
99380
  return result;
@@ -99125,11 +99403,12 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99125
99403
  * @method
99126
99404
  * @name coinone#fetchBalance
99127
99405
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
99406
+ * @see https://docs.coinone.co.kr/v1.0/reference/v21
99128
99407
  * @param {object} [params] extra parameters specific to the exchange API endpoint
99129
99408
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
99130
99409
  */
99131
99410
  await this.loadMarkets();
99132
- const response = await this.privatePostAccountBalance(params);
99411
+ const response = await this.v2PrivatePostAccountBalance(params);
99133
99412
  return this.parseBalance(response);
99134
99413
  }
99135
99414
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
@@ -99137,6 +99416,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99137
99416
  * @method
99138
99417
  * @name coinone#fetchOrderBook
99139
99418
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
99419
+ * @see https://docs.coinone.co.kr/v1.0/reference/orderbook
99140
99420
  * @param {string} symbol unified symbol of the market to fetch the order book for
99141
99421
  * @param {int} [limit] the maximum amount of order book entries to return
99142
99422
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -99145,18 +99425,46 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99145
99425
  await this.loadMarkets();
99146
99426
  const market = this.market(symbol);
99147
99427
  const request = {
99148
- 'currency': market['id'],
99149
- 'format': 'json',
99428
+ 'quote_currency': market['quote'],
99429
+ 'target_currency': market['base'],
99150
99430
  };
99151
- const response = await this.publicGetOrderbook(this.extend(request, params));
99152
- const timestamp = this.safeTimestamp(response, 'timestamp');
99153
- return this.parseOrderBook(response, market['symbol'], timestamp, 'bid', 'ask', 'price', 'qty');
99431
+ if (limit !== undefined) {
99432
+ request['size'] = limit; // only support 5, 10, 15, 16
99433
+ }
99434
+ const response = await this.v2PublicGetOrderbookQuoteCurrencyTargetCurrency(this.extend(request, params));
99435
+ //
99436
+ // {
99437
+ // "result": "success",
99438
+ // "error_code": "0",
99439
+ // "timestamp": 1701071108673,
99440
+ // "id": "1701071108673001",
99441
+ // "quote_currency": "KRW",
99442
+ // "target_currency": "BTC",
99443
+ // "order_book_unit": "0.0",
99444
+ // "bids": [
99445
+ // {
99446
+ // "price": "50048000",
99447
+ // "qty": "0.01080229"
99448
+ // }
99449
+ // ],
99450
+ // "asks": [
99451
+ // {
99452
+ // "price": "50058000",
99453
+ // "qty": "0.00272592"
99454
+ // }
99455
+ // ]
99456
+ // }
99457
+ //
99458
+ const timestamp = this.safeInteger(response, 'timestamp');
99459
+ return this.parseOrderBook(response, market['symbol'], timestamp, 'bids', 'asks', 'price', 'qty');
99154
99460
  }
99155
99461
  async fetchTickers(symbols = undefined, params = {}) {
99156
99462
  /**
99157
99463
  * @method
99158
99464
  * @name coinone#fetchTickers
99159
99465
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
99466
+ * @see https://docs.coinone.co.kr/v1.0/reference/tickers
99467
+ * @see https://docs.coinone.co.kr/v1.0/reference/ticker
99160
99468
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
99161
99469
  * @param {object} [params] extra parameters specific to the exchange API endpoint
99162
99470
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -99164,28 +99472,62 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99164
99472
  await this.loadMarkets();
99165
99473
  symbols = this.marketSymbols(symbols);
99166
99474
  const request = {
99167
- 'currency': 'all',
99168
- 'format': 'json',
99475
+ 'quote_currency': 'KRW',
99169
99476
  };
99170
- const response = await this.publicGetTicker(this.extend(request, params));
99171
- const result = {};
99172
- const ids = Object.keys(response);
99173
- const timestamp = this.safeTimestamp(response, 'timestamp');
99174
- for (let i = 0; i < ids.length; i++) {
99175
- const id = ids[i];
99176
- const market = this.safeMarket(id);
99177
- const symbol = market['symbol'];
99178
- const ticker = response[id];
99179
- result[symbol] = this.parseTicker(ticker, market);
99180
- result[symbol]['timestamp'] = timestamp;
99477
+ let market = undefined;
99478
+ let response = undefined;
99479
+ if (symbols !== undefined) {
99480
+ const first = this.safeString(symbols, 0);
99481
+ market = this.market(first);
99482
+ request['quote_currency'] = market['quote'];
99483
+ request['target_currency'] = market['base'];
99484
+ response = await this.v2PublicGetTickerNewQuoteCurrencyTargetCurrency(this.extend(request, params));
99181
99485
  }
99182
- return this.filterByArrayTickers(result, 'symbol', symbols);
99486
+ else {
99487
+ response = await this.v2PublicGetTickerNewQuoteCurrency(this.extend(request, params));
99488
+ }
99489
+ //
99490
+ // {
99491
+ // "result": "success",
99492
+ // "error_code": "0",
99493
+ // "server_time": 1701073358487,
99494
+ // "tickers": [
99495
+ // {
99496
+ // "quote_currency": "krw",
99497
+ // "target_currency": "btc",
99498
+ // "timestamp": 1701073357818,
99499
+ // "high": "50543000.0",
99500
+ // "low": "49945000.0",
99501
+ // "first": "50487000.0",
99502
+ // "last": "50062000.0",
99503
+ // "quote_volume": "11349804285.3859",
99504
+ // "target_volume": "226.07268994",
99505
+ // "best_asks": [
99506
+ // {
99507
+ // "price": "50081000.0",
99508
+ // "qty": "0.18471358"
99509
+ // }
99510
+ // ],
99511
+ // "best_bids": [
99512
+ // {
99513
+ // "price": "50062000.0",
99514
+ // "qty": "0.04213455"
99515
+ // }
99516
+ // ],
99517
+ // "id": "1701073357818001"
99518
+ // }
99519
+ // ]
99520
+ // }
99521
+ //
99522
+ const data = this.safeValue(response, 'tickers', []);
99523
+ return this.parseTickers(data, symbols);
99183
99524
  }
99184
99525
  async fetchTicker(symbol, params = {}) {
99185
99526
  /**
99186
99527
  * @method
99187
99528
  * @name coinone#fetchTicker
99188
99529
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
99530
+ * @see https://docs.coinone.co.kr/v1.0/reference/ticker
99189
99531
  * @param {string} symbol unified symbol of the market to fetch the ticker for
99190
99532
  * @param {object} [params] extra parameters specific to the exchange API endpoint
99191
99533
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -99193,53 +99535,102 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99193
99535
  await this.loadMarkets();
99194
99536
  const market = this.market(symbol);
99195
99537
  const request = {
99196
- 'currency': market['id'],
99197
- 'format': 'json',
99538
+ 'quote_currency': market['quote'],
99539
+ 'target_currency': market['base'],
99198
99540
  };
99199
- const response = await this.publicGetTicker(this.extend(request, params));
99200
- return this.parseTicker(response, market);
99541
+ const response = await this.v2PublicGetTickerNewQuoteCurrencyTargetCurrency(this.extend(request, params));
99542
+ //
99543
+ // {
99544
+ // "result": "success",
99545
+ // "error_code": "0",
99546
+ // "server_time": 1701073358487,
99547
+ // "tickers": [
99548
+ // {
99549
+ // "quote_currency": "krw",
99550
+ // "target_currency": "btc",
99551
+ // "timestamp": 1701073357818,
99552
+ // "high": "50543000.0",
99553
+ // "low": "49945000.0",
99554
+ // "first": "50487000.0",
99555
+ // "last": "50062000.0",
99556
+ // "quote_volume": "11349804285.3859",
99557
+ // "target_volume": "226.07268994",
99558
+ // "best_asks": [
99559
+ // {
99560
+ // "price": "50081000.0",
99561
+ // "qty": "0.18471358"
99562
+ // }
99563
+ // ],
99564
+ // "best_bids": [
99565
+ // {
99566
+ // "price": "50062000.0",
99567
+ // "qty": "0.04213455"
99568
+ // }
99569
+ // ],
99570
+ // "id": "1701073357818001"
99571
+ // }
99572
+ // ]
99573
+ // }
99574
+ //
99575
+ const data = this.safeValue(response, 'tickers', []);
99576
+ const ticker = this.safeValue(data, 0, {});
99577
+ return this.parseTicker(ticker, market);
99201
99578
  }
99202
99579
  parseTicker(ticker, market = undefined) {
99203
99580
  //
99204
99581
  // {
99205
- // "currency":"xec",
99206
- // "first":"0.1069",
99207
- // "low":"0.09",
99208
- // "high":"0.1069",
99209
- // "last":"0.0911",
99210
- // "volume":"4591217267.4974",
99211
- // "yesterday_first":"0.1128",
99212
- // "yesterday_low":"0.1035",
99213
- // "yesterday_high":"0.1167",
99214
- // "yesterday_last":"0.1069",
99215
- // "yesterday_volume":"4014832231.5102"
99582
+ // "quote_currency": "krw",
99583
+ // "target_currency": "btc",
99584
+ // "timestamp": 1701073357818,
99585
+ // "high": "50543000.0",
99586
+ // "low": "49945000.0",
99587
+ // "first": "50487000.0",
99588
+ // "last": "50062000.0",
99589
+ // "quote_volume": "11349804285.3859",
99590
+ // "target_volume": "226.07268994",
99591
+ // "best_asks": [
99592
+ // {
99593
+ // "price": "50081000.0",
99594
+ // "qty": "0.18471358"
99595
+ // }
99596
+ // ],
99597
+ // "best_bids": [
99598
+ // {
99599
+ // "price": "50062000.0",
99600
+ // "qty": "0.04213455"
99601
+ // }
99602
+ // ],
99603
+ // "id": "1701073357818001"
99216
99604
  // }
99217
99605
  //
99218
- const timestamp = this.safeTimestamp(ticker, 'timestamp');
99219
- const open = this.safeString(ticker, 'first');
99606
+ const timestamp = this.safeInteger(ticker, 'timestamp');
99220
99607
  const last = this.safeString(ticker, 'last');
99221
- const previousClose = this.safeString(ticker, 'yesterday_last');
99222
- const symbol = this.safeSymbol(undefined, market);
99608
+ const asks = this.safeValue(ticker, 'best_asks');
99609
+ const bids = this.safeValue(ticker, 'best_bids');
99610
+ const baseId = this.safeString(ticker, 'target_currency');
99611
+ const quoteId = this.safeString(ticker, 'quote_currency');
99612
+ const base = this.safeCurrencyCode(baseId);
99613
+ const quote = this.safeCurrencyCode(quoteId);
99223
99614
  return this.safeTicker({
99224
- 'symbol': symbol,
99615
+ 'symbol': base + '/' + quote,
99225
99616
  'timestamp': timestamp,
99226
99617
  'datetime': this.iso8601(timestamp),
99227
99618
  'high': this.safeString(ticker, 'high'),
99228
99619
  'low': this.safeString(ticker, 'low'),
99229
- 'bid': undefined,
99230
- 'bidVolume': undefined,
99231
- 'ask': undefined,
99232
- 'askVolume': undefined,
99620
+ 'bid': this.safeString(bids, 'price'),
99621
+ 'bidVolume': this.safeString(bids, 'qty'),
99622
+ 'ask': this.safeString(asks, 'price'),
99623
+ 'askVolume': this.safeString(asks, 'qty'),
99233
99624
  'vwap': undefined,
99234
- 'open': open,
99625
+ 'open': this.safeString(ticker, 'first'),
99235
99626
  'close': last,
99236
99627
  'last': last,
99237
- 'previousClose': previousClose,
99628
+ 'previousClose': undefined,
99238
99629
  'change': undefined,
99239
99630
  'percentage': undefined,
99240
99631
  'average': undefined,
99241
- 'baseVolume': this.safeString(ticker, 'volume'),
99242
- 'quoteVolume': undefined,
99632
+ 'baseVolume': this.safeString(ticker, 'target_volume'),
99633
+ 'quoteVolume': this.safeString(ticker, 'quote_volume'),
99243
99634
  'info': ticker,
99244
99635
  }, market);
99245
99636
  }
@@ -99248,10 +99639,11 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99248
99639
  // fetchTrades (public)
99249
99640
  //
99250
99641
  // {
99251
- // "timestamp": "1416893212",
99252
- // "price": "420000.0",
99253
- // "qty": "0.1",
99254
- // "is_ask": "1"
99642
+ // "id": "1701075265708001",
99643
+ // "timestamp": 1701075265708,
99644
+ // "price": "50020000",
99645
+ // "qty": "0.00155177",
99646
+ // "is_seller_maker": false
99255
99647
  // }
99256
99648
  //
99257
99649
  // fetchMyTrades (private)
@@ -99266,25 +99658,12 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99266
99658
  // "orderId": "E84A1AC2-8088-4FA0-B093-A3BCDB9B3C85"
99267
99659
  // }
99268
99660
  //
99269
- const timestamp = this.safeTimestamp(trade, 'timestamp');
99661
+ const timestamp = this.safeInteger(trade, 'timestamp');
99270
99662
  market = this.safeMarket(undefined, market);
99271
- const is_ask = this.safeString(trade, 'is_ask');
99272
- let side = this.safeString(trade, 'type');
99273
- if (is_ask !== undefined) {
99274
- if (is_ask === '1') {
99275
- side = 'sell';
99276
- }
99277
- else if (is_ask === '0') {
99278
- side = 'buy';
99279
- }
99280
- }
99281
- else {
99282
- if (side === 'ask') {
99283
- side = 'sell';
99284
- }
99285
- else if (side === 'bid') {
99286
- side = 'buy';
99287
- }
99663
+ const isSellerMaker = this.safeValue(trade, 'is_seller_maker');
99664
+ let side = undefined;
99665
+ if (isSellerMaker !== undefined) {
99666
+ side = isSellerMaker ? 'sell' : 'buy';
99288
99667
  }
99289
99668
  const priceString = this.safeString(trade, 'price');
99290
99669
  const amountString = this.safeString(trade, 'qty');
@@ -99323,6 +99702,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99323
99702
  * @method
99324
99703
  * @name coinone#fetchTrades
99325
99704
  * @description get the list of most recent trades for a particular symbol
99705
+ * @see https://docs.coinone.co.kr/v1.0/reference/recent-completed-orders
99326
99706
  * @param {string} symbol unified symbol of the market to fetch trades for
99327
99707
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
99328
99708
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -99332,28 +99712,33 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99332
99712
  await this.loadMarkets();
99333
99713
  const market = this.market(symbol);
99334
99714
  const request = {
99335
- 'currency': market['id'],
99336
- 'format': 'json',
99715
+ 'quote_currency': market['quote'],
99716
+ 'target_currency': market['base'],
99337
99717
  };
99338
- const response = await this.publicGetTrades(this.extend(request, params));
99718
+ if (limit !== undefined) {
99719
+ request['size'] = limit; // only support 10, 50, 100, 150, 200
99720
+ }
99721
+ const response = await this.v2PublicGetTradesQuoteCurrencyTargetCurrency(this.extend(request, params));
99339
99722
  //
99340
99723
  // {
99341
99724
  // "result": "success",
99342
- // "errorCode": "0",
99343
- // "timestamp": "1416895635",
99344
- // "currency": "btc",
99345
- // "completeOrders": [
99725
+ // "error_code": "0",
99726
+ // "server_time": 1701075315771,
99727
+ // "quote_currency": "KRW",
99728
+ // "target_currency": "BTC",
99729
+ // "transactions": [
99346
99730
  // {
99347
- // "timestamp": "1416893212",
99348
- // "price": "420000.0",
99349
- // "qty": "0.1",
99350
- // "is_ask": "1"
99731
+ // "id": "1701075265708001",
99732
+ // "timestamp": 1701075265708,
99733
+ // "price": "50020000",
99734
+ // "qty": "0.00155177",
99735
+ // "is_seller_maker": false
99351
99736
  // }
99352
99737
  // ]
99353
99738
  // }
99354
99739
  //
99355
- const completeOrders = this.safeValue(response, 'completeOrders', []);
99356
- return this.parseTrades(completeOrders, market, since, limit);
99740
+ const data = this.safeValue(response, 'transactions', []);
99741
+ return this.parseTrades(data, market, since, limit);
99357
99742
  }
99358
99743
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
99359
99744
  /**
@@ -99409,7 +99794,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99409
99794
  'order_id': id,
99410
99795
  'currency': market['id'],
99411
99796
  };
99412
- const response = await this.privatePostOrderQueryOrder(this.extend(request, params));
99797
+ const response = await this.v2PrivatePostOrderQueryOrder(this.extend(request, params));
99413
99798
  //
99414
99799
  // {
99415
99800
  // "result": "success",
@@ -99620,7 +100005,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99620
100005
  const request = {
99621
100006
  'currency': market['id'],
99622
100007
  };
99623
- const response = await this.privatePostOrderCompleteOrders(this.extend(request, params));
100008
+ const response = await this.v2PrivatePostOrderCompleteOrders(this.extend(request, params));
99624
100009
  //
99625
100010
  // despite the name of the endpoint it returns trades which may have a duplicate orderId
99626
100011
  // https://github.com/ccxt/ccxt/pull/7067
@@ -99673,7 +100058,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99673
100058
  'is_ask': isAsk,
99674
100059
  'currency': this.marketId(symbol),
99675
100060
  };
99676
- const response = await this.privatePostOrderCancel(this.extend(request, params));
100061
+ const response = await this.v2PrivatePostOrderCancel(this.extend(request, params));
99677
100062
  //
99678
100063
  // {
99679
100064
  // "result": "success",
@@ -99692,7 +100077,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99692
100077
  * @returns {object} a list of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}
99693
100078
  */
99694
100079
  await this.loadMarkets();
99695
- const response = await this.privatePostAccountDepositAddress(params);
100080
+ const response = await this.v2PrivatePostAccountDepositAddress(params);
99696
100081
  //
99697
100082
  // {
99698
100083
  // "result": "success",
@@ -99745,6 +100130,16 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99745
100130
  const request = this.implodeParams(path, params);
99746
100131
  const query = this.omit(params, this.extractParams(path));
99747
100132
  let url = this.urls['api']['rest'] + '/';
100133
+ if (api === 'v2Public') {
100134
+ url = this.urls['api']['v2Public'] + '/';
100135
+ api = 'public';
100136
+ }
100137
+ else if (api === 'v2Private') {
100138
+ url = this.urls['api']['v2Private'] + '/';
100139
+ }
100140
+ else if (api === 'v2_1Private') {
100141
+ url = this.urls['api']['v2_1Private'] + '/';
100142
+ }
99748
100143
  if (api === 'public') {
99749
100144
  url += request;
99750
100145
  if (Object.keys(query).length) {
@@ -99753,7 +100148,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99753
100148
  }
99754
100149
  else {
99755
100150
  this.checkRequiredCredentials();
99756
- url += this.version + '/' + request;
100151
+ url += request;
99757
100152
  const nonce = this.nonce().toString();
99758
100153
  const json = this.json(this.extend({
99759
100154
  'access_token': this.apiKey,
@@ -129806,6 +130201,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
129806
130201
  'addMargin': true,
129807
130202
  'cancelAllOrders': true,
129808
130203
  'cancelOrder': true,
130204
+ 'closePosition': false,
129809
130205
  'createDepositAddress': true,
129810
130206
  'createOrder': true,
129811
130207
  'createPostOnlyOrder': true,
@@ -132645,6 +133041,9 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
132645
133041
  let marketType = undefined;
132646
133042
  let marginMode = undefined;
132647
133043
  [marketType, params] = this.handleMarketTypeAndParams('fetchPositions', undefined, params);
133044
+ if (marketType === 'spot') {
133045
+ marketType = 'swap';
133046
+ }
132648
133047
  [marginMode, params] = this.handleMarginModeAndParams('fetchPositions', params);
132649
133048
  params = this.omit(params, ['marginMode', 'margin']);
132650
133049
  let response = undefined;
@@ -133303,6 +133702,43 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
133303
133702
  }
133304
133703
  return result;
133305
133704
  }
133705
+ async closePosition(symbol, side = undefined, params = {}) {
133706
+ /**
133707
+ * @method
133708
+ * @name hitbtc#closePosition
133709
+ * @description closes open positions for a market
133710
+ * @see https://api.hitbtc.com/#close-all-futures-margin-positions
133711
+ * @param {object} [params] extra parameters specific to the okx api endpoint
133712
+ * @param {string} [params.symbol] *required* unified market symbol
133713
+ * @param {string} [params.marginMode] 'cross' or 'isolated', default is 'cross'
133714
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
133715
+ */
133716
+ await this.loadMarkets();
133717
+ let marginMode = undefined;
133718
+ [marginMode, params] = this.handleMarginModeAndParams('closePosition', params, 'cross');
133719
+ const market = this.market(symbol);
133720
+ const request = {
133721
+ 'symbol': market['id'],
133722
+ 'margin_mode': marginMode,
133723
+ };
133724
+ const response = await this.privateDeleteFuturesPositionMarginModeSymbol(this.extend(request, params));
133725
+ //
133726
+ // {
133727
+ // "id":"202471640",
133728
+ // "symbol":"TRXUSDT_PERP",
133729
+ // "margin_mode":"Cross",
133730
+ // "leverage":"1.00",
133731
+ // "quantity":"0",
133732
+ // "price_entry":"0",
133733
+ // "price_margin_call":"0",
133734
+ // "price_liquidation":"0",
133735
+ // "pnl":"0.001234100000",
133736
+ // "created_at":"2023-10-29T14:46:13.235Z",
133737
+ // "updated_at":"2023-12-19T09:34:40.014Z"
133738
+ // }
133739
+ //
133740
+ return this.parseOrder(response, market);
133741
+ }
133306
133742
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
133307
133743
  /**
133308
133744
  * @ignore
@@ -155466,6 +155902,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155466
155902
  'commonCurrencies': {
155467
155903
  'BIFI': 'BIFIF',
155468
155904
  'VAI': 'VAIOT',
155905
+ 'WAX': 'WAXP',
155469
155906
  },
155470
155907
  'options': {
155471
155908
  'version': 'v1',
@@ -159408,6 +159845,8 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159408
159845
  'addMargin': true,
159409
159846
  'cancelAllOrders': true,
159410
159847
  'cancelOrder': true,
159848
+ 'closePosition': true,
159849
+ 'closePositions': false,
159411
159850
  'createDepositAddress': true,
159412
159851
  'createOrder': true,
159413
159852
  'createReduceOnlyOrder': true,
@@ -159528,6 +159967,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159528
159967
  'positions': 4.44,
159529
159968
  'funding-history': 4.44,
159530
159969
  'sub/api-key': 1,
159970
+ 'trade-statistics': 1,
159531
159971
  },
159532
159972
  'post': {
159533
159973
  'withdrawals': 1,
@@ -159549,6 +159989,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159549
159989
  'orders': 4.44,
159550
159990
  'stopOrders': 1,
159551
159991
  'sub/api-key': 1,
159992
+ 'orders/client-order/{clientOid}': 1,
159552
159993
  },
159553
159994
  },
159554
159995
  'webExchange': {
@@ -160611,13 +161052,27 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
160611
161052
  * @param {string} id order id
160612
161053
  * @param {string} symbol unified symbol of the market the order was made in
160613
161054
  * @param {object} [params] extra parameters specific to the exchange API endpoint
161055
+ * @param {string} [params.clientOrderId] cancel order by client order id
160614
161056
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
160615
161057
  */
160616
161058
  await this.loadMarkets();
160617
- const request = {
160618
- 'orderId': id,
160619
- };
160620
- const response = await this.futuresPrivateDeleteOrdersOrderId(this.extend(request, params));
161059
+ const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
161060
+ params = this.omit(params, ['clientOrderId']);
161061
+ const request = {};
161062
+ let response = undefined;
161063
+ if (clientOrderId !== undefined) {
161064
+ if (symbol === undefined) {
161065
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument when cancelling by clientOrderId');
161066
+ }
161067
+ const market = this.market(symbol);
161068
+ request['symbol'] = market['id'];
161069
+ request['clientOid'] = clientOrderId;
161070
+ response = await this.futuresPrivateDeleteOrdersClientOrderClientOid(this.extend(request, params));
161071
+ }
161072
+ else {
161073
+ request['orderId'] = id;
161074
+ response = await this.futuresPrivateDeleteOrdersOrderId(this.extend(request, params));
161075
+ }
160621
161076
  //
160622
161077
  // {
160623
161078
  // "code": "200000",
@@ -161791,6 +162246,41 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
161791
162246
  'datetime': this.iso8601(timestamp),
161792
162247
  };
161793
162248
  }
162249
+ async closePosition(symbol, side = undefined, params = {}) {
162250
+ /**
162251
+ * @method
162252
+ * @name kucoinfutures#closePosition
162253
+ * @description closes open positions for a market
162254
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/place-order
162255
+ * @param {string} symbol Unified CCXT market symbol
162256
+ * @param {string} side not used by kucoinfutures closePositions
162257
+ * @param {object} [params] extra parameters specific to the okx api endpoint
162258
+ * @param {string} [params.clientOrderId] client order id of the order
162259
+ * @returns {[object]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
162260
+ */
162261
+ await this.loadMarkets();
162262
+ const market = this.market(symbol);
162263
+ let clientOrderId = this.safeString(params, 'clientOrderId');
162264
+ const testOrder = this.safeValue(params, 'test', false);
162265
+ params = this.omit(params, ['test', 'clientOrderId']);
162266
+ if (clientOrderId === undefined) {
162267
+ clientOrderId = this.numberToString(this.nonce());
162268
+ }
162269
+ const request = {
162270
+ 'symbol': market['id'],
162271
+ 'closeOrder': true,
162272
+ 'clientOid': clientOrderId,
162273
+ 'type': 'market',
162274
+ };
162275
+ let response = undefined;
162276
+ if (testOrder) {
162277
+ response = await this.futuresPrivatePostOrdersTest(this.extend(request, params));
162278
+ }
162279
+ else {
162280
+ response = await this.futuresPrivatePostOrders(this.extend(request, params));
162281
+ }
162282
+ return this.parseOrder(response, market);
162283
+ }
161794
162284
  }
161795
162285
 
161796
162286
 
@@ -185395,6 +185885,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
185395
185885
  // rfq
185396
185886
  'rfq/counterparties': 4,
185397
185887
  'rfq/maker-instrument-settings': 4,
185888
+ 'rfq/mmp-config': 4,
185398
185889
  'rfq/rfqs': 10,
185399
185890
  'rfq/quotes': 10,
185400
185891
  'rfq/trades': 4,
@@ -185534,6 +186025,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
185534
186025
  'rfq/execute-quote': 15,
185535
186026
  'rfq/maker-instrument-settings': 4,
185536
186027
  'rfq/mmp-reset': 4,
186028
+ 'rfq/mmp-config': 100,
185537
186029
  'rfq/create-quote': 0.4,
185538
186030
  'rfq/cancel-quote': 0.4,
185539
186031
  'rfq/cancel-batch-quotes': 10,
@@ -194749,6 +195241,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
194749
195241
  'networks': {
194750
195242
  'TRC20': 'TRX',
194751
195243
  'ERC20': 'ETH',
195244
+ 'BEP20': 'BNB',
194752
195245
  },
194753
195246
  'defaultNetworks': {
194754
195247
  'USDT': 'ETH',
@@ -197687,6 +198180,19 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
197687
198180
  const statuses = {
197688
198181
  'Success': 'ok',
197689
198182
  'Succeed': 'ok',
198183
+ 'Rejected': 'failed',
198184
+ 'Security check failed': 'failed',
198185
+ 'SecurityCheckFailed': 'failed',
198186
+ 'Expired': 'failed',
198187
+ 'Address Risk': 'failed',
198188
+ 'Security Checking': 'pending',
198189
+ 'SecurityChecking': 'pending',
198190
+ 'Pending Review': 'pending',
198191
+ 'Pending Transfer': 'pending',
198192
+ 'AmlCsApporve': 'pending',
198193
+ 'New': 'pending',
198194
+ 'Confirmed': 'pending',
198195
+ 'Cancelled': 'canceled',
197690
198196
  };
197691
198197
  return this.safeString(statuses, status, status);
197692
198198
  }
@@ -197694,36 +198200,68 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
197694
198200
  //
197695
198201
  // withdraw
197696
198202
  //
197697
- // ...
198203
+ // {
198204
+ // "id": "10000001",
198205
+ // "freezeId": null,
198206
+ // "address": "44exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
198207
+ // "amountRv": "100",
198208
+ // "chainCode": "11",
198209
+ // "chainName": "TRX",
198210
+ // "currency": "USDT",
198211
+ // "currencyCode": 3,
198212
+ // "email": "abc@gmail.com",
198213
+ // "expiredTime": "0",
198214
+ // "feeRv": "1",
198215
+ // "nickName": null,
198216
+ // "phone": null,
198217
+ // "rejectReason": "",
198218
+ // "submitedAt": "1670000000000",
198219
+ // "submittedAt": "1670000000000",
198220
+ // "txHash": null,
198221
+ // "userId": "10000001",
198222
+ // "status": "Success"
197698
198223
  //
197699
198224
  // fetchDeposits
197700
198225
  //
197701
198226
  // {
197702
- // "id":29200,
197703
- // "currency":"USDT",
197704
- // "currencyCode":3,
197705
- // "txHash":"0x0bdbdc47807769a03b158d5753f54dfc58b92993d2f5e818db21863e01238e5d",
197706
- // "address":"0x5bfbf60e0fa7f63598e6cfd8a7fd3ffac4ccc6ad",
197707
- // "amountEv":3000000000,
197708
- // "confirmations":13,
197709
- // "type":"Deposit",
197710
- // "status":"Success",
197711
- // "createdAt":1592722565000
198227
+ // "id": "29200",
198228
+ // "currency": "USDT",
198229
+ // "currencyCode": "3",
198230
+ // "chainName": "ETH",
198231
+ // "chainCode": "4",
198232
+ // "txHash": "0x0bdbdc47807769a03b158d5753f54dfc58b92993d2f5e818db21863e01238e5d",
198233
+ // "address": "0x5bfbf60e0fa7f63598e6cfd8a7fd3ffac4ccc6ad",
198234
+ // "amountEv": "3000000000",
198235
+ // "confirmations": "13",
198236
+ // "type": "Deposit",
198237
+ // "status": "Success",
198238
+ // "createdAt": "1592722565000",
197712
198239
  // }
197713
198240
  //
197714
198241
  // fetchWithdrawals
197715
198242
  //
197716
198243
  // {
197717
- // "address": "1Lxxxxxxxxxxx"
197718
- // "amountEv": 200000
197719
- // "currency": "BTC"
197720
- // "currencyCode": 1
197721
- // "expiredTime": 0
197722
- // "feeEv": 50000
197723
- // "rejectReason": null
197724
- // "status": "Succeed"
197725
- // "txHash": "44exxxxxxxxxxxxxxxxxxxxxx"
197726
- // "withdrawStatus: ""
198244
+ // "id": "10000001",
198245
+ // "userId": "10000001",
198246
+ // "freezeId": "10000002",
198247
+ // "phone": null,
198248
+ // "email": "abc@gmail.com",
198249
+ // "nickName": null,
198250
+ // "currency": "USDT",
198251
+ // "currencyCode": "3",
198252
+ // "status": "Succeed",
198253
+ // "withdrawStatus": "Succeed",
198254
+ // "amountEv": "8800000000",
198255
+ // "feeEv": "1200000000",
198256
+ // "address": "0x5xxxad",
198257
+ // "txHash: "0x0xxxx5d",
198258
+ // "submitedAt": "1702571922000",
198259
+ // "submittedAt": "1702571922000",
198260
+ // "expiredTime": "0",
198261
+ // "rejectReason": null,
198262
+ // "chainName": "ETH",
198263
+ // "chainCode": "4",
198264
+ // "proxyAddress": null
197727
198265
  // }
197728
198266
  //
197729
198267
  const id = this.safeString(transaction, 'id');
@@ -197733,9 +198271,13 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
197733
198271
  const currencyId = this.safeString(transaction, 'currency');
197734
198272
  currency = this.safeCurrency(currencyId, currency);
197735
198273
  const code = currency['code'];
197736
- const timestamp = this.safeInteger2(transaction, 'createdAt', 'submitedAt');
198274
+ const networkId = this.safeString(transaction, 'chainName');
198275
+ const timestamp = this.safeIntegerN(transaction, ['createdAt', 'submitedAt', 'submittedAt']);
197737
198276
  let type = this.safeStringLower(transaction, 'type');
197738
- const feeCost = this.parseNumber(this.fromEn(this.safeString(transaction, 'feeEv'), currency['valueScale']));
198277
+ let feeCost = this.parseNumber(this.fromEn(this.safeString(transaction, 'feeEv'), currency['valueScale']));
198278
+ if (feeCost === undefined) {
198279
+ feeCost = this.safeNumber(transaction, 'feeRv');
198280
+ }
197739
198281
  let fee = undefined;
197740
198282
  if (feeCost !== undefined) {
197741
198283
  type = 'withdrawal';
@@ -197745,14 +198287,17 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
197745
198287
  };
197746
198288
  }
197747
198289
  const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
197748
- const amount = this.parseNumber(this.fromEn(this.safeString(transaction, 'amountEv'), currency['valueScale']));
198290
+ let amount = this.parseNumber(this.fromEn(this.safeString(transaction, 'amountEv'), currency['valueScale']));
198291
+ if (amount === undefined) {
198292
+ amount = this.safeNumber(transaction, 'amountRv');
198293
+ }
197749
198294
  return {
197750
198295
  'info': transaction,
197751
198296
  'id': id,
197752
198297
  'txid': txid,
197753
198298
  'timestamp': timestamp,
197754
198299
  'datetime': this.iso8601(timestamp),
197755
- 'network': undefined,
198300
+ 'network': this.networkIdToCode(networkId),
197756
198301
  'address': address,
197757
198302
  'addressTo': address,
197758
198303
  'addressFrom': undefined,
@@ -198894,10 +199439,38 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
198894
199439
  'chainName': networkId.toUpperCase(),
198895
199440
  };
198896
199441
  if (tag !== undefined) {
198897
- request['tag'] = tag;
199442
+ request['addressTag'] = tag;
198898
199443
  }
198899
199444
  const response = await this.privatePostPhemexWithdrawWalletsApiCreateWithdraw(this.extend(request, params));
198900
- return this.parseTransaction(response, currency);
199445
+ //
199446
+ // {
199447
+ // "code": 0,
199448
+ // "msg": "OK",
199449
+ // "data": {
199450
+ // "id": "10000001",
199451
+ // "freezeId": null,
199452
+ // "address": "44exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
199453
+ // "amountRv": "100",
199454
+ // "chainCode": "11",
199455
+ // "chainName": "TRX",
199456
+ // "currency": "USDT",
199457
+ // "currencyCode": 3,
199458
+ // "email": "abc@gmail.com",
199459
+ // "expiredTime": "0",
199460
+ // "feeRv": "1",
199461
+ // "nickName": null,
199462
+ // "phone": null,
199463
+ // "rejectReason": "",
199464
+ // "submitedAt": "1670000000000",
199465
+ // "submittedAt": "1670000000000",
199466
+ // "txHash": null,
199467
+ // "userId": "10000001",
199468
+ // "status": "Success"
199469
+ // }
199470
+ // }
199471
+ //
199472
+ const data = this.safeValue(response, 'data', {});
199473
+ return this.parseTransaction(data, currency);
198901
199474
  }
198902
199475
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
198903
199476
  if (response === undefined) {
@@ -207700,10 +208273,12 @@ class binanceusdm extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
207700
208273
  /* harmony import */ var _bingx_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7960);
207701
208274
  /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
207702
208275
  /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3020);
208276
+ /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2194);
207703
208277
  // ---------------------------------------------------------------------------
207704
208278
 
207705
208279
 
207706
208280
 
208281
+
207707
208282
  // ---------------------------------------------------------------------------
207708
208283
  class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
207709
208284
  describe() {
@@ -207759,6 +208334,10 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
207759
208334
  '1d': '1day',
207760
208335
  },
207761
208336
  },
208337
+ 'watchBalance': {
208338
+ 'fetchBalanceSnapshot': true,
208339
+ 'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
208340
+ },
207762
208341
  },
207763
208342
  'streaming': {
207764
208343
  'keepAlive': 1800000, // 30 minutes
@@ -208246,8 +208825,41 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208246
208825
  'dataType': 'ACCOUNT_UPDATE',
208247
208826
  };
208248
208827
  }
208828
+ const client = this.client(url);
208829
+ this.setBalanceCache(client, type, subscriptionHash, params);
208830
+ let fetchBalanceSnapshot = undefined;
208831
+ let awaitBalanceSnapshot = undefined;
208832
+ [fetchBalanceSnapshot, params] = this.handleOptionAndParams(params, 'watchBalance', 'fetchBalanceSnapshot', true);
208833
+ [awaitBalanceSnapshot, params] = this.handleOptionAndParams(params, 'watchBalance', 'awaitBalanceSnapshot', false);
208834
+ if (fetchBalanceSnapshot && awaitBalanceSnapshot) {
208835
+ await client.future(type + ':fetchBalanceSnapshot');
208836
+ }
208249
208837
  return await this.watch(url, messageHash, request, subscriptionHash);
208250
208838
  }
208839
+ setBalanceCache(client, type, subscriptionHash, params) {
208840
+ if (subscriptionHash in client.subscriptions) {
208841
+ return undefined;
208842
+ }
208843
+ const fetchBalanceSnapshot = this.handleOptionAndParams(params, 'watchBalance', 'fetchBalanceSnapshot', true);
208844
+ if (fetchBalanceSnapshot) {
208845
+ const messageHash = type + ':fetchBalanceSnapshot';
208846
+ if (!(messageHash in client.futures)) {
208847
+ client.future(messageHash);
208848
+ this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
208849
+ }
208850
+ }
208851
+ else {
208852
+ this.balance[type] = {};
208853
+ }
208854
+ }
208855
+ async loadBalanceSnapshot(client, messageHash, type) {
208856
+ const response = await this.fetchBalance({ 'type': type });
208857
+ this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
208858
+ // don't remove the future from the .futures cache
208859
+ const future = client.futures[messageHash];
208860
+ future.resolve();
208861
+ client.resolve(this.balance[type], type + ':balance');
208862
+ }
208251
208863
  handleErrorMessage(client, message) {
208252
208864
  //
208253
208865
  // { code: 100400, msg: '', timestamp: 1696245808833 }
@@ -208530,9 +209142,6 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208530
209142
  const data = this.safeValue(a, 'B', []);
208531
209143
  const timestamp = this.safeInteger2(message, 'T', 'E');
208532
209144
  const type = ('P' in a) ? 'swap' : 'spot';
208533
- if (!(type in this.balance)) {
208534
- this.balance[type] = {};
208535
- }
208536
209145
  this.balance[type]['info'] = data;
208537
209146
  this.balance[type]['timestamp'] = timestamp;
208538
209147
  this.balance[type]['datetime'] = this.iso8601(timestamp);
@@ -208540,8 +209149,12 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208540
209149
  const balance = data[i];
208541
209150
  const currencyId = this.safeString(balance, 'a');
208542
209151
  const code = this.safeCurrencyCode(currencyId);
208543
- const account = (code in this.balance) ? this.balance[code] : this.account();
208544
- account['total'] = this.safeString(balance, 'wb');
209152
+ const account = (code in this.balance[type]) ? this.balance[type][code] : this.account();
209153
+ account['free'] = this.safeString(balance, 'wb');
209154
+ const balanceChange = this.safeString(balance, 'bc');
209155
+ if (account['used'] !== undefined) {
209156
+ account['used'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.stringSub(this.safeString(account, 'used'), balanceChange);
209157
+ }
208545
209158
  this.balance[type][code] = account;
208546
209159
  }
208547
209160
  this.balance[type] = this.safeBalance(this.balance[type]);
@@ -212283,7 +212896,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212283
212896
  'defaultType': 'spot',
212284
212897
  'watchBalance': {
212285
212898
  'fetchBalanceSnapshot': true,
212286
- 'awaitBalanceSnapshot': true, // whether to wait for the balance snapshot before providing updates
212899
+ 'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
212287
212900
  },
212288
212901
  'watchOrderBook': {
212289
212902
  'depth': 'depth50', // depth5, depth20, depth50
@@ -212363,30 +212976,31 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212363
212976
  const messageHash = 'balance:' + type;
212364
212977
  const url = this.implodeHostname(this.urls['api']['ws'][type]['private']);
212365
212978
  const client = this.client(url);
212366
- this.setBalanceCache(client, type);
212367
- const fetchBalanceSnapshot = this.handleOptionAndParams(this.options, 'watchBalance', 'fetchBalanceSnapshot', true);
212368
- const awaitBalanceSnapshot = this.handleOptionAndParams(this.options, 'watchBalance', 'awaitBalanceSnapshot', false);
212979
+ this.setBalanceCache(client, type, messageHash);
212980
+ let fetchBalanceSnapshot = undefined;
212981
+ let awaitBalanceSnapshot = undefined;
212982
+ [fetchBalanceSnapshot, params] = this.handleOptionAndParams(this.options, 'watchBalance', 'fetchBalanceSnapshot', true);
212983
+ [awaitBalanceSnapshot, params] = this.handleOptionAndParams(this.options, 'watchBalance', 'awaitBalanceSnapshot', false);
212369
212984
  if (fetchBalanceSnapshot && awaitBalanceSnapshot) {
212370
212985
  await client.future(type + ':fetchBalanceSnapshot');
212371
212986
  }
212372
212987
  return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
212373
212988
  }
212374
- setBalanceCache(client, type) {
212375
- if (type in client.subscriptions) {
212376
- return undefined;
212989
+ setBalanceCache(client, type, subscribeHash) {
212990
+ if (subscribeHash in client.subscriptions) {
212991
+ return;
212377
212992
  }
212378
212993
  const options = this.safeValue(this.options, 'watchBalance');
212379
- const fetchBalanceSnapshot = this.handleOptionAndParams(options, 'watchBalance', 'fetchBalanceSnapshot', true);
212380
- if (fetchBalanceSnapshot) {
212381
- const messageHash = type + ':fetchBalanceSnapshot';
212994
+ const snapshot = this.safeValue(options, 'fetchBalanceSnapshot', true);
212995
+ if (snapshot) {
212996
+ const messageHash = type + ':' + 'fetchBalanceSnapshot';
212382
212997
  if (!(messageHash in client.futures)) {
212383
212998
  client.future(messageHash);
212384
212999
  this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
212385
213000
  }
212386
213001
  }
212387
- else {
212388
- this.balance[type] = {};
212389
- }
213002
+ this.balance[type] = {};
213003
+ // without this comment, transpilation breaks for some reason...
212390
213004
  }
212391
213005
  async loadBalanceSnapshot(client, messageHash, type) {
212392
213006
  const response = await this.fetchBalance({ 'type': type });
@@ -212433,15 +213047,15 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212433
213047
  }
212434
213048
  const isSpot = (channel.indexOf('spot') >= 0);
212435
213049
  const type = isSpot ? 'spot' : 'swap';
212436
- this.balance['info'] = message;
213050
+ this.balance[type]['info'] = message;
212437
213051
  if (isSpot) {
212438
213052
  if (!Array.isArray(data)) {
212439
213053
  return;
212440
213054
  }
212441
213055
  for (let i = 0; i < data.length; i++) {
212442
213056
  const timestamp = this.safeInteger(message, 'event_time');
212443
- this.balance['timestamp'] = timestamp;
212444
- this.balance['datetime'] = this.iso8601(timestamp);
213057
+ this.balance[type]['timestamp'] = timestamp;
213058
+ this.balance[type]['datetime'] = this.iso8601(timestamp);
212445
213059
  const balanceDetails = this.safeValue(data[i], 'balance_details', []);
212446
213060
  for (let ii = 0; ii < balanceDetails.length; ii++) {
212447
213061
  const rawBalance = balanceDetails[i];
@@ -212449,8 +213063,8 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212449
213063
  const currencyId = this.safeString(rawBalance, 'ccy');
212450
213064
  const code = this.safeCurrencyCode(currencyId);
212451
213065
  account['free'] = this.safeString(rawBalance, 'av_bal');
212452
- account['total'] = this.safeString(rawBalance, 'fz_bal');
212453
- this.balance[code] = account;
213066
+ account['used'] = this.safeString(rawBalance, 'fz_bal');
213067
+ this.balance[type][code] = account;
212454
213068
  }
212455
213069
  }
212456
213070
  }
@@ -279932,15 +280546,14 @@ class zaif extends _abstract_zaif_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
279932
280546
  // }
279933
280547
  //
279934
280548
  const symbol = this.safeSymbol(undefined, market);
279935
- const timestamp = this.milliseconds();
279936
280549
  const vwap = this.safeString(ticker, 'vwap');
279937
280550
  const baseVolume = this.safeString(ticker, 'volume');
279938
280551
  const quoteVolume = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(baseVolume, vwap);
279939
280552
  const last = this.safeString(ticker, 'last');
279940
280553
  return this.safeTicker({
279941
280554
  'symbol': symbol,
279942
- 'timestamp': timestamp,
279943
- 'datetime': this.iso8601(timestamp),
280555
+ 'timestamp': undefined,
280556
+ 'datetime': undefined,
279944
280557
  'high': this.safeString(ticker, 'high'),
279945
280558
  'low': this.safeString(ticker, 'low'),
279946
280559
  'bid': this.safeString(ticker, 'bid'),
@@ -287814,7 +288427,7 @@ SOFTWARE.
287814
288427
 
287815
288428
  //-----------------------------------------------------------------------------
287816
288429
  // this is updated by vss.js when building
287817
- const version = '4.1.90';
288430
+ const version = '4.1.94';
287818
288431
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
287819
288432
  //-----------------------------------------------------------------------------
287820
288433