ccxt 4.2.64 → 4.2.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9731,6 +9731,18 @@ class Exchange {
9731
9731
  return this.filterBySymbolSinceLimit(results, symbol, since, limit);
9732
9732
  }
9733
9733
  calculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) {
9734
+ /**
9735
+ * @method
9736
+ * @description calculates the presumptive fee that would be charged for an order
9737
+ * @param {string} symbol unified market symbol
9738
+ * @param {string} type 'market' or 'limit'
9739
+ * @param {string} side 'buy' or 'sell'
9740
+ * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts
9741
+ * @param {float} price the price for the order to be filled at, in units of the quote currency
9742
+ * @param {string} takerOrMaker 'taker' or 'maker'
9743
+ * @param {object} params
9744
+ * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
9745
+ */
9734
9746
  if (type === 'market' && takerOrMaker === 'maker') {
9735
9747
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' calculateFee() - you have provided incompatible arguments - "market" type order can not be "maker". Change either the "type" or the "takerOrMaker" argument to calculate the fee.');
9736
9748
  }
@@ -20700,6 +20712,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20700
20712
  * @see https://binance-docs.github.io/apidocs/futures/en/#check-server-time // swap
20701
20713
  * @see https://binance-docs.github.io/apidocs/delivery/en/#check-server-time // future
20702
20714
  * @param {object} [params] extra parameters specific to the exchange API endpoint
20715
+ * @param {string} [params.subType] "linear" or "inverse"
20703
20716
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
20704
20717
  */
20705
20718
  const defaultType = this.safeString2(this.options, 'fetchTime', 'defaultType', 'spot');
@@ -21495,6 +21508,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21495
21508
  * @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
21496
21509
  * @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
21497
21510
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
21511
+ * @param {string} [params.subType] "linear" or "inverse"
21498
21512
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
21499
21513
  */
21500
21514
  await this.loadMarkets();
@@ -22073,6 +22087,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22073
22087
  * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker // future
22074
22088
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
22075
22089
  * @param {object} [params] extra parameters specific to the exchange API endpoint
22090
+ * @param {string} [params.subType] "linear" or "inverse"
22076
22091
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
22077
22092
  */
22078
22093
  await this.loadMarkets();
@@ -22113,6 +22128,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22113
22128
  * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker // future
22114
22129
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
22115
22130
  * @param {object} [params] extra parameters specific to the exchange API endpoint
22131
+ * @param {string} [params.subType] "linear" or "inverse"
22116
22132
  * @returns {object} a dictionary of lastprices structures
22117
22133
  */
22118
22134
  await this.loadMarkets();
@@ -22218,6 +22234,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22218
22234
  * @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics // option
22219
22235
  * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
22220
22236
  * @param {object} [params] extra parameters specific to the exchange API endpoint
22237
+ * @param {string} [params.subType] "linear" or "inverse"
22221
22238
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
22222
22239
  */
22223
22240
  await this.loadMarkets();
@@ -24644,6 +24661,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24644
24661
  * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
24645
24662
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch open orders in the portfolio margin account
24646
24663
  * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account conditional orders
24664
+ * @param {string} [params.subType] "linear" or "inverse"
24647
24665
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
24648
24666
  */
24649
24667
  await this.loadMarkets();
@@ -26787,6 +26805,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26787
26805
  * @param {string} symbol unified market symbol
26788
26806
  * @param {object} [params] extra parameters specific to the exchange API endpoint
26789
26807
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
26808
+ * @param {string} [params.subType] "linear" or "inverse"
26790
26809
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
26791
26810
  */
26792
26811
  await this.loadMarkets();
@@ -26855,6 +26874,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
26855
26874
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
26856
26875
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
26857
26876
  * @param {object} [params] extra parameters specific to the exchange API endpoint
26877
+ * @param {string} [params.subType] "linear" or "inverse"
26858
26878
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
26859
26879
  */
26860
26880
  await this.loadMarkets();
@@ -27112,6 +27132,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27112
27132
  * @param {object} [params] extra parameters specific to the exchange API endpoint
27113
27133
  * @param {int} [params.until] timestamp in ms of the latest funding rate
27114
27134
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
27135
+ * @param {string} [params.subType] "linear" or "inverse"
27115
27136
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
27116
27137
  */
27117
27138
  await this.loadMarkets();
@@ -27185,6 +27206,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27185
27206
  * @see https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
27186
27207
  * @param {string[]|undefined} symbols list of unified market symbols
27187
27208
  * @param {object} [params] extra parameters specific to the exchange API endpoint
27209
+ * @param {string} [params.subType] "linear" or "inverse"
27188
27210
  * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
27189
27211
  */
27190
27212
  await this.loadMarkets();
@@ -27808,6 +27830,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
27808
27830
  * @param {string[]|undefined} symbols list of unified market symbols
27809
27831
  * @param {object} [params] extra parameters specific to the exchange API endpoint
27810
27832
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the leverage tiers for a portfolio margin account
27833
+ * @param {string} [params.subType] "linear" or "inverse"
27811
27834
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
27812
27835
  */
27813
27836
  await this.loadMarkets();
@@ -28122,6 +28145,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28122
28145
  * @param {string[]|undefined} symbols list of unified market symbols
28123
28146
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28124
28147
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
28148
+ * @param {string} [params.subType] "linear" or "inverse"
28125
28149
  * @returns {object} data on account positions
28126
28150
  */
28127
28151
  if (symbols !== undefined) {
@@ -28175,6 +28199,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28175
28199
  * @param {string[]|undefined} symbols list of unified market symbols
28176
28200
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28177
28201
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
28202
+ * @param {string} [params.subType] "linear" or "inverse"
28178
28203
  * @returns {object} data on the positions risk
28179
28204
  */
28180
28205
  if (symbols !== undefined) {
@@ -28334,6 +28359,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28334
28359
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28335
28360
  * @param {int} [params.until] timestamp in ms of the latest funding history entry
28336
28361
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the funding history for a portfolio margin account
28362
+ * @param {string} [params.subType] "linear" or "inverse"
28337
28363
  * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
28338
28364
  */
28339
28365
  await this.loadMarkets();
@@ -28518,6 +28544,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28518
28544
  * @param {string} symbol not used by binance setPositionMode ()
28519
28545
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28520
28546
  * @param {boolean} [params.portfolioMargin] set to true if you would like to set the position mode for a portfolio margin account
28547
+ * @param {string} [params.subType] "linear" or "inverse"
28521
28548
  * @returns {object} response from the exchange
28522
28549
  */
28523
28550
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
@@ -28546,7 +28573,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28546
28573
  response = await this.dapiPrivatePostPositionSideDual(this.extend(request, params));
28547
28574
  }
28548
28575
  }
