ccxt 4.4.3 → 4.4.4

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 (120) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +2 -2
  5. package/dist/cjs/src/base/functions/misc.js +11 -0
  6. package/dist/cjs/src/base/functions.js +1 -0
  7. package/dist/cjs/src/base/ws/WsClient.js +2 -1
  8. package/dist/cjs/src/binance.js +39 -12
  9. package/dist/cjs/src/bingx.js +1 -0
  10. package/dist/cjs/src/bitfinex2.js +7 -6
  11. package/dist/cjs/src/bitget.js +10 -6
  12. package/dist/cjs/src/bitmex.js +11 -10
  13. package/dist/cjs/src/bitso.js +5 -4
  14. package/dist/cjs/src/bitstamp.js +9 -9
  15. package/dist/cjs/src/blofin.js +21 -23
  16. package/dist/cjs/src/bybit.js +21 -20
  17. package/dist/cjs/src/coinbase.js +28 -7
  18. package/dist/cjs/src/coinbaseexchange.js +11 -11
  19. package/dist/cjs/src/coinlist.js +6 -5
  20. package/dist/cjs/src/coinmetro.js +3 -3
  21. package/dist/cjs/src/cryptocom.js +7 -5
  22. package/dist/cjs/src/currencycom.js +6 -6
  23. package/dist/cjs/src/delta.js +5 -5
  24. package/dist/cjs/src/digifinex.js +8 -6
  25. package/dist/cjs/src/gate.js +6 -5
  26. package/dist/cjs/src/hashkey.js +9 -7
  27. package/dist/cjs/src/htx.js +13 -16
  28. package/dist/cjs/src/hyperliquid.js +67 -114
  29. package/dist/cjs/src/kraken.js +8 -6
  30. package/dist/cjs/src/kucoin.js +9 -8
  31. package/dist/cjs/src/luno.js +10 -9
  32. package/dist/cjs/src/mexc.js +35 -2
  33. package/dist/cjs/src/ndax.js +6 -5
  34. package/dist/cjs/src/okcoin.js +18 -27
  35. package/dist/cjs/src/okx.js +18 -26
  36. package/dist/cjs/src/p2b.js +2 -2
  37. package/dist/cjs/src/pro/bybit.js +56 -0
  38. package/dist/cjs/src/pro/mexc.js +83 -0
  39. package/dist/cjs/src/woo.js +7 -6
  40. package/dist/cjs/src/woofipro.js +8 -6
  41. package/dist/cjs/src/xt.js +4 -3
  42. package/dist/cjs/src/zonda.js +6 -5
  43. package/js/ccxt.d.ts +1 -1
  44. package/js/ccxt.js +1 -1
  45. package/js/src/base/Exchange.d.ts +2 -2
  46. package/js/src/base/Exchange.js +2 -2
  47. package/js/src/base/functions/misc.d.ts +2 -1
  48. package/js/src/base/functions/misc.js +11 -1
  49. package/js/src/base/types.d.ts +1 -1
  50. package/js/src/base/ws/WsClient.js +2 -2
  51. package/js/src/binance.d.ts +4 -20
  52. package/js/src/binance.js +39 -12
  53. package/js/src/bingx.js +1 -0
  54. package/js/src/bitfinex2.d.ts +3 -19
  55. package/js/src/bitfinex2.js +7 -6
  56. package/js/src/bitget.d.ts +3 -19
  57. package/js/src/bitget.js +10 -6
  58. package/js/src/bitmex.d.ts +3 -22
  59. package/js/src/bitmex.js +11 -10
  60. package/js/src/bitso.d.ts +3 -19
  61. package/js/src/bitso.js +5 -4
  62. package/js/src/bitstamp.d.ts +3 -35
  63. package/js/src/bitstamp.js +9 -9
  64. package/js/src/blofin.d.ts +3 -15
  65. package/js/src/blofin.js +21 -23
  66. package/js/src/bybit.d.ts +3 -19
  67. package/js/src/bybit.js +21 -20
  68. package/js/src/coinbase.d.ts +3 -19
  69. package/js/src/coinbase.js +28 -7
  70. package/js/src/coinbaseexchange.d.ts +3 -19
  71. package/js/src/coinbaseexchange.js +11 -11
  72. package/js/src/coinlist.d.ts +3 -19
  73. package/js/src/coinlist.js +6 -5
  74. package/js/src/coinmetro.d.ts +3 -19
  75. package/js/src/coinmetro.js +3 -3
  76. package/js/src/cryptocom.d.ts +3 -22
  77. package/js/src/cryptocom.js +7 -5
  78. package/js/src/currencycom.d.ts +3 -3
  79. package/js/src/currencycom.js +6 -6
  80. package/js/src/delta.d.ts +3 -19
  81. package/js/src/delta.js +5 -5
  82. package/js/src/digifinex.d.ts +3 -19
  83. package/js/src/digifinex.js +8 -6
  84. package/js/src/gate.d.ts +3 -19
  85. package/js/src/gate.js +6 -5
  86. package/js/src/hashkey.d.ts +3 -20
  87. package/js/src/hashkey.js +9 -7
  88. package/js/src/htx.d.ts +3 -19
  89. package/js/src/htx.js +13 -16
  90. package/js/src/hyperliquid.d.ts +3 -19
  91. package/js/src/hyperliquid.js +68 -115
  92. package/js/src/kraken.d.ts +5 -24
  93. package/js/src/kraken.js +8 -6
  94. package/js/src/kucoin.d.ts +3 -19
  95. package/js/src/kucoin.js +9 -8
  96. package/js/src/luno.d.ts +4 -20
  97. package/js/src/luno.js +10 -9
  98. package/js/src/mexc.js +35 -2
  99. package/js/src/ndax.d.ts +3 -19
  100. package/js/src/ndax.js +6 -5
  101. package/js/src/okcoin.d.ts +3 -19
  102. package/js/src/okcoin.js +18 -27
  103. package/js/src/okx.d.ts +3 -19
  104. package/js/src/okx.js +18 -26
  105. package/js/src/p2b.js +2 -2
  106. package/js/src/pro/bybit.d.ts +2 -0
  107. package/js/src/pro/bybit.js +56 -0
  108. package/js/src/pro/mexc.d.ts +4 -1
  109. package/js/src/pro/mexc.js +84 -1
  110. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  111. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  112. package/js/src/woo.d.ts +3 -19
  113. package/js/src/woo.js +7 -6
  114. package/js/src/woofipro.d.ts +3 -19
  115. package/js/src/woofipro.js +8 -6
  116. package/js/src/xt.d.ts +3 -22
  117. package/js/src/xt.js +4 -3
  118. package/js/src/zonda.d.ts +3 -19
  119. package/js/src/zonda.js +6 -5
  120. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
