ccxt 4.3.68 → 4.3.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.
Files changed (47) hide show
  1. package/README.md +5 -5
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +359 -353
  5. package/dist/cjs/src/bingx.js +134 -75
  6. package/dist/cjs/src/btcbox.js +2 -1
  7. package/dist/cjs/src/coinbaseinternational.js +79 -1
  8. package/dist/cjs/src/hyperliquid.js +0 -3
  9. package/dist/cjs/src/kucoin.js +12 -5
  10. package/dist/cjs/src/oxfun.js +2 -2
  11. package/dist/cjs/src/poloniex.js +33 -33
  12. package/dist/cjs/src/poloniexfutures.js +26 -26
  13. package/dist/cjs/src/pro/poloniex.js +13 -13
  14. package/dist/cjs/src/pro/poloniexfutures.js +5 -5
  15. package/js/ccxt.d.ts +3 -3
  16. package/js/ccxt.js +1 -1
  17. package/js/src/base/Exchange.d.ts +107 -82
  18. package/js/src/base/Exchange.js +359 -353
  19. package/js/src/base/types.d.ts +0 -2
  20. package/js/src/binance.d.ts +2 -2
  21. package/js/src/bingx.d.ts +2 -2
  22. package/js/src/bingx.js +134 -75
  23. package/js/src/bitget.d.ts +2 -2
  24. package/js/src/bitmart.d.ts +2 -2
  25. package/js/src/bitrue.d.ts +2 -2
  26. package/js/src/btcbox.js +2 -1
  27. package/js/src/bybit.d.ts +2 -2
  28. package/js/src/coinbaseinternational.d.ts +11 -0
  29. package/js/src/coinbaseinternational.js +79 -1
  30. package/js/src/coinex.d.ts +2 -2
  31. package/js/src/coinlist.d.ts +2 -2
  32. package/js/src/deribit.d.ts +2 -2
  33. package/js/src/digifinex.d.ts +2 -2
  34. package/js/src/hyperliquid.js +0 -3
  35. package/js/src/kucoin.js +12 -5
  36. package/js/src/latoken.d.ts +2 -2
  37. package/js/src/mexc.d.ts +2 -2
  38. package/js/src/okx.d.ts +2 -2
  39. package/js/src/oxfun.d.ts +1 -1
  40. package/js/src/oxfun.js +2 -2
  41. package/js/src/phemex.d.ts +2 -2
  42. package/js/src/poloniex.js +33 -33
  43. package/js/src/poloniexfutures.js +26 -26
  44. package/js/src/pro/poloniex.js +13 -13
  45. package/js/src/pro/poloniexfutures.js +5 -5
  46. package/js/src/woo.d.ts +2 -2
  47. package/package.json +1 -1
