ccxt 4.2.44 → 4.2.45

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.
package/dist/cjs/ccxt.js CHANGED
@@ -177,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
177
177
 
178
178
  //-----------------------------------------------------------------------------
179
179
  // this is updated by vss.js when building
180
- const version = '4.2.44';
180
+ const version = '4.2.45';
181
181
  Exchange["default"].ccxtVersion = version;
182
182
  const exchanges = {
183
183
  'ace': ace,
@@ -71,6 +71,7 @@ class Exchange {
71
71
  this.balance = {};
72
72
  this.orderbooks = {};
73
73
  this.tickers = {};
74
+ this.bidsasks = {};
74
75
  this.orders = undefined;
75
76
  this.triggerOrders = undefined;
76
77
  this.transactions = {};
@@ -3430,12 +3431,46 @@ class Exchange {
3430
3431
  const market = this.market(symbol);
3431
3432
  return this.safeString(market, 'symbol', symbol);
3432
3433
  }
3434
+ handleParamString(params, paramName, defaultValue = undefined) {
3435
+ const value = this.safeString(params, paramName, defaultValue);
3436
+ if (value !== undefined) {
3437
+ params = this.omit(params, paramName);
3438
+ }
3439
+ return [value, params];
3440
+ }
3433
3441
  resolvePath(path, params) {
3434
3442
  return [
3435
3443
  this.implodeParams(path, params),
3436
3444
  this.omit(params, this.extractParams(path)),
3437
3445
  ];
3438
3446
  }
3447
+ getListFromObjectValues(objects, key) {
3448
+ const newArray = this.toArray(objects);
3449
+ const results = [];
3450
+ for (let i = 0; i < newArray.length; i++) {
3451
+ results.push(newArray[i][key]);
3452
+ }
3453
+ return results;
3454
+ }
3455
+ getSymbolsForMarketType(marketType = undefined, subType = undefined, symbolWithActiveStatus = true, symbolWithUnknownStatus = true) {
3456
+ let filteredMarkets = this.markets;
3457
+ if (marketType !== undefined) {
3458
+ filteredMarkets = this.filterBy(filteredMarkets, 'type', marketType);
3459
+ }
3460
+ if (subType !== undefined) {
3461
+ this.checkRequiredArgument('getSymbolsForMarketType', subType, 'subType', ['linear', 'inverse', 'quanto']);
3462
+ filteredMarkets = this.filterBy(filteredMarkets, 'subType', subType);
3463
+ }
3464
+ const activeStatuses = [];
3465
+ if (symbolWithActiveStatus) {
3466
+ activeStatuses.push(true);
3467
+ }
3468
+ if (symbolWithUnknownStatus) {
3469
+ activeStatuses.push(undefined);
3470
+ }
3471
+ filteredMarkets = this.filterByArray(filteredMarkets, 'active', activeStatuses, false);
3472
+ return this.getListFromObjectValues(filteredMarkets, 'symbol');
3473
+ }
3439
3474
  filterByArray(objects, key, values = undefined, indexed = true) {
3440
3475
  objects = this.toArray(objects);
3441
3476
  // return all of them if no values were passed
@@ -4361,6 +4396,19 @@ class Exchange {
4361
4396
  return depositAddress;
4362
4397
  }
4363
4398
  }
4399
+ else if (this.has['fetchDepositAddressesByNetwork']) {
4400
+ const network = this.safeString(params, 'network');
4401
+ params = this.omit(params, 'network');
4402
+ const addressStructures = await this.fetchDepositAddressesByNetwork(code, params);
4403
+ if (network !== undefined) {
4404
+ return this.safeDict(addressStructures, network);
4405
+ }
4406
+ else {
4407
+ const keys = Object.keys(addressStructures);
4408
+ const key = this.safeString(keys, 0);
4409
+ return this.safeDict(addressStructures, key);
4410
+ }
4411
+ }
4364
4412
  else {
4365
4413
  throw new errors.NotSupported(this.id + ' fetchDepositAddress() is not supported yet');
4366
4414
  }
@@ -99,7 +99,7 @@ class binance extends binance$1 {
99
99
  'fetchOHLCV': true,
100
100
  'fetchOpenInterest': true,
101
101
  'fetchOpenInterestHistory': true,
102
- 'fetchOpenOrder': false,
102
+ 'fetchOpenOrder': true,
103
103
  'fetchOpenOrders': true,
104
104
  'fetchOrder': true,
105
105
  'fetchOrderBook': true,
@@ -5168,7 +5168,7 @@ class binance extends binance$1 {
5168
5168
  // "status": "NEW"
5169
5169
  // }
5170
5170
  //
5171
- // createOrder, fetchOpenOrders: portfolio margin linear swap and future conditional
5171
+ // createOrder, fetchOpenOrders, fetchOpenOrder: portfolio margin linear swap and future conditional
5172
5172
  //
5173
5173
  // {
5174
5174
  // "newClientStrategyId": "x-xcKtGhcu27f109953d6e4dc0974006",
@@ -5307,6 +5307,130 @@ class binance extends binance$1 {
5307
5307
  // "selfTradePreventionMode": "NONE"
5308
5308
  // }
5309
5309
  //
5310
+ // fetchOpenOrder: linear swap
5311
+ //
5312
+ // {
5313
+ // "orderId": 3697213934,
5314
+ // "symbol": "BTCUSDT",
5315
+ // "status": "NEW",
5316
+ // "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
5317
+ // "price": "33000.00",
5318
+ // "avgPrice": "0.00000",
5319
+ // "origQty": "0.010",
5320
+ // "executedQty": "0.000",
5321
+ // "cumQuote": "0.00000",
5322
+ // "timeInForce": "GTC",
5323
+ // "type": "LIMIT",
5324
+ // "reduceOnly": false,
5325
+ // "closePosition": false,
5326
+ // "side": "BUY",
5327
+ // "positionSide": "BOTH",
5328
+ // "stopPrice": "0.00",
5329
+ // "workingType": "CONTRACT_PRICE",
5330
+ // "priceProtect": false,
5331
+ // "origType": "LIMIT",
5332
+ // "priceMatch": "NONE",
5333
+ // "selfTradePreventionMode": "NONE",
5334
+ // "goodTillDate": 0,
5335
+ // "time": 1707892893502,
5336
+ // "updateTime": 1707892893515
5337
+ // }
5338
+ //
5339
+ // fetchOpenOrder: inverse swap
5340
+ //
5341
+ // {
5342
+ // "orderId": 597368542,
5343
+ // "symbol": "BTCUSD_PERP",
5344
+ // "pair": "BTCUSD",
5345
+ // "status": "NEW",
5346
+ // "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
5347
+ // "price": "35000",
5348
+ // "avgPrice": "0",
5349
+ // "origQty": "1",
5350
+ // "executedQty": "0",
5351
+ // "cumBase": "0",
5352
+ // "timeInForce": "GTC",
5353
+ // "type": "LIMIT",
5354
+ // "reduceOnly": false,
5355
+ // "closePosition": false,
5356
+ // "side": "BUY",
5357
+ // "positionSide": "BOTH",
5358
+ // "stopPrice": "0",
5359
+ // "workingType": "CONTRACT_PRICE",
5360
+ // "priceProtect": false,
5361
+ // "origType": "LIMIT",
5362
+ // "time": 1707893453199,
5363
+ // "updateTime": 1707893453199
5364
+ // }
5365
+ //
5366
+ // fetchOpenOrder: linear portfolio margin
5367
+ //
5368
+ // {
5369
+ // "orderId": 264895013409,
5370
+ // "symbol": "BTCUSDT",
5371
+ // "status": "NEW",
5372
+ // "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
5373
+ // "price": "35000",
5374
+ // "avgPrice": "0",
5375
+ // "origQty": "0.010",
5376
+ // "executedQty": "0",
5377
+ // "cumQuote": "0",
5378
+ // "timeInForce": "GTC",
5379
+ // "type": "LIMIT",
5380
+ // "reduceOnly": false,
5381
+ // "side": "BUY",
5382
+ // "positionSide": "LONG",
5383
+ // "origType": "LIMIT",
5384
+ // "time": 1707893839364,
5385
+ // "updateTime": 1707893839364,
5386
+ // "goodTillDate": 0,
5387
+ // "selfTradePreventionMode": "NONE"
5388
+ // }
5389
+ //
5390
+ // fetchOpenOrder: inverse portfolio margin
5391
+ //
5392
+ // {
5393
+ // "orderId": 71790316950,
5394
+ // "symbol": "ETHUSD_PERP",
5395
+ // "pair": "ETHUSD",
5396
+ // "status": "NEW",
5397
+ // "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
5398
+ // "price": "2500",
5399
+ // "avgPrice": "0",
5400
+ // "origQty": "1",
5401
+ // "executedQty": "0",
5402
+ // "cumBase": "0",
5403
+ // "timeInForce": "GTC",
5404
+ // "type": "LIMIT",
5405
+ // "reduceOnly": false,
5406
+ // "side": "BUY",
5407
+ // "positionSide": "LONG",
5408
+ // "origType": "LIMIT",
5409
+ // "time": 1707894181694,
5410
+ // "updateTime": 1707894181694
5411
+ // }
5412
+ //
5413
+ // fetchOpenOrder: inverse portfolio margin conditional
5414
+ //
5415
+ // {
5416
+ // "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
5417
+ // "strategyId": 1423501,
5418
+ // "strategyStatus": "NEW",
5419
+ // "strategyType": "STOP",
5420
+ // "origQty": "1",
5421
+ // "price": "2500",
5422
+ // "reduceOnly": false,
5423
+ // "side": "BUY",
5424
+ // "positionSide": "LONG",
5425
+ // "stopPrice": "4000",
5426
+ // "symbol": "ETHUSD_PERP",
5427
+ // "bookTime": 1707894782679,
5428
+ // "updateTime": 1707894782679,
5429
+ // "timeInForce": "GTC",
5430
+ // "workingType": "CONTRACT_PRICE",
5431
+ // "priceProtect": false
5432
+ // }
5433
+ //
5310
5434
  const code = this.safeString(order, 'code');
5311
5435
  if (code !== undefined) {
5312
5436
  // cancelOrders/createOrders might have a partial success
@@ -6306,7 +6430,7 @@ class binance extends binance$1 {
6306
6430
  [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
6307
6431
  let isPortfolioMargin = undefined;
6308
6432
  [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOpenOrders', 'papi', 'portfolioMargin', false);
6309
- const isConditional = this.safeBool2(params, 'stop', 'conditional');
6433
+ const isConditional = this.safeBoolN(params, ['stop', 'conditional', 'trigger']);
6310
6434
  if (symbol !== undefined) {
6311
6435
  market = this.market(symbol);
6312
6436
  request['symbol'] = market['id'];
@@ -6326,7 +6450,7 @@ class binance extends binance$1 {
6326
6450
  }
6327
6451
  let subType = undefined;
6328
6452
  [subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
6329
- params = this.omit(params, ['type', 'stop', 'conditional']);
6453
+ params = this.omit(params, ['type', 'stop', 'conditional', 'trigger']);
6330
6454
  let response = undefined;
6331
6455
  if (type === 'option') {
6332
6456
  if (since !== undefined) {
@@ -6382,6 +6506,223 @@ class binance extends binance$1 {
6382
6506
  }
6383
6507
  return this.parseOrders(response, market, since, limit);
6384
6508
  }
6509
+ async fetchOpenOrder(id, symbol = undefined, params = {}) {
6510
+ /**
6511
+ * @method
6512
+ * @name binance#fetchOpenOrder
6513
+ * @description fetch an open order by the id
6514
+ * @see https://binance-docs.github.io/apidocs/futures/en/#query-current-open-order-user_data
6515
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#query-current-open-order-user_data
6516
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-order-user_data
6517
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-order-user_data
6518
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-conditional-order-user_data
6519
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-conditional-order-user_data
6520
+ * @param {string} id order id
6521
+ * @param {string} symbol unified market symbol
6522
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6523
+ * @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
6524
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
6525
+ */
6526
+ if (symbol === undefined) {
6527
+ throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrder() requires a symbol argument');
6528
+ }
6529
+ await this.loadMarkets();
6530
+ const market = this.market(symbol);
6531
+ const request = {
6532
+ 'symbol': market['id'],
6533
+ };
6534
+ let isPortfolioMargin = undefined;
6535
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOpenOrder', 'papi', 'portfolioMargin', false);
6536
+ const isConditional = this.safeBoolN(params, ['stop', 'conditional', 'trigger']);
6537
+ params = this.omit(params, ['stop', 'conditional', 'trigger']);
6538
+ const isPortfolioMarginConditional = (isPortfolioMargin && isConditional);
6539
+ const orderIdRequest = isPortfolioMarginConditional ? 'strategyId' : 'orderId';
6540
+ request[orderIdRequest] = id;
6541
+ let response = undefined;
6542
+ if (market['linear']) {
6543
+ if (isPortfolioMargin) {
6544
+ if (isConditional) {
6545
+ response = await this.papiGetUmConditionalOpenOrder(this.extend(request, params));
6546
+ }
6547
+ else {
6548
+ response = await this.papiGetUmOpenOrder(this.extend(request, params));
6549
+ }
6550
+ }
6551
+ else {
6552
+ response = await this.fapiPrivateGetOpenOrder(this.extend(request, params));
6553
+ }
6554
+ }
6555
+ else if (market['inverse']) {
6556
+ if (isPortfolioMargin) {
6557
+ if (isConditional) {
6558
+ response = await this.papiGetCmConditionalOpenOrder(this.extend(request, params));
6559
+ }
6560
+ else {
6561
+ response = await this.papiGetCmOpenOrder(this.extend(request, params));
6562
+ }
6563
+ }
6564
+ else {
6565
+ response = await this.dapiPrivateGetOpenOrder(this.extend(request, params));
6566
+ }
6567
+ }
6568
+ else {
6569
+ if (market['option']) {
6570
+ throw new errors.NotSupported(this.id + ' fetchOpenOrder() does not support option markets');
6571
+ }
6572
+ else if (market['spot']) {
6573
+ throw new errors.NotSupported(this.id + ' fetchOpenOrder() does not support spot markets');
6574
+ }
6575
+ }
6576
+ //
6577
+ // linear swap
6578
+ //
6579
+ // {
6580
+ // "orderId": 3697213934,
6581
+ // "symbol": "BTCUSDT",
6582
+ // "status": "NEW",
6583
+ // "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
6584
+ // "price": "33000.00",
6585
+ // "avgPrice": "0.00000",
6586
+ // "origQty": "0.010",
6587
+ // "executedQty": "0.000",
6588
+ // "cumQuote": "0.00000",
6589
+ // "timeInForce": "GTC",
6590
+ // "type": "LIMIT",
6591
+ // "reduceOnly": false,
6592
+ // "closePosition": false,
6593
+ // "side": "BUY",
6594
+ // "positionSide": "BOTH",
6595
+ // "stopPrice": "0.00",
6596
+ // "workingType": "CONTRACT_PRICE",
6597
+ // "priceProtect": false,
6598
+ // "origType": "LIMIT",
6599
+ // "priceMatch": "NONE",
6600
+ // "selfTradePreventionMode": "NONE",
6601
+ // "goodTillDate": 0,
6602
+ // "time": 1707892893502,
6603
+ // "updateTime": 1707892893515
6604
+ // }
6605
+ //
6606
+ // inverse swap
6607
+ //
6608
+ // {
6609
+ // "orderId": 597368542,
6610
+ // "symbol": "BTCUSD_PERP",
6611
+ // "pair": "BTCUSD",
6612
+ // "status": "NEW",
6613
+ // "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
6614
+ // "price": "35000",
6615
+ // "avgPrice": "0",
6616
+ // "origQty": "1",
6617
+ // "executedQty": "0",
6618
+ // "cumBase": "0",
6619
+ // "timeInForce": "GTC",
6620
+ // "type": "LIMIT",
6621
+ // "reduceOnly": false,
6622
+ // "closePosition": false,
6623
+ // "side": "BUY",
6624
+ // "positionSide": "BOTH",
6625
+ // "stopPrice": "0",
6626
+ // "workingType": "CONTRACT_PRICE",
6627
+ // "priceProtect": false,
6628
+ // "origType": "LIMIT",
6629
+ // "time": 1707893453199,
6630
+ // "updateTime": 1707893453199
6631
+ // }
6632
+ //
6633
+ // linear portfolio margin
6634
+ //
6635
+ // {
6636
+ // "orderId": 264895013409,
6637
+ // "symbol": "BTCUSDT",
6638
+ // "status": "NEW",
6639
+ // "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
6640
+ // "price": "35000",
6641
+ // "avgPrice": "0",
6642
+ // "origQty": "0.010",
6643
+ // "executedQty": "0",
6644
+ // "cumQuote": "0",
6645
+ // "timeInForce": "GTC",
6646
+ // "type": "LIMIT",
6647
+ // "reduceOnly": false,
6648
+ // "side": "BUY",
6649
+ // "positionSide": "LONG",
6650
+ // "origType": "LIMIT",
6651
+ // "time": 1707893839364,
6652
+ // "updateTime": 1707893839364,
6653
+ // "goodTillDate": 0,
6654
+ // "selfTradePreventionMode": "NONE"
6655
+ // }
6656
+ //
6657
+ // inverse portfolio margin
6658
+ //
6659
+ // {
6660
+ // "orderId": 71790316950,
6661
+ // "symbol": "ETHUSD_PERP",
6662
+ // "pair": "ETHUSD",
6663
+ // "status": "NEW",
6664
+ // "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
6665
+ // "price": "2500",
6666
+ // "avgPrice": "0",
6667
+ // "origQty": "1",
6668
+ // "executedQty": "0",
6669
+ // "cumBase": "0",
6670
+ // "timeInForce": "GTC",
6671
+ // "type": "LIMIT",
6672
+ // "reduceOnly": false,
6673
+ // "side": "BUY",
6674
+ // "positionSide": "LONG",
6675
+ // "origType": "LIMIT",
6676
+ // "time": 1707894181694,
6677
+ // "updateTime": 1707894181694
6678
+ // }
6679
+ //
6680
+ // linear portfolio margin conditional
6681
+ //
6682
+ // {
6683
+ // "newClientStrategyId": "x-xcKtGhcu2205fde44418483ca21874",
6684
+ // "strategyId": 4084339,
6685
+ // "strategyStatus": "NEW",
6686
+ // "strategyType": "STOP",
6687
+ // "origQty": "0.010",
6688
+ // "price": "35000",
6689
+ // "reduceOnly": false,
6690
+ // "side": "BUY",
6691
+ // "positionSide": "LONG",
6692
+ // "stopPrice": "60000",
6693
+ // "symbol": "BTCUSDT",
6694
+ // "bookTime": 1707894490094,
6695
+ // "updateTime": 1707894490094,
6696
+ // "timeInForce": "GTC",
6697
+ // "workingType": "CONTRACT_PRICE",
6698
+ // "priceProtect": false,
6699
+ // "goodTillDate": 0,
6700
+ // "selfTradePreventionMode": "NONE"
6701
+ // }
6702
+ //
6703
+ // inverse portfolio margin conditional
6704
+ //
6705
+ // {
6706
+ // "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
6707
+ // "strategyId": 1423501,
6708
+ // "strategyStatus": "NEW",
6709
+ // "strategyType": "STOP",
6710
+ // "origQty": "1",
6711
+ // "price": "2500",
6712
+ // "reduceOnly": false,
6713
+ // "side": "BUY",
6714
+ // "positionSide": "LONG",
6715
+ // "stopPrice": "4000",
6716
+ // "symbol": "ETHUSD_PERP",
6717
+ // "bookTime": 1707894782679,
6718
+ // "updateTime": 1707894782679,
6719
+ // "timeInForce": "GTC",
6720
+ // "workingType": "CONTRACT_PRICE",
6721
+ // "priceProtect": false
6722
+ // }
6723
+ //
6724
+ return this.parseOrder(response, market);
6725
+ }
6385
6726
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
6386
6727
  /**
6387
6728
  * @method
@@ -11295,12 +11636,16 @@ class binance extends binance$1 {
11295
11636
  * @see https://binance-docs.github.io/apidocs/spot/en/#get-force-liquidation-record-user_data
11296
11637
  * @see https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data
11297
11638
  * @see https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
11639
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-margin-force-orders-user_data
11640
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-um-force-orders-user_data
11641
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-cm-force-orders-user_data
11298
11642
  * @param {string} [symbol] unified CCXT market symbol
11299
11643
  * @param {int} [since] the earliest time in ms to fetch liquidations for
11300
11644
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
11301
11645
  * @param {object} [params] exchange specific parameters for the binance api endpoint
11302
11646
  * @param {int} [params.until] timestamp in ms of the latest liquidation
11303
11647
  * @param {boolean} [params.paginate] *spot only* default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
11648
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
11304
11649
  * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
11305
11650
  */
11306
11651
  await this.loadMarkets();
@@ -11317,13 +11662,17 @@ class binance extends binance$1 {
11317
11662
  [type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
11318
11663
  let subType = undefined;
11319
11664
  [subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params, 'linear');
11665
+ let isPortfolioMargin = undefined;
11666
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchMyLiquidations', 'papi', 'portfolioMargin', false);
11320
11667
  let request = {};
11321
11668
  if (type !== 'spot') {
11322
11669
  request['autoCloseType'] = 'LIQUIDATION';
11323
11670
  }
11324
11671
  if (market !== undefined) {
11325
11672
  const symbolKey = market['spot'] ? 'isolatedSymbol' : 'symbol';
11326
- request[symbolKey] = market['id'];
11673
+ if (!isPortfolioMargin) {
11674
+ request[symbolKey] = market['id'];
11675
+ }
11327
11676
  }
11328
11677
  if (since !== undefined) {
11329
11678
  request['startTime'] = since;
@@ -11339,13 +11688,28 @@ class binance extends binance$1 {
11339
11688
  [request, params] = this.handleUntilOption('endTime', request, params);
11340
11689
  let response = undefined;
11341
11690
  if (type === 'spot') {
11342
- response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
11691
+ if (isPortfolioMargin) {
11692
+ response = await this.papiGetMarginForceOrders(this.extend(request, params));
11693
+ }
11694
+ else {
11695
+ response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
11696
+ }
11343
11697
  }
11344
11698
  else if (subType === 'linear') {
11345
- response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
11699
+ if (isPortfolioMargin) {
11700
+ response = await this.papiGetUmForceOrders(this.extend(request, params));
11701
+ }
11702
+ else {
11703
+ response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
11704
+ }
11346
11705
  }
11347
11706
  else if (subType === 'inverse') {
11348
- response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
11707
+ if (isPortfolioMargin) {
11708
+ response = await this.papiGetCmForceOrders(this.extend(request, params));
11709
+ }
11710
+ else {
11711
+ response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
11712
+ }
11349
11713
  }
11350
11714
  else {
11351
11715
  throw new errors.NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
@@ -11427,7 +11791,7 @@ class binance extends binance$1 {
11427
11791
  // },
11428
11792
  // ]
11429
11793
  //
11430
- const liquidations = this.safeValue(response, 'rows', response);
11794
+ const liquidations = this.safeList(response, 'rows', response);
11431
11795
  return this.parseLiquidations(liquidations, market, since, limit);
11432
11796
  }
11433
11797
  parseLiquidation(liquidation, market = undefined) {
@@ -50,6 +50,7 @@ class bingx extends bingx$1 {
50
50
  'fetchClosedOrders': true,
51
51
  'fetchCurrencies': true,
52
52
  'fetchDepositAddress': true,
53
+ 'fetchDepositAddressesByNetwork': true,
53
54
  'fetchDeposits': true,
54
55
  'fetchDepositWithdrawFee': 'emulated',
55
56
  'fetchDepositWithdrawFees': true,
@@ -402,6 +403,13 @@ class bingx extends bingx$1 {
402
403
  },
403
404
  'recvWindow': 5 * 1000,
404
405
  'broker': 'CCXT',
406
+ 'defaultNetworks': {
407
+ 'ETH': 'ETH',
408
+ 'USDT': 'ERC20',
409
+ 'USDC': 'ERC20',
410
+ 'BTC': 'BTC',
411
+ 'LTC': 'LTC',
412
+ },
405
413
  },
406
414
  });
407
415
  }
@@ -3085,15 +3093,15 @@ class bingx extends bingx$1 {
3085
3093
  'status': status,
3086
3094
  };
3087
3095
  }
3088
- async fetchDepositAddress(code, params = {}) {
3096
+ async fetchDepositAddressesByNetwork(code, params = {}) {
3089
3097
  /**
3090
3098
  * @method
3091
- * @name bingx#fetchDepositAddress
3092
- * @description fetch the deposit address for a currency associated with this account
3093
- * @see https://bingx-api.github.io/docs/#/common/sub-account#Query%20Main%20Account%20Deposit%20Address
3099
+ * @name bingx#fetchDepositAddressesByNetwork
3100
+ * @description fetch the deposit addresses for a currency associated with this account
3101
+ * @see https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query%20Main%20Account%20Deposit%20Address
3094
3102
  * @param {string} code unified currency code
3095
3103
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3096
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3104
+ * @returns {object} a dictionary [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}, indexed by the network
3097
3105
  */
3098
3106
  await this.loadMarkets();
3099
3107
  const currency = this.currency(code);
@@ -3128,6 +3136,36 @@ class bingx extends bingx$1 {
3128
3136
  const parsed = this.parseDepositAddresses(data, [currency['code']], false);
3129
3137
  return this.indexBy(parsed, 'network');
3130
3138
  }
3139
+ async fetchDepositAddress(code, params = {}) {
3140
+ /**
3141
+ * @method
3142
+ * @name bingx#fetchDepositAddress
3143
+ * @description fetch the deposit address for a currency associated with this account
3144
+ * @see https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query%20Main%20Account%20Deposit%20Address
3145
+ * @param {string} code unified currency code
3146
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3147
+ * @param {string} [params.network] The chain of currency. This only apply for multi-chain currency, and there is no need for single chain currency
3148
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3149
+ */
3150
+ const network = this.safeString(params, 'network');
3151
+ params = this.omit(params, ['network']);
3152
+ const addressStructures = await this.fetchDepositAddressesByNetwork(code, params);
3153
+ if (network !== undefined) {
3154
+ return this.safeDict(addressStructures, network);
3155
+ }
3156
+ else {
3157
+ const options = this.safeDict(this.options, 'defaultNetworks');
3158
+ const defaultNetworkForCurrency = this.safeString(options, code);
3159
+ if (defaultNetworkForCurrency !== undefined) {
3160
+ return this.safeDict(addressStructures, defaultNetworkForCurrency);
3161
+ }
3162
+ else {
3163
+ const keys = Object.keys(addressStructures);
3164
+ const key = this.safeString(keys, 0);
3165
+ return this.safeDict(addressStructures, key);
3166
+ }
3167
+ }
3168
+ }
3131
3169
  parseDepositAddress(depositAddress, currency = undefined) {
3132
3170
  //
3133
3171
  // {
@@ -818,7 +818,7 @@ class bitstamp extends bitstamp$1 {
818
818
  for (let i = 0; i < ids.length; i++) {
819
819
  const id = ids[i];
820
820
  if (id.indexOf('_') < 0) {
821
- const value = this.safeNumber(transaction, id);
821
+ const value = this.safeInteger(transaction, id);
822
822
  if ((value !== undefined) && (value !== 0)) {
823
823
  return id;
824
824
  }