28549
- else {
28576
+ else if (this.isLinear(type, subType)) {
28550
28577
  if (isPortfolioMargin) {
28551
28578
  response = await this.papiPostUmPositionSideDual(this.extend(request, params));
28552
28579
  }
@@ -28554,6 +28581,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28554
28581
  response = await this.fapiPrivatePostPositionSideDual(this.extend(request, params));
28555
28582
  }
28556
28583
  }
28584
+ else {
28585
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' setPositionMode() supports linear and inverse contracts only');
28586
+ }
28557
28587
  //
28558
28588
  // {
28559
28589
  // "code": 200,
@@ -28573,6 +28603,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28573
28603
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
28574
28604
  * @param {string[]} [symbols] a list of unified market symbols
28575
28605
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28606
+ * @param {string} [params.subType] "linear" or "inverse"
28576
28607
  * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
28577
28608
  */
28578
28609
  await this.loadMarkets();
@@ -28847,6 +28878,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28847
28878
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
28848
28879
  * @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)
28849
28880
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the ledger for a portfolio margin account
28881
+ * @param {string} [params.subType] "linear" or "inverse"
28850
28882
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
28851
28883
  */
28852
28884
  await this.loadMarkets();
@@ -29990,6 +30022,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
29990
30022
  * @param {int} [params.until] timestamp in ms of the latest liquidation
29991
30023
  * @param {boolean} [params.paginate] *spot only* 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)
29992
30024
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
30025
+ * @param {string} [params.type] "spot"
30026
+ * @param {string} [params.subType] "linear" or "inverse"
29993
30027
  * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
29994
30028
  */
29995
30029
  await this.loadMarkets();
@@ -30315,8 +30349,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
30315
30349
  * @name binance#fetchPositionMode
30316
30350
  * @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
30317
30351
  * @param {string} symbol unified symbol of the market to fetch the order book for
30318
- * @param {object} params extra parameters specific to the exchange API endpoint
30319
- * @param {string} params.subType "linear" or "inverse"
30352
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
30353
+ * @param {string} [params.subType] "linear" or "inverse"
30320
30354
  * @returns {object} an object detailing whether the market is in hedged or one-way mode
30321
30355
  */
30322
30356
  let market = undefined;
@@ -30354,6 +30388,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
30354
30388
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
30355
30389
  * @param {string} symbol unified symbol of the market the order was made in
30356
30390
  * @param {object} [params] extra parameters specific to the exchange API endpoint
30391
+ * @param {string} [params.subType] "linear" or "inverse"
30357
30392
  * @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
30358
30393
  */
30359
30394
  await this.loadMarkets();
@@ -32711,6 +32746,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
32711
32746
  const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
32712
32747
  const trailingAmount = this.safeString(params, 'trailingAmount');
32713
32748
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'priceRate');
32749
+ const trailingType = this.safeString(params, 'trailingType', 'TRAILING_STOP_MARKET');
32714
32750
  const isTriggerOrder = triggerPrice !== undefined;
32715
32751
  const isStopLossPriceOrder = stopLossPrice !== undefined;
32716
32752
  const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
@@ -32757,7 +32793,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
32757
32793
  }
32758
32794
  }
32759
32795
  else if (isTrailing) {
32760
- request['type'] = 'TRAILING_STOP_MARKET';
32796
+ request['type'] = trailingType;
32761
32797
  if (isTrailingAmountOrder) {
32762
32798
  request['price'] = this.parseToNumeric(trailingAmount);
32763
32799
  }
@@ -32812,7 +32848,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
32812
32848
  }
32813
32849
  request['positionSide'] = positionSide;
32814
32850
  request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
32815
- params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss', 'clientOrderId']);
32851
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
32816
32852
  }
32817
32853
  return this.extend(request, params);
32818
32854
  }
@@ -32843,14 +32879,22 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
32843
32879
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
32844
32880
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
32845
32881
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
32882
+ * @param {boolean} [params.test] *swap only* whether to use the test endpoint or not, default is false
32846
32883
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
32847
32884
  */
32848
32885
  await this.loadMarkets();
32849
32886
  const market = this.market(symbol);
32887
+ const test = this.safeBool(params, 'test', false);
32888
+ params = this.omit(params, 'test');
32850
32889
  const request = this.createOrderRequest(symbol, type, side, amount, price, params);
32851
32890
  let response = undefined;
32852
32891
  if (market['swap']) {
32853
- response = await this.swapV2PrivatePostTradeOrder(request);
32892
+ if (test) {
32893
+ response = await this.swapV2PrivatePostTradeOrderTest(request);
32894
+ }
32895
+ else {
32896
+ response = await this.swapV2PrivatePostTradeOrder(request);
32897
+ }
32854
32898
  }
