ccxt 4.1.67 → 4.1.69

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.
@@ -3887,7 +3887,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
3887
3887
  'account-category': 'cash',
3888
3888
  'account-group': undefined,
3889
3889
  'fetchClosedOrders': {
3890
- 'method': 'v2PrivateDataGetOrderHist', // 'v1PrivateAccountGroupGetAccountCategoryOrderHistCurrent'
3890
+ 'method': 'v2PrivateDataGetOrderHist', // 'v1PrivateAccountCategoryGetOrderHistCurrent'
3891
3891
  },
3892
3892
  'defaultType': 'spot',
3893
3893
  'accountsByType': {
@@ -4427,6 +4427,9 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
4427
4427
  * @method
4428
4428
  * @name ascendex#fetchBalance
4429
4429
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
4430
+ * @see https://ascendex.github.io/ascendex-pro-api/#cash-account-balance
4431
+ * @see https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
4432
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
4430
4433
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4431
4434
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
4432
4435
  */
@@ -4437,8 +4440,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
4437
4440
  [marketType, query] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
4438
4441
  const isMargin = this.safeValue(params, 'margin', false);
4439
4442
  marketType = isMargin ? 'margin' : marketType;
4440
- params = this.omit(params, 'margin');
4441
- const options = this.safeValue(this.options, 'fetchBalance', {});
4443
+ query = this.omit(query, 'margin');
4442
4444
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
4443
4445
  const accountCategory = this.safeString(accountsByType, marketType, 'cash');
4444
4446
  const account = this.safeValue(this.accounts, 0, {});
@@ -4446,16 +4448,19 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
4446
4448
  const request = {
4447
4449
  'account-group': accountGroup,
4448
4450
  };
4449
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetBalance');
4450
- const method = this.getSupportedMapping(marketType, {
4451
- 'spot': defaultMethod,
4452
- 'margin': defaultMethod,
4453
- 'swap': 'v2PrivateAccountGroupGetFuturesPosition',
4454
- });
4455
4451
  if ((accountCategory === 'cash') || (accountCategory === 'margin')) {
4456
4452
  request['account-category'] = accountCategory;
4457
4453
  }
4458
- const response = await this[method](this.extend(request, query));
4454
+ let response = undefined;
4455
+ if ((marketType === 'spot') || (marketType === 'margin')) {
4456
+ response = await this.v1PrivateAccountCategoryGetBalance(this.extend(request, query));
4457
+ }
4458
+ else if (marketType === 'swap') {
4459
+ response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, query));
4460
+ }
4461
+ else {
4462
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchBalance() is not currently supported for ' + marketType + ' markets');
4463
+ }
4459
4464
  //
4460
4465
  // cash
4461
4466
  //
@@ -5380,6 +5385,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5380
5385
  * @method
5381
5386
  * @name ascendex#fetchOrder
5382
5387
  * @description fetches information on an order made by the user
5388
+ * @see https://ascendex.github.io/ascendex-pro-api/#query-order
5389
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#query-order-by-id
5383
5390
  * @param {string} symbol unified symbol of the market the order was made in
5384
5391
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5385
5392
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -5391,7 +5398,6 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5391
5398
  market = this.market(symbol);
5392
5399
  }
5393
5400
  const [type, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
5394
- const options = this.safeValue(this.options, 'fetchOrder', {});
5395
5401
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
5396
5402
  const accountCategory = this.safeString(accountsByType, type, 'cash');
5397
5403
  const account = this.safeValue(this.accounts, 0, {});
@@ -5401,21 +5407,17 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5401
5407
  'account-category': accountCategory,
5402
5408
  'orderId': id,
5403
5409
  };