194
194
 
195
195
  //-----------------------------------------------------------------------------
196
196
  // this is updated by vss.js when building
197
- const version = '4.4.3';
197
+ const version = '4.4.4';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'ace': ace,
@@ -50,7 +50,7 @@ function _interopNamespace(e) {
50
50
  }
51
51
 
52
52
  // ----------------------------------------------------------------------------
53
- const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
53
+ const { isNode, selfIsDefined, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
54
54
  // ----------------------------------------------------------------------------
55
55
  /**
56
56
  * @class Exchange
@@ -640,7 +640,7 @@ class Exchange {
640
640
  }
641
641
  }
642
642
  else {
643
- this.fetchImplementation = self.fetch;
643
+ this.fetchImplementation = (selfIsDefined()) ? self.fetch : fetch;
644
644
  this.AbortError = DOMException;
645
645
  this.FetchError = TypeError;
646
646
  }
@@ -86,6 +86,16 @@ function aggregate(bidasks) {
86
86
  }
87
87
  return Object.keys(result).map((price) => [parseFloat(price), parseFloat(result[price])]); // TODO: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}', No index signature with a parameter of type 'string' was found on type '{}'.ts(7053)
88
88
  }
89
+ function selfIsDefined() {
90
+ let selfIsDefined = false;
91
+ try {
92
+ selfIsDefined = self !== undefined;
93
+ }
94
+ catch (e) {
95
+ selfIsDefined = false;
96
+ }
97
+ return selfIsDefined;
98
+ }
89
99
  /* ------------------------------------------------------------------------ */
90
100
 
91
101
  exports.aggregate = aggregate;
@@ -93,4 +103,5 @@ exports.extractParams = extractParams;
93
103
  exports.implodeParams = implodeParams;
94
104
  exports.parseTimeframe = parseTimeframe;
95
105
  exports.roundTimeframe = roundTimeframe;
106
+ exports.selfIsDefined = selfIsDefined;
96
107
  exports.vwap = vwap;
@@ -156,4 +156,5 @@ exports.extractParams = misc.extractParams;
156
156
  exports.implodeParams = misc.implodeParams;
157
157
  exports.parseTimeframe = misc.parseTimeframe;
158
158
  exports.roundTimeframe = misc.roundTimeframe;
159
+ exports.selfIsDefined = misc.selfIsDefined;
159
160
  exports.vwap = misc.vwap;
@@ -6,6 +6,7 @@ var platform = require('../functions/platform.js');
6
6
  require('../functions/encode.js');
7
7
  require('../functions/crypto.js');
8
8
  var time = require('../functions/time.js');
9
+ var misc = require('../functions/misc.js');
9
10
  var Future = require('./Future.js');
10
11
 
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -14,7 +15,7 @@ var WebSocket__default = /*#__PURE__*/_interopDefaultLegacy(WebSocket);
14
15
 
15
16
  // eslint-disable-next-line no-shadow
16
17
  // eslint-disable-next-line no-restricted-globals
17
- const WebSocketPlatform = platform.isNode ? WebSocket__default["default"] : self.WebSocket;
18
+ const WebSocketPlatform = platform.isNode || !misc.selfIsDefined() ? WebSocket__default["default"] : self.WebSocket;
18
19
  class WsClient extends Client {
19
20
  constructor() {
20
21
  super(...arguments);
@@ -11219,17 +11219,42 @@ class binance extends binance$1 {
11219
11219
  return result;
11220
11220
  }
11221
11221
  async fetchLedgerEntry(id, code = undefined, params = {}) {
11222
+ /**
11223
+ * @method
11224
+ * @name binance#fetchLedgerEntry
11225
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
11226
+ * @see https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
11227
+ * @param {string} id the identification number of the ledger entry
11228
+ * @param {string} code unified currency code
11229
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
11230
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
11231
+ */
11222
11232
  await this.loadMarkets();
11223
11233
  let type = undefined;
11224
11234
  [type, params] = this.handleMarketTypeAndParams('fetchLedgerEntry', undefined, params);
11225
- const query = {
11226
- 'recordId': id,
11227
- 'type': type,
11228
- };
11229
11235
  if (type !== 'option') {
11230
- throw new errors.BadRequest(this.id + ' fetchLedgerEntry () can only be used for type option');
11236
+ throw new errors.BadRequest(this.id + ' fetchLedgerEntry() can only be used for type option');
11231
11237
  }
11232
- return await this.fetchLedger(code, undefined, undefined, this.extend(query, params));
11238
+ this.checkRequiredArgument('fetchLedgerEntry', code, 'code');
11239
+ const currency = this.currency(code);
11240
+ const request = {
11241
+ 'recordId': id,
11242
+ 'currency': currency['id'],
11243
+ };
11244
+ const response = await this.eapiPrivateGetBill(this.extend(request, params));
11245
+ //
11246
+ // [
11247
+ // {
11248
+ // "id": "1125899906845701870",
11249
+ // "asset": "USDT",
11250
+ // "amount": "-0.16518203",
11251
+ // "type": "FEE",
11252
+ // "createDate": 1676621042489
11253
+ // }
11254
+ // ]
11255
+ //
11256
+ const first = this.safeDict(response, 0, response);
11257
+ return this.parseLedgerEntry(first, currency);
11233
11258
  }
11234
11259
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
11235
11260
  /**
@@ -11241,9 +11266,9 @@ class binance extends binance$1 {
11241
11266
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Get-Income-History
11242
11267
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
11243
11268
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
11244
- * @param {string} code unified currency code
11269
+ * @param {string} [code] unified currency code
11245
11270
  * @param {int} [since] timestamp in ms of the earliest ledger entry
11246
- * @param {int} [limit] max number of ledger entrys to return
11271
+ * @param {int} [limit] max number of ledger entries to return
11247
11272
  * @param {object} [params] extra parameters specific to the exchange API endpoint
11248
11273
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
11249
11274
  * @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)
@@ -11369,16 +11394,19 @@ class binance extends binance$1 {
11369
11394
  direction = 'in';
11370
11395
  }
11371
11396
  const currencyId = this.safeString(item, 'asset');
11397
+ const code = this.safeCurrencyCode(currencyId, currency);
11398
+ currency = this.safeCurrency(currencyId, currency);
11372
11399
  const timestamp = this.safeInteger2(item, 'createDate', 'time');
11373
11400
  const type = this.safeString2(item, 'type', 'incomeType');
11374
- return {
11401
+ return this.safeLedgerEntry({
11402
+ 'info': item,
11375
11403
  'id': this.safeString2(item, 'id', 'tranId'),
11376
11404
  'direction': direction,
11377
11405
  'account': undefined,
11378
11406
  'referenceAccount': undefined,
11379
11407
  'referenceId': this.safeString(item, 'tradeId'),
11380
11408
  'type': this.parseLedgerEntryType(type),
11381
- 'currency': this.safeCurrencyCode(currencyId, currency),
11409
+ 'currency': code,
11382
11410
  'amount': this.parseNumber(amount),
11383
11411
  'timestamp': timestamp,
11384
11412
  'datetime': this.iso8601(timestamp),
@@ -11386,8 +11414,7 @@ class binance extends binance$1 {
11386
11414
  'after': undefined,
11387
11415
  'status': undefined,
11388
11416
  'fee': undefined,
11389
- 'info': item,
11390
- };
11417
+ }, currency);
11391
11418
  }
11392
11419
  parseLedgerEntryType(type) {
11393
11420
  const ledgerType = {
@@ -465,6 +465,7 @@ class bingx extends bingx$1 {
465
465
  'commonCurrencies': {
466
466
  'SNOW': 'Snowman',
467
467
  'OMNI': 'OmniCat',
468
+ 'NAP': '$NAP', // NAP on SOL = SNAP
468
469
  },
469
470
  'options': {
470
471
  'defaultType': 'spot',
@@ -2917,6 +2917,7 @@ class bitfinex2 extends bitfinex2$1 {
2917
2917
  const id = this.safeString(itemList, 0);
2918
2918
  const currencyId = this.safeString(itemList, 1);
2919
2919
  const code = this.safeCurrencyCode(currencyId, currency);
2920
+ currency = this.safeCurrency(currencyId, currency);
2920
2921
  const timestamp = this.safeInteger(itemList, 3);
2921
2922
  const amount = this.safeNumber(itemList, 5);
2922
2923
  const after = this.safeNumber(itemList, 6);
@@ -2926,7 +2927,8 @@ class bitfinex2 extends bitfinex2$1 {
2926
2927
  const first = this.safeStringLower(parts, 0);
2927
2928
  type = this.parseLedgerEntryType(first);
2928
2929
  }
2929
- return {
2930
+ return this.safeLedgerEntry({
2931
+ 'info': item,
2930
2932
  'id': id,
2931
2933
  'direction': undefined,
2932
2934
  'account': undefined,
@@ -2941,18 +2943,17 @@ class bitfinex2 extends bitfinex2$1 {
2941
2943
  'after': after,
2942
2944
  'status': undefined,
2943
2945
  'fee': undefined,
2944
- 'info': item,
2945
- };
2946
+ }, currency);
2946
2947
  }
2947
2948
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2948
2949
  /**
2949
2950
  * @method
2950
2951
  * @name bitfinex2#fetchLedger
2951
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2952
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2952
2953
  * @see https://docs.bitfinex.com/reference/rest-auth-ledgers
2953
- * @param {string} code unified currency code, default is undefined
2954
+ * @param {string} [code] unified currency code, default is undefined
2954
2955
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2955
- * @param {int} [limit] max number of ledger entrys to return, default is undefined max is 2500
2956
+ * @param {int} [limit] max number of ledger entries to return, default is undefined, max is 2500
2956
2957
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2957
2958
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
2958
2959
  * @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)
@@ -5901,12 +5901,12 @@ class bitget extends bitget$1 {
5901
5901
  /**
5902
5902
  * @method
5903
5903
  * @name bitget#fetchLedger
5904
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
5904
5905
  * @see https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
5905
5906
  * @see https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
5906
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
5907
- * @param {string} code unified currency code, default is undefined
5907
+ * @param {string} [code] unified currency code, default is undefined
5908
5908
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
5909
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
5909
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
5910
5910
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5911
5911
  * @param {int} [params.until] end time in ms
5912
5912
  * @param {string} [params.symbol] *contract only* unified market symbol
@@ -6046,6 +6046,7 @@ class bitget extends bitget$1 {
6046
6046
  //
6047
6047
  const currencyId = this.safeString(item, 'coin');
6048
6048
  const code = this.safeCurrencyCode(currencyId, currency);
6049
+ currency = this.safeCurrency(currencyId, currency);
6049
6050
  const timestamp = this.safeInteger(item, 'cTime');
6050
6051
  const after = this.safeNumber(item, 'balance');
6051
6052
  const fee = this.safeNumber2(item, 'fees', 'fee');
@@ -6055,7 +6056,7 @@ class bitget extends bitget$1 {
6055
6056
  if (amountRaw.indexOf('-') >= 0) {
6056
6057
  direction = 'out';
6057
6058
  }
6058
- return {
6059
+ return this.safeLedgerEntry({
6059
6060
  'info': item,
6060
6061
  'id': this.safeString(item, 'billId'),
6061
6062
  'timestamp': timestamp,
@@ -6070,8 +6071,11 @@ class bitget extends bitget$1 {
6070
6071
  'before': undefined,
6071
6072
  'after': after,
6072
6073
  'status': undefined,
6073
- 'fee': fee,
6074
- };
6074
+ 'fee': {
6075
+ 'currency': code,
6076
+ 'cost': fee,
6077
+ },
6078
+ }, currency);
6075
6079
  }
6076
6080
  parseLedgerType(type) {
6077
6081
  const types = {
@@ -1143,6 +1143,7 @@ class bitmex extends bitmex$1 {
1143
1143
  const type = this.parseLedgerEntryType(this.safeString(item, 'transactType'));
1144
1144
  const currencyId = this.safeString(item, 'currency');
1145
1145
  const code = this.safeCurrencyCode(currencyId, currency);
1146
+ currency = this.safeCurrency(currencyId, currency);
1146
1147
  const amountString = this.safeString(item, 'amount');
1147
1148
  let amount = this.convertToRealAmount(code, amountString);
1148
1149
  let timestamp = this.parse8601(this.safeString(item, 'transactTime'));
@@ -1157,14 +1158,14 @@ class bitmex extends bitmex$1 {
1157
1158
  feeCost = this.convertToRealAmount(code, feeCost);
1158
1159
  }
1159
1160
  const fee = {
1160
- 'cost': this.parseNumber(feeCost),
1161
+ 'cost': this.parseToNumeric(feeCost),
1161
1162
  'currency': code,
1162
1163
  };
1163
1164
  let after = this.safeString(item, 'walletBalance');
1164
1165
  if (after !== undefined) {
1165
1166
  after = this.convertToRealAmount(code, after);
1166
1167
  }
1167
- const before = this.parseNumber(Precise["default"].stringSub(this.numberToString(after), this.numberToString(amount)));
1168
+ const before = this.parseToNumeric(Precise["default"].stringSub(this.numberToString(after), this.numberToString(amount)));
1168
1169
  let direction = undefined;
1169
1170
  if (Precise["default"].stringLt(amountString, '0')) {
1170
1171
  direction = 'out';
@@ -1174,9 +1175,9 @@ class bitmex extends bitmex$1 {
1174
1175
  direction = 'in';
1175
1176
  }
1176
1177
  const status = this.parseTransactionStatus(this.safeString(item, 'transactStatus'));
1177
- return {
1178
- 'id': id,
1178
+ return this.safeLedgerEntry({
1179
1179
  'info': item,
1180
+ 'id': id,
1180
1181
  'timestamp': timestamp,
1181
1182
  'datetime': this.iso8601(timestamp),
1182
1183
  'direction': direction,
@@ -1185,22 +1186,22 @@ class bitmex extends bitmex$1 {
1185
1186
  'referenceAccount': referenceAccount,
1186
1187
  'type': type,
1187
1188
  'currency': code,
1188
- 'amount': amount,
1189
+ 'amount': this.parseToNumeric(amount),
1189
1190
  'before': before,
1190
- 'after': this.parseNumber(after),
1191
+ 'after': this.parseToNumeric(after),
1191
1192
  'status': status,
1192
1193
  'fee': fee,
1193
- };
1194
+ }, currency);
1194
1195
  }
1195
1196
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1196
1197
  /**
1197
1198
  * @method
1198
1199
  * @name bitmex#fetchLedger
1199
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1200
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1200
1201
  * @see https://www.bitmex.com/api/explorer/#!/User/User_getWalletHistory
1201
- * @param {string} code unified currency code, default is undefined
1202
+ * @param {string} [code] unified currency code, default is undefined
1202
1203
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1203
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1204
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1204
1205
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1205
1206
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1206
1207
  */
@@ -191,10 +191,10 @@ class bitso extends bitso$1 {
191
191
  /**
192
192
  * @method
193
193
  * @name bitso#fetchLedger
194
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
195
- * @param {string} code unified currency code, default is undefined
194
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
195
+ * @param {string} [code] unified currency code, default is undefined
196
196
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
197
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
197
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
198
198
  * @param {object} [params] extra parameters specific to the exchange API endpoint
199
199
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
200
200
  */
@@ -303,6 +303,7 @@ class bitso extends bitso$1 {
303
303
  const amount = this.safeString(firstBalance, 'amount');
304
304
  const currencyId = this.safeString(firstBalance, 'currency');
305
305
  const code = this.safeCurrencyCode(currencyId, currency);
306
+ currency = this.safeCurrency(currencyId, currency);
306
307
  const details = this.safeValue(item, 'details', {});
307
308
  let referenceId = this.safeString2(details, 'fid', 'wid');
308
309
  if (referenceId === undefined) {
@@ -327,6 +328,7 @@ class bitso extends bitso$1 {
327
328
  }
328
329
  const timestamp = this.parse8601(this.safeString(item, 'created_at'));
329
330
  return this.safeLedgerEntry({
331
+ 'info': item,
330
332
  'id': this.safeString(item, 'eid'),
331
333
  'direction': direction,
332
334
  'account': undefined,
@@ -341,7 +343,6 @@ class bitso extends bitso$1 {
341
343
  'after': undefined,
342
344
  'status': 'ok',
343
345
  'fee': fee,
344
- 'info': item,
345
346
  }, currency);
346
347
  }
347
348
  async fetchMarkets(params = {}) {
@@ -1978,9 +1978,9 @@ class bitstamp extends bitstamp$1 {
1978
1978
  market = this.getMarketFromTrade(item);
1979
1979
  }
1980
1980
  const direction = (parsedTrade['side'] === 'buy') ? 'in' : 'out';
1981
- return {
1982
- 'id': parsedTrade['id'],
1981
+ return this.safeLedgerEntry({
1983
1982
  'info': item,
1983
+ 'id': parsedTrade['id'],
1984
1984
  'timestamp': parsedTrade['timestamp'],
1985
1985
  'datetime': parsedTrade['datetime'],
1986
1986
  'direction': direction,
@@ -1994,7 +1994,7 @@ class bitstamp extends bitstamp$1 {
1994
1994
  'after': undefined,
1995
1995
  'status': 'ok',
1996
1996
  'fee': parsedTrade['fee'],
1997
- };
1997
+ }, currency);
1998
1998
  }
1999
1999
  else {
2000
2000
  const parsedTransaction = this.parseTransaction(item, currency);
@@ -2009,9 +2009,9 @@ class bitstamp extends bitstamp$1 {
2009
2009
  const amount = this.safeString(item, currency['id']);
2010
2010
  direction = Precise["default"].stringGt(amount, '0') ? 'in' : 'out';
2011
2011
  }
2012
- return {
2013
- 'id': parsedTransaction['id'],
2012
+ return this.safeLedgerEntry({
2014
2013
  'info': item,
2014
+ 'id': parsedTransaction['id'],
2015
2015
  'timestamp': parsedTransaction['timestamp'],
2016
2016
  'datetime': parsedTransaction['datetime'],
2017
2017
  'direction': direction,
@@ -2025,18 +2025,18 @@ class bitstamp extends bitstamp$1 {
2025
2025
  'after': undefined,
2026
2026
  'status': parsedTransaction['status'],
2027
2027
  'fee': parsedTransaction['fee'],
2028
- };
2028
+ }, currency);
2029
2029
  }
2030
2030
  }
2031
2031
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2032
2032
  /**
2033
2033
  * @method
2034
2034
  * @name bitstamp#fetchLedger
2035
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2035
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2036
2036
  * @see https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions
2037
- * @param {string} code unified currency code, default is undefined
2037
+ * @param {string} [code] unified currency code, default is undefined
2038
2038
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2039
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2039
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2040
2040
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2041
2041
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2042
2042
  */
@@ -1503,15 +1503,15 @@ class blofin extends blofin$1 {
1503
1503
  /**
1504
1504
  * @method
1505
1505
  * @name blofin#fetchLedger
1506
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1506
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1507
1507
  * @see https://blofin.com/docs#get-funds-transfer-history
1508
- * @param {string} code unified currency code, default is undefined
1508
+ * @param {string} [code] unified currency code, default is undefined
1509
1509
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1510
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1510
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1511
1511
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1512
1512
  * @param {string} [params.marginMode] 'cross' or 'isolated'
1513
1513
  * @param {int} [params.until] the latest time in ms to fetch entries for
1514
- * @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)
1514
+ * @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)
1515
1515
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1516
1516
  */
1517
1517
  await this.loadMarkets();
@@ -1647,29 +1647,27 @@ class blofin extends blofin$1 {
1647
1647
  return this.safeString(types, type, type);
1648
1648
  }
1649
1649
  parseLedgerEntry(item, currency = undefined) {
1650
- const id = this.safeString(item, 'transferId');
1651
- const referenceId = this.safeString(item, 'clientId');
1652
- const fromAccount = this.safeString(item, 'fromAccount');
1653
- const toAccount = this.safeString(item, 'toAccount');
1654
- const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
1655
- const code = this.safeCurrencyCode(this.safeString(item, 'currency'), currency);
1656
- const amountString = this.safeString(item, 'amount');
1657
- const amount = this.parseNumber(amountString);
1650
+ const currencyId = this.safeString(item, 'currency');
1651
+ const code = this.safeCurrencyCode(currencyId, currency);
1652
+ currency = this.safeCurrency(currencyId, currency);
1658
1653
  const timestamp = this.safeInteger(item, 'ts');
1659
- const status = 'ok';
1660
- return {
1661
- 'id': id,
1654
+ return this.safeLedgerEntry({
1662
1655
  'info': item,
1656
+ 'id': this.safeString(item, 'transferId'),
1657
+ 'direction': undefined,
1658
+ 'account': undefined,
1659
+ 'referenceId': this.safeString(item, 'clientId'),
1660
+ 'referenceAccount': undefined,
1661
+ 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
1662
+ 'currency': code,
1663
+ 'amount': this.safeNumber(item, 'amount'),
1663
1664
  'timestamp': timestamp,
1664
1665
  'datetime': this.iso8601(timestamp),
1665
- 'fromAccount': fromAccount,
1666
- 'toAccount': toAccount,
1667
- 'type': type,
1668
- 'currency': code,
1669
- 'amount': amount,
1670
- 'clientId': referenceId,
1671
- 'status': status,
1672
- };
1666
+ 'before': undefined,
1667
+ 'after': undefined,
1668
+ 'status': 'ok',
1669
+ 'fee': undefined,
1670
+ }, currency);
1673
1671
  }
1674
1672
  parseIds(ids) {
1675
1673
  /**
@@ -5923,13 +5923,13 @@ class bybit extends bybit$1 {
5923
5923
  /**
5924
5924
  * @method
5925
5925
  * @name bybit#fetchLedger
5926
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
5926
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
5927
5927
  * @see https://bybit-exchange.github.io/docs/v5/account/transaction-log
5928
5928
  * @see https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log
5929
- * @param {string} code unified currency code, default is undefined
5929
+ * @param {string} [code] unified currency code, default is undefined
5930
5930
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
5931
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
5932
- * @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)
5931
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
5932
+ * @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)
5933
5933
  * @param {string} [params.subType] if inverse will use v5/account/contract-transaction-log
5934
5934
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5935
5935
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
@@ -6139,6 +6139,7 @@ class bybit extends bybit$1 {
6139
6139
  //
6140
6140
  const currencyId = this.safeString2(item, 'coin', 'currency');
6141
6141
  const code = this.safeCurrencyCode(currencyId, currency);
6142
+ currency = this.safeCurrency(currencyId, currency);
6142
6143
  const amount = this.safeString2(item, 'amount', 'change');
6143
6144
  const after = this.safeString2(item, 'wallet_balance', 'cashBalance');
6144
6145
  const direction = Precise["default"].stringLt(amount, '0') ? 'out' : 'in';
@@ -6151,26 +6152,26 @@ class bybit extends bybit$1 {
6151
6152
  if (timestamp === undefined) {
6152
6153
  timestamp = this.safeInteger(item, 'transactionTime');
6153
6154
  }
6154
- const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
6155
- const id = this.safeString(item, 'id');
6156
- const referenceId = this.safeString(item, 'tx_id');
6157
- return {
6158
- 'id': id,
6159
- 'currency': code,
6155
+ return this.safeLedgerEntry({
6156
+ 'info': item,
6157
+ 'id': this.safeString(item, 'id'),
6158
+ 'direction': direction,
6160
6159
  'account': this.safeString(item, 'wallet_id'),
6160
+ 'referenceId': this.safeString(item, 'tx_id'),
6161
6161
  'referenceAccount': undefined,
6162
- 'referenceId': referenceId,
6163
- 'status': undefined,
6164
- 'amount': this.parseNumber(Precise["default"].stringAbs(amount)),
6165
- 'before': this.parseNumber(before),
6166
- 'after': this.parseNumber(after),
6167
- 'fee': this.parseNumber(this.safeString(item, 'fee')),
6168
- 'direction': direction,
6162
+ 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
6163
+ 'currency': code,
6164
+ 'amount': this.parseToNumeric(Precise["default"].stringAbs(amount)),
6169
6165
  'timestamp': timestamp,
6170
6166
  'datetime': this.iso8601(timestamp),
6171
- 'type': type,
6172
- 'info': item,
6173
- };
6167
+ 'before': this.parseToNumeric(before),
6168
+ 'after': this.parseToNumeric(after),
6169
+ 'status': 'ok',
6170
+ 'fee': {
6171
+ 'currency': code,
6172
+ 'cost': this.parseToNumeric(this.safeString(item, 'fee')),
6173
+ },
6174
+ }, currency);
6174
6175
  }
6175
6176
  parseLedgerEntryType(type) {
6176
6177
  const types = {