32855
32899
  else {
32856
32900
  response = await this.spotV1PrivatePostTradeOrder(request);
@@ -34904,7 +34948,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34904
34948
  * @param {string} [params.newClientOrderId] custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
34905
34949
  * @param {string} [params.positionSide] *contract only* position direction, required for single position as BOTH, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
34906
34950
  * @param {string} [params.reduceOnly] *contract only* true or false, default=false for single position mode. this parameter is not accepted for both long and short positions mode
34907
- * @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market, Max = 1
34951
+ * @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market or TRAILING_TP_SL, Max = 1
34908
34952
  * @param {string} [params.workingType] *contract only* StopPrice trigger price types, MARK_PRICE (default), CONTRACT_PRICE, or INDEX_PRICE
34909
34953
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
34910
34954
  */
@@ -61499,7 +61543,9 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
61499
61543
  if (until !== undefined) {
61500
61544
  request['endTime'] = this.iso8601(until);
61501
61545
  }
61502
- request['reverse'] = true;
61546
+ if ((since === undefined) && (until === undefined)) {
61547
+ request['reverse'] = true;
61548
+ }
61503
61549
  const response = await this.publicGetFunding(this.extend(request, params));
61504
61550
  //
61505
61551
  // [
@@ -77104,6 +77150,8 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
77104
77150
  'fetchLeverage': true,
77105
77151
  'fetchLeverages': true,
77106
77152
  'fetchLeverageTiers': false,
77153
+ 'fetchMarginMode': true,
77154
+ 'fetchMarginModes': false,
77107
77155
  'fetchMarketLeverageTiers': false,
77108
77156
  'fetchMarkets': true,
77109
77157
  'fetchMarkOHLCV': false,
@@ -77207,6 +77255,7 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
77207
77255
  'account/balance': 1,
77208
77256
  'account/positions': 1,
77209
77257
  'account/leverage-info': 1,
77258
+ 'account/margin-mode': 1,
77210
77259
  'account/batch-leverage-info': 1,
77211
77260
  'trade/orders-tpsl-pending': 1,
77212
77261
  'trade/orders-history': 1,
@@ -79127,6 +79176,38 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
79127
79176
  const data = this.safeList(response, 'data', []);
79128
79177
  return this.parseOrders(data, market, since, limit);
79129
79178
  }
79179
+ async fetchMarginMode(symbol, params = {}) {
79180
+ /**
79181
+ * @method
79182
+ * @name blofin#fetchMarginMode
79183
+ * @description fetches the margin mode of a trading pair
79184
+ * @see https://docs.blofin.com/index.html#get-margin-mode
79185
+ * @param {string} symbol unified symbol of the market to fetch the margin mode for
79186
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
79187
+ * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
79188
+ */
79189
+ await this.loadMarkets();
79190
+ const market = this.market(symbol);
79191
+ const response = await this.privateGetAccountMarginMode(params);
79192
+ //
79193
+ // {
79194
+ // "code": "0",
79195
+ // "msg": "success",
79196
+ // "data": {
79197
+ // "marginMode": "cross"
79198
+ // }
79199
+ // }
79200
+ //
79201
+ const data = this.safeDict(response, 'data', {});
79202
+ return this.parseMarginMode(data, market);
79203
+ }
79204
+ parseMarginMode(marginMode, market = undefined) {
79205
+ return {
79206
+ 'info': marginMode,
79207
+ 'symbol': market['symbol'],
79208
+ 'marginMode': this.safeString(marginMode, 'marginMode'),
79209
+ };
79210
+ }
79130
79211
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
79131
79212
  if (response === undefined) {
79132
79213
  return undefined; // fallback to default error handler
@@ -81667,6 +81748,18 @@ class btcmarkets extends _abstract_btcmarkets_js__WEBPACK_IMPORTED_MODULE_0__/*
81667
81748
  return await this.privateDeleteOrdersId(this.extend(request, params));
81668
81749
  }
81669
81750
  calculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) {
81751
+ /**
81752
+ * @method
81753
+ * @description calculates the presumptive fee that would be charged for an order
81754
+ * @param {string} symbol unified market symbol
81755
+ * @param {string} type not used by btcmarkets.calculateFee
81756
+ * @param {string} side not used by btcmarkets.calculateFee
81757
+ * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts
81758
+ * @param {float} price the price for the order to be filled at, in units of the quote currency
81759
+ * @param {string} takerOrMaker 'taker' or 'maker'
81760
+ * @param {object} params
81761
+ * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
81762
+ */
81670
81763
  const market = this.markets[symbol];
81671
81764
  let currency = undefined;
81672
81765
  let cost = undefined;
@@ -96575,7 +96668,8 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96575
96668
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
96576
96669
  const version = api[0];
96577
96670
  const signed = api[1] === 'private';
96578
- const pathPart = (version === 'v3') ? 'api/v3' : 'v2';
96671
+ const isV3 = version === 'v3';
96672
+ const pathPart = (isV3) ? 'api/v3' : 'v2';
96579
96673
  let fullPath = '/' + pathPart + '/' + this.implodeParams(path, params);
96580
96674
  const query = this.omit(params, this.extractParams(path));
96581
96675
  const savedPath = fullPath;
@@ -96619,8 +96713,17 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96619
96713
  payload = body;
96620
96714
  }
96621
96715
  }
96622
- // 'GET' doesn't need payload in the signature. inside url is enough
96716
+ else {
96717
+ if (!isV3) {
96718
+ if (Object.keys(query).length) {
96719
+ payload += '?' + this.urlencode(query);
96720
+ }
96721
+ }
96722
+ }
96723
+ // v3: 'GET' doesn't need payload in the signature. inside url is enough
96623
96724
  // https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#example-request
96725
+ // v2: 'GET' require payload in the signature
96726
+ // https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-key-authentication
96624
96727
  const auth = timestampString + method + savedPath + payload;
96625
96728
  const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J);
96626
96729
  headers = {
@@ -119217,7 +119320,8 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
119217
119320
  'fetchLedger': true,
119218
119321
  'fetchLeverage': true,
119219
119322
  'fetchLeverageTiers': false,
119220
- 'fetchMarginMode': false,
119323
+ 'fetchMarginMode': true,
119324
+ 'fetchMarginModes': false,
119221
119325
  'fetchMarketLeverageTiers': false,
119222
119326
  'fetchMarkets': true,
119223
119327
  'fetchMarkOHLCV': true,
@@ -122367,6 +122471,99 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
122367
122471
  const position = this.parsePosition(this.safeValue(response, 'result', {}));
122368
122472
  return [position];
122369
122473
  }