5404
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetOrderStatus');
5405
- const method = this.getSupportedMapping(type, {
5406
- 'spot': defaultMethod,
5407
- 'margin': defaultMethod,
5408
- 'swap': 'v2PrivateAccountGroupGetFuturesOrderStatus',
5409
- });
5410
- if (method === 'v1PrivateAccountCategoryGetOrderStatus') {
5411
- if (accountCategory !== undefined) {
5412
- request['category'] = accountCategory;
5413
- }
5410
+ let response = undefined;
5411
+ if ((type === 'spot') || (type === 'margin')) {
5412
+ response = await this.v1PrivateAccountCategoryGetOrderStatus(this.extend(request, query));
5414
5413
  }
5415
- else {
5414
+ else if (type === 'swap') {
5416
5415
  request['account-category'] = accountCategory;
5416
+ response = await this.v2PrivateAccountGroupGetFuturesOrderStatus(this.extend(request, query));
5417
+ }
5418
+ else {
5419
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrder() is not currently supported for ' + type + ' markets');
5417
5420
  }
5418
- const response = await this[method](this.extend(request, query));
5419
5421
  //
5420
5422
  // AccountCategoryGetOrderStatus
5421
5423
  //
@@ -5491,6 +5493,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5491
5493
  * @method
5492
5494
  * @name ascendex#fetchOpenOrders
5493
5495
  * @description fetch all unfilled currently open orders
5496
+ * @see https://ascendex.github.io/ascendex-pro-api/#list-open-orders
5497
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-open-orders
5494
5498
  * @param {string} symbol unified market symbol
5495
5499
  * @param {int} [since] the earliest time in ms to fetch open orders for
5496
5500
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -5513,22 +5517,17 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5513
5517
  'account-group': accountGroup,
5514
5518
  'account-category': accountCategory,
5515
5519
  };
5516
- const options = this.safeValue(this.options, 'fetchOpenOrders', {});
5517
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryGetOrderOpen');
5518
- const method = this.getSupportedMapping(type, {
5519
- 'spot': defaultMethod,
5520
- 'margin': defaultMethod,
5521
- 'swap': 'v2PrivateAccountGroupGetFuturesOrderOpen',
5522
- });
5523
- if (method === 'v1PrivateAccountCategoryGetOrderOpen') {
5524
- if (accountCategory !== undefined) {
5525
- request['category'] = accountCategory;
5526
- }
5520
+ let response = undefined;
5521
+ if ((type === 'spot') || (type === 'margin')) {
5522
+ response = await this.v1PrivateAccountCategoryGetOrderOpen(this.extend(request, query));
5527
5523
  }
5528
- else {
5524
+ else if (type === 'swap') {
5529
5525
  request['account-category'] = accountCategory;
5526
+ response = await this.v2PrivateAccountGroupGetFuturesOrderOpen(this.extend(request, query));
5527
+ }
5528
+ else {
5529
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOpenOrders() is not currently supported for ' + type + ' markets');
5530
5530
  }
5531
- const response = await this[method](this.extend(request, query));
5532
5531
  //
5533
5532
  // AccountCategoryGetOrderOpen
5534
5533
  //
@@ -5614,6 +5613,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5614
5613
  * @name ascendex#fetchClosedOrders
5615
5614
  * @description fetches information on multiple closed orders made by the user
5616
5615
  * @see https://ascendex.github.io/ascendex-pro-api/#list-history-orders-v2
5616
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
5617
5617
  * @param {string} symbol unified market symbol of the market orders were made in
5618
5618
  * @param {int} [since] the earliest time in ms to fetch orders for
5619
5619
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -5626,16 +5626,15 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5626
5626
  const account = this.safeValue(this.accounts, 0, {});
5627
5627
  const accountGroup = this.safeValue(account, 'id');
5628
5628
  const request = {
5629
- 'account-group': accountGroup,
5630
- // 'category': accountCategory,
5631
- // 'symbol': market['id'],
5632
- // 'orderType': 'market', // optional, string
5633
- // 'side': 'buy', // or 'sell', optional, case insensitive.
5634
- // 'status': 'Filled', // "Filled", "Canceled", or "Rejected"
5635
- // 'startTime': exchange.milliseconds (),
5636
- // 'endTime': exchange.milliseconds (),
5637
- // 'page': 1,
5638
- // 'pageSize': 100,
5629
+ // 'category': accountCategory,
5630
+ // 'symbol': market['id'],
5631
+ // 'orderType': 'market', // optional, string
5632
+ // 'side': 'buy', // or 'sell', optional, case insensitive.
5633
+ // 'status': 'Filled', // "Filled", "Canceled", or "Rejected"
5634
+ // 'startTime': exchange.milliseconds (),
5635
+ // 'endTime': exchange.milliseconds (),
5636
+ // 'page': 1,
5637
+ // 'pageSize': 100,
5639
5638
  };
5640
5639
  let market = undefined;
5641
5640
  if (symbol !== undefined) {
@@ -5650,28 +5649,42 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5650
5649
  'margin': defaultMethod,
5651
5650
  'swap': 'v2PrivateAccountGroupGetFuturesOrderHistCurrent',
5652
5651
  });
5652
+ if (since !== undefined) {
5653
+ request['startTime'] = since;
5654
+ }
5655
+ const until = this.safeString(params, 'until');
5656
+ if (until !== undefined) {
5657
+ request['endTime'] = until;
5658
+ }
5653
5659
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
5654
5660
  const accountCategory = this.safeString(accountsByType, type, 'cash'); // margin, futures
5655
- if (method === 'v2PrivateDataGetOrderHist') {
5661
+ let response = undefined;
5662
+ if (method === 'v1PrivateAccountCategoryGetOrderHistCurrent') {
5663
+ request['account-group'] = accountGroup;
5664
+ request['account-category'] = accountCategory;
5665
+ if (limit !== undefined) {
5666
+ request['limit'] = limit;
5667
+ }
5668
+ response = await this.v1PrivateAccountCategoryGetOrderHistCurrent(this.extend(request, query));
5669
+ }
5670
+ else if (method === 'v2PrivateDataGetOrderHist') {
5656
5671
  request['account'] = accountCategory;
5657
5672
  if (limit !== undefined) {
5658
5673
  request['limit'] = limit;
5659
5674
  }
5675
+ response = await this.v2PrivateDataGetOrderHist(this.extend(request, query));
5660
5676
  }
5661
- else {
5677
+ else if (method === 'v2PrivateAccountGroupGetFuturesOrderHistCurrent') {
5678
+ request['account-group'] = accountGroup;
5662
5679
  request['account-category'] = accountCategory;
5663
5680
  if (limit !== undefined) {
5664
5681
  request['pageSize'] = limit;
5665
5682
  }
5683
+ response = await this.v2PrivateAccountGroupGetFuturesOrderHistCurrent(this.extend(request, query));
5666
5684
  }
5667
- if (since !== undefined) {
5668
- request['startTime'] = since;
5669
- }
5670
- const until = this.safeString(params, 'until');
5671
- if (until !== undefined) {
5672
- request['endTime'] = until;
5685
+ else {
5686
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchClosedOrders() is not currently supported for ' + type + ' markets');
5673
5687
  }
5674
- const response = await this[method](this.extend(request, query));
5675
5688
  //
5676
5689
  // accountCategoryGetOrderHistCurrent
5677
5690
  //
@@ -5775,6 +5788,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5775
5788
  * @method
5776
5789
  * @name ascendex#cancelOrder
5777
5790
  * @description cancels an open order
5791
+ * @see https://ascendex.github.io/ascendex-pro-api/#cancel-order
5792
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-order
5778
5793
  * @param {string} id order id
5779
5794
  * @param {string} symbol unified symbol of the market the order was made in
5780
5795
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -5787,7 +5802,6 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5787
5802
  await this.loadAccounts();
5788
5803
  const market = this.market(symbol);
5789
5804
  const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
5790
- const options = this.safeValue(this.options, 'cancelOrder', {});
5791
5805
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
5792
5806
  const accountCategory = this.safeString(accountsByType, type, 'cash');
5793
5807
  const account = this.safeValue(this.accounts, 0, {});
@@ -5799,20 +5813,6 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5799
5813
  'time': this.milliseconds(),
5800
5814
  'id': 'foobar',
5801
5815
  };
5802
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryDeleteOrder');
5803
- const method = this.getSupportedMapping(type, {
5804
- 'spot': defaultMethod,
5805
- 'margin': defaultMethod,
5806
- 'swap': 'v2PrivateAccountGroupDeleteFuturesOrder',
5807
- });
5808
- if (method === 'v1PrivateAccountCategoryDeleteOrder') {
5809
- if (accountCategory !== undefined) {
5810
- request['category'] = accountCategory;
5811
- }
5812
- }
5813
- else {
5814
- request['account-category'] = accountCategory;
5815
- }
5816
5816
  const clientOrderId = this.safeString2(params, 'clientOrderId', 'id');
5817
5817
  if (clientOrderId === undefined) {
5818
5818
  request['orderId'] = id;
@@ -5821,7 +5821,17 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5821
5821
  request['id'] = clientOrderId;
5822
5822
  params = this.omit(params, ['clientOrderId', 'id']);
5823
5823
  }
5824
- const response = await this[method](this.extend(request, query));
5824
+ let response = undefined;
5825
+ if ((type === 'spot') || (type === 'margin')) {
5826
+ response = await this.v1PrivateAccountCategoryDeleteOrder(this.extend(request, query));
5827
+ }
5828
+ else if (type === 'swap') {
5829
+ request['account-category'] = accountCategory;
5830
+ response = await this.v2PrivateAccountGroupDeleteFuturesOrder(this.extend(request, query));
5831
+ }
5832
+ else {
5833
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelOrder() is not currently supported for ' + type + ' markets');
5834
+ }
5825
5835
  //
5826
5836
  // AccountCategoryDeleteOrder
5827
5837
  //
@@ -5894,6 +5904,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5894
5904
  * @method
5895
5905
  * @name ascendex#cancelAllOrders
5896
5906
  * @description cancel all open orders
5907
+ * @see https://ascendex.github.io/ascendex-pro-api/#cancel-all-orders
5908
+ * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-all-open-orders
5897
5909
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
5898
5910
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5899
5911
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -5905,7 +5917,6 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5905
5917
  market = this.market(symbol);
5906
5918
  }
5907
5919
  const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
5908
- const options = this.safeValue(this.options, 'cancelAllOrders', {});
5909
5920
  const accountsByType = this.safeValue(this.options, 'accountsByType', {});
5910
5921
  const accountCategory = this.safeString(accountsByType, type, 'cash');
5911
5922
  const account = this.safeValue(this.accounts, 0, {});
@@ -5918,21 +5929,17 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5918
5929
  if (symbol !== undefined) {
5919
5930
  request['symbol'] = market['id'];
5920
5931
  }
5921
- const defaultMethod = this.safeString(options, 'method', 'v1PrivateAccountCategoryDeleteOrderAll');
5922
- const method = this.getSupportedMapping(type, {
5923
- 'spot': defaultMethod,
5924
- 'margin': defaultMethod,
5925
- 'swap': 'v2PrivateAccountGroupDeleteFuturesOrderAll',
5926
- });
5927
- if (method === 'v1PrivateAccountCategoryDeleteOrderAll') {
5928
- if (accountCategory !== undefined) {
5929
- request['category'] = accountCategory;
5930
- }
5932
+ let response = undefined;
5933
+ if ((type === 'spot') || (type === 'margin')) {
5934
+ response = await this.v1PrivateAccountCategoryDeleteOrderAll(this.extend(request, query));
5931
5935
  }
5932
- else {
5936
+ else if (type === 'swap') {
5933
5937
  request['account-category'] = accountCategory;
5938
+ response = await this.v2PrivateAccountGroupDeleteFuturesOrderAll(this.extend(request, query));
5939
+ }
5940
+ else {
5941
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelAllOrders() is not currently supported for ' + type + ' markets');
5934
5942
  }
5935
- const response = await this[method](this.extend(request, query));
5936
5943
  //
5937
5944
  // AccountCategoryDeleteOrderAll
5938
5945
  //
@@ -9505,7 +9512,7 @@ class Exchange {
9505
9512
  'bidVolume': this.safeNumber(ticker, 'bidVolume'),
9506
9513
  'ask': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'ask'))),
9507
9514
  'askVolume': this.safeNumber(ticker, 'askVolume'),
9508
- 'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high"'))),
9515
+ 'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high'))),
9509
9516
  'low': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'low'))),
