ccxt 4.2.52 → 4.2.54

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 (49) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +511 -102
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/binance.js +136 -9
  7. package/dist/cjs/src/bingx.js +32 -1
  8. package/dist/cjs/src/bitget.js +1 -0
  9. package/dist/cjs/src/bitvavo.js +1 -1
  10. package/dist/cjs/src/bybit.js +19 -0
  11. package/dist/cjs/src/coinbase.js +186 -12
  12. package/dist/cjs/src/htx.js +10 -4
  13. package/dist/cjs/src/pro/binance.js +92 -38
  14. package/dist/cjs/src/pro/bitvavo.js +1 -1
  15. package/dist/cjs/src/pro/blockchaincom.js +7 -25
  16. package/dist/cjs/src/pro/deribit.js +2 -2
  17. package/dist/cjs/src/pro/gemini.js +1 -1
  18. package/dist/cjs/src/pro/okx.js +18 -4
  19. package/dist/cjs/src/whitebit.js +4 -3
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/binance.d.ts +9 -3
  23. package/js/src/abstract/binancecoinm.d.ts +9 -3
  24. package/js/src/abstract/binanceus.d.ts +9 -3
  25. package/js/src/abstract/binanceusdm.d.ts +9 -3
  26. package/js/src/abstract/coinbase.d.ts +1 -1
  27. package/js/src/binance.d.ts +4 -0
  28. package/js/src/binance.js +136 -9
  29. package/js/src/bingx.d.ts +4 -0
  30. package/js/src/bingx.js +32 -1
  31. package/js/src/bitget.js +1 -0
  32. package/js/src/bitvavo.js +1 -1
  33. package/js/src/bybit.d.ts +5 -0
  34. package/js/src/bybit.js +19 -0
  35. package/js/src/coinbase.d.ts +2 -0
  36. package/js/src/coinbase.js +186 -12
  37. package/js/src/htx.js +10 -4
  38. package/js/src/pro/binance.d.ts +4 -4
  39. package/js/src/pro/binance.js +92 -38
  40. package/js/src/pro/bitvavo.js +1 -1
  41. package/js/src/pro/blockchaincom.d.ts +0 -1
  42. package/js/src/pro/blockchaincom.js +7 -25
  43. package/js/src/pro/deribit.js +2 -2
  44. package/js/src/pro/gemini.js +1 -1
  45. package/js/src/pro/okx.js +18 -4
  46. package/js/src/whitebit.js +4 -3
  47. package/jsdoc2md.js +3 -2
  48. package/package.json +2 -1
  49. package/skip-tests.json +26 -9
@@ -18127,13 +18127,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18127
18127
  'closeAllPositions': false,
18128
18128
  'closePosition': false,
18129
18129
  'createDepositAddress': false,
18130
- 'createMarketBuyOrderWithCost': true,
18131
- 'createMarketOrderWithCost': true,
18132
- 'createMarketSellOrderWithCost': true,
18133
18130
  'createLimitBuyOrder': true,
18134
18131
  'createLimitSellOrder': true,
18135
18132
  'createMarketBuyOrder': true,
18133
+ 'createMarketBuyOrderWithCost': true,
18134
+ 'createMarketOrderWithCost': true,
18136
18135
  'createMarketSellOrder': true,
18136
+ 'createMarketSellOrderWithCost': true,
18137
18137
  'createOrder': true,
18138
18138
  'createOrders': true,
18139
18139
  'createOrderWithTakeProfitAndStopLoss': true,
@@ -18153,6 +18153,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18153
18153
  'fetchBorrowInterest': true,
18154
18154
  'fetchBorrowRateHistories': false,
18155
18155
  'fetchBorrowRateHistory': true,
18156
+ 'fetchCanceledAndClosedOrders': 'emulated',
18156
18157
  'fetchCanceledOrders': 'emulated',
18157
18158
  'fetchClosedOrder': false,
18158
18159
  'fetchClosedOrders': 'emulated',
@@ -18178,7 +18179,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18178
18179
  'fetchL3OrderBook': false,
18179
18180
  'fetchLastPrices': true,
18180
18181
  'fetchLedger': true,
18181
- 'fetchLeverage': false,
18182
+ 'fetchLedgerEntry': true,
18183
+ 'fetchLeverage': true,
18182
18184
  'fetchLeverageTiers': true,
18183
18185
  'fetchLiquidations': false,
18184
18186
  'fetchMarketLeverageTiers': 'emulated',
@@ -18210,7 +18212,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18210
18212
  'fetchTrades': true,
18211
18213
  'fetchTradingFee': true,
18212
18214
  'fetchTradingFees': true,
18213
- 'fetchTradingLimits': undefined,
18215
+ 'fetchTradingLimits': 'emulated',
18214
18216
  'fetchTransactionFee': 'emulated',
18215
18217
  'fetchTransactionFees': true,
18216
18218
  'fetchTransactions': false,
@@ -18378,8 +18380,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18378
18380
  'loan/flexible/borrow/history': 40,
18379
18381
  'loan/flexible/repay/history': 40,
18380
18382
  'loan/flexible/ltv/adjustment/history': 40,
18381
- 'loan/flexible/loanable/data': 40,
18382
- 'loan/flexible/collateral/data': 40,
18383
18383
  'loan/vip/ongoing/orders': 40,
18384
18384
  'loan/vip/repay/history': 40,
18385
18385
  'loan/vip/collateral/account': 600,
@@ -18671,7 +18671,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18671
18671
  'loan/repay': 40.002,
18672
18672
  'loan/adjust/ltv': 40.002,
18673
18673
  'loan/customize/margin_call': 40.002,
18674
- 'loan/flexible/borrow': 40.002,
18675
18674
  'loan/flexible/repay': 40.002,
18676
18675
  'loan/flexible/adjust/ltv': 40.002,
18677
18676
  'loan/vip/repay': 40.002,
@@ -18726,10 +18725,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18726
18725
  'sub-account/futures/account': 0.1,
18727
18726
  'sub-account/futures/accountSummary': 1,
18728
18727
  'sub-account/futures/positionRisk': 0.1,
18728
+ 'loan/flexible/ongoing/orders': 30,
18729
+ 'loan/flexible/borrow/history': 40,
18730
+ 'loan/flexible/repay/history': 40,
18731
+ 'loan/flexible/ltv/adjustment/history': 40,
18732
+ 'loan/flexible/loanable/data': 40,
18733
+ 'loan/flexible/collateral/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
18729
18734
  },
18730
18735
  'post': {
18731
18736
  'eth-staking/eth/stake': 15,
18732
- 'sub-account/subAccountApi/ipRestriction': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
18737
+ 'sub-account/subAccountApi/ipRestriction': 20.001,
18738
+ 'loan/flexible/borrow': 40.002,
18739
+ 'loan/flexible/repay': 40.002,
18740
+ 'loan/flexible/adjust/ltv': 40.002, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40.002
18733
18741
  },