122474
+ async fetchMarginMode(symbol, params = {}) {
122475
+ /**
122476
+ * @method
122477
+ * @name delta#fetchMarginMode
122478
+ * @description fetches the margin mode of a trading pair
122479
+ * @see https://docs.delta.exchange/#get-user
122480
+ * @param {string} symbol unified symbol of the market to fetch the margin mode for
122481
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
122482
+ * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
122483
+ */
122484
+ await this.loadMarkets();
122485
+ let market = undefined;
122486
+ if (symbol !== undefined) {
122487
+ market = this.market(symbol);
122488
+ }
122489
+ const response = await this.privateGetProfile(params);
122490
+ //
122491
+ // {
122492
+ // "result": {
122493
+ // "is_password_set": true,
122494
+ // "kyc_expiry_date": null,
122495
+ // "phishing_code": "12345",
122496
+ // "preferences": {
122497
+ // "favorites": []
122498
+ // },
122499
+ // "is_kyc_provisioned": false,
122500
+ // "country": "Canada",
122501
+ // "margin_mode": "isolated",
122502
+ // "mfa_updated_at": "2023-07-19T01:04:43Z",
122503
+ // "last_name": "",
122504
+ // "oauth_apple_active": false,
122505
+ // "pf_index_symbol": null,
122506
+ // "proof_of_identity_status": "approved",
122507
+ // "dob": null,
122508
+ // "email": "abc_123@gmail.com",
122509
+ // "force_change_password": false,
122510
+ // "nick_name": "still-breeze-123",
122511
+ // "oauth_google_active": false,
122512
+ // "phone_verification_status": "verified",
122513
+ // "id": 12345678,
122514
+ // "last_seen": null,
122515
+ // "is_withdrawal_enabled": true,
122516
+ // "force_change_mfa": false,
122517
+ // "enable_bots": false,
122518
+ // "kyc_verified_on": null,
122519
+ // "created_at": "2023-07-19T01:02:32Z",
122520
+ // "withdrawal_blocked_till": null,
122521
+ // "proof_of_address_status": "approved",
122522
+ // "is_password_change_blocked": false,
122523
+ // "is_mfa_enabled": true,
122524
+ // "is_kyc_done": true,
122525
+ // "oauth": null,
122526
+ // "account_name": "Main",
122527
+ // "sub_account_permissions": null,
122528
+ // "phone_number": null,
122529
+ // "tracking_info": {
122530
+ // "ga_cid": "1234.4321",
122531
+ // "is_kyc_gtm_tracked": true,
122532
+ // "sub_account_config": {
122533
+ // "cross": 2,
122534
+ // "isolated": 2,
122535
+ // "portfolio": 2
122536
+ // }
122537
+ // },
122538
+ // "first_name": "",
122539
+ // "phone_verified_on": null,
122540
+ // "seen_intro": false,
122541
+ // "password_updated_at": null,
122542
+ // "is_login_enabled": true,
122543
+ // "registration_date": "2023-07-19T01:02:32Z",
122544
+ // "permissions": {},
122545
+ // "max_sub_accounts_limit": 2,
122546
+ // "country_calling_code": null,
122547
+ // "is_sub_account": false,
122548
+ // "is_kyc_refresh_required": false
122549
+ // },
122550
+ // "success": true
122551
+ // }
122552
+ //
122553
+ const result = this.safeDict(response, 'result', {});
122554
+ return this.parseMarginMode(result, market);
122555
+ }
122556
+ parseMarginMode(marginMode, market = undefined) {
122557
+ let symbol = undefined;
122558
+ if (market !== undefined) {
122559
+ symbol = market['symbol'];
122560
+ }
122561
+ return {
122562
+ 'info': marginMode,
122563
+ 'symbol': symbol,
122564
+ 'marginMode': this.safeString(marginMode, 'margin_mode'),
122565
+ };
122566
+ }
122370
122567
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
122371
122568
  const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
122372
122569
  let url = this.urls['api'][api] + requestPath;
@@ -170407,6 +170604,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
170407
170604
  'futuresPrivate': 'https://api-futures.kucoin.com',
170408
170605
  'futuresPublic': 'https://api-futures.kucoin.com',
170409
170606
  'webExchange': 'https://kucoin.com/_api',
170607
+ 'broker': 'https://api-broker.kucoin.com',
170410
170608
  },
170411
170609
  'www': 'https://www.kucoin.com',
170412
170610
  'doc': [
@@ -170520,6 +170718,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
170520
170718
  'project/marketInterestRate': 7.5,
170521
170719
  'redeem/orders': 10,
170522
170720
  'purchase/orders': 10,
170721
+ // broker
170523
170722
  'broker/api/rebase/download': 3,
170524
170723
  },
170525
170724
  'post': {
@@ -170666,6 +170865,23 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
170666
170865
  'currency/currency/chain-info': 1, // this is temporary from webApi
170667
170866
  },
170668
170867
  },
170868
+ 'broker': {
170869
+ 'get': {
170870
+ 'broker/nd/info': 2,
170871
+ 'broker/nd/account': 2,
170872
+ 'broker/nd/account/apikey': 2,
170873
+ 'broker/nd/rebase/download': 3,
170874
+ },
170875
+ 'post': {
170876
+ 'broker/nd/transfer': 1,
170877
+ 'broker/nd/account': 3,
170878
+ 'broker/nd/account/apikey': 3,
170879
+ 'broker/nd/account/update-apikey': 3,
170880
+ },
170881
+ 'delete': {
170882
+ 'broker/nd/account/apikey': 3,
170883
+ },
170884
+ },
170669
170885
  },
