ccxt 4.2.40 → 4.2.42

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 (44) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +261 -58
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/binance.js +189 -22
  6. package/dist/cjs/src/bingx.js +22 -3
  7. package/dist/cjs/src/bitforex.js +2 -2
  8. package/dist/cjs/src/bitget.js +9 -2
  9. package/dist/cjs/src/bitrue.js +7 -15
  10. package/dist/cjs/src/currencycom.js +1 -1
  11. package/dist/cjs/src/digifinex.js +4 -1
  12. package/dist/cjs/src/gate.js +4 -1
  13. package/dist/cjs/src/gemini.js +4 -1
  14. package/dist/cjs/src/htx.js +1 -1
  15. package/dist/cjs/src/mexc.js +5 -2
  16. package/dist/cjs/src/phemex.js +4 -1
  17. package/dist/cjs/src/poloniex.js +4 -1
  18. package/dist/cjs/src/pro/cex.js +1 -1
  19. package/dist/cjs/src/pro/gemini.js +1 -1
  20. package/dist/cjs/src/pro/hitbtc.js +1 -1
  21. package/dist/cjs/src/pro/poloniex.js +1 -1
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/base/Exchange.d.ts +20 -20
  25. package/js/src/binance.js +189 -22
  26. package/js/src/bingx.d.ts +1 -0
  27. package/js/src/bingx.js +22 -3
  28. package/js/src/bitforex.js +2 -2
  29. package/js/src/bitget.d.ts +2 -2
  30. package/js/src/bitget.js +9 -2
  31. package/js/src/bitrue.js +7 -15
  32. package/js/src/currencycom.js +1 -1
  33. package/js/src/digifinex.js +4 -1
  34. package/js/src/gate.js +4 -1
  35. package/js/src/gemini.js +4 -1
  36. package/js/src/htx.js +1 -1
  37. package/js/src/mexc.js +5 -2
  38. package/js/src/phemex.js +4 -1
  39. package/js/src/poloniex.js +4 -1
  40. package/js/src/pro/cex.js +1 -1
  41. package/js/src/pro/gemini.js +1 -1
  42. package/js/src/pro/hitbtc.js +1 -1
  43. package/js/src/pro/poloniex.js +1 -1
  44. package/package.json +1 -1
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.40';
180
+ const version = '4.2.42';
181
181
  Exchange["default"].ccxtVersion = version;