18734
18742
  },
18735
18743
  'sapiV3': {
@@ -24909,6 +24917,38 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24909
24917
  const filteredOrders = this.filterBy(orders, 'status', 'canceled');
24910
24918
  return this.filterBySinceLimit(filteredOrders, since, limit);
24911
24919
  }
24920
+ async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
24921
+ /**
24922
+ * @method
24923
+ * @name binance#fetchCanceledAndClosedOrders
24924
+ * @description fetches information on multiple canceled orders made by the user
24925
+ * @see https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
24926
+ * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
24927
+ * @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
24928
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
24929
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
24930
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
24931
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
24932
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
24933
+ * @param {string} symbol unified market symbol of the market the orders were made in
24934
+ * @param {int} [since] the earliest time in ms to fetch orders for
24935
+ * @param {int} [limit] the maximum number of order structures to retrieve
24936
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
24937
+ * @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)
24938
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
24939
+ * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
24940
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
24941
+ */
24942
+ if (symbol === undefined) {
24943
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchCanceledAndClosedOrders() requires a symbol argument');
24944
+ }
24945
+ const orders = await this.fetchOrders(symbol, since, undefined, params);
24946
+ const canceledOrders = this.filterBy(orders, 'status', 'canceled');
24947
+ const closedOrders = this.filterBy(orders, 'status', 'closed');
24948
+ const filteredOrders = this.arrayConcat(canceledOrders, closedOrders);
24949
+ const sortedOrders = this.sortBy(filteredOrders, 'timestamp');
24950
+ return this.filterBySinceLimit(sortedOrders, since, limit);
24951
+ }
24912
24952
  async cancelOrder(id, symbol = undefined, params = {}) {
24913
24953
  /**
24914
24954
  * @method
@@ -28432,6 +28472,67 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28432
28472
  //
28433
28473
  return response;
28434
28474
  }
28475
+ async fetchLeverage(symbol, params = {}) {
28476
+ /**
28477
+ * @method
28478
+ * @name binance#fetchLeverage
28479
+ * @description fetch the set leverage for a market
28480
+ * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
28481
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
28482
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
28483
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
28484
+ * @param {string} symbol unified market symbol
28485
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
28486
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
28487
+ */
28488
+ await this.loadMarkets();
28489
+ await this.loadLeverageBrackets(false, params);
28490
+ const market = this.market(symbol);
28491
+ if (!market['contract']) {
28492
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
28493
+ }
28494
+ let type = undefined;
28495
+ [type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
28496
+ let subType = undefined;
28497
+ [subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
28498
+ let isPortfolioMargin = undefined;
28499
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
28500
+ let response = undefined;
28501
+ if (this.isLinear(type, subType)) {
28502
+ if (isPortfolioMargin) {
28503
+ response = await this.papiGetUmAccount(params);
28504
+ }
28505
+ else {
28506
+ response = await this.fapiPrivateV2GetAccount(params);
28507
+ }
28508
+ }
28509
+ else if (this.isInverse(type, subType)) {
28510
+ if (isPortfolioMargin) {
28511
+ response = await this.papiGetCmAccount(params);
28512
+ }
28513
+ else {
28514
+ response = await this.dapiPrivateGetAccount(params);
28515
+ }
28516
+ }
28517
+ else {
28518
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
28519
+ }
28520
+ const positions = this.safeList(response, 'positions', []);
28521
+ for (let i = 0; i < positions.length; i++) {
28522
+ const position = positions[i];
28523
+ const innerSymbol = this.safeString(position, 'symbol');
28524
+ if (innerSymbol === market['id']) {
28525
+ const isolated = this.safeBool(position, 'isolated');
28526
+ const marginMode = isolated ? 'isolated' : 'cross';
28527
+ return {
28528
+ 'info': position,
28529
+ 'marginMode': marginMode,
28530
+ 'leverage': this.safeInteger(position, 'leverage'),
28531
+ };
28532
+ }
28533
+ }
28534
+ return response;
28535
+ }
28435
28536
  async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
28436
28537
  /**
28437
28538
  * @method
@@ -28614,6 +28715,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28614
28715
  }
28615
28716
  return result;
28616
28717
  }
28718
+ async fetchLedgerEntry(id, code = undefined, params = {}) {
28719
+ await this.loadMarkets();
28720
+ let type = undefined;
28721
+ [type, params] = this.handleMarketTypeAndParams('fetchLedgerEntry', undefined, params);
28722
+ const query = {
28723
+ 'recordId': id,
28724
+ 'type': type,
28725
+ };
28726
+ if (type !== 'option') {
28727
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchLedgerEntry () can only be used for type option');
28728
+ }
28729
+ return await this.fetchLedger(code, undefined, undefined, this.extend(query, params));
28730
+ }
28617
28731
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
28618
28732
  /**
28619
28733
  * @method
@@ -30080,6 +30194,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
30080
30194
  'info': greeks,
30081
30195
  };
30082
30196
  }
30197
+ async fetchTradingLimits(symbols = undefined, params = {}) {
30198
+ // this method should not be called directly, use loadTradingLimits () instead
30199
+ const markets = await this.fetchMarkets();
30200
+ const tradingLimits = {};
30201
+ for (let i = 0; i < markets.length; i++) {
30202
+ const market = markets[i];
30203
+ const symbol = market['symbol'];
30204
+ if ((symbols === undefined) || (this.inArray(symbol, symbols))) {
30205
+ tradingLimits[symbol] = market['limits']['amount'];
30206
+ }
30207
+ }
30208
+ return tradingLimits;
30209
+ }
30083
30210
  async fetchPositionMode(symbol = undefined, params = {}) {
30084
30211
  /**
30085
30212
  * @method
@@ -30532,6 +30659,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
30532
30659
  'fetchOpenOrders': true,
30533
30660
  'fetchOrder': true,
30534
30661
  'fetchOrderBook': true,
30662
+ 'fetchPositionMode': true,
30535
30663
  'fetchPositions': true,
30536
30664
  'fetchTicker': true,
30537
30665
  'fetchTickers': true,
@@ -30542,6 +30670,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
30542
30670
  'setLeverage': true,
30543
30671
  'setMargin': true,
30544
30672
  'setMarginMode': true,
30673
+ 'setPositionMode': true,
30545
30674
  'transfer': true,
30546
30675
  },
30547
30676
  'hostname': 'bingx.com',
@@ -33968,13 +34097,14 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
33968
34097
  * @param {float} leverage the rate of leverage
33969
34098
  * @param {string} symbol unified market symbol
33970
34099
  * @param {object} [params] extra parameters specific to the exchange API endpoint
34100
+ * @param {string} [params.side] hedged: ['long' or 'short']. one way: ['both']
33971
34101
  * @returns {object} response from the exchange
33972
34102
  */
33973
34103
  if (symbol === undefined) {
33974
34104
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
33975
34105
  }
33976
34106
  const side = this.safeStringUpper(params, 'side');
33977
- this.checkRequiredArgument('setLeverage', side, 'side', ['LONG', 'SHORT']);
34107
+ this.checkRequiredArgument('setLeverage', side, 'side', ['LONG', 'SHORT', 'BOTH']);
33978
34108
  await this.loadMarkets();
33979
34109
  const market = this.market(symbol);
33980
34110
  const request = {
@@ -34418,6 +34548,34 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34418
34548
  }
34419
34549
  return positions;
34420
34550
  }
34551
+ async fetchPositionMode(symbol = undefined, params = {}) {
34552
+ /**
34553
+ * @method
34554
+ * @name bingx#fetchPositionMode
34555
+ * @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
34556
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Get%20Position%20Mode
34557
+ * @param {string} symbol unified symbol of the market to fetch the order book for
34558
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
34559
+ * @returns {object} an object detailing whether the market is in hedged or one-way mode
34560
+ */
34561
+ const response = await this.swapV1PrivateGetPositionSideDual(params);
34562
+ //
34563
+ // {
34564
+ // "code": "0",
34565
+ // "msg": "",
34566
+ // "timeStamp": "1709002057516",
34567
+ // "data": {
34568
+ // "dualSidePosition": "false"
34569
+ // }
34570
+ // }
34571
+ //
34572
+ const data = this.safeDict(response, 'data', {});
34573
+ const dualSidePosition = this.safeString(data, 'dualSidePosition');
34574
+ return {
34575
+ 'info': response,
34576
+ 'hedged': (dualSidePosition === 'true'),
34577
+ };
34578
+ }
34421
34579
  async setPositionMode(hedged, symbol = undefined, params = {}) {
34422
34580
  /**
34423
34581
  * @method
@@ -47955,6 +48113,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47955
48113
  'not_trigger': 'open',
47956
48114
  'partial_fill': 'open',
47957
48115
  'partially_fill': 'open',
48116
+ 'partially_filled': 'open',
47958
48117
  'triggered': 'closed',
47959
48118
  'full_fill': 'closed',
47960
48119
  'filled': 'closed',
@@ -73137,7 +73296,7 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
73137
73296
  // "market":"ETH-BTC",
73138
73297
  // "open":"0.022578",
73139
73298
  // "high":"0.023019",
73140
- // "low":"0.022573",
73299
+ // "low":"0.022572",
73141
73300
  // "last":"0.023019",
73142
73301
  // "volume":"25.16366324",
73143
73302
  // "volumeQuote":"0.57333305",
@@ -82330,6 +82489,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
82330
82489
  'fetchUnderlyingAssets': false,
82331
82490
  'fetchVolatilityHistory': true,
82332
82491
  'fetchWithdrawals': true,
82492
+ 'fetchLeverage': true,
82333
82493
  'repayCrossMargin': true,
82334
82494
  'setLeverage': true,
82335
82495
  'setMarginMode': true,
@@ -88566,6 +88726,24 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
88566
88726
  'takeProfitPrice': this.safeNumber2(position, 'take_profit', 'takeProfit'),
88567
88727
  });
88568
88728
  }
88729
+ async fetchLeverage(symbol, params = {}) {
88730
+ /**
88731
+ * @method
88732
+ * @name bybit#fetchLeverage
88733
+ * @description fetch the set leverage for a market
88734
+ * @see https://bybit-exchange.github.io/docs/v5/position
88735
+ * @param {string} symbol unified market symbol
88736
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
88737
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
88738
+ */
88739
+ await this.loadMarkets();
88740
+ const position = await this.fetchPosition(symbol, params);
88741
+ return {
88742
+ 'info': position,
88743
+ 'leverage': this.safeInteger(position, 'leverage'),
88744
+ 'marginMode': this.safeNumber(position, 'marginMode'),
88745
+ };
88746
+ }
88569
88747
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
88570
88748
  /**
88571
88749
  * @method
@@ -92029,6 +92207,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
92029
92207
  'createStopLimitOrder': true,
92030
92208
  'createStopMarketOrder': false,
92031
92209
  'createStopOrder': true,
92210
+ 'deposit': true,
92032
92211
  'editOrder': true,
92033
92212
  'fetchAccounts': true,
92034
92213
  'fetchBalance': true,
@@ -92040,6 +92219,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
92040
92219
  'fetchCrossBorrowRate': false,
92041
92220
  'fetchCrossBorrowRates': false,
92042
92221
  'fetchCurrencies': true,
92222
+ 'fetchDeposit': true,
92043
92223
  'fetchDepositAddress': 'emulated',
92044
92224
  'fetchDepositAddresses': false,
92045
92225
  'fetchDepositAddressesByNetwork': true,
@@ -92168,6 +92348,11 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
92168
92348
  },
92169
92349
  },
92170
92350
  'v3': {
92351
+ 'public': {
92352
+ 'get': [
92353
+ 'brokerage/time',
92354
+ ],
92355
+ },
92171
92356
  'private': {
92172
92357
  'get': [
92173
92358
  'brokerage/accounts',
@@ -92185,7 +92370,6 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
92185
92370
  'brokerage/product_book',
92186
92371
  'brokerage/best_bid_ask',
92187
92372
  'brokerage/convert/trade/{trade_id}',
92188
- 'brokerage/time',
92189
92373
  'brokerage/cfm/balance_summary',
92190
92374
  'brokerage/cfm/positions',
92191
92375
  'brokerage/cfm/positions/{product_id}',
@@ -92316,6 +92500,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
92316
92500
  'fetchTickers': 'fetchTickersV3',
92317
92501
  'fetchAccounts': 'fetchAccountsV3',
92318
92502
  'fetchBalance': 'v2PrivateGetAccounts',
92503
+ 'fetchTime': 'v2PublicGetTime',
92319
92504
  'user_native_currency': 'USD', // needed to get fees for v3
92320
92505
  },
92321
92506
  });
@@ -92327,19 +92512,36 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
92327
92512
  * @description fetches the current integer timestamp in milliseconds from the exchange server
92328
92513
  * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-time#http-request
92329
92514
  * @param {object} [params] extra parameters specific to the exchange API endpoint
92515
+ * @param {string} [params.method] 'v2PublicGetTime' or 'v3PublicGetBrokerageTime' default is 'v2PublicGetTime'
92330
92516
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
92331
92517
  */
92332
- const response = await this.v2PublicGetTime(params);
92333
- //
92334
- // {
92335
- // "data": {
92336
- // "epoch": 1589295679,
92337
- // "iso": "2020-05-12T15:01:19Z"
92338
- // }
92339
- // }
92340
- //
92341
- const data = this.safeValue(response, 'data', {});
92342
- return this.safeTimestamp(data, 'epoch');
92518
+ const defaultMethod = this.safeString(this.options, 'fetchTime', 'v2PublicGetTime');
92519
+ const method = this.safeString(params, 'method', defaultMethod);
92520
+ params = this.omit(params, 'method');
92521
+ let response = undefined;
92522
+ if (method === 'v2PublicGetTime') {
92523
+ response = await this.v2PublicGetTime(params);
92524
+ //
92525
+ // {
92526
+ // "data": {
92527
+ // "epoch": 1589295679,
92528
+ // "iso": "2020-05-12T15:01:19Z"
92529
+ // }
92530
+ // }
92531
+ //
92532
+ response = this.safeValue(response, 'data', {});
92533
+ }
92534
+ else {
92535
+ response = await this.v3PublicGetBrokerageTime(params);
92536
+ //
92537
+ // {
92538
+ // "iso": "2024-02-27T03:37:14Z",
92539
+ // "epochSeconds": "1709005034",
92540
+ // "epochMillis": "1709005034333"
92541
+ // }
92542
+ //
92543
+ }
92544
+ return this.safeTimestamp2(response, 'epoch', 'epochSeconds');
92343
92545
  }