170670
170886
  'timeframes': {
170671
170887
  '1m': '1min',
@@ -171183,7 +171399,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171183
171399
  // }
171184
171400
  // }
171185
171401
  //
171186
- const data = this.safeValue(response, 'data', {});
171402
+ const data = this.safeDict(response, 'data', {});
171187
171403
  const status = this.safeString(data, 'status');
171188
171404
  return {
171189
171405
  'status': (status === 'open') ? 'ok' : 'maintenance',
@@ -171229,8 +171445,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171229
171445
  // ]
171230
171446
  // }
171231
171447
  //
171232
- const data = this.safeValue(response, 'data');
171233
- const options = this.safeValue(this.options, 'fetchMarkets', {});
171448
+ const data = this.safeList(response, 'data');
171449
+ const options = this.safeDict(this.options, 'fetchMarkets', {});
171234
171450
  const fetchTickersFees = this.safeBool(options, 'fetchTickersFees', true);
171235
171451
  let tickersResponse = {};
171236
171452
  if (fetchTickersFees) {
@@ -171264,8 +171480,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171264
171480
  // }
171265
171481
  // }
171266
171482
  //
171267
- const tickersData = this.safeValue(tickersResponse, 'data', {});
171268
- const tickers = this.safeValue(tickersData, 'ticker', []);
171483
+ const tickersData = this.safeDict(tickersResponse, 'data', {});
171484
+ const tickers = this.safeList(tickersData, 'ticker', []);
171269
171485
  const tickersByMarketId = this.indexBy(tickers, 'symbol');
171270
171486
  const result = [];
171271
171487
  for (let i = 0; i < data.length; i++) {
@@ -171275,7 +171491,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171275
171491
  const base = this.safeCurrencyCode(baseId);
171276
171492
  const quote = this.safeCurrencyCode(quoteId);
171277
171493
  // const quoteIncrement = this.safeNumber (market, 'quoteIncrement');
171278
- const ticker = this.safeValue(tickersByMarketId, id, {});
171494
+ const ticker = this.safeDict(tickersByMarketId, id, {});
171279
171495
  const makerFeeRate = this.safeString(ticker, 'makerFeeRate');
171280
171496
  const takerFeeRate = this.safeString(ticker, 'takerFeeRate');
171281
171497
  const makerCoefficient = this.safeString(ticker, 'makerCoefficient');
@@ -171291,11 +171507,11 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171291
171507
  'settleId': undefined,
171292
171508
  'type': 'spot',
171293
171509
  'spot': true,
171294
- 'margin': this.safeValue(market, 'isMarginEnabled'),
171510
+ 'margin': this.safeBool(market, 'isMarginEnabled'),
171295
171511
  'swap': false,
171296
171512
  'future': false,
171297
171513
  'option': false,
171298
- 'active': this.safeValue(market, 'enableTrading'),
171514
+ 'active': this.safeBool(market, 'enableTrading'),
171299
171515
  'contract': false,
171300
171516
  'linear': undefined,
171301
171517
  'inverse': undefined,
@@ -171425,7 +171641,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171425
171641
  let isWithdrawEnabled = undefined;
171426
171642
  let isDepositEnabled = undefined;
171427
171643
  const networks = {};
171428
- const chains = this.safeValue(entry, 'chains', []);
171644
+ const chains = this.safeList(entry, 'chains', []);
171429
171645
  const extraChainsData = this.indexBy(this.safeValue(additionalDataGrouped, id, []), 'chain');
171430
171646
  const rawPrecision = this.safeString(entry, 'precision');
171431
171647
  const precision = this.parseNumber(this.parsePrecision(rawPrecision));
@@ -171453,7 +171669,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171453
171669
  else {
171454
171670
  isDepositEnabled = isDepositEnabled || chainDepositEnabled;
171455
171671
  }
171456
- const chainExtraData = this.safeValue(extraChainsData, chainId, {});
171672
+ const chainExtraData = this.safeDict(extraChainsData, chainId, {});
171457
171673
  networks[networkCode] = {
171458
171674
  'info': chain,
171459
171675
  'id': chainId,
@@ -171528,7 +171744,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171528
171744
  // ]
171529
171745
  // }
171530
171746
  //
171531
- const data = this.safeValue(response, 'data', []);
171747
+ const data = this.safeList(response, 'data', []);
171532
171748
  const result = [];
171533
171749
  for (let i = 0; i < data.length; i++) {
171534
171750
  const account = data[i];
@@ -171616,7 +171832,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171616
171832
  // }
171617
171833
  // }
171618
171834
  //
171619
- const data = this.safeValue(response, 'data');
171835
+ const data = this.safeDict(response, 'data');
171620
171836
  return this.parseDepositWithdrawFee(data, currency);
171621
171837
  }
171622
171838
  parseDepositWithdrawFee(fee, currency = undefined) {
@@ -171647,7 +171863,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171647
171863
  },
171648
171864
  'networks': {},
171649
171865
  };
171650
- const isWithdrawEnabled = this.safeValue(fee, 'isWithdrawEnabled');
171866
+ const isWithdrawEnabled = this.safeBool(fee, 'isWithdrawEnabled');
171651
171867
  if (isWithdrawEnabled) {
171652
171868
  result['withdraw']['fee'] = this.safeNumber2(fee, 'withdrawalMinFee', 'withdrawMinFee');
171653
171869
  result['withdraw']['percentage'] = false;
@@ -171674,7 +171890,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171674
171890
  //
171675
171891
  const defaultType = this.safeString2(this.options, methodName, 'defaultType', 'trade');
171676
171892
  const requestedType = this.safeString(params, 'type', defaultType);
171677
- const accountsByType = this.safeValue(this.options, 'accountsByType');
171893
+ const accountsByType = this.safeDict(this.options, 'accountsByType');
171678
171894
  const type = this.safeString(accountsByType, requestedType);
171679
171895
  if (type === undefined) {
171680
171896
  const keys = Object.keys(accountsByType);
@@ -171815,8 +172031,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171815
172031
  // }
171816
172032
  // }
171817
172033
  //
171818
- const data = this.safeValue(response, 'data', {});
171819
- const tickers = this.safeValue(data, 'ticker', []);
172034
+ const data = this.safeDict(response, 'data', {});
172035
+ const tickers = this.safeList(data, 'ticker', []);
171820
172036
  const time = this.safeInteger(data, 'time');
171821
172037
  const result = {};
171822
172038
  for (let i = 0; i < tickers.length; i++) {
@@ -171946,7 +172162,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171946
172162
  // ]
171947
172163
  // }
171948
172164
  //
171949
- const data = this.safeValue(response, 'data', []);
172165
+ const data = this.safeList(response, 'data', []);
171950
172166
  return this.parseOHLCVs(data, market, timeframe, since, limit);
171951
172167
  }
171952
172168
  async createDepositAddress(code, params = {}) {
@@ -171974,7 +172190,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
171974
172190
  // {"code":"260000","msg":"Deposit address already exists."}
171975
172191
  // BCH {"code":"200000","data":{"address":"bitcoincash:qza3m4nj9rx7l9r0cdadfqxts6f92shvhvr5ls4q7z","memo":""}}
171976
172192
  // BTC {"code":"200000","data":{"address":"36SjucKqQpQSvsak9A7h6qzFjrVXpRNZhE","memo":""}}
171977
- const data = this.safeValue(response, 'data', {});
172193
+ const data = this.safeDict(response, 'data', {});
171978
172194
  return this.parseDepositAddress(data, currency);
171979
172195
  }
171980
172196
  async fetchDepositAddress(code, params = {}) {
@@ -172069,7 +172285,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172069
172285
  // }
172070
172286
  //
172071
172287
  this.options['versions']['private']['GET']['deposit-addresses'] = version;
172072
- const chains = this.safeValue(response, 'data', []);
172288
+ const chains = this.safeList(response, 'data', []);
172073
172289
  const parsed = this.parseDepositAddresses(chains, [currency['code']], false, {
172074
172290
  'currency': currency['id'],
172075
172291
  });
@@ -172142,7 +172358,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172142
172358
  // ]
172143
172359
  // }
172144
172360
  //
172145
- const data = this.safeValue(response, 'data', {});
172361
+ const data = this.safeDict(response, 'data', {});
172146
172362
  const timestamp = this.safeInteger(data, 'time');
172147
172363
  const orderbook = this.parseOrderBook(data, market['symbol'], timestamp, 'bids', 'asks', level - 2, level - 1);
172148
172364
  orderbook['nonce'] = this.safeInteger(data, 'sequence');
@@ -172244,7 +172460,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172244
172460
  // }
172245
172461
  // }
172246
172462
  //
172247
- const data = this.safeValue(response, 'data', {});
172463
+ const data = this.safeDict(response, 'data', {});
172248
172464
  return this.parseOrder(data, market);
172249
172465
  }
172250
172466
  async createMarketOrderWithCost(symbol, side, cost, params = {}) {
@@ -172372,8 +172588,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172372
172588
  // },
172373
172589
  // }
172374
172590
  //
172375
- let data = this.safeValue(response, 'data', {});
172376
- data = this.safeValue(data, 'data', []);
172591
+ let data = this.safeDict(response, 'data', {});
172592
+ data = this.safeList(data, 'data', []);
172377
172593
  return this.parseOrders(data);
172378
172594
  }
172379
172595
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
@@ -172490,7 +172706,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172490
172706
  // }
172491
172707
  // }
172492
172708
  //
172493
- const data = this.safeValue(response, 'data', {});
172709
+ const data = this.safeDict(response, 'data', {});
172494
172710
  return this.parseOrder(data, market);
172495
172711
  }
172496
172712
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -172514,7 +172730,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172514
172730
  await this.loadMarkets();
172515
172731
  const request = {};
172516
172732
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
172517
- const stop = this.safeValue2(params, 'stop', 'trigger', false);
172733
+ const stop = this.safeBool2(params, 'stop', 'trigger', false);
172518
172734
  const hf = this.safeBool(params, 'hf', false);
172519
172735
  if (hf) {
172520
172736
  if (symbol === undefined) {
@@ -172714,7 +172930,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172714
172930
  // ]
172715
172931
  // }
172716
172932
  // }
172717
- const responseData = this.safeValue(response, 'data', {});
172933
+ const responseData = this.safeDict(response, 'data', {});
172718
172934
  const orders = this.safeValue(responseData, 'items', responseData);
172719
172935
  return this.parseOrders(orders, market, since, limit);
172720
172936
  }
@@ -172850,7 +173066,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172850
173066
  response = await this.privateGetOrdersOrderId(this.extend(request, params));
172851
173067
  }
172852
173068
  }
172853
- let responseData = this.safeValue(response, 'data', {});
173069
+ let responseData = this.safeDict(response, 'data', {});
172854
173070
  if (Array.isArray(responseData)) {
172855
173071
  responseData = this.safeValue(responseData, 0);
172856
173072
  }
@@ -172985,7 +173201,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
172985
173201
  const responseStop = this.safeString(order, 'stop');
172986
173202
  const stop = responseStop !== undefined;
172987
173203
  const stopTriggered = this.safeBool(order, 'stopTriggered', false);
172988
- const isActive = this.safeValue2(order, 'isActive', 'active');
173204
+ const isActive = this.safeBool2(order, 'isActive', 'active');
172989
173205
  const responseStatus = this.safeString(order, 'status');
172990
173206
  let status = undefined;
172991
173207
  if (isActive !== undefined) {
@@ -173018,7 +173234,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173018
173234
  'symbol': this.safeSymbol(marketId, market, '-'),
173019
173235
  'type': this.safeString(order, 'type'),
173020
173236
  'timeInForce': this.safeString(order, 'timeInForce'),
173021
- 'postOnly': this.safeValue(order, 'postOnly'),
173237
+ 'postOnly': this.safeBool(order, 'postOnly'),
173022
173238
  'side': this.safeString(order, 'side'),
173023
173239
  'amount': this.safeString(order, 'size'),
173024
173240
  'price': this.safeString(order, 'price'),
@@ -173158,13 +173374,13 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173158
173374
  // ]
173159
173375
  // }
173160
173376
  //
173161
- const data = this.safeValue(response, 'data', {});
173377
+ const data = this.safeDict(response, 'data', {});
173162
173378
  let trades = undefined;
173163
173379
  if (parseResponseData) {
173164
173380
  trades = data;
173165
173381
  }
173166
173382
  else {
173167
- trades = this.safeValue(data, 'items', []);
173383
+ trades = this.safeList(data, 'items', []);
173168
173384
  }
173169
173385
  return this.parseTrades(trades, market, since, limit);
173170
173386
  }
@@ -173207,7 +173423,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173207
173423
  // ]
173208
173424
  // }
173209
173425
  //
173210
- const trades = this.safeValue(response, 'data', []);
173426
+ const trades = this.safeList(response, 'data', []);
173211
173427
  return this.parseTrades(trades, market, since, limit);
173212
173428
  }
173213
173429
  parseTrade(trade, market = undefined) {
@@ -173369,8 +173585,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173369
173585
  // ]
173370
173586
  // }
173371
173587
  //
173372
- const data = this.safeValue(response, 'data', []);
173373
- const first = this.safeValue(data, 0);
173588
+ const data = this.safeList(response, 'data', []);
173589
+ const first = this.safeDict(data, 0);
173374
173590
  const marketId = this.safeString(first, 'symbol');
173375
173591
  return {
173376
173592
  'info': response,
@@ -173431,7 +173647,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173431
173647
  // }
173432
173648
  // }
173433
173649
  //
173434
- const data = this.safeValue(response, 'data', {});
173650
+ const data = this.safeDict(response, 'data', {});
173435
173651
  return this.parseTransaction(data, currency);
173436
173652
  }
173437
173653
  parseTransactionStatus(status) {
@@ -173531,7 +173747,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173531
173747
  updated = updated * 1000;
173532
173748
  }
173533
173749
  }
173534
- const internal = this.safeValue(transaction, 'isInner');
173750
+ const internal = this.safeBool(transaction, 'isInner');
173535
173751
  const tag = this.safeString(transaction, 'memo');
173536
173752
  return {
173537
173753
  'info': transaction,
@@ -173757,7 +173973,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173757
173973
  }
173758
173974
  const defaultType = this.safeString2(this.options, 'fetchBalance', 'defaultType', 'spot');
173759
173975
  const requestedType = this.safeString(params, 'type', defaultType);
173760
- const accountsByType = this.safeValue(this.options, 'accountsByType');
173976
+ const accountsByType = this.safeDict(this.options, 'accountsByType');
173761
173977
  let type = this.safeString(accountsByType, requestedType, requestedType);
173762
173978
  params = this.omit(params, 'type');
173763
173979
  const isHf = this.safeBool(params, 'hf', false);
@@ -173839,7 +174055,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173839
174055
  // }
173840
174056
  // }
173841
174057
  //
173842
- const data = this.safeValue(response, 'data', []);
174058
+ const data = this.safeList(response, 'data', []);
173843
174059
  const result = {
173844
174060
  'info': response,
173845
174061
  'timestamp': undefined,
@@ -173851,8 +174067,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173851
174067
  const entry = assets[i];
173852
174068
  const marketId = this.safeString(entry, 'symbol');
173853
174069
  const symbol = this.safeSymbol(marketId, undefined, '_');
173854
- const base = this.safeValue(entry, 'baseAsset', {});
173855
- const quote = this.safeValue(entry, 'quoteAsset', {});
174070
+ const base = this.safeDict(entry, 'baseAsset', {});
174071
+ const quote = this.safeDict(entry, 'quoteAsset', {});
173856
174072
  const baseCode = this.safeCurrencyCode(this.safeString(base, 'currency'));
173857
174073
  const quoteCode = this.safeCurrencyCode(this.safeString(quote, 'currency'));
173858
174074
  const subResult = {};
@@ -173862,7 +174078,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173862
174078
  }
173863
174079
  }
173864
174080
  else if (cross) {
173865
- const accounts = this.safeValue(data, 'accounts', []);
174081
+ const accounts = this.safeList(data, 'accounts', []);
173866
174082
  for (let i = 0; i < accounts.length; i++) {
173867
174083
  const balance = accounts[i];
173868
174084
  const currencyId = this.safeString(balance, 'currency');
@@ -173947,7 +174163,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173947
174163
  // }
173948
174164
  // }
173949
174165
  //
173950
- const data = this.safeValue(response, 'data');
174166
+ const data = this.safeDict(response, 'data');
173951
174167
  return this.parseTransfer(data, currency);
173952
174168
  }
173953
174169
  else {
@@ -173979,7 +174195,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
173979
174195
  // }
173980
174196
  // }
173981
174197
  //
173982
- const data = this.safeValue(response, 'data');
174198
+ const data = this.safeDict(response, 'data');
173983
174199
  return this.parseTransfer(data, currency);
173984
174200
  }
173985
174201
  }
@@ -174023,7 +174239,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174023
174239
  const rawStatus = this.safeString(transfer, 'status');
174024
174240
  const accountFromRaw = this.safeStringLower(transfer, 'payAccountType');
174025
174241
  const accountToRaw = this.safeStringLower(transfer, 'recAccountType');
174026
- const accountsByType = this.safeValue(this.options, 'accountsByType');
174242
+ const accountsByType = this.safeDict(this.options, 'accountsByType');
174027
174243
  const accountFrom = this.safeString(accountsByType, accountFromRaw, accountFromRaw);
174028
174244
  const accountTo = this.safeString(accountsByType, accountToRaw, accountToRaw);
174029
174245
  return {
@@ -174193,7 +174409,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174193
174409
  await this.loadAccounts();
174194
174410
  let paginate = false;
174195
174411
  [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
174196
- const isHf = this.safeValue(params, 'hf');
174412
+ const isHf = this.safeBool(params, 'hf');
174197
174413
  params = this.omit(params, 'hf');
174198
174414
  if (paginate) {
174199
174415
  return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params);
@@ -174275,9 +174491,9 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174275
174491
  return this.parseLedger(items, currency, since, limit);
174276
174492
  }
174277
174493
  calculateRateLimiterCost(api, method, path, params, config = {}) {
174278
- const versions = this.safeValue(this.options, 'versions', {});
174279
- const apiVersions = this.safeValue(versions, api, {});
174280
- const methodVersions = this.safeValue(apiVersions, method, {});
174494
+ const versions = this.safeDict(this.options, 'versions', {});
174495
+ const apiVersions = this.safeDict(versions, api, {});
174496
+ const methodVersions = this.safeDict(apiVersions, method, {});
174281
174497
  const defaultVersion = this.safeString(methodVersions, path, this.options['version']);
174282
174498
  const version = this.safeString(params, 'version', defaultVersion);
174283
174499
  if (version === 'v3' && ('v3' in config)) {
@@ -174421,8 +174637,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174421
174637
  // }
174422
174638
  // }
174423
174639
  //
174424
- const data = this.safeValue(response, 'data', {});
174425
- const assets = (marginMode === 'isolated') ? this.safeValue(data, 'assets', []) : this.safeValue(data, 'accounts', []);
174640
+ const data = this.safeDict(response, 'data', {});
174641
+ const assets = (marginMode === 'isolated') ? this.safeList(data, 'assets', []) : this.safeList(data, 'accounts', []);
174426
174642
  return this.parseBorrowInterests(assets, undefined);
174427
174643
  }
174428
174644
  parseBorrowInterest(info, market = undefined) {
@@ -174475,7 +174691,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174475
174691
  market = this.safeMarket(marketId, market);
174476
174692
  const symbol = this.safeString(market, 'symbol');
174477
174693
  const timestamp = this.safeInteger(info, 'createdAt');
174478
- const isolatedBase = this.safeValue(info, 'baseAsset', {});
174694
+ const isolatedBase = this.safeDict(info, 'baseAsset', {});
174479
174695
  let amountBorrowed = undefined;
174480
174696
  let interest = undefined;
174481
174697
  let currencyId = undefined;
@@ -174533,7 +174749,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174533
174749
  // }
174534
174750
  // }
174535
174751
  //
174536
- const data = this.safeValue(response, 'data', {});
174752
+ const data = this.safeDict(response, 'data', {});
174537
174753
  return this.parseMarginLoan(data, currency);
174538
174754
  }
174539
174755
  async borrowIsolatedMargin(symbol, code, amount, params = {}) {
@@ -174572,7 +174788,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174572
174788
  // }
174573
174789
  // }
174574
174790
  //
174575
- const data = this.safeValue(response, 'data', {});
174791
+ const data = this.safeDict(response, 'data', {});
174576
174792
  return this.parseMarginLoan(data, currency);
174577
174793
  }
174578
174794
  async repayCrossMargin(code, amount, params = {}) {
@@ -174605,7 +174821,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174605
174821
  // }
174606
174822
  // }
174607
174823
  //
174608
- const data = this.safeValue(response, 'data', {});
174824
+ const data = this.safeDict(response, 'data', {});
174609
174825
  return this.parseMarginLoan(data, currency);
174610
174826
  }
174611
174827
  async repayIsolatedMargin(symbol, code, amount, params = {}) {
@@ -174642,7 +174858,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174642
174858
  // }
174643
174859
  // }
174644
174860
  //
174645
- const data = this.safeValue(response, 'data', {});
174861
+ const data = this.safeDict(response, 'data', {});
174646
174862
  return this.parseMarginLoan(data, currency);
174647
174863
  }
174648
174864
  parseMarginLoan(info, currency = undefined) {
@@ -174694,7 +174910,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174694
174910
  // },
174695
174911
  // ]
174696
174912
  //
174697
- const data = this.safeValue(response, 'data', []);
174913
+ const data = this.safeList(response, 'data', []);
174698
174914
  return this.parseDepositWithdrawFees(data, codes, 'currency');
174699
174915
  }
174700
174916
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
@@ -174703,9 +174919,9 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174703
174919
  // ↑ ↑
174704
174920
  // ↑ ↑
174705
174921
  //
174706
- const versions = this.safeValue(this.options, 'versions', {});
174707
- const apiVersions = this.safeValue(versions, api, {});
174708
- const methodVersions = this.safeValue(apiVersions, method, {});
174922
+ const versions = this.safeDict(this.options, 'versions', {});
174923
+ const apiVersions = this.safeDict(versions, api, {});
174924
+ const methodVersions = this.safeDict(apiVersions, method, {});
174709
174925
  const defaultVersion = this.safeString(methodVersions, path, this.options['version']);
174710
174926
  const version = this.safeString(params, 'version', defaultVersion);
174711
174927
  params = this.omit(params, 'version');
@@ -174730,7 +174946,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174730
174946
  url = url + endpoint;
174731
174947
  const isFuturePrivate = (api === 'futuresPrivate');
174732
174948
  const isPrivate = (api === 'private');
174733
- if (isPrivate || isFuturePrivate) {
174949
+ const isBroker = (api === 'private');
174950
+ if (isPrivate || isFuturePrivate || isBroker) {
174734
174951
  this.checkRequiredCredentials();
174735
174952
  const timestamp = this.nonce().toString();
174736
174953
  headers = this.extend({
@@ -174749,7 +174966,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174749
174966
  const payload = timestamp + method + endpoint + endpart;
174750
174967
  const signature = this.hmac(this.encode(payload), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J, 'base64');
174751
174968
  headers['KC-API-SIGN'] = signature;
174752
- let partner = this.safeValue(this.options, 'partner', {});
174969
+ let partner = this.safeDict(this.options, 'partner', {});
174753
174970
  partner = isFuturePrivate ? this.safeValue(partner, 'future', partner) : this.safeValue(partner, 'spot', partner);
174754
174971
  const partnerId = this.safeString(partner, 'id');
174755
174972
  const partnerSecret = this.safeString2(partner, 'secret', 'key');
@@ -174759,6 +174976,10 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174759
174976
  headers['KC-API-PARTNER-SIGN'] = partnerSignature;
174760
174977
  headers['KC-API-PARTNER'] = partnerId;
174761
174978
  }
174979
+ if (isBroker) {
174980
+ const brokerName = this.safeString(partner, 'name');
174981
+ headers['KC-BROKER-NAME'] = brokerName;
174982
+ }
174762
174983
  }
174763
174984
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
174764
174985
  }
@@ -245798,7 +246019,7 @@ class currencycom extends _currencycom_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
245798
246019
  'fee': undefined,
245799
246020
  };
245800
246021
  }
245801
- handleTrades(client, message, subscription) {
246022
+ handleTrades(client, message) {
245802
246023
  //
245803
246024
  // {
245804
246025
  // "status": "OK",
@@ -316543,7 +316764,7 @@ SOFTWARE.
316543
316764
 
316544
316765
  //-----------------------------------------------------------------------------
316545
316766
  // this is updated by vss.js when building
316546
- const version = '4.2.64';
316767
+ const version = '4.2.65';
316547
316768
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
316548
316769
  //-----------------------------------------------------------------------------
316549
316770