@@ -1132,7 +1132,27 @@ class bingx extends bingx$1 {
1132
1132
  // "s": "BTC-USDT"
1133
1133
  // }
1134
1134
  //
1135
- let time = this.safeIntegerN(trade, ['time', 'filledTm', 'T']);
1135
+ // inverse swap fetchMyTrades
1136
+ //
1137
+ // {
1138
+ // "orderId": "1817441228670648320",
1139
+ // "symbol": "SOL-USD",
1140
+ // "type": "MARKET",
1141
+ // "side": "BUY",
1142
+ // "positionSide": "LONG",
1143
+ // "tradeId": "97244554",
1144
+ // "volume": "2",
1145
+ // "tradePrice": "182.652",
1146
+ // "amount": "20.00000000",
1147
+ // "realizedPnl": "0.00000000",
1148
+ // "commission": "-0.00005475",
1149
+ // "currency": "SOL",
1150
+ // "buyer": true,
1151
+ // "maker": false,
1152
+ // "tradeTime": 1722146730000
1153
+ // }
1154
+ //
1155
+ let time = this.safeIntegerN(trade, ['time', 'filledTm', 'T', 'tradeTime']);
1136
1156
  const datetimeId = this.safeString(trade, 'filledTm');
1137
1157
  if (datetimeId !== undefined) {
1138
1158
  time = this.parse8601(datetimeId);
@@ -1145,8 +1165,8 @@ class bingx extends bingx$1 {
1145
1165
  const currencyId = this.safeStringN(trade, ['currency', 'N', 'commissionAsset']);
1146
1166
  const currencyCode = this.safeCurrencyCode(currencyId);
1147
1167
  const m = this.safeBool(trade, 'm');
1148
- const marketId = this.safeString(trade, 's');
1149
- const isBuyerMaker = this.safeBool2(trade, 'buyerMaker', 'isBuyerMaker');
1168
+ const marketId = this.safeString2(trade, 's', 'symbol');
1169
+ const isBuyerMaker = this.safeBoolN(trade, ['buyerMaker', 'isBuyerMaker', 'maker']);
1150
1170
  let takeOrMaker = undefined;
1151
1171
  if ((isBuyerMaker !== undefined) || (m !== undefined)) {
1152
1172
  takeOrMaker = (isBuyerMaker || m) ? 'maker' : 'taker';
@@ -1183,7 +1203,7 @@ class bingx extends bingx$1 {
1183
1203
  'type': this.safeStringLower(trade, 'o'),
1184
1204
  'side': this.parseOrderSide(side),
1185
1205
  'takerOrMaker': takeOrMaker,
1186
- 'price': this.safeString2(trade, 'price', 'p'),
1206
+ 'price': this.safeStringN(trade, ['price', 'p', 'tradePrice']),
1187
1207
  'amount': amount,
1188
1208
  'cost': cost,
1189
1209
  'fee': {
@@ -4896,14 +4916,16 @@ class bingx extends bingx$1 {
4896
4916
  * @method
4897
4917
  * @name bingx#fetchMyTrades
4898
4918
  * @description fetch all trades made by the user
4899
- * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20History
4900
- * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20historical%20transaction%20orders
4919
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20transaction%20details
4920
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20orders
4921
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order%20Trade%20Detail
4901
4922
  * @param {string} [symbol] unified market symbol
4902
4923
  * @param {int} [since] the earliest time in ms to fetch trades for
4903
4924
  * @param {int} [limit] the maximum number of trades structures to retrieve
4904
4925
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4905
4926
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is undefined
4906
4927
  * @param {string} params.trandingUnit COIN (directly represent assets such as BTC and ETH) or CONT (represents the number of contract sheets)
4928
+ * @param {string} params.orderId the order id required for inverse swap
4907
4929
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
4908
4930
  */
4909
4931
  if (symbol === undefined) {
@@ -4911,84 +4933,121 @@ class bingx extends bingx$1 {
4911
4933
  }
4912
4934
  await this.loadMarkets();
4913
4935
  const market = this.market(symbol);
4914
- const now = this.milliseconds();
4915
- let response = undefined;
4916
- const request = {
4917
- 'symbol': market['id'],
4918
- };
4919
- if (since !== undefined) {
4920
- const startTimeReq = market['spot'] ? 'startTime' : 'startTs';
4921
- request[startTimeReq] = since;
4922
- }
4923
- else if (market['swap']) {
4924
- request['startTs'] = now - 7776000000; // 90 days
4925
- }
4926
- const until = this.safeInteger(params, 'until');
4927
- params = this.omit(params, 'until');
4928
- if (until !== undefined) {
4929
- const endTimeReq = market['spot'] ? 'endTime' : 'endTs';
4930
- request[endTimeReq] = until;
4931
- }
4932
- else if (market['swap']) {
4933
- request['endTs'] = now;
4934
- }
4936
+ const request = {};
4935
4937
  let fills = undefined;
4936
- if (market['spot']) {
4937
- response = await this.spotV1PrivateGetTradeMyTrades(this.extend(request, params));
4938
- const data = this.safeDict(response, 'data', {});
4939
- fills = this.safeList(data, 'fills', []);
4938
+ let response = undefined;
4939
+ let subType = undefined;
4940
+ [subType, params] = this.handleSubTypeAndParams('fetchMyTrades', market, params);
4941
+ if (subType === 'inverse') {
4942
+ const orderId = this.safeString(params, 'orderId');
4943
+ if (orderId === undefined) {
4944
+ throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires an orderId argument for inverse swap trades');
4945
+ }
4946
+ response = await this.cswapV1PrivateGetTradeAllFillOrders(this.extend(request, params));
4947
+ fills = this.safeList(response, 'data', []);
4940
4948
  //
4941
4949
  // {
4942
4950
  // "code": 0,
4943
4951
  // "msg": "",
4944
- // "debugMsg": "",
4945
- // "data": {
4946
- // "fills": [
4947
- // {
4948
- // "symbol": "LTC-USDT",
4949
- // "id": 36237072,
4950
- // "orderId": 1674069326895775744,
4951
- // "price": "85.891",
4952
- // "qty": "0.0582",
4953
- // "quoteQty": "4.9988562000000005",
4954
- // "commission": -0.00005820000000000001,
4955
- // "commissionAsset": "LTC",
4956
- // "time": 1687964205000,
4957
- // "isBuyer": true,
4958
- // "isMaker": false
4959
- // }
4960
- // ]
4961
- // }
4952
+ // "timestamp": 1722147756019,
4953
+ // "data": [
4954
+ // {
4955
+ // "orderId": "1817441228670648320",
4956
+ // "symbol": "SOL-USD",
4957
+ // "type": "MARKET",
4958
+ // "side": "BUY",
4959
+ // "positionSide": "LONG",
4960
+ // "tradeId": "97244554",
4961
+ // "volume": "2",
4962
+ // "tradePrice": "182.652",
4963
+ // "amount": "20.00000000",
4964
+ // "realizedPnl": "0.00000000",
4965
+ // "commission": "-0.00005475",
4966
+ // "currency": "SOL",
4967
+ // "buyer": true,
4968
+ // "maker": false,
4969
+ // "tradeTime": 1722146730000
4970
+ // }
4971
+ // ]
4962
4972
  // }
4963
4973
  //
4964
4974
  }
4965
4975
  else {
4966
- const tradingUnit = this.safeStringUpper(params, 'tradingUnit', 'CONT');
4967
- params = this.omit(params, 'tradingUnit');
4968
- request['tradingUnit'] = tradingUnit;
4969
- response = await this.swapV2PrivateGetTradeAllFillOrders(this.extend(request, params));
4970
- const data = this.safeDict(response, 'data', {});
4971
- fills = this.safeList(data, 'fill_orders', []);
4972
- //
4973
- // {
4974
- // "code": "0",
4975
- // "msg": '',
4976
- // "data": { fill_orders: [
4977
- // {
4978
- // "volume": "0.1",
4979
- // "price": "106.75",
4980
- // "amount": "10.6750",
4981
- // "commission": "-0.0053",
4982
- // "currency": "USDT",
4983
- // "orderId": "1676213270274379776",
4984
- // "liquidatedPrice": "0.00",
4985
- // "liquidatedMarginRatio": "0.00",
4986
- // "filledTime": "2023-07-04T20:56:01.000+0800"
4987
- // }
4988
- // ]
4989
- // }
4990
- // }
4991
- //
4976
+ request['symbol'] = market['id'];
4977
+ const now = this.milliseconds();
4978
+ if (since !== undefined) {
4979
+ const startTimeReq = market['spot'] ? 'startTime' : 'startTs';
4980
+ request[startTimeReq] = since;
4981
+ }
4982
+ else if (market['swap']) {
4983
+ request['startTs'] = now - 7776000000; // 90 days
4984
+ }
4985
+ const until = this.safeInteger(params, 'until');
4986
+ params = this.omit(params, 'until');
4987
+ if (until !== undefined) {
4988
+ const endTimeReq = market['spot'] ? 'endTime' : 'endTs';
4989
+ request[endTimeReq] = until;
4990
+ }
4991
+ else if (market['swap']) {
4992
+ request['endTs'] = now;
4993
+ }
4994
+ if (market['spot']) {
4995
+ response = await this.spotV1PrivateGetTradeMyTrades(this.extend(request, params));
4996
+ const data = this.safeDict(response, 'data', {});
4997
+ fills = this.safeList(data, 'fills', []);
4998
+ //
4999
+ // {
5000
+ // "code": 0,
5001
+ // "msg": "",
5002
+ // "debugMsg": "",
5003
+ // "data": {
5004
+ // "fills": [
5005
+ // {
5006
+ // "symbol": "LTC-USDT",
5007
+ // "id": 36237072,
5008
+ // "orderId": 1674069326895775744,
5009
+ // "price": "85.891",
5010
+ // "qty": "0.0582",
5011
+ // "quoteQty": "4.9988562000000005",
5012
+ // "commission": -0.00005820000000000001,
5013
+ // "commissionAsset": "LTC",
5014
+ // "time": 1687964205000,
5015
+ // "isBuyer": true,
5016
+ // "isMaker": false
5017
+ // }
5018
+ // ]
5019
+ // }
5020
+ // }
5021
+ //
5022
+ }
5023
+ else {
5024
+ const tradingUnit = this.safeStringUpper(params, 'tradingUnit', 'CONT');
5025
+ params = this.omit(params, 'tradingUnit');
5026
+ request['tradingUnit'] = tradingUnit;
5027
+ response = await this.swapV2PrivateGetTradeAllFillOrders(this.extend(request, params));
5028
+ const data = this.safeDict(response, 'data', {});
5029
+ fills = this.safeList(data, 'fill_orders', []);
5030
+ //
5031
+ // {
5032
+ // "code": "0",
5033
+ // "msg": '',
5034
+ // "data": { fill_orders: [
5035
+ // {
5036
+ // "volume": "0.1",
5037
+ // "price": "106.75",
5038
+ // "amount": "10.6750",
5039
+ // "commission": "-0.0053",
5040
+ // "currency": "USDT",
5041
+ // "orderId": "1676213270274379776",
5042
+ // "liquidatedPrice": "0.00",
5043
+ // "liquidatedMarginRatio": "0.00",
5044
+ // "filledTime": "2023-07-04T20:56:01.000+0800"
5045
+ // }
5046
+ // ]
5047
+ // }
5048
+ // }
5049
+ //
5050
+ }
4992
5051
  }
4993
5052
  return this.parseTrades(fills, market, since, limit, params);
4994
5053
  }
@@ -5,6 +5,7 @@ var errors = require('./base/errors.js');
5
5
  var Precise = require('./base/Precise.js');
6
6
  var number = require('./base/functions/number.js');
7
7
  var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
8
+ var md5 = require('./static_dependencies/noble-hashes/md5.js');
8
9
 
9
10
  // ---------------------------------------------------------------------------
10
11
  // ---------------------------------------------------------------------------
@@ -676,7 +677,7 @@ class btcbox extends btcbox$1 {
676
677
  'nonce': nonce,
677
678
  }, params);
678
679
  const request = this.urlencode(query);
679
- const secret = this.hash(this.encode(this.secret), sha256.sha256);
680
+ const secret = this.hash(this.encode(this.secret), md5.md5);
680
681
  query['signature'] = this.hmac(this.encode(request), this.encode(secret), sha256.sha256);
681
682
  body = this.urlencode(query);
682
683
  headers = {
@@ -65,7 +65,7 @@ class coinbaseinternational extends coinbaseinternational$1 {
65
65
  'fetchCrossBorrowRates': false,
66
66
  'fetchCurrencies': true,
67
67
  'fetchDeposits': true,
68
- 'fetchFundingHistory': false,
68
+ 'fetchFundingHistory': true,
69
69
  'fetchFundingRate': false,
70
70
  'fetchFundingRateHistory': true,
71
71
  'fetchFundingRates': false,
@@ -439,6 +439,84 @@ class coinbaseinternational extends coinbaseinternational$1 {
439
439
  'previousFundingDatetime': undefined,
440
440
  };
441
441
  }
442
+ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
443
+ /**
444
+ * @method
445
+ * @name coinbaseinternational#fetchFundingHistory
446
+ * @description fetch the history of funding payments paid and received on this account
447
+ * @see https://docs.cdp.coinbase.com/intx/reference/gettransfers
448
+ * @param {string} [symbol] unified market symbol
449
+ * @param {int} [since] the earliest time in ms to fetch funding history for
450
+ * @param {int} [limit] the maximum number of funding history structures to retrieve
451
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
452
+ * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
453
+ */
454
+ await this.loadMarkets();
455
+ const request = {
456
+ 'type': 'FUNDING',
457
+ };
458
+ let market = undefined;
459
+ if (symbol !== undefined) {
460
+ market = this.market(symbol);
461
+ }
462
+ let portfolios = undefined;
463
+ [portfolios, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'portfolios');
464
+ if (portfolios !== undefined) {
465
+ request['portfolios'] = portfolios;
466
+ }
467
+ if (since !== undefined) {
468
+ request['time_from'] = this.iso8601(since);
469
+ }
470
+ if (limit !== undefined) {
471
+ request['result_limit'] = limit;
472
+ }
473
+ else {
474
+ request['result_limit'] = 100;
475
+ }
476
+ const response = await this.v1PrivateGetTransfers(this.extend(request, params));
477
+ const fundings = this.safeList(response, 'results', []);
478
+ return this.parseIncomes(fundings, market, since, limit);
479
+ }
480
+ parseIncome(income, market = undefined) {
481
+ //
482
+ // {
483
+ // "amount":"0.0008",
484
+ // "asset":"USDC",
485
+ // "created_at":"2024-02-22T16:00:00Z",
486
+ // "from_portfolio":{
487
+ // "id":"13yuk1fs-1-0",
488
+ // "name":"Eng Test Portfolio - 2",
489
+ // "uuid":"018712f2-5ff9-7de3-9010-xxxxxxxxx"
490
+ // },
491
+ // "instrument_id":"149264164756389888",
492
+ // "instrument_symbol":"ETH-PERP",
493
+ // "position_id":"1xy4v51m-1-2",
494
+ // "status":"PROCESSED",
495
+ // "to_portfolio":{
496
+ // "name":"CB_FUND"
497
+ // },
498
+ // "transfer_type":"FUNDING",
499
+ // "transfer_uuid":"a6b708df-2c44-32c5-bb98-xxxxxxxxxx",
500
+ // "updated_at":"2024-02-22T16:00:00Z"
501
+ // }
502
+ //
503
+ const marketId = this.safeString(income, 'symbol');
504
+ market = this.safeMarket(marketId, market, undefined, 'contract');
505
+ const datetime = this.safeInteger(income, 'created_at');
506
+ const timestamp = this.parse8601(datetime);
507
+ const currencyId = this.safeString(income, 'asset');
508
+ const code = this.safeCurrencyCode(currencyId);
509
+ return {
510
+ 'info': income,
511
+ 'symbol': market['symbol'],
512
+ 'code': code,
513
+ 'timestamp': timestamp,
514
+ 'datetime': this.iso8601(timestamp),
515
+ 'id': this.safeString(income, 'transfer_uuid'),
516
+ 'amount': this.safeNumber(income, 'amount'),
517
+ 'rate': undefined,
518
+ };
519
+ }
442
520
  async createDepositAddress(code, params = {}) {
443
521
  /**
444
522
  * @method
@@ -829,9 +829,6 @@ class hyperliquid extends hyperliquid$1 {
829
829
  if (since === undefined) {
830
830
  since = 0;
831
831
  }
832
- if (limit === undefined) {
833
- limit = 500;
834
- }
835
832
  params = this.omit(params, ['until']);
836
833
  const request = {
837
834
  'type': 'candleSnapshot',
@@ -1521,21 +1521,28 @@ class kucoin extends kucoin$1 {
1521
1521
  },
1522
1522
  'networks': {},
1523
1523
  };
1524
- const isWithdrawEnabled = this.safeBool(fee, 'isWithdrawEnabled');
1524
+ const isWithdrawEnabled = this.safeBool(fee, 'isWithdrawEnabled', true);
1525
+ let minFee = undefined;
1525
1526
  if (isWithdrawEnabled) {
1526
- result['withdraw']['fee'] = this.safeNumber2(fee, 'withdrawalMinFee', 'withdrawMinFee');
1527
1527
  result['withdraw']['percentage'] = false;
1528
- const networkId = this.safeString(fee, 'chain');
1529
- if (networkId) {
1528
+ const chains = this.safeList(fee, 'chains', []);
1529
+ for (let i = 0; i < chains.length; i++) {
1530
+ const chain = chains[i];
1531
+ const networkId = this.safeString(chain, 'chainId');
1530
1532
  const networkCode = this.networkIdToCode(networkId, this.safeString(currency, 'code'));
1533
+ const withdrawFee = this.safeString(chain, 'withdrawalMinFee');
1534
+ if (minFee === undefined || (Precise["default"].stringLt(withdrawFee, minFee))) {
1535
+ minFee = withdrawFee;
1536
+ }
1531
1537
  result['networks'][networkCode] = {
1532
- 'withdraw': result['withdraw'],
1538
+ 'withdraw': this.parseNumber(withdrawFee),
1533
1539
  'deposit': {
1534
1540
  'fee': undefined,
1535
1541
  'percentage': undefined,
1536
1542
  },
1537
1543
  };
1538
1544
  }
1545
+ result['withdraw']['fee'] = this.parseNumber(minFee);
1539
1546
  }
1540
1547
  return result;
1541
1548
  }
@@ -2044,9 +2044,9 @@ class oxfun extends oxfun$1 {
2044
2044
  async withdraw(code, amount, address, tag = undefined, params = {}) {
2045
2045
  /**
2046
2046
  * @method
2047
- * @name bitflex#withdraw
2047
+ * @name oxfun#withdraw
2048
2048
  * @description make a withdrawal
2049
- * @see https://docs.bitflex.com/spot#withdraw
2049
+ * @see https://docs.ox.fun/?json#post-v3-withdrawal
2050
2050
  * @param {string} code unified currency code
2051
2051
  * @param {float} amount the amount to withdraw
2052
2052
  * @param {string} address the address to withdraw to