182
182
  const exchanges = {
183
183
  'ace': ace,
@@ -4337,20 +4337,73 @@ class binance extends binance$1 {
4337
4337
  // "time": 1676366446072
4338
4338
  // }
4339
4339
  //
4340
+ // fetchMyTrades: linear portfolio margin
4341
+ //
4342
+ // {
4343
+ // "symbol": "BTCUSDT",
4344
+ // "id": 4575108247,
4345
+ // "orderId": 261942655610,
4346
+ // "side": "SELL",
4347
+ // "price": "47263.40",
4348
+ // "qty": "0.010",
4349
+ // "realizedPnl": "27.38400000",
4350
+ // "marginAsset": "USDT",
4351
+ // "quoteQty": "472.63",
4352
+ // "commission": "0.18905360",
4353
+ // "commissionAsset": "USDT",
4354
+ // "time": 1707530039409,
4355
+ // "buyer": false,
4356
+ // "maker": false,
4357
+ // "positionSide": "LONG"
4358
+ // }
4359
+ //
4360
+ // fetchMyTrades: inverse portfolio margin
4361
+ //
4362
+ // {
4363
+ // "symbol": "ETHUSD_PERP",
4364
+ // "id": 701907838,
4365
+ // "orderId": 71548909034,
4366
+ // "pair": "ETHUSD",
4367
+ // "side": "SELL",
4368
+ // "price": "2498.15",
4369
+ // "qty": "1",
4370
+ // "realizedPnl": "0.00012517",
4371
+ // "marginAsset": "ETH",
4372
+ // "baseQty": "0.00400296",
4373
+ // "commission": "0.00000160",
4374
+ // "commissionAsset": "ETH",
4375
+ // "time": 1707530317519,
4376
+ // "positionSide": "LONG",
4377
+ // "buyer": false,
4378
+ // "maker": false
4379
+ // }
4380
+ //
4381
+ // fetchMyTrades: spot margin portfolio margin
4382
+ //
4383
+ // {
4384
+ // "symbol": "ADAUSDT",
4385
+ // "id": 470227543,
4386
+ // "orderId": 4421170947,
4387
+ // "price": "0.53880000",
4388
+ // "qty": "10.00000000",
4389
+ // "quoteQty": "5.38800000",
4390
+ // "commission": "0.00538800",
4391
+ // "commissionAsset": "USDT",
4392
+ // "time": 1707545780522,
4393
+ // "isBuyer": false,
4394
+ // "isMaker": false,
4395
+ // "isBestMatch": true
4396
+ // }
4397
+ //
4340
4398
  const timestamp = this.safeInteger2(trade, 'T', 'time');
4341
- const price = this.safeString2(trade, 'p', 'price');
4342
4399
  let amount = this.safeString2(trade, 'q', 'qty');
4343
4400
  amount = this.safeString(trade, 'quantity', amount);
4344
- const cost = this.safeString2(trade, 'quoteQty', 'baseQty'); // inverse futures
4345
4401
  const marketId = this.safeString(trade, 'symbol');
4346
- const isSpotTrade = ('isIsolated' in trade) || ('M' in trade) || ('orderListId' in trade);
4402
+ const isSpotTrade = ('isIsolated' in trade) || ('M' in trade) || ('orderListId' in trade) || ('isMaker' in trade);
4347
4403
  const marketType = isSpotTrade ? 'spot' : 'contract';
4348
4404
  market = this.safeMarket(marketId, market, undefined, marketType);
4349
4405
  const symbol = market['symbol'];
4350
- let id = this.safeString2(trade, 't', 'a');
4351
- id = this.safeString2(trade, 'tradeId', 'id', id);
4352
4406
  let side = undefined;
4353
- const orderId = this.safeString(trade, 'orderId');
4354
4407
  const buyerMaker = this.safeValue2(trade, 'm', 'isBuyerMaker');
4355
4408
  let takerOrMaker = undefined;
4356
4409
  if (buyerMaker !== undefined) {
@@ -4400,14 +4453,14 @@ class binance extends binance$1 {
4400
4453
  'timestamp': timestamp,
4401
4454
  'datetime': this.iso8601(timestamp),
4402
4455
  'symbol': symbol,
4403
- 'id': id,
4404
- 'order': orderId,
4456
+ 'id': this.safeStringN(trade, ['t', 'a', 'tradeId', 'id']),
4457
+ 'order': this.safeString(trade, 'orderId'),
4405
4458
  'type': this.safeStringLower(trade, 'type'),
4406
4459
  'side': side,
4407
4460
  'takerOrMaker': takerOrMaker,
4408
- 'price': price,
4461
+ 'price': this.safeString2(trade, 'p', 'price'),
4409
4462
  'amount': amount,
4410
- 'cost': cost,
4463
+ 'cost': this.safeString2(trade, 'quoteQty', 'baseQty'),
4411
4464
  'fee': fee,
4412
4465
  }, market);
4413
4466
  }
@@ -6496,12 +6549,16 @@ class binance extends binance$1 {
6496
6549
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data
6497
6550
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-trade-list-user_data
6498
6551
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-trade-list-user_data
6552
+ * @see https://binance-docs.github.io/apidocs/pm/en/#margin-account-trade-list-user_data
6553
+ * @see https://binance-docs.github.io/apidocs/pm/en/#um-account-trade-list-user_data
6554
+ * @see https://binance-docs.github.io/apidocs/pm/en/#cm-account-trade-list-user_data
6499
6555
  * @param {string} symbol unified market symbol
6500
6556
  * @param {int} [since] the earliest time in ms to fetch trades for
6501
6557
  * @param {int} [limit] the maximum number of trades structures to retrieve
6502
6558
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6503
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6559
+ * @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)
6504
6560
  * @param {int} [params.until] the latest time in ms to fetch entries for
6561
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trades for a portfolio margin account
6505
6562
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
6506
6563
  */
6507
6564
  await this.loadMarkets();
@@ -6555,8 +6612,13 @@ class binance extends binance$1 {
6555
6612
  throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
6556
6613
  }
6557
6614
  [marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
6615
+ let isPortfolioMargin = undefined;
6616
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchMyTrades', 'papi', 'portfolioMargin', false);
6558
6617
  if (type === 'spot' || type === 'margin') {
6559
- if ((type === 'margin') || (marginMode !== undefined)) {
6618
+ if (isPortfolioMargin) {
6619
+ response = await this.papiGetMarginMyTrades(this.extend(request, params));
6620
+ }
6621
+ else if ((type === 'margin') || (marginMode !== undefined)) {
6560
6622
  if (marginMode === 'isolated') {
6561
6623
  request['isIsolated'] = true;
6562
6624
  }
@@ -6567,10 +6629,20 @@ class binance extends binance$1 {
6567
6629
  }
6568
6630
  }
6569
6631
  else if (market['linear']) {
6570
- response = await this.fapiPrivateGetUserTrades(this.extend(request, params));
6632
+ if (isPortfolioMargin) {
6633
+ response = await this.papiGetUmUserTrades(this.extend(request, params));
6634
+ }
6635
+ else {
6636
+ response = await this.fapiPrivateGetUserTrades(this.extend(request, params));
6637
+ }
6571
6638
  }
6572
6639
  else if (market['inverse']) {
6573
- response = await this.dapiPrivateGetUserTrades(this.extend(request, params));
6640
+ if (isPortfolioMargin) {
6641
+ response = await this.papiGetCmUserTrades(this.extend(request, params));
6642
+ }
6643
+ else {
6644
+ response = await this.dapiPrivateGetUserTrades(this.extend(request, params));
6645
+ }
6574
6646
  }
6575
6647
  }
6576
6648
  //
@@ -6638,6 +6710,70 @@ class binance extends binance$1 {
6638
6710
  // }
6639
6711
  // ]
6640
6712
  //
6713
+ // linear portfolio margin
6714
+ //
6715
+ // [
6716
+ // {
6717
+ // "symbol": "BTCUSDT",
6718
+ // "id": 4575108247,
6719
+ // "orderId": 261942655610,
6720
+ // "side": "SELL",
6721
+ // "price": "47263.40",
6722
+ // "qty": "0.010",
6723
+ // "realizedPnl": "27.38400000",
6724
+ // "marginAsset": "USDT",
6725
+ // "quoteQty": "472.63",
6726
+ // "commission": "0.18905360",
6727
+ // "commissionAsset": "USDT",
6728
+ // "time": 1707530039409,
6729
+ // "buyer": false,
6730
+ // "maker": false,
6731
+ // "positionSide": "LONG"
6732
+ // }
6733
+ // ]
6734
+ //
6735
+ // inverse portfolio margin
6736
+ //
6737
+ // [
6738
+ // {
6739
+ // "symbol": "ETHUSD_PERP",
6740
+ // "id": 701907838,
6741
+ // "orderId": 71548909034,
6742
+ // "pair": "ETHUSD",
6743
+ // "side": "SELL",
6744
+ // "price": "2498.15",
6745
+ // "qty": "1",
6746
+ // "realizedPnl": "0.00012517",
6747
+ // "marginAsset": "ETH",
6748
+ // "baseQty": "0.00400296",
6749
+ // "commission": "0.00000160",
6750
+ // "commissionAsset": "ETH",
6751
+ // "time": 1707530317519,
6752
+ // "positionSide": "LONG",
6753
+ // "buyer": false,
6754
+ // "maker": false
6755
+ // }
6756
+ // ]
6757
+ //
6758
+ // spot margin portfolio margin
6759
+ //
6760
+ // [
6761
+ // {
6762
+ // "symbol": "ADAUSDT",
6763
+ // "id": 470227543,
6764
+ // "orderId": 4421170947,
6765
+ // "price": "0.53880000",
6766
+ // "qty": "10.00000000",
6767
+ // "quoteQty": "5.38800000",
6768
+ // "commission": "0.00538800",
6769
+ // "commissionAsset": "USDT",
6770
+ // "time": 1707545780522,
6771
+ // "isBuyer": false,
6772
+ // "isMaker": false,
6773
+ // "isBestMatch": true
6774
+ // }
6775
+ // ]
6776
+ //
6641
6777
  return this.parseTrades(response, market, since, limit);
6642
6778
  }
6643
6779
  async fetchMyDustTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -10524,15 +10660,19 @@ class binance extends binance$1 {
10524
10660
  * @name binance#fetchBorrowInterest
10525
10661
  * @description fetch the interest owed by the user for borrowing currency for margin trading
10526
10662
  * @see https://binance-docs.github.io/apidocs/spot/en/#get-interest-history-user_data
10527
- * @param {string} code unified currency code
10528
- * @param {string} symbol unified market symbol when fetch interest in isolated markets
10663
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-margin-borrow-loan-interest-history-user_data
10664
+ * @param {string} [code] unified currency code
10665
+ * @param {string} [symbol] unified market symbol when fetch interest in isolated markets
10529
10666
  * @param {int} [since] the earliest time in ms to fetch borrrow interest for
10530
10667
  * @param {int} [limit] the maximum number of structures to retrieve
10531
10668
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10669
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the borrow interest in a portfolio margin account
10532
10670
  * @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
10533
10671
  */
10534
10672
  await this.loadMarkets();
10535
- const request = {};
10673
+ let isPortfolioMargin = undefined;
10674
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchBorrowInterest', 'papi', 'portfolioMargin', false);
10675
+ let request = {};
10536
10676
  let market = undefined;
10537
10677
  if (code !== undefined) {
10538
10678
  const currency = this.currency(code);
@@ -10544,11 +10684,20 @@ class binance extends binance$1 {
10544
10684
  if (limit !== undefined) {
10545
10685
  request['size'] = limit;
10546
10686
  }
10547
- if (symbol !== undefined) { // Isolated
10548
- market = this.market(symbol);
10549
- request['isolatedSymbol'] = market['id'];
10687
+ [request, params] = this.handleUntilOption('endTime', request, params);
10688
+ let response = undefined;
10689
+ if (isPortfolioMargin) {
10690
+ response = await this.papiGetMarginMarginInterestHistory(this.extend(request, params));
10691
+ }
10692
+ else {
10693
+ if (symbol !== undefined) {
10694
+ market = this.market(symbol);
10695
+ request['isolatedSymbol'] = market['id'];
10696
+ }
10697
+ response = await this.sapiGetMarginInterestHistory(this.extend(request, params));
10550
10698
  }
10551
- const response = await this.sapiGetMarginInterestHistory(this.extend(request, params));
10699
+ //
10700
+ // spot margin
10552
10701
  //
10553
10702
  // {
10554
10703
  // "rows":[
@@ -10565,13 +10714,31 @@ class binance extends binance$1 {
10565
10714
  // "total": 1
10566
10715
  // }
10567
10716
  //
10717
+ // spot margin portfolio margin
10718
+ //
10719
+ // {
10720
+ // "total": 49,
10721
+ // "rows": [
10722
+ // {
10723
+ // "txId": 1656187724899910076,
10724
+ // "interestAccuredTime": 1707541200000,
10725
+ // "asset": "USDT",
10726
+ // "rawAsset": "USDT",
10727
+ // "principal": "0.00011146",
10728
+ // "interest": "0.00000001",
10729
+ // "interestRate": "0.00089489",
10730
+ // "type": "PERIODIC"
10731
+ // },
10732
+ // ]
10733
+ // }
10734
+ //
10568
10735
  const rows = this.safeList(response, 'rows');
10569
10736
  const interest = this.parseBorrowInterests(rows, market);
10570
10737
  return this.filterByCurrencySinceLimit(interest, code, since, limit);
10571
10738
  }
10572
10739
  parseBorrowInterest(info, market = undefined) {
10573
10740
  const symbol = this.safeString(info, 'isolatedSymbol');
10574
- const timestamp = this.safeNumber(info, 'interestAccuredTime');
10741
+ const timestamp = this.safeInteger(info, 'interestAccuredTime');
10575
10742
  const marginMode = (symbol === undefined) ? 'cross' : 'isolated';
10576
10743
  return {
10577
10744
  'account': (symbol === undefined) ? 'cross' : symbol,
@@ -1797,6 +1797,7 @@ class bingx extends bingx$1 {
1797
1797
  if (timeInForce === 'IOC') {
1798
1798
  request['timeInForce'] = 'IOC';
1799
1799
  }
1800
+ const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
1800
1801
  if (isSpot) {
1801
1802
  [postOnly, params] = this.handlePostOnly(isMarketOrder, timeInForce === 'POC', params);
1802
1803
  if (postOnly || (timeInForce === 'POC')) {
@@ -1808,7 +1809,7 @@ class bingx extends bingx$1 {
1808
1809
  request['quoteOrderQty'] = this.parseToNumeric(this.costToPrecision(symbol, cost));
1809
1810
  }
1810
1811
  else {
1811
- if (market['spot'] && isMarketOrder && (price !== undefined)) {
1812
+ if (isMarketOrder && (price !== undefined)) {
1812
1813
  // keep the legacy behavior, to avoid breaking the old spot-market-buying code
1813
1814
  const calculatedCost = Precise["default"].stringMul(this.numberToString(amount), this.numberToString(price));
1814
1815
  request['quoteOrderQty'] = this.parseToNumeric(calculatedCost);
@@ -1820,6 +1821,18 @@ class bingx extends bingx$1 {
1820
1821
  if (!isMarketOrder) {
1821
1822
  request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
1822
1823
  }
1824
+ if (triggerPrice !== undefined) {
1825
+ if (isMarketOrder && this.safeString(request, 'quoteOrderQty') === undefined) {
1826
+ throw new errors.ArgumentsRequired(this.id + ' createOrder() requires the cost parameter (or the amount + price) for placing spot market-buy trigger orders');
1827
+ }
1828
+ request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
1829
+ if (type === 'LIMIT') {
1830
+ request['type'] = 'TRIGGER_LIMIT';
1831
+ }
1832
+ else if (type === 'MARKET') {
1833
+ request['type'] = 'TRIGGER_MARKET';
1834
+ }
1835
+ }
1823
1836
  }
1824
1837
  else {
1825
1838
  [postOnly, params] = this.handlePostOnly(isMarketOrder, timeInForce === 'PostOnly', params);
@@ -1832,7 +1845,6 @@ class bingx extends bingx$1 {
1832
1845
  else if (timeInForce === 'FOK') {
1833
1846
  request['timeInForce'] = 'FOK';
1834
1847
  }
1835
- const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
1836
1848
  const stopLossPrice = this.safeString(params, 'stopLossPrice');
1837
1849
  const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
1838
1850
  const trailingAmount = this.safeString(params, 'trailingAmount');
@@ -2132,6 +2144,13 @@ class bingx extends bingx$1 {
2132
2144
  };
2133
2145
  return this.safeString(sides, side, side);
2134
2146
  }
2147
+ parseOrderType(type) {
2148
+ const types = {
2149
+ 'trigger_market': 'market',
2150
+ 'trigger_limit': 'limit',
2151
+ };
2152
+ return this.safeString(types, type, type);
2153
+ }
2135
2154
  parseOrder(order, market = undefined) {
2136
2155
  //
2137
2156
  // spot
@@ -2396,7 +2415,7 @@ class bingx extends bingx$1 {
2396
2415
  'datetime': this.iso8601(timestamp),
2397
2416
  'lastTradeTimestamp': lastTradeTimestamp,
2398
2417
  'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
2399
- 'type': this.safeStringLower2(order, 'type', 'o'),
2418
+ 'type': this.parseOrderType(this.safeStringLower2(order, 'type', 'o')),
2400
2419
  'timeInForce': this.safeString(order, 'timeInForce'),
2401
2420
  'postOnly': undefined,
2402
2421
  'side': this.parseOrderSide(side),
@@ -642,8 +642,8 @@ class bitforex extends bitforex$1 {
642
642
  }
643
643
  parseOrder(order, market = undefined) {
644
644
  const id = this.safeString(order, 'orderId');
645
- const timestamp = this.safeNumber(order, 'createTime');
646
- const lastTradeTimestamp = this.safeNumber(order, 'lastTime');
645
+ const timestamp = this.safeInteger(order, 'createTime');
646
+ const lastTradeTimestamp = this.safeInteger(order, 'lastTime');
647
647
  const symbol = market['symbol'];
648
648
  const sideId = this.safeInteger(order, 'tradeType');
649
649
  const side = this.parseSide(sideId);
@@ -2418,7 +2418,10 @@ class bitget extends bitget$1 {
2418
2418
  await this.loadMarkets();
2419
2419
  const networkCode = this.safeString2(params, 'chain', 'network');
2420
2420
  params = this.omit(params, 'network');
2421
- const networkId = this.networkCodeToId(networkCode, code);
2421
+ let networkId = undefined;
2422
+ if (networkCode !== undefined) {
2423
+ networkId = this.networkCodeToId(networkCode, code);
2424
+ }
2422
2425
  const currency = this.currency(code);
2423
2426
  const request = {
2424
2427
  'coin': currency['code'],
@@ -2457,11 +2460,15 @@ class bitget extends bitget$1 {
2457
2460
  const currencyId = this.safeString(depositAddress, 'coin');
2458
2461
  const networkId = this.safeString(depositAddress, 'chain');
2459
2462
  const parsedCurrency = this.safeCurrencyCode(currencyId, currency);
2463
+ let network = undefined;
2464
+ if (networkId !== undefined) {
2465
+ network = this.networkIdToCode(networkId, parsedCurrency);
2466
+ }
2460
2467
  return {
2461
2468
  'currency': parsedCurrency,
2462
2469
  'address': this.safeString(depositAddress, 'address'),
2463
2470
  'tag': this.safeString(depositAddress, 'tag'),
2464
- 'network': this.networkIdToCode(networkId, parsedCurrency),
2471
+ 'network': network,
2465
2472
  'info': depositAddress,
2466
2473
  };
2467
2474
  }
@@ -2777,28 +2777,20 @@ class bitrue extends bitrue$1 {
2777
2777
  this.checkAddress(address);
2778
2778
  await this.loadMarkets();
2779
2779
  const currency = this.currency(code);
2780
- let chainName = this.safeString2(params, 'network', 'chainName');
2781
- if (chainName === undefined) {
2782
- const networks = this.safeValue(currency, 'networks', {});
2783
- const optionsNetworks = this.safeValue(this.options, 'networks', {});
2784
- let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
2785
- network = this.safeString(optionsNetworks, network, network);
2786
- const networkEntry = this.safeValue(networks, network, {});
2787
- chainName = this.safeString(networkEntry, 'id'); // handle ERC20>ETH alias
2788
- if (chainName === undefined) {
2789
- throw new errors.ArgumentsRequired(this.id + ' withdraw() requires a network parameter or a chainName parameter');
2790
- }
2791
- params = this.omit(params, 'network');
2792
- }
2793
2780
  const request = {
2794
- 'coin': currency['id'].toUpperCase(),
2781
+ 'coin': currency['id'],
2795
2782
  'amount': amount,
2796
2783
  'addressTo': address,
2797
- 'chainName': chainName, // 'ERC20', 'TRC20', 'SOL'
2784
+ // 'chainName': chainName, // 'ERC20', 'TRC20', 'SOL'
2798
2785
  // 'addressMark': '', // mark of address
2799
2786
  // 'addrType': '', // type of address
2800
2787
  // 'tag': tag,
2801
2788
  };
2789
+ let networkCode = undefined;
2790
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
2791
+ if (networkCode !== undefined) {
2792
+ request['chainName'] = this.networkCodeToId(networkCode);
2793
+ }
2802
2794
  if (tag !== undefined) {
2803
2795
  request['tag'] = tag;
2804
2796
  }
@@ -1936,7 +1936,7 @@ class currencycom extends currencycom$1 {
1936
1936
  //
1937
1937
  market = this.safeMarket(this.safeString(position, 'symbol'), market);
1938
1938
  const symbol = market['symbol'];
1939
- const timestamp = this.safeNumber(position, 'createdTimestamp');
1939
+ const timestamp = this.safeInteger(position, 'createdTimestamp');
1940
1940
  const quantityRaw = this.safeString(position, 'openQuantity');
1941
1941
  const side = Precise["default"].stringGt(quantityRaw, '0') ? 'long' : 'short';
1942
1942
  const quantity = Precise["default"].stringAbs(quantityRaw);
@@ -412,7 +412,10 @@ class digifinex extends digifinex$1 {
412
412
  const minFoundPrecision = Precise["default"].stringMin(feeString, Precise["default"].stringMin(minDepositString, minWithdrawString));
413
413
  const precision = this.parseNumber(minFoundPrecision);
414
414
  const networkId = this.safeString(currency, 'chain');
415
- const networkCode = this.networkIdToCode(networkId);
415
+ let networkCode = undefined;
416
+ if (networkId !== undefined) {
417
+ networkCode = this.networkIdToCode(networkId);
418
+ }
416
419
  const network = {
417
420
  'info': currency,
418
421
  'id': networkId,
@@ -1587,7 +1587,10 @@ class gate extends gate$1 {
1587
1587
  const currency = parts[0];
1588
1588
  const code = this.safeCurrencyCode(currency);
1589
1589
  const networkId = this.safeString(entry, 'chain');
1590
- const networkCode = this.networkIdToCode(networkId, code);
1590
+ let networkCode = undefined;
1591
+ if (networkId !== undefined) {
1592
+ networkCode = this.networkIdToCode(networkId, code);
1593
+ }
1591
1594
  const delisted = this.safeValue(entry, 'delisted');
1592
1595
  const withdrawDisabled = this.safeBool(entry, 'withdraw_disabled', false);
1593
1596
  const depositDisabled = this.safeBool(entry, 'deposit_disabled', false);
@@ -343,7 +343,10 @@ class gemini extends gemini$1 {
343
343
  const precision = this.parseNumber(this.parsePrecision(this.safeString(currency, 5)));
344
344
  const networks = {};
345
345
  const networkId = this.safeString(currency, 9);
346
- const networkCode = this.networkIdToCode(networkId);
346
+ let networkCode = undefined;
347
+ if (networkId !== undefined) {
348
+ networkCode = this.networkIdToCode(networkId);
349
+ }
347
350
  if (networkCode !== undefined) {
348
351
  networks[networkCode] = {
349
352
  'info': currency,
@@ -7088,7 +7088,7 @@ class htx extends htx$1 {
7088
7088
  const marginMode = (marketId === undefined) ? 'cross' : 'isolated';
7089
7089
  market = this.safeMarket(marketId);
7090
7090
  const symbol = this.safeString(market, 'symbol');
7091
- const timestamp = this.safeNumber(info, 'accrued-at');
7091
+ const timestamp = this.safeInteger(info, 'accrued-at');
7092
7092
  return {
7093
7093
  'account': (marginMode === 'isolated') ? symbol : 'cross',
7094
7094
  'symbol': symbol,
@@ -4326,7 +4326,10 @@ class mexc extends mexc$1 {
4326
4326
  'coin': currency['id'],
4327
4327
  };
4328
4328
  const networkCode = this.safeString(params, 'network');
4329
- const networkId = this.networkCodeToId(networkCode, code);
4329
+ let networkId = undefined;
4330
+ if (networkCode !== undefined) {
4331
+ networkId = this.networkCodeToId(networkCode, code);
4332
+ }
4330
4333
  if (networkId !== undefined) {
4331
4334
  request['network'] = networkId;
4332
4335
  }
@@ -4752,7 +4755,7 @@ class mexc extends mexc$1 {
4752
4755
  const marginType = (openType === '1') ? 'isolated' : 'cross';
4753
4756
  const leverage = this.safeNumber(position, 'leverage');
4754
4757
  const liquidationPrice = this.safeNumber(position, 'liquidatePrice');
4755
- const timestamp = this.safeNumber(position, 'updateTime');
4758
+ const timestamp = this.safeInteger(position, 'updateTime');
4756
4759
  return this.safePosition({
4757
4760
  'info': position,
4758
4761
  'id': undefined,
@@ -4663,7 +4663,10 @@ class phemex extends phemex$1 {
4663
4663
  const currency = this.currency(code);
4664
4664
  let networkCode = undefined;
4665
4665
  [networkCode, params] = this.handleNetworkCodeAndParams(params);
4666
- let networkId = this.networkCodeToId(networkCode);
4666
+ let networkId = undefined;
4667
+ if (networkCode !== undefined) {
4668
+ networkId = this.networkCodeToId(networkCode);
4669
+ }
4667
4670
  const stableCoins = this.safeValue(this.options, 'stableCoins');
4668
4671
  if (networkId === undefined) {
4669
4672
  if (!(this.inArray(code, stableCoins))) {
@@ -711,7 +711,10 @@ class poloniex extends poloniex$1 {
711
711
  const code = this.safeCurrencyCode(id);
712
712
  const name = this.safeString(currency, 'name');
713
713
  const networkId = this.safeString(currency, 'blockchain');
714
- const networkCode = this.networkIdToCode(networkId, code);
714
+ let networkCode = undefined;
715
+ if (networkId !== undefined) {
716
+ networkCode = this.networkIdToCode(networkId, code);
717
+ }
715
718
  const delisted = this.safeValue(currency, 'delisted');
716
719
  const walletEnabled = this.safeString(currency, 'walletState') === 'ENABLED';
717
720
  const depositEnabled = this.safeString(currency, 'walletDepositState') === 'ENABLED';
@@ -185,7 +185,7 @@ class cex extends cex$1 {
185
185
  trade = trade.split(':');
186
186
  }
187
187
  const side = this.safeString(trade, 0);
188
- const timestamp = this.safeNumber(trade, 1);
188
+ const timestamp = this.safeInteger(trade, 1);
189
189
  const amount = this.safeString(trade, 2);
190
190
  const price = this.safeString(trade, 3);
191
191
  const id = this.safeString(trade, 4);
@@ -641,7 +641,7 @@ class gemini extends gemini$1 {
641
641
  // "socket_sequence": 139
642
642
  // }
643
643
  //
644
- const timestamp = this.safeNumber(order, 'timestampms');
644
+ const timestamp = this.safeInteger(order, 'timestampms');
645
645
  const status = this.safeString(order, 'type');
646
646
  const marketId = this.safeString(order, 'symbol');
647
647
  const typeId = this.safeString(order, 'order_type');
@@ -171,7 +171,7 @@ class hitbtc extends hitbtc$1 {
171
171
  await this.loadMarkets();
172
172
  await this.authenticate();
173
173
  const url = this.urls['api']['ws']['private'];
174
- const messageHash = this.nonce();
174
+ const messageHash = this.nonce().toString();
175
175
  const subscribe = {
176
176
  'method': name,
177
177
  'params': params,
@@ -172,7 +172,7 @@ class poloniex extends poloniex$1 {
172
172
  * @returns {object} data from the websocket stream
173
173
  */
174
174
  const url = this.urls['api']['ws']['private'];
175
- const messageHash = this.nonce();
175
+ const messageHash = this.nonce().toString();
176
176
  const subscribe = {
177
177
  'id': messageHash,
178
178
  'event': name,
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.39";
7
+ declare const version = "4.2.41";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.40';
41
+ const version = '4.2.42';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';