92344
92546
  async fetchAccounts(params = {}) {
92345
92547
  /**
@@ -93735,6 +93937,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
93735
93937
  response = await this.v3PrivateGetBrokerageAccounts(this.extend(request, params));
93736
93938
  }
93737
93939
  else {
93940
+ request['limit'] = 100;
93738
93941
  response = await this.v2PrivateGetAccounts(this.extend(request, params));
93739
93942
  }
93740
93943
  //
@@ -95514,6 +95717,145 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
95514
95717
  'network': this.networkIdToCode(networkId, code),
95515
95718
  };
95516
95719
  }
95720
+ async deposit(code, amount, id, params = {}) {
95721
+ /**
95722
+ * @method
95723
+ * @name coinbase#deposit
95724
+ * @description make a deposit
95725
+ * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#deposit-funds
95726
+ * @param {string} code unified currency code
95727
+ * @param {float} amount the amount to deposit
95728
+ * @param {string} id the payment method id to be used for the deposit, can be retrieved from v2PrivateGetPaymentMethods
95729
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
95730
+ * @param {string} [params.accountId] the id of the account to deposit into
95731
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
95732
+ */
95733
+ await this.loadMarkets();
95734
+ let accountId = this.safeString2(params, 'account_id', 'accountId');
95735
+ params = this.omit(params, ['account_id', 'accountId']);
95736
+ if (accountId === undefined) {
95737
+ if (code === undefined) {
95738
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' deposit() requires an account_id (or accountId) parameter OR a currency code argument');
95739
+ }
95740
+ accountId = await this.findAccountId(code);
95741
+ if (accountId === undefined) {
95742
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' deposit() could not find account id for ' + code);
95743
+ }
95744
+ }
95745
+ const request = {
95746
+ 'account_id': accountId,
95747
+ 'amount': this.numberToString(amount),
95748
+ 'currency': code.toUpperCase(),
95749
+ 'payment_method': id,
95750
+ };
95751
+ const response = await this.v2PrivatePostAccountsAccountIdDeposits(this.extend(request, params));
95752
+ //
95753
+ // {
95754
+ // "data": {
95755
+ // "id": "67e0eaec-07d7-54c4-a72c-2e92826897df",
95756
+ // "status": "created",
95757
+ // "payment_method": {
95758
+ // "id": "83562370-3e5c-51db-87da-752af5ab9559",
95759
+ // "resource": "payment_method",
95760
+ // "resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
95761
+ // },
95762
+ // "transaction": {
95763
+ // "id": "441b9494-b3f0-5b98-b9b0-4d82c21c252a",
95764
+ // "resource": "transaction",
95765
+ // "resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/441b9494-b3f0-5b98-b9b0-4d82c21c252a"
95766
+ // },
95767
+ // "amount": {
95768
+ // "amount": "10.00",
95769
+ // "currency": "USD"
95770
+ // },
95771
+ // "subtotal": {
95772
+ // "amount": "10.00",
95773
+ // "currency": "USD"
95774
+ // },
95775
+ // "created_at": "2015-01-31T20:49:02Z",
95776
+ // "updated_at": "2015-02-11T16:54:02-08:00",
95777
+ // "resource": "deposit",
95778
+ // "resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/deposits/67e0eaec-07d7-54c4-a72c-2e92826897df",
95779
+ // "committed": true,
95780
+ // "fee": {
95781
+ // "amount": "0.00",
95782
+ // "currency": "USD"
95783
+ // },
95784
+ // "payout_at": "2015-02-18T16:54:00-08:00"
95785
+ // }
95786
+ // }
95787
+ //
95788
+ const data = this.safeDict(response, 'data', {});
95789
+ return this.parseTransaction(data);
95790
+ }
95791
+ async fetchDeposit(id, code = undefined, params = {}) {
95792
+ /**
95793
+ * @method
95794
+ * @name coinbase#fetchDeposit
95795
+ * @description fetch information on a deposit, fiat only, for crypto transactions use fetchLedger
95796
+ * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#show-deposit
95797
+ * @param {string} id deposit id
95798
+ * @param {string} [code] unified currency code
95799
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
95800
+ * @param {string} [params.accountId] the id of the account that the funds were deposited into
95801
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
95802
+ */
95803
+ await this.loadMarkets();
95804
+ let accountId = this.safeString2(params, 'account_id', 'accountId');
95805
+ params = this.omit(params, ['account_id', 'accountId']);
95806
+ if (accountId === undefined) {
95807
+ if (code === undefined) {
95808
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchDeposit() requires an account_id (or accountId) parameter OR a currency code argument');
95809
+ }
95810
+ accountId = await this.findAccountId(code);
95811
+ if (accountId === undefined) {
95812
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' fetchDeposit() could not find account id for ' + code);
95813
+ }
95814
+ }
95815
+ const request = {
95816
+ 'account_id': accountId,
95817
+ 'deposit_id': id,
95818
+ };
95819
+ const response = await this.v2PrivateGetAccountsAccountIdDepositsDepositId(this.extend(request, params));
95820
+ //
95821
+ // {
95822
+ // "data": {
95823
+ // "id": "67e0eaec-07d7-54c4-a72c-2e92826897df",
95824
+ // "status": "completed",
95825
+ // "payment_method": {
95826
+ // "id": "83562370-3e5c-51db-87da-752af5ab9559",
95827
+ // "resource": "payment_method",
95828
+ // "resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
95829
+ // },
95830
+ // "transaction": {
95831
+ // "id": "441b9494-b3f0-5b98-b9b0-4d82c21c252a",
95832
+ // "resource": "transaction",
95833
+ // "resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/441b9494-b3f0-5b98-b9b0-4d82c21c252a"
95834
+ // },
95835
+ // "amount": {
95836
+ // "amount": "10.00",
95837
+ // "currency": "USD"
95838
+ // },
95839
+ // "subtotal": {
95840
+ // "amount": "10.00",
95841
+ // "currency": "USD"
95842
+ // },
95843
+ // "created_at": "2015-01-31T20:49:02Z",
95844
+ // "updated_at": "2015-02-11T16:54:02-08:00",
95845
+ // "resource": "deposit",
95846
+ // "resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/deposits/67e0eaec-07d7-54c4-a72c-2e92826897df",
95847
+ // "committed": true,
95848
+ // "fee": {
95849
+ // "amount": "0.00",
95850
+ // "currency": "USD"
95851
+ // },
95852
+ // "payout_at": "2015-02-18T16:54:00-08:00"
95853
+ // }
95854
+ // }
95855
+ //
95856
+ const data = this.safeValue(response, 'data', {});
95857
+ return this.parseTransaction(data);
95858
+ }
95517
95859
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
95518
95860
  const version = api[0];