9510
9517
  'open': this.parseNumber(this.omitZero(this.parseNumber(open))),
9511
9518
  'close': this.parseNumber(this.omitZero(this.parseNumber(close))),
@@ -10174,7 +10181,7 @@ class Exchange {
10174
10181
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' watchPositions() is not supported yet');
10175
10182
  }
10176
10183
  async watchPositionForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
10177
- return this.watchPositions(symbols, since, limit, params);
10184
+ return await this.watchPositions(symbols, since, limit, params);
10178
10185
  }
10179
10186
  async fetchPositionsForSymbol(symbol, params = {}) {
10180
10187
  /**
@@ -77984,8 +77991,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
77984
77991
  }
77985
77992
  const request = {
77986
77993
  // 'symbol': market['id'],
77987
- // 'baseCoin': '', Base coin. For option only
77988
- // 'expDate': '', Expiry date. e.g., 25DEC22. For option only
77994
+ // 'baseCoin': '', // Base coin. For option only
77995
+ // 'expDate': '', // Expiry date. e.g., 25DEC22. For option only
77989
77996
  };
77990
77997
  let type = undefined;
77991
77998
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
@@ -121955,8 +121962,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
121955
121962
  'AXIS': 'Axis DeFi',
121956
121963
  'BIFI': 'Bitcoin File',
121957
121964
  'BOX': 'DefiBox',
121958
- 'BTCBEAR': 'BEAR',
121959
- 'BTCBULL': 'BULL',
121960
121965
  'BYN': 'BeyondFi',
121961
121966
  'EGG': 'Goose Finance',
121962
121967
  'GTC': 'Game.com',
@@ -122252,6 +122257,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
122252
122257
  'AUTO_TRIGGER_PRICE_LESS_LAST': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
122253
122258
  'AUTO_TRIGGER_PRICE_GREATE_LAST': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
122254
122259
  'POSITION_HOLDING': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
122260
+ 'USER_LOAN_EXCEEDED': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, // {"label":"USER_LOAN_EXCEEDED","message":"Max loan amount per user would be exceeded"}
122255
122261
  },
122256
122262
  'broad': {},
122257
122263
  },
@@ -126971,6 +126977,216 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
126971
126977
  }
126972
126978
  return tiers;
126973
126979
  }
126980
+ async repayMargin(code, amount, symbol = undefined, params = {}) {
126981
+ /**
126982
+ * @method
126983
+ * @name gate#repayMargin
126984
+ * @description repay borrowed margin and interest
126985
+ * @see https://www.gate.io/docs/apiv4/en/#repay-cross-margin-loan
126986
+ * @see https://www.gate.io/docs/apiv4/en/#repay-a-loan
126987
+ * @param {string} code unified currency code of the currency to repay
126988
+ * @param {float} amount the amount to repay
126989
+ * @param {string} symbol unified market symbol, required for isolated margin
126990
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
126991
+ * @param {string} [params.mode] 'all' or 'partial' payment mode, extra parameter required for isolated margin
126992
+ * @param {string} [params.id] '34267567' loan id, extra parameter required for isolated margin
126993
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
126994
+ */
126995
+ let marginMode = undefined;
126996
+ [marginMode, params] = this.handleOptionAndParams(params, 'repayMargin', 'marginMode');
126997
+ this.checkRequiredArgument('repayMargin', marginMode, 'marginMode', ['cross', 'isolated']);
126998
+ this.checkRequiredMarginArgument('repayMargin', symbol, marginMode);
126999
+ await this.loadMarkets();
127000
+ const currency = this.currency(code);
127001
+ const request = {
127002
+ 'currency': currency['id'].toUpperCase(),
127003
+ 'amount': this.currencyToPrecision(code, amount),
127004
+ };
127005
+ let response = undefined;
127006
+ if ((marginMode === 'cross') && (symbol === undefined)) {
127007
+ response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
127008
+ }
127009
+ else if ((marginMode === 'isolated') || (symbol !== undefined)) {
127010
+ if (symbol === undefined) {
127011
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' repayMargin() requires a symbol argument for isolated margin');
127012
+ }
127013
+ const market = this.market(symbol);
127014
+ request['currency_pair'] = market['id'];
127015
+ request['type'] = 'repay';
127016
+ response = await this.privateMarginPostUniLoans(this.extend(request, params));
127017
+ }
127018
+ //
127019
+ // Cross
127020
+ //
127021
+ // [
127022
+ // {
127023
+ // "id": "17",
127024
+ // "create_time": 1620381696159,
127025
+ // "update_time": 1620381696159,
127026
+ // "currency": "EOS",
127027
+ // "amount": "110.553635",
127028
+ // "text": "web",
127029
+ // "status": 2,
127030
+ // "repaid": "110.506649705159",
127031
+ // "repaid_interest": "0.046985294841",
127032
+ // "unpaid_interest": "0.0000074393366667"
127033
+ // }
127034
+ // ]
127035
+ //
127036
+ // Isolated
127037
+ //
127038
+ // {
127039
+ // "id": "34267567",
127040
+ // "create_time": "1656394778",
127041
+ // "expire_time": "1657258778",
127042
+ // "status": "finished",
127043
+ // "side": "borrow",
127044
+ // "currency": "USDT",
127045
+ // "rate": "0.0002",
127046
+ // "amount": "100",
127047
+ // "days": 10,
127048
+ // "auto_renew": false,
127049
+ // "currency_pair": "LTC_USDT",
127050
+ // "left": "0",
127051
+ // "repaid": "100",
127052
+ // "paid_interest": "0.003333333333",
127053
+ // "unpaid_interest": "0"
127054
+ // }
127055
+ //
127056
+ if (marginMode === 'cross') {
127057
+ response = response[0];
127058
+ }
127059
+ return this.parseMarginLoan(response, currency);
127060
+ }
127061
+ async borrowMargin(code, amount, symbol = undefined, params = {}) {
127062
+ /**
127063
+ * @method
127064
+ * @name gate#borrowMargin
127065
+ * @description create a loan to borrow margin
127066
+ * @see https://www.gate.io/docs/apiv4/en/#create-a-cross-margin-borrow-loan
127067
+ * @see https://www.gate.io/docs/developers/apiv4/en/#marginuni
127068
+ * @param {string} code unified currency code of the currency to borrow
127069
+ * @param {float} amount the amount to borrow
127070
+ * @param {string} symbol unified market symbol, required for isolated margin
127071
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
127072
+ * @param {string} [params.rate] '0.0002' or '0.002' extra parameter required for isolated margin
127073
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
127074
+ */
127075
+ let marginMode = undefined;
127076
+ [marginMode, params] = this.handleOptionAndParams(params, 'borrowMargin', 'marginMode');
127077
+ this.checkRequiredArgument('borrowMargin', marginMode, 'marginMode', ['cross', 'isolated']);
127078
+ this.checkRequiredMarginArgument('borrowMargin', symbol, marginMode);
127079
+ await this.loadMarkets();
127080
+ const currency = this.currency(code);
127081
+ const request = {
127082
+ 'currency': currency['id'].toUpperCase(),
127083
+ 'amount': this.currencyToPrecision(code, amount),
127084
+ };
127085
+ let response = undefined;
127086
+ if ((marginMode === 'cross') && (symbol === undefined)) {
127087
+ response = await this.privateMarginPostCrossLoans(this.extend(request, params));
127088
+ }
127089
+ else if ((marginMode === 'isolated') || (symbol !== undefined)) {
127090
+ if (symbol === undefined) {
127091
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' borrowMargin() requires a symbol argument for isolated margin');
127092
+ }
127093
+ const market = this.market(symbol);
127094
+ request['currency_pair'] = market['id'];
127095
+ request['type'] = 'borrow';
127096
+ response = await this.privateMarginPostUniLoans(this.extend(request, params));
127097
+ }
127098
+ //
127099
+ // Cross
127100
+ //
127101
+ // {
127102
+ // "id": "17",
127103
+ // "create_time": 1620381696159,
127104
+ // "update_time": 1620381696159,
127105
+ // "currency": "EOS",
127106
+ // "amount": "110.553635",
127107
+ // "text": "web",
127108
+ // "status": 2,
127109
+ // "repaid": "110.506649705159",
127110
+ // "repaid_interest": "0.046985294841",
127111
+ // "unpaid_interest": "0.0000074393366667"
127112
+ // }
127113
+ //
127114
+ // Isolated
127115
+ //
127116
+ // {
127117
+ // "id": "34267567",
127118
+ // "create_time": "1656394778",
127119
+ // "expire_time": "1657258778",
127120
+ // "status": "loaned",
127121
+ // "side": "borrow",
127122
+ // "currency": "USDT",
127123
+ // "rate": "0.0002",
127124
+ // "amount": "100",
127125
+ // "days": 10,
127126
+ // "auto_renew": false,
127127
+ // "currency_pair": "LTC_USDT",
127128
+ // "left": "0",
127129
+ // "repaid": "0",
127130
+ // "paid_interest": "0",
127131
+ // "unpaid_interest": "0.003333333333"
127132
+ // }
127133
+ //
127134
+ return this.parseMarginLoan(response, currency);
127135
+ }
127136
+ parseMarginLoan(info, currency = undefined) {
127137
+ //
127138
+ // Cross
127139
+ //
127140
+ // {
127141
+ // "id": "17",
127142
+ // "create_time": 1620381696159,
127143
+ // "update_time": 1620381696159,
127144
+ // "currency": "EOS",
127145
+ // "amount": "110.553635",
127146
+ // "text": "web",
127147
+ // "status": 2,
127148
+ // "repaid": "110.506649705159",
127149
+ // "repaid_interest": "0.046985294841",
127150
+ // "unpaid_interest": "0.0000074393366667"
127151
+ // }
127152
+ //
127153
+ // Isolated
127154
+ //
127155
+ // {
127156
+ // "id": "34267567",
127157
+ // "create_time": "1656394778",
127158
+ // "expire_time": "1657258778",
127159
+ // "status": "loaned",
127160
+ // "side": "borrow",
127161
+ // "currency": "USDT",
127162
+ // "rate": "0.0002",
127163
+ // "amount": "100",
127164
+ // "days": 10,
127165
+ // "auto_renew": false,
127166
+ // "currency_pair": "LTC_USDT",
127167
+ // "left": "0",
127168
+ // "repaid": "0",
127169
+ // "paid_interest": "0",
127170
+ // "unpaid_interest": "0.003333333333"
127171
+ // }
127172
+ //
127173
+ const marginMode = this.safeString2(this.options, 'defaultMarginMode', 'marginMode', 'cross');
127174
+ let timestamp = this.safeInteger(info, 'create_time');
127175
+ if (marginMode === 'isolated') {
127176
+ timestamp = this.safeTimestamp(info, 'create_time');
127177
+ }
127178
+ const currencyId = this.safeString(info, 'currency');
127179
+ const marketId = this.safeString(info, 'currency_pair');
127180
+ return {
127181
+ 'id': this.safeInteger(info, 'id'),
127182
+ 'currency': this.safeCurrencyCode(currencyId, currency),
127183
+ 'amount': this.safeNumber(info, 'amount'),
127184
+ 'symbol': this.safeSymbol(marketId, undefined, '_', 'margin'),
127185
+ 'timestamp': timestamp,
127186
+ 'datetime': this.iso8601(timestamp),
127187
+ 'info': info,
127188
+ };
127189
+ }
126974
127190
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
126975
127191
  const authentication = api[0]; // public, private