95519
95861
  const signed = api[1] === 'private';
@@ -95534,6 +95876,11 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
95534
95876
  'Authorization': authorization,
95535
95877
  'Content-Type': 'application/json',
95536
95878
  };
95879
+ if (method !== 'GET') {
95880
+ if (Object.keys(query).length) {
95881
+ body = this.json(query);
95882
+ }
95883
+ }
95537
95884
  }
95538
95885
  else if (this.token && !this.checkRequiredCredentials(false)) {
95539
95886
  headers = {
@@ -95556,6 +95903,11 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
95556
95903
  payload = body;
95557
95904
  }
95558
95905
  }
95906
+ else {
95907
+ if (Object.keys(query).length) {
95908
+ payload += '?' + this.urlencode(query);
95909
+ }
95910
+ }
95559
95911
  const auth = nonce + method + savedPath + payload;
95560
95912
  const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J);
95561
95913
  headers = {
@@ -147610,9 +147962,10 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
147610
147962
  async fetchStatus(params = {}) {
147611
147963
  await this.loadMarkets();
147612
147964
  let marketType = undefined;
147613
- [marketType, params] = this.handleMarketTypeAndParams('fetchMyTrades', undefined, params);
147965
+ [marketType, params] = this.handleMarketTypeAndParams('fetchStatus', undefined, params);
147966
+ const enabledForContracts = this.handleOption('fetchStatus', 'enableForContracts', false); // temp fix for: https://status-linear-swap.huobigroup.com/api/v2/summary.json
147614
147967
  let response = undefined;
147615
- if (marketType !== 'spot') {
147968
+ if (marketType !== 'spot' && enabledForContracts) {
147616
147969
  const subType = this.safeString(params, 'subType', this.options['defaultSubType']);
147617
147970
  if (marketType === 'swap') {
147618
147971
  if (subType === 'linear') {
@@ -147634,7 +147987,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
147634
147987
  response = await this.contractPublicGetHeartbeat();
147635
147988
  }
147636
147989
  }
147637
- else {
147990
+ else if (marketType === 'spot') {
147638
147991
  response = await this.statusPublicSpotGetApiV2SummaryJson();
147639
147992
  }
147640
147993
  //
@@ -147803,7 +148156,12 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
147803
148156
  let url = undefined;
147804
148157
  if (marketType === 'contract') {
147805
148158
  const statusRaw = this.safeString(response, 'status');
147806
- status = (statusRaw === 'ok') ? 'ok' : 'maintenance'; // 'ok', 'error'
148159
+ if (statusRaw === undefined) {
148160
+ status = undefined;
148161
+ }
148162
+ else {
148163
+ status = (statusRaw === 'ok') ? 'ok' : 'maintenance'; // 'ok', 'error'
148164
+ }
147807
148165
  updated = this.safeString(response, 'ts');
147808
148166
  }
147809
148167
  else {
@@ -219748,6 +220106,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
219748
220106
  'future': 'wss://fstream.binance.com/ws',
219749
220107
  'delivery': 'wss://dstream.binance.com/ws',
219750
220108
  'ws': 'wss://ws-api.binance.com:443/ws-api/v3',
220109
+ 'papi': 'wss://fstream.binance.com/pm/ws',
219751
220110
  },
219752
220111
  },
219753
220112
  },
@@ -220923,11 +221282,12 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
220923
221282
  }
220924
221283
  async authenticate(params = {}) {
220925
221284
  const time = this.milliseconds();
220926
- let query = undefined;
220927
221285
  let type = undefined;
220928
- [type, query] = this.handleMarketTypeAndParams('authenticate', undefined, params);
221286
+ [type, params] = this.handleMarketTypeAndParams('authenticate', undefined, params);
220929
221287
  let subType = undefined;
220930
- [subType, query] = this.handleSubTypeAndParams('authenticate', undefined, query);
221288
+ [subType, params] = this.handleSubTypeAndParams('authenticate', undefined, params);
221289
+ let isPortfolioMargin = undefined;
221290
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'authenticate', 'papi', 'portfolioMargin', false);
220931
221291
  if (this.isLinear(type, subType)) {
220932
221292
  type = 'future';
220933
221293
  }
@@ -220935,36 +221295,39 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
220935
221295
  type = 'delivery';
220936
221296
  }
220937
221297
  let marginMode = undefined;
220938
- [marginMode, query] = this.handleMarginModeAndParams('authenticate', query);
221298
+ [marginMode, params] = this.handleMarginModeAndParams('authenticate', params);
220939
221299
  const isIsolatedMargin = (marginMode === 'isolated');
220940
221300
  const isCrossMargin = (marginMode === 'cross') || (marginMode === undefined);
220941
- const symbol = this.safeString(query, 'symbol');
220942
- query = this.omit(query, 'symbol');
221301
+ const symbol = this.safeString(params, 'symbol');
221302
+ params = this.omit(params, 'symbol');
220943
221303
  const options = this.safeValue(this.options, type, {});
220944
221304
  const lastAuthenticatedTime = this.safeInteger(options, 'lastAuthenticatedTime', 0);
220945
221305
  const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 1200000);