126976
127192
  const type = api[1]; // spot, margin, future, delivery
@@ -193657,6 +193873,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
193657
193873
  },
193658
193874
  'v1': {
193659
193875
  'get': {
193876
+ 'md/fullbook': 5,
193660
193877
  'md/orderbook': 5,
193661
193878
  'md/trade': 5,
193662
193879
  'md/ticker/24hr': 5,
@@ -193710,6 +193927,11 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
193710
193927
  'phemex-user/users/children': 5,
193711
193928
  'phemex-user/wallets/v2/depositAddress': 5,
193712
193929
  'phemex-user/wallets/tradeAccountDetail': 5,
193930
+ 'phemex-deposit/wallets/api/depositAddress': 5,
193931
+ 'phemex-deposit/wallets/api/depositHist': 5,
193932
+ 'phemex-deposit/wallets/api/chainCfg': 5,
193933
+ 'phemex-withdraw/wallets/api/withdrawHist': 5,
193934
+ 'phemex-withdraw/wallets/api/asset/info': 5,
193713
193935
  'phemex-user/order/closedPositionList': 5,
193714
193936
  'exchange/margins/transfer': 5,
193715
193937
  'exchange/wallets/confirm/withdraw': 5,
@@ -193748,6 +193970,9 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
193748
193970
  'assets/futures/sub-accounts/transfer': 5,
193749
193971
  'assets/universal-transfer': 5,
193750
193972
  'assets/convert': 5,
193973
+ // withdraw
193974
+ 'phemex-withdraw/wallets/api/createWithdraw': 5,
193975
+ 'phemex-withdraw/wallets/api/cancelWithdraw': 5, // ?id=<id>
193751
193976
  },
193752
193977
  'put': {
193753
193978
  // spot
@@ -194504,7 +194729,12 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
194504
194729
  response = await this.v2GetMdV2Orderbook(this.extend(request, params));
194505
194730
  }
194506
194731
  else {
194507
- response = await this.v1GetMdOrderbook(this.extend(request, params));
194732
+ if ((limit !== undefined) && (limit <= 30)) {
194733
+ response = await this.v1GetMdOrderbook(this.extend(request, params));
194734
+ }
194735
+ else {
194736
+ response = await this.v1GetMdFullbook(this.extend(request, params));
194737
+ }
194508
194738
  }
194509
194739
  //
194510
194740
  // {
@@ -204611,7 +204841,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
204611
204841
  handleTrade(client, message) {
204612
204842
  // the trade streams push raw trade information in real-time
204613
204843
  // each trade has a unique buyer and seller
204614
- const isSpot = ((client.url.indexOf('/stream') > -1) || (client.url.indexOf('/testnet.binance') > -1));
204844
+ const isSpot = ((client.url.indexOf('wss://stream.binance.com') > -1) || (client.url.indexOf('/testnet.binance') > -1));
204615
204845
  const marketType = (isSpot) ? 'spot' : 'contract';
204616
204846
  const marketId = this.safeString(message, 's');
204617
204847
  const market = this.safeMarket(marketId, undefined, undefined, marketType);
@@ -231763,9 +231993,11 @@ class htx extends _htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
231763
231993
  // which means whenever there is an order book change at that level, it pushes an update;
231764
231994
  // 150-levels/400-level incremental MBP feed is based on the gap
231765
231995
  // between two snapshots at 100ms interval.
231766
- limit = (limit === undefined) ? 20 : limit;
231996
+ if (limit === undefined) {
231997
+ limit = market['spot'] ? 150 : 20;
231998
+ }
231767
231999
  if (!this.inArray(limit, allowedLimits)) {
231768
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' watchOrderBook swap market accepts limits of 20 and 150 only');
232000
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' watchOrderBook market accepts limits of 20 and 150 only');
231769
232001
  }
231770
232002
  let messageHash = undefined;
231771
232003
  if (market['spot']) {
@@ -287753,7 +287985,7 @@ SOFTWARE.
287753
287985
 
287754
287986
  //-----------------------------------------------------------------------------
287755
287987
  // this is updated by vss.js when building
287756
- const version = '4.1.67';
287988
+ const version = '4.1.69';
287757
287989
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
287758
287990
  //-----------------------------------------------------------------------------
287759
287991