220946
221306
  const delay = this.sum(listenKeyRefreshRate, 10000);
220947
221307
  if (time - lastAuthenticatedTime > delay) {
220948
221308
  let response = undefined;
220949
- if (type === 'future') {
220950
- response = await this.fapiPrivatePostListenKey(query);
221309
+ if (isPortfolioMargin) {
221310
+ response = await this.papiPostListenKey(params);
221311
+ }
221312
+ else if (type === 'future') {
221313
+ response = await this.fapiPrivatePostListenKey(params);
220951
221314
  }
220952
221315
  else if (type === 'delivery') {
220953
- response = await this.dapiPrivatePostListenKey(query);
221316
+ response = await this.dapiPrivatePostListenKey(params);
220954
221317
  }
220955
221318
  else if (type === 'margin' && isCrossMargin) {
220956
- response = await this.sapiPostUserDataStream(query);
221319
+ response = await this.sapiPostUserDataStream(params);
220957
221320
  }
220958
221321
  else if (isIsolatedMargin) {
220959
221322
  if (symbol === undefined) {
220960
221323
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' authenticate() requires a symbol argument for isolated margin mode');
220961
221324
  }
220962
221325
  const marketId = this.marketId(symbol);
220963
- query = this.extend(query, { 'symbol': marketId });
220964
- response = await this.sapiPostUserDataStreamIsolated(query);
221326
+ params = this.extend(params, { 'symbol': marketId });
221327
+ response = await this.sapiPostUserDataStreamIsolated(params);
220965
221328
  }
220966
221329
  else {
220967
- response = await this.publicPostUserDataStream(query);
221330
+ response = await this.publicPostUserDataStream(params);
220968
221331
  }
220969
221332
  this.options[type] = this.extend(options, {
220970
221333
  'listenKey': this.safeString(response, 'listenKey'),
@@ -220977,6 +221340,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
220977
221340
  // https://binance-docs.github.io/apidocs/spot/en/#listen-key-spot
220978
221341
  let type = this.safeString2(this.options, 'defaultType', 'authenticate', 'spot');
220979
221342
  type = this.safeString(params, 'type', type);
221343
+ let isPortfolioMargin = undefined;
221344
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'keepAliveListenKey', 'papi', 'portfolioMargin', false);
220980
221345
  const subTypeInfo = this.handleSubTypeAndParams('keepAliveListenKey', undefined, params);
220981
221346
  const subType = subTypeInfo[0];
220982
221347
  if (this.isLinear(type, subType)) {
@@ -220993,28 +221358,35 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
220993
221358
  }
220994
221359
  const request = {};
220995
221360
  const symbol = this.safeString(params, 'symbol');
220996
- const sendParams = this.omit(params, ['type', 'symbol']);
221361
+ params = this.omit(params, ['type', 'symbol']);
220997
221362
  const time = this.milliseconds();
220998
221363
  try {
220999
- if (type === 'future') {
221000
- await this.fapiPrivatePutListenKey(this.extend(request, sendParams));
221364
+ if (isPortfolioMargin) {
221365
+ await this.papiPutListenKey(this.extend(request, params));
221366
+ }
221367
+ else if (type === 'future') {
221368
+ await this.fapiPrivatePutListenKey(this.extend(request, params));
221001
221369
  }
221002
221370
  else if (type === 'delivery') {
221003
- await this.dapiPrivatePutListenKey(this.extend(request, sendParams));
221371
+ await this.dapiPrivatePutListenKey(this.extend(request, params));
221004
221372
  }
221005
221373
  else {
221006
221374
  request['listenKey'] = listenKey;
221007
221375
  if (type === 'margin') {
221008
221376
  request['symbol'] = symbol;
221009
- await this.sapiPutUserDataStream(this.extend(request, sendParams));
221377
+ await this.sapiPutUserDataStream(this.extend(request, params));
221010
221378
  }
221011
221379
  else {
221012
- await this.publicPutUserDataStream(this.extend(request, sendParams));
221380
+ await this.publicPutUserDataStream(this.extend(request, params));
221013
221381
  }
221014
221382
  }
221015
221383
  }
221016
221384
  catch (error) {
221017
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
221385
+ let urlType = type;
221386
+ if (isPortfolioMargin) {
221387
+ urlType = 'papi';
221388
+ }
221389
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
221018
221390
  const client = this.client(url);
221019
221391
  const messageHashes = Object.keys(client.futures);
221020
221392
  for (let i = 0; i < messageHashes.length; i++) {
@@ -221046,7 +221418,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221046
221418
  }
221047
221419
  }
221048
221420
  }
221049
- setBalanceCache(client, type) {
221421
+ setBalanceCache(client, type, isPortfolioMargin = false) {
221050
221422
  if (type in client.subscriptions) {
221051
221423
  return;
221052
221424
  }
@@ -221056,15 +221428,21 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221056
221428
  const messageHash = type + ':fetchBalanceSnapshot';
221057
221429
  if (!(messageHash in client.futures)) {
221058
221430
  client.future(messageHash);
221059
- this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
221431
+ this.spawn(this.loadBalanceSnapshot, client, messageHash, type, isPortfolioMargin);
221060
221432
  }
221061
221433
  }
221062
221434
  else {
221063
221435
  this.balance[type] = {};
221064
221436
  }
221065
221437
  }
221066
- async loadBalanceSnapshot(client, messageHash, type) {
221067
- const response = await this.fetchBalance({ 'type': type });
221438
+ async loadBalanceSnapshot(client, messageHash, type, isPortfolioMargin) {
221439
+ const params = {
221440
+ 'type': type,
221441
+ };
221442
+ if (isPortfolioMargin) {
221443
+ params['portfolioMargin'] = true;
221444
+ }
221445
+ const response = await this.fetchBalance(params);
221068
221446
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
221069
221447
  // don't remove the future from the .futures cache
221070
221448
  const future = client.futures[messageHash];
@@ -221158,6 +221536,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221158
221536
  * @name binance#watchBalance
221159
221537
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
221160
221538
  * @param {object} [params] extra parameters specific to the exchange API endpoint
221539
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch the balance of a portfolio margin account
221161
221540
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
221162
221541
  */
221163
221542
  await this.loadMarkets();
@@ -221166,16 +221545,22 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221166
221545
  let type = this.safeString(params, 'type', defaultType);
221167
221546
  let subType = undefined;
221168
221547
  [subType, params] = this.handleSubTypeAndParams('watchBalance', undefined, params);
221548
+ let isPortfolioMargin = undefined;
221549
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchBalance', 'papi', 'portfolioMargin', false);
221550
+ let urlType = type;
221551
+ if (isPortfolioMargin) {
221552
+ urlType = 'papi';
221553
+ }
221169
221554
  if (this.isLinear(type, subType)) {
221170
221555
  type = 'future';
221171
221556
  }
221172
221557
  else if (this.isInverse(type, subType)) {
221173
221558
  type = 'delivery';
221174
221559
  }
221175
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
221560
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
221176
221561
  const client = this.client(url);
221177
- this.setBalanceCache(client, type);
221178
- this.setPositionsCache(client, type);
221562
+ this.setBalanceCache(client, type, isPortfolioMargin);
221563
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
221179
221564
  const options = this.safeValue(this.options, 'watchBalance');
221180
221565
  const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
221181
221566
  const awaitBalanceSnapshot = this.safeBool(options, 'awaitBalanceSnapshot', true);
@@ -221782,11 +222167,14 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221782
222167
  * @name binance#watchOrders
221783
222168
  * @description watches information on multiple orders made by the user
221784
222169
  * @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
222170
+ * @see https://binance-docs.github.io/apidocs/pm/en/#event-futures-order-update
222171
+ * @see https://binance-docs.github.io/apidocs/pm/en/#event-margin-order-update
221785
222172
  * @param {string} symbol unified market symbol of the market the orders were made in
221786
222173
  * @param {int} [since] the earliest time in ms to fetch orders for
221787
222174
  * @param {int} [limit] the maximum number of order structures to retrieve
221788
222175
  * @param {object} [params] extra parameters specific to the exchange API endpoint
221789
222176
  * @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for spot margin
222177
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch portfolio margin account orders
221790
222178
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
221791
222179
  */
221792
222180
  await this.loadMarkets();
@@ -221815,10 +222203,15 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221815
222203
  if ((type === 'margin') || ((type === 'spot') && (marginMode !== undefined))) {
221816
222204
  urlType = 'spot'; // spot-margin shares the same stream as regular spot
221817
222205
  }
222206
+ let isPortfolioMargin = undefined;
222207
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchOrders', 'papi', 'portfolioMargin', false);
222208
+ if (isPortfolioMargin) {
222209
+ urlType = 'papi';
222210
+ }
221818
222211
  const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
221819
222212
  const client = this.client(url);
221820
- this.setBalanceCache(client, type);
221821
- this.setPositionsCache(client, type);
222213
+ this.setBalanceCache(client, type, isPortfolioMargin);
222214
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
221822
222215
  const message = undefined;
221823
222216
  const orders = await this.watch(url, messageHash, message, type);
221824
222217
  if (this.newUpdates) {
@@ -222073,6 +222466,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222073
222466
  * @description watch all open positions
222074
222467
  * @param {string[]|undefined} symbols list of unified market symbols
222075
222468
  * @param {object} params extra parameters specific to the exchange API endpoint
222469
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch positions in a portfolio margin account
222076
222470
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
222077
222471
  */
222078
222472
  await this.loadMarkets();
@@ -222103,10 +222497,16 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222103
222497
  type = 'delivery';
222104
222498
  }
222105
222499
  messageHash = type + ':positions' + messageHash;
222106
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
222500
+ let isPortfolioMargin = undefined;
222501
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchPositions', 'papi', 'portfolioMargin', false);
222502
+ let urlType = type;
222503
+ if (isPortfolioMargin) {
222504
+ urlType = 'papi';
222505
+ }
222506
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
222107
222507
  const client = this.client(url);
222108
- this.setBalanceCache(client, type);
222109
- this.setPositionsCache(client, type, symbols);
222508
+ this.setBalanceCache(client, type, isPortfolioMargin);
222509
+ this.setPositionsCache(client, type, symbols, isPortfolioMargin);
222110
222510
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
222111
222511
  const awaitPositionsSnapshot = this.safeValue('watchPositions', 'awaitPositionsSnapshot', true);
222112
222512
  const cache = this.safeValue(this.positions, type);
@@ -222120,7 +222520,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222120
222520
  }
222121
222521
  return this.filterBySymbolsSinceLimit(cache, symbols, since, limit, true);
222122
222522
  }
222123
- setPositionsCache(client, type, symbols = undefined) {
222523
+ setPositionsCache(client, type, symbols = undefined, isPortfolioMargin = false) {
222124
222524
  if (type === 'spot') {
222125
222525
  return;
222126
222526
  }
@@ -222135,15 +222535,21 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222135
222535
  const messageHash = type + ':fetchPositionsSnapshot';
222136
222536
  if (!(messageHash in client.futures)) {
222137
222537
  client.future(messageHash);
222138
- this.spawn(this.loadPositionsSnapshot, client, messageHash, type);
222538
+ this.spawn(this.loadPositionsSnapshot, client, messageHash, type, isPortfolioMargin);
222139
222539
  }
222140
222540
  }
222141
222541
  else {
222142
222542
  this.positions[type] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolBySide */ .tU();
222143
222543
  }
222144
222544
  }
222145
- async loadPositionsSnapshot(client, messageHash, type) {
222146
- const positions = await this.fetchPositions(undefined, { 'type': type });
222545
+ async loadPositionsSnapshot(client, messageHash, type, isPortfolioMargin) {
222546
+ const params = {
222547
+ 'type': type,
222548
+ };
222549
+ if (isPortfolioMargin) {
222550
+ params['portfolioMargin'] = true;
222551
+ }
222552
+ const positions = await this.fetchPositions(undefined, params);
222147
222553
  this.positions[type] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolBySide */ .tU();
222148
222554
  const cache = this.positions[type];
222149
222555
  for (let i = 0; i < positions.length; i++) {
@@ -222416,6 +222822,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222416
222822
  * @param {int} [since] the earliest time in ms to fetch orders for
222417
222823
  * @param {int} [limit] the maximum number of order structures to retrieve
222418
222824
  * @param {object} [params] extra parameters specific to the exchange API endpoint
222825
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch trades in a portfolio margin account
222419
222826
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
222420
222827
  */
222421
222828
  await this.loadMarkets();
@@ -222445,10 +222852,15 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222445
222852
  if (type === 'margin') {
222446
222853
  urlType = 'spot'; // spot-margin shares the same stream as regular spot
222447
222854
  }
222855
+ let isPortfolioMargin = undefined;
222856
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchMyTrades', 'papi', 'portfolioMargin', false);
222857
+ if (isPortfolioMargin) {
222858
+ urlType = 'papi';
222859
+ }
222448
222860
  const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
222449
222861
  const client = this.client(url);
222450
- this.setBalanceCache(client, type);
222451
- this.setPositionsCache(client, type);
222862
+ this.setBalanceCache(client, type, isPortfolioMargin);
222863
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
222452
222864
  const message = undefined;
222453
222865
  const trades = await this.watch(url, messageHash, message, type);
222454
222866
  if (this.newUpdates) {
@@ -232428,7 +232840,7 @@ class bitvavo extends _bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
232428
232840
  // "volume": "3587.05020246",
232429
232841
  // "volumeQuote": "708030.17",
232430
232842
  // "bid": "199.56",
232431
- // "bidSize": "4.14730803",
232843
+ // "bidSize": "4.14730802",
232432
232844
  // "ask": "199.57",
232433
232845
  // "askSize": "6.13642074",
232434
232846
  // "timestamp": 1590770885217
@@ -233725,7 +234137,6 @@ class blockchaincom extends _blockchaincom_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
233725
234137
  },
233726
234138
  'noOriginHeader': false,
233727
234139
  },
233728
- 'sequenceNumbers': {},
233729
234140
  },
233730
234141
  'streaming': {},
233731
234142
  'exceptions': {},
@@ -234369,21 +234780,20 @@ class blockchaincom extends _blockchaincom_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
234369
234780
  // }
234370
234781
  //
234371
234782
  const event = this.safeString(message, 'event');
234783
+ if (event === 'subscribed') {
234784
+ return;
234785
+ }
234372
234786
  const type = this.safeString(message, 'channel');
234373
234787
  const marketId = this.safeString(message, 'symbol');
234374
234788
  const symbol = this.safeSymbol(marketId);
234375
234789
  const messageHash = 'orderbook:' + symbol + ':' + type;
234376
234790
  const datetime = this.safeString(message, 'timestamp');
234377
234791
  const timestamp = this.parse8601(datetime);
234378
- let orderbook = this.safeValue(this.orderbooks, symbol);
234379
- if (orderbook === undefined) {
234380
- orderbook = this.countedOrderBook({});
234381
- this.orderbooks[symbol] = orderbook;
234382
- }
234383
- if (event === 'subscribed') {
234384
- return;
234792
+ if (this.safeValue(this.orderbooks, symbol) === undefined) {
234793
+ this.orderbooks[symbol] = this.countedOrderBook();
234385
234794
  }
234386
- else if (event === 'snapshot') {
234795
+ const orderbook = this.orderbooks[symbol];
234796
+ if (event === 'snapshot') {
234387
234797
  const snapshot = this.parseOrderBook(message, symbol, timestamp, 'bids', 'asks', 'px', 'qty', 'num');
234388
234798
  orderbook.reset(snapshot);
234389
234799
  }
@@ -234409,23 +234819,7 @@ class blockchaincom extends _blockchaincom_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
234409
234819
  this.handleDelta(bookside, deltas[i]);
234410
234820
  }
234411
234821
  }
234412
- checkSequenceNumber(client, message) {
234413
- const seqnum = this.safeInteger(message, 'seqnum', 0);
234414
- const channel = this.safeString(message, 'channel', '');
234415
- const sequenceNumbersByChannel = this.safeValue(this.options, 'sequenceNumbers', {});
234416
- const lastSeqnum = this.safeInteger(sequenceNumbersByChannel, channel);
234417
- if (lastSeqnum === undefined) {
234418
- this.options['sequenceNumbers'][channel] = seqnum;
234419
- }
234420
- else {
234421
- if (seqnum !== lastSeqnum + 1) {
234422
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' ' + channel + ' seqnum ' + seqnum + ' is not the expected ' + (lastSeqnum + 1));
234423
- }
234424
- this.options['sequenceNumbers'][channel] = seqnum;
234425
- }
234426
- }
234427
234822
  handleMessage(client, message) {
234428
- this.checkSequenceNumber(client, message);
234429
234823
  const channel = this.safeString(message, 'channel');
234430
234824
  const handlers = {
234431
234825
  'ticker': this.handleTicker,
@@ -242932,7 +243326,7 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
242932
243326
  // "params": {
242933
243327
  // "channel": "ticker.BTC_USDC-PERPETUAL.raw",
242934
243328
  // "data": {
242935
- // "timestamp": 1655393725041,
243329
+ // "timestamp": 1655393725040,
242936
243330
  // "stats": [Object],
242937
243331
  // "state": "open",
242938
243332
  // "settlement_price": 21729.5891,
@@ -243415,7 +243809,7 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
243415
243809
  const symbol = this.safeSymbol(marketId);
243416
243810
  const ohlcv = this.safeValue(params, 'data', {});
243417
243811
  const parsed = [
243418
- this.safeNumber(ohlcv, 'tick'),
243812
+ this.safeInteger(ohlcv, 'tick'),
243419
243813
  this.safeNumber(ohlcv, 'open'),
243420
243814
  this.safeNumber(ohlcv, 'high'),
243421
243815
  this.safeNumber(ohlcv, 'low'),
@@ -245845,7 +246239,7 @@ class gemini extends _gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
245845
246239
  // "time_ms": 1655323185000,
245846
246240
  // "result": "failure",
245847
246241
  // "highest_bid_price": "21661.90",
245848
- // "lowest_ask_price": "21663.79",
246242
+ // "lowest_ask_price": "21663.78",
245849
246243
  // "collar_price": "21662.845"
245850
246244
  // },
245851
246245
  // ]
@@ -262154,9 +262548,6 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
262154
262548
  * @param {object} params extra parameters specific to the exchange API endpoint
262155
262549
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
262156
262550
  */
262157
- if (this.isEmpty(symbols)) {
262158
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchPositions requires a list of symbols');
262159
- }
262160
262551
  await this.loadMarkets();
262161
262552
  await this.authenticate(params);
262162
262553
  symbols = this.marketSymbols(symbols);
@@ -262164,7 +262555,23 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
262164
262555
  'instType': 'ANY',
262165
262556
  };
262166
262557
  const channel = 'positions';
262167
- const newPositions = await this.subscribeMultiple('private', channel, symbols, this.extend(request, params));
262558
+ let newPositions = undefined;
262559
+ if (symbols === undefined) {
262560
+ const arg = {
262561
+ 'channel': 'positions',
262562
+ 'instType': 'ANY',
262563
+ };
262564
+ const args = [arg];
262565
+ const nonSymbolRequest = {
262566
+ 'op': 'subscribe',
262567
+ 'args': args,
262568
+ };
262569
+ const url = this.getUrl(channel, 'private');
262570
+ newPositions = await this.watch(url, channel, nonSymbolRequest, channel);
262571
+ }
262572
+ else {
262573
+ newPositions = await this.subscribeMultiple('private', channel, symbols, this.extend(request, params));
262574
+ }
262168
262575
  if (this.newUpdates) {
262169
262576
  return newPositions;
262170
262577
  }
@@ -262262,6 +262669,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
262262
262669
  client.resolve(positions, messageHash);
262263
262670
  }
262264
262671
  }
262672
+ client.resolve(newPositions, channel);
262265
262673
  }
262266
262674
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
262267
262675
  /**
@@ -292749,6 +293157,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
292749
293157
  'account': 'spot',
292750
293158
  },
292751
293159
  'accountsByType': {
293160
+ 'funding': 'main',
292752
293161
  'main': 'main',
292753
293162
  'spot': 'spot',
292754
293163
  'margin': 'collateral',
@@ -293842,9 +294251,9 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
293842
294251
  else {
293843
294252
  const options = this.safeValue(this.options, 'fetchBalance', {});
293844
294253
  const defaultAccount = this.safeString(options, 'account');
293845
- const account = this.safeString(params, 'account', defaultAccount);
293846
- params = this.omit(params, 'account');
293847
- if (account === 'main') {
294254
+ const account = this.safeString2(params, 'account', 'type', defaultAccount);
294255
+ params = this.omit(params, ['account', 'type']);
294256
+ if (account === 'main' || account === 'funding') {
293848
294257
  response = await this.v4PrivatePostMainAccountBalance(params);
293849
294258
  }
293850
294259
  else {
@@ -307206,7 +307615,7 @@ SOFTWARE.
307206
307615
 
307207
307616
  //-----------------------------------------------------------------------------
307208
307617
  // this is updated by vss.js when building
307209
- const version = '4.2.52';
307618
+ const version = '4.2.54';
307210
307619
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
307211
307620
  //-----------------------------------------------------------------------------
307212
307621