ccxt 4.4.3 → 4.4.5

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 (134) 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 +42 -15
  9. package/dist/cjs/src/binanceus.js +1 -0
  10. package/dist/cjs/src/bingx.js +1 -0
  11. package/dist/cjs/src/bitfinex2.js +7 -6
  12. package/dist/cjs/src/bitget.js +57 -100
  13. package/dist/cjs/src/bitmex.js +11 -10
  14. package/dist/cjs/src/bitso.js +5 -4
  15. package/dist/cjs/src/bitstamp.js +9 -9
  16. package/dist/cjs/src/blofin.js +21 -23
  17. package/dist/cjs/src/bybit.js +100 -26
  18. package/dist/cjs/src/coinbase.js +28 -7
  19. package/dist/cjs/src/coinbaseexchange.js +11 -11
  20. package/dist/cjs/src/coinlist.js +6 -5
  21. package/dist/cjs/src/coinmetro.js +3 -3
  22. package/dist/cjs/src/cryptocom.js +7 -5
  23. package/dist/cjs/src/currencycom.js +6 -6
  24. package/dist/cjs/src/delta.js +5 -5
  25. package/dist/cjs/src/digifinex.js +8 -6
  26. package/dist/cjs/src/gate.js +6 -5
  27. package/dist/cjs/src/hashkey.js +9 -7
  28. package/dist/cjs/src/htx.js +13 -16
  29. package/dist/cjs/src/hyperliquid.js +67 -114
  30. package/dist/cjs/src/kraken.js +8 -6
  31. package/dist/cjs/src/kucoin.js +9 -8
  32. package/dist/cjs/src/luno.js +10 -9
  33. package/dist/cjs/src/lykke.js +2 -2
  34. package/dist/cjs/src/mexc.js +42 -3
  35. package/dist/cjs/src/ndax.js +6 -5
  36. package/dist/cjs/src/okcoin.js +18 -27
  37. package/dist/cjs/src/okx.js +18 -26
  38. package/dist/cjs/src/p2b.js +2 -2
  39. package/dist/cjs/src/paradex.js +1 -1
  40. package/dist/cjs/src/pro/binance.js +6 -2
  41. package/dist/cjs/src/pro/binanceus.js +2 -1
  42. package/dist/cjs/src/pro/bybit.js +56 -0
  43. package/dist/cjs/src/pro/hyperliquid.js +16 -1
  44. package/dist/cjs/src/pro/mexc.js +83 -0
  45. package/dist/cjs/src/pro/paradex.js +1 -0
  46. package/dist/cjs/src/woo.js +7 -6
  47. package/dist/cjs/src/woofipro.js +8 -6
  48. package/dist/cjs/src/xt.js +4 -3
  49. package/dist/cjs/src/zonda.js +6 -5
  50. package/js/ccxt.d.ts +1 -1
  51. package/js/ccxt.js +1 -1
  52. package/js/src/base/Exchange.d.ts +2 -2
  53. package/js/src/base/Exchange.js +2 -2
  54. package/js/src/base/functions/misc.d.ts +2 -1
  55. package/js/src/base/functions/misc.js +11 -1
  56. package/js/src/base/types.d.ts +1 -1
  57. package/js/src/base/ws/WsClient.js +2 -2
  58. package/js/src/binance.d.ts +4 -20
  59. package/js/src/binance.js +42 -15
  60. package/js/src/binanceus.js +1 -0
  61. package/js/src/bingx.js +1 -0
  62. package/js/src/bitfinex2.d.ts +3 -19
  63. package/js/src/bitfinex2.js +7 -6
  64. package/js/src/bitget.d.ts +3 -20
  65. package/js/src/bitget.js +57 -100
  66. package/js/src/bitmex.d.ts +3 -22
  67. package/js/src/bitmex.js +11 -10
  68. package/js/src/bitso.d.ts +3 -19
  69. package/js/src/bitso.js +5 -4
  70. package/js/src/bitstamp.d.ts +3 -35
  71. package/js/src/bitstamp.js +9 -9
  72. package/js/src/blofin.d.ts +3 -15
  73. package/js/src/blofin.js +21 -23
  74. package/js/src/bybit.d.ts +3 -19
  75. package/js/src/bybit.js +100 -26
  76. package/js/src/coinbase.d.ts +3 -19
  77. package/js/src/coinbase.js +28 -7
  78. package/js/src/coinbaseexchange.d.ts +3 -19
  79. package/js/src/coinbaseexchange.js +11 -11
  80. package/js/src/coinlist.d.ts +3 -19
  81. package/js/src/coinlist.js +6 -5
  82. package/js/src/coinmetro.d.ts +3 -19
  83. package/js/src/coinmetro.js +3 -3
  84. package/js/src/cryptocom.d.ts +3 -22
  85. package/js/src/cryptocom.js +7 -5
  86. package/js/src/currencycom.d.ts +3 -3
  87. package/js/src/currencycom.js +6 -6
  88. package/js/src/delta.d.ts +3 -19
  89. package/js/src/delta.js +5 -5
  90. package/js/src/digifinex.d.ts +3 -19
  91. package/js/src/digifinex.js +8 -6
  92. package/js/src/gate.d.ts +3 -19
  93. package/js/src/gate.js +6 -5
  94. package/js/src/hashkey.d.ts +3 -20
  95. package/js/src/hashkey.js +9 -7
  96. package/js/src/htx.d.ts +3 -19
  97. package/js/src/htx.js +13 -16
  98. package/js/src/hyperliquid.d.ts +3 -19
  99. package/js/src/hyperliquid.js +68 -115
  100. package/js/src/kraken.d.ts +5 -24
  101. package/js/src/kraken.js +8 -6
  102. package/js/src/kucoin.d.ts +3 -19
  103. package/js/src/kucoin.js +9 -8
  104. package/js/src/luno.d.ts +4 -20
  105. package/js/src/luno.js +10 -9
  106. package/js/src/lykke.js +2 -2
  107. package/js/src/mexc.js +42 -3
  108. package/js/src/ndax.d.ts +3 -19
  109. package/js/src/ndax.js +6 -5
  110. package/js/src/okcoin.d.ts +3 -19
  111. package/js/src/okcoin.js +18 -27
  112. package/js/src/okx.d.ts +3 -19
  113. package/js/src/okx.js +18 -26
  114. package/js/src/p2b.js +2 -2
  115. package/js/src/paradex.js +1 -1
  116. package/js/src/pro/binance.d.ts +140 -0
  117. package/js/src/pro/binance.js +6 -2
  118. package/js/src/pro/binanceus.js +2 -1
  119. package/js/src/pro/bybit.d.ts +2 -0
  120. package/js/src/pro/bybit.js +56 -0
  121. package/js/src/pro/hyperliquid.d.ts +1 -0
  122. package/js/src/pro/hyperliquid.js +16 -1
  123. package/js/src/pro/mexc.d.ts +4 -1
  124. package/js/src/pro/mexc.js +84 -1
  125. package/js/src/pro/paradex.js +1 -0
  126. package/js/src/woo.d.ts +3 -19
  127. package/js/src/woo.js +7 -6
  128. package/js/src/woofipro.d.ts +3 -19
  129. package/js/src/woofipro.js +8 -6
  130. package/js/src/xt.d.ts +3 -22
  131. package/js/src/xt.js +4 -3
  132. package/js/src/zonda.d.ts +3 -19
  133. package/js/src/zonda.js +6 -5
  134. package/package.json +1 -1
@@ -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
  /**
@@ -98,7 +98,7 @@ class bybit extends bybit$1 {
98
98
  'fetchOpenOrders': true,
99
99
  'fetchOption': true,
100
100
  'fetchOptionChain': true,
101
- 'fetchOrder': false,
101
+ 'fetchOrder': true,
102
102
  'fetchOrderBook': true,
103
103
  'fetchOrders': false,
104
104
  'fetchOrderTrades': true,
@@ -4873,14 +4873,87 @@ class bybit extends bybit$1 {
4873
4873
  * @param {string} id the order id
4874
4874
  * @param {string} symbol unified symbol of the market the order was made in
4875
4875
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4876
+ * @param {object} [params.acknowledged] to suppress the warning, set to true
4876
4877
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4877
4878
  */
4878
- const res = await this.isUnifiedEnabled();
4879
- const enableUnifiedAccount = this.safeBool(res, 1);
4880
- if (enableUnifiedAccount) {
4881
- throw new errors.NotSupported(this.id + ' fetchOrder() is not supported after the 5/02 update for UTA accounts, please use fetchOpenOrder or fetchClosedOrder');
4879
+ await this.loadMarkets();
4880
+ const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4881
+ const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
4882
+ if (!isUnifiedAccount) {
4883
+ return await this.fetchOrderClassic(id, symbol, params);
4882
4884
  }
4883
- return await this.fetchOrderClassic(id, symbol, params);
4885
+ let acknowledge = false;
4886
+ [acknowledge, params] = this.handleOptionAndParams(params, 'fetchOrder', 'acknowledged');
4887
+ if (!acknowledge) {
4888
+ throw new errors.ArgumentsRequired(this.id + ' fetchOrder() can only access an order if it is in last 500 orders (of any status) for your account. Set params["acknowledged"] = true to hide this warning. Alternatively, we suggest to use fetchOpenOrder or fetchClosedOrder');
4889
+ }
4890
+ const market = this.market(symbol);
4891
+ let marketType = undefined;
4892
+ [marketType, params] = this.getBybitType('fetchOrder', market, params);
4893
+ const request = {
4894
+ 'symbol': market['id'],
4895
+ 'orderId': id,
4896
+ 'category': marketType,
4897
+ };
4898
+ let isTrigger = undefined;
4899
+ [isTrigger, params] = this.handleParamBool2(params, 'trigger', 'stop', false);
4900
+ if (isTrigger) {
4901
+ request['orderFilter'] = 'StopOrder';
4902
+ }
4903
+ const response = await this.privateGetV5OrderRealtime(this.extend(request, params));
4904
+ //
4905
+ // {
4906
+ // "retCode": 0,
4907
+ // "retMsg": "OK",
4908
+ // "result": {
4909
+ // "nextPageCursor": "1321052653536515584%3A1672217748287%2C1321052653536515584%3A1672217748287",
4910
+ // "category": "spot",
4911
+ // "list": [
4912
+ // {
4913
+ // "symbol": "ETHUSDT",
4914
+ // "orderType": "Limit",
4915
+ // "orderLinkId": "1672217748277652",
4916
+ // "orderId": "1321052653536515584",
4917
+ // "cancelType": "UNKNOWN",
4918
+ // "avgPrice": "",
4919
+ // "stopOrderType": "tpslOrder",
4920
+ // "lastPriceOnCreated": "",
4921
+ // "orderStatus": "Cancelled",
4922
+ // "takeProfit": "",
4923
+ // "cumExecValue": "0",
4924
+ // "triggerDirection": 0,
4925
+ // "isLeverage": "0",
4926
+ // "rejectReason": "",
4927
+ // "price": "1000",
4928
+ // "orderIv": "",
4929
+ // "createdTime": "1672217748287",
4930
+ // "tpTriggerBy": "",
4931
+ // "positionIdx": 0,
4932
+ // "timeInForce": "GTC",
4933
+ // "leavesValue": "500",
4934
+ // "updatedTime": "1672217748287",
4935
+ // "side": "Buy",
4936
+ // "triggerPrice": "1500",
4937
+ // "cumExecFee": "0",
4938
+ // "leavesQty": "0",
4939
+ // "slTriggerBy": "",
4940
+ // "closeOnTrigger": false,
4941
+ // "cumExecQty": "0",
4942
+ // "reduceOnly": false,
4943
+ // "qty": "0.5",
4944
+ // "stopLoss": "",
4945
+ // "triggerBy": "1192.5"
4946
+ // }
4947
+ // ]
4948
+ // },
4949
+ // "retExtInfo": {},
4950
+ // "time": 1672219526294
4951
+ // }
4952
+ //
4953
+ const result = this.safeDict(response, 'result', {});
4954
+ const innerList = this.safeList(result, 'list', []);
4955
+ const order = this.safeDict(innerList, 0, {});
4956
+ return this.parseOrder(order, market);
4884
4957
  }
4885
4958
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4886
4959
  const res = await this.isUnifiedEnabled();
@@ -5923,13 +5996,13 @@ class bybit extends bybit$1 {
5923
5996
  /**
5924
5997
  * @method
5925
5998
  * @name bybit#fetchLedger
5926
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
5999
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
5927
6000
  * @see https://bybit-exchange.github.io/docs/v5/account/transaction-log
5928
6001
  * @see https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log
5929
- * @param {string} code unified currency code, default is undefined
6002
+ * @param {string} [code] unified currency code, default is undefined
5930
6003
  * @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)
6004
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
6005
+ * @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
6006
  * @param {string} [params.subType] if inverse will use v5/account/contract-transaction-log
5934
6007
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5935
6008
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
@@ -6139,6 +6212,7 @@ class bybit extends bybit$1 {
6139
6212
  //
6140
6213
  const currencyId = this.safeString2(item, 'coin', 'currency');
6141
6214
  const code = this.safeCurrencyCode(currencyId, currency);
6215
+ currency = this.safeCurrency(currencyId, currency);
6142
6216
  const amount = this.safeString2(item, 'amount', 'change');
6143
6217
  const after = this.safeString2(item, 'wallet_balance', 'cashBalance');
6144
6218
  const direction = Precise["default"].stringLt(amount, '0') ? 'out' : 'in';
@@ -6151,26 +6225,26 @@ class bybit extends bybit$1 {
6151
6225
  if (timestamp === undefined) {
6152
6226
  timestamp = this.safeInteger(item, 'transactionTime');
6153
6227
  }
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,
6228
+ return this.safeLedgerEntry({
6229
+ 'info': item,
6230
+ 'id': this.safeString(item, 'id'),
6231
+ 'direction': direction,
6160
6232
  'account': this.safeString(item, 'wallet_id'),
6233
+ 'referenceId': this.safeString(item, 'tx_id'),
6161
6234
  '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,
6235
+ 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
6236
+ 'currency': code,
6237
+ 'amount': this.parseToNumeric(Precise["default"].stringAbs(amount)),
6169
6238
  'timestamp': timestamp,
6170
6239
  'datetime': this.iso8601(timestamp),
6171
- 'type': type,
6172
- 'info': item,
6173
- };
6240
+ 'before': this.parseToNumeric(before),
6241
+ 'after': this.parseToNumeric(after),
6242
+ 'status': 'ok',
6243
+ 'fee': {
6244
+ 'currency': code,
6245
+ 'cost': this.parseToNumeric(this.safeString(item, 'fee')),
6246
+ },
6247
+ }, currency);
6174
6248
  }
6175
6249
  parseLedgerEntryType(type) {
6176
6250
  const types = {
@@ -2257,13 +2257,13 @@ class coinbase extends coinbase$1 {
2257
2257
  /**
2258
2258
  * @method
2259
2259
  * @name coinbase#fetchLedger
2260
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2260
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2261
2261
  * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions#list-transactions
2262
- * @param {string} code unified currency code, default is undefined
2262
+ * @param {string} [code] unified currency code, default is undefined
2263
2263
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2264
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2264
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2265
2265
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2266
- * @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)
2266
+ * @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)
2267
2267
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2268
2268
  */
2269
2269
  await this.loadMarkets();
@@ -2292,8 +2292,28 @@ class coinbase extends coinbase$1 {
2292
2292
  const pagination = this.safeDict(response, 'pagination', {});
2293
2293
  const cursor = this.safeString(pagination, 'next_starting_after');
2294
2294
  if ((cursor !== undefined) && (cursor !== '')) {
2295
+ const lastFee = this.safeDict(last, 'fee');
2295
2296
  last['next_starting_after'] = cursor;
2296
- ledger[lastIndex] = last;
2297
+ ledger[lastIndex] = {
2298
+ 'info': this.safeDict(last, 'info'),
2299
+ 'id': this.safeString(last, 'id'),
2300
+ 'timestamp': this.safeInteger(last, 'timestamp'),
2301
+ 'datetime': this.safeString(last, 'datetime'),
2302
+ 'direction': this.safeString(last, 'direction'),
2303
+ 'account': this.safeString(last, 'account'),
2304
+ 'referenceId': undefined,
2305
+ 'referenceAccount': undefined,
2306
+ 'type': this.safeString(last, 'type'),
2307
+ 'currency': this.safeString(last, 'currency'),
2308
+ 'amount': this.safeNumber(last, 'amount'),
2309
+ 'before': undefined,
2310
+ 'after': undefined,
2311
+ 'status': this.safeString(last, 'status'),
2312
+ 'fee': {
2313
+ 'cost': this.safeNumber(lastFee, 'cost'),
2314
+ 'currency': this.safeString(lastFee, 'currency'),
2315
+ },
2316
+ };
2297
2317
  }
2298
2318
  return ledger;
2299
2319
  }
@@ -2573,6 +2593,7 @@ class coinbase extends coinbase$1 {
2573
2593
  }
2574
2594
  const currencyId = this.safeString(amountInfo, 'currency');
2575
2595
  const code = this.safeCurrencyCode(currencyId, currency);
2596
+ currency = this.safeCurrency(currencyId, currency);
2576
2597
  //
2577
2598
  // the address and txid do not belong to the unified ledger structure
2578
2599
  //
@@ -2608,7 +2629,7 @@ class coinbase extends coinbase$1 {
2608
2629
  accountId = parts[3];
2609
2630
  }
2610
2631
  }
2611
- return {
2632
+ return this.safeLedgerEntry({
2612
2633
  'info': item,
2613
2634
  'id': id,
2614
2635
  'timestamp': timestamp,
@@ -2624,7 +2645,7 @@ class coinbase extends coinbase$1 {
2624
2645
  'after': undefined,
2625
2646
  'status': status,
2626
2647
  'fee': fee,
2627
- };
2648
+ }, currency);
2628
2649
  }
2629
2650
  async findAccountId(code, params = {}) {
2630
2651
  await this.loadMarkets();
@@ -1469,33 +1469,33 @@ class coinbaseexchange extends coinbaseexchange$1 {
1469
1469
  referenceId = this.safeString(details, 'order_id');
1470
1470
  }
1471
1471
  const status = 'ok';
1472
- return {
1472
+ return this.safeLedgerEntry({
1473
+ 'info': item,
1473
1474
  'id': id,
1474
- 'currency': code,
1475
+ 'timestamp': timestamp,
1476
+ 'datetime': this.iso8601(timestamp),
1477
+ 'direction': direction,
1475
1478
  'account': account,
1476
1479
  'referenceAccount': referenceAccount,
1477
1480
  'referenceId': referenceId,
1478
- 'status': status,
1481
+ 'type': type,
1482
+ 'currency': code,
1479
1483
  'amount': amount,
1480
1484
  'before': before,
1481
1485
  'after': after,
1486
+ 'status': status,
1482
1487
  'fee': undefined,
1483
- 'direction': direction,
1484
- 'timestamp': timestamp,
1485
- 'datetime': this.iso8601(timestamp),
1486
- 'type': type,
1487
- 'info': item,
1488
- };
1488
+ }, currency);
1489
1489
  }
1490
1490
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1491
1491
  /**
1492
1492
  * @method
1493
1493
  * @name coinbaseexchange#fetchLedger
1494
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1494
1495
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccountledger
1495
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1496
1496
  * @param {string} code unified currency code, default is undefined
1497
1497
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1498
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1498
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1499
1499
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1500
1500
  * @param {int} [params.until] the latest time in ms to fetch trades for
1501
1501
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
@@ -2084,11 +2084,11 @@ class coinlist extends coinlist$1 {
2084
2084
  /**
2085
2085
  * @method
2086
2086
  * @name coinlist#fetchLedger
2087
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2087
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2088
2088
  * @see https://trade-docs.coinlist.co/?javascript--nodejs#get-account-history
2089
- * @param {string} code unified currency code, default is undefined
2089
+ * @param {string} [code] unified currency code, default is undefined
2090
2090
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2091
- * @param {int} [limit] max number of ledger entrys to return (default 200, max 500)
2091
+ * @param {int} [limit] max number of ledger entries to return (default 200, max 500)
2092
2092
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2093
2093
  * @param {int} [params.until] the latest time in ms to fetch entries for
2094
2094
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
@@ -2272,8 +2272,9 @@ class coinlist extends coinlist$1 {
2272
2272
  }
2273
2273
  const currencyId = this.safeString(item, 'asset');
2274
2274
  const code = this.safeCurrencyCode(currencyId, currency);
2275
+ currency = this.safeCurrency(currencyId, currency);
2275
2276
  const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
2276
- return {
2277
+ return this.safeLedgerEntry({
2277
2278
  'info': item,
2278
2279
  'id': id,
2279
2280
  'timestamp': timestamp,
@@ -2289,7 +2290,7 @@ class coinlist extends coinlist$1 {
2289
2290
  'after': undefined,
2290
2291
  'status': 'ok',
2291
2292
  'fee': undefined,
2292
- };
2293
+ }, currency);
2293
2294
  }
2294
2295
  parseLedgerEntryType(type) {
2295
2296
  const types = {
@@ -984,11 +984,11 @@ class coinmetro extends coinmetro$1 {
984
984
  /**
985
985
  * @method
986
986
  * @name coinmetro#fetchLedger
987
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
987
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
988
988
  * @see https://documenter.getpostman.com/view/3653795/SVfWN6KS#4e7831f7-a0e7-4c3e-9336-1d0e5dcb15cf
989
- * @param {string} code unified currency code, default is undefined
989
+ * @param {string} [code] unified currency code, default is undefined
990
990
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
991
- * @param {int} [limit] max number of ledger entrys to return (default 200, max 500)
991
+ * @param {int} [limit] max number of ledger entries to return (default 200, max 500)
992
992
  * @param {object} [params] extra parameters specific to the exchange API endpoint
993
993
  * @param {int} [params.until] the latest time in ms to fetch entries for
994
994
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
@@ -2393,7 +2393,7 @@ class cryptocom extends cryptocom$1 {
2393
2393
  * @name cryptocom#fetchLedger
2394
2394
  * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2395
2395
  * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-transactions
2396
- * @param {string} code unified currency code
2396
+ * @param {string} [code] unified currency code
2397
2397
  * @param {int} [since] timestamp in ms of the earliest ledger entry
2398
2398
  * @param {int} [limit] max number of ledger entries to return
2399
2399
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2474,6 +2474,8 @@ class cryptocom extends cryptocom$1 {
2474
2474
  //
2475
2475
  const timestamp = this.safeInteger(item, 'event_timestamp_ms');
2476
2476
  const currencyId = this.safeString(item, 'instrument_name');
2477
+ const code = this.safeCurrencyCode(currencyId, currency);
2478
+ currency = this.safeCurrency(currencyId, currency);
2477
2479
  let amount = this.safeString(item, 'transaction_qty');
2478
2480
  let direction = undefined;
2479
2481
  if (Precise["default"].stringLt(amount, '0')) {
@@ -2483,14 +2485,15 @@ class cryptocom extends cryptocom$1 {
2483
2485
  else {
2484
2486
  direction = 'in';
2485
2487
  }
2486
- return {
2488
+ return this.safeLedgerEntry({
2489
+ 'info': item,
2487
2490
  'id': this.safeString(item, 'order_id'),
2488
2491
  'direction': direction,
2489
2492
  'account': this.safeString(item, 'account_id'),
2490
2493
  'referenceId': this.safeString(item, 'trade_id'),
2491
2494
  'referenceAccount': this.safeString(item, 'trade_match_id'),
2492
2495
  'type': this.parseLedgerEntryType(this.safeString(item, 'journal_type')),
2493
- 'currency': this.safeCurrencyCode(currencyId, currency),
2496
+ 'currency': code,
2494
2497
  'amount': this.parseNumber(amount),
2495
2498
  'timestamp': timestamp,
2496
2499
  'datetime': this.iso8601(timestamp),
@@ -2501,8 +2504,7 @@ class cryptocom extends cryptocom$1 {
2501
2504
  'currency': undefined,
2502
2505
  'cost': undefined,
2503
2506
  },
2504
- 'info': item,
2505
- };
2507
+ }, currency);
2506
2508
  }
2507
2509
  parseLedgerEntryType(type) {
2508
2510
  const ledgerType = {
@@ -1692,11 +1692,11 @@ class currencycom extends currencycom$1 {
1692
1692
  /**
1693
1693
  * @method
1694
1694
  * @name currencycom#fetchLedger
1695
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1695
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1696
1696
  * @see https://apitradedoc.currency.com/swagger-ui.html#/rest-api/getLedgerUsingGET
1697
- * @param {string} code unified currency code, default is undefined
1697
+ * @param {string} [code] unified currency code, default is undefined
1698
1698
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1699
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1699
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1700
1700
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1701
1701
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1702
1702
  */
@@ -1749,13 +1749,14 @@ class currencycom extends currencycom$1 {
1749
1749
  const timestamp = this.safeInteger(item, 'timestamp');
1750
1750
  const currencyId = this.safeString(item, 'currency');
1751
1751
  const code = this.safeCurrencyCode(currencyId, currency);
1752
+ currency = this.safeCurrency(currencyId, currency);
1752
1753
  const feeCost = this.safeString(item, 'commission');
1753
1754
  let fee = undefined;
1754
1755
  if (feeCost !== undefined) {
1755
1756
  fee = { 'currency': code, 'cost': feeCost };
1756
1757
  }
1757
1758
  const direction = Precise["default"].stringLt(amountString, '0') ? 'out' : 'in';
1758
- const result = {
1759
+ return this.safeLedgerEntry({
1759
1760
  'id': id,
1760
1761
  'timestamp': timestamp,
1761
1762
  'datetime': this.iso8601(timestamp),
@@ -1771,8 +1772,7 @@ class currencycom extends currencycom$1 {
1771
1772
  'status': this.parseLedgerEntryStatus(this.safeString(item, 'status')),
1772
1773
  'fee': fee,
1773
1774
  'info': item,
1774
- };
1775
- return result;
1775
+ }, currency);
1776
1776
  }
1777
1777
  parseLedgerEntryStatus(status) {
1778
1778
  const statuses = {
@@ -2188,11 +2188,11 @@ class delta extends delta$1 {
2188
2188
  /**
2189
2189
  * @method
2190
2190
  * @name delta#fetchLedger
2191
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2191
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2192
2192
  * @see https://docs.delta.exchange/#get-wallet-transactions
2193
- * @param {string} code unified currency code, default is undefined
2193
+ * @param {string} [code] unified currency code, default is undefined
2194
2194
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2195
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2195
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2196
2196
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2197
2197
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2198
2198
  */
@@ -2291,7 +2291,7 @@ class delta extends delta$1 {
2291
2291
  const after = this.safeString(item, 'balance');
2292
2292
  const before = Precise["default"].stringMax('0', Precise["default"].stringSub(after, amount));
2293
2293
  const status = 'ok';
2294
- return {
2294
+ return this.safeLedgerEntry({
2295
2295
  'info': item,
2296
2296
  'id': id,
2297
2297
  'direction': direction,
@@ -2307,7 +2307,7 @@ class delta extends delta$1 {
2307
2307
  'timestamp': timestamp,
2308
2308
  'datetime': this.iso8601(timestamp),
2309
2309
  'fee': undefined,
2310
- };
2310
+ }, currency);
2311
2311
  }
2312
2312
  async fetchDepositAddress(code, params = {}) {
2313
2313
  /**
@@ -2599,14 +2599,16 @@ class digifinex extends digifinex$1 {
2599
2599
  // }
2600
2600
  //
2601
2601
  const type = this.parseLedgerEntryType(this.safeString2(item, 'type', 'finance_type'));
2602
- const code = this.safeCurrencyCode(this.safeString2(item, 'currency_mark', 'currency'), currency);
2602
+ const currencyId = this.safeString2(item, 'currency_mark', 'currency');
2603
+ const code = this.safeCurrencyCode(currencyId, currency);
2604
+ currency = this.safeCurrency(currencyId, currency);
2603
2605
  const amount = this.safeNumber2(item, 'num', 'change');
2604
2606
  const after = this.safeNumber(item, 'balance');
2605
2607
  let timestamp = this.safeTimestamp(item, 'time');
2606
2608
  if (timestamp === undefined) {
2607
2609
  timestamp = this.safeInteger(item, 'timestamp');
2608
2610
  }
2609
- return {
2611
+ return this.safeLedgerEntry({
2610
2612
  'info': item,
2611
2613
  'id': undefined,
2612
2614
  'direction': undefined,
@@ -2622,18 +2624,18 @@ class digifinex extends digifinex$1 {
2622
2624
  'timestamp': timestamp,
2623
2625
  'datetime': this.iso8601(timestamp),
2624
2626
  'fee': undefined,
2625
- };
2627
+ }, currency);
2626
2628
  }
2627
2629
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2628
2630
  /**
2629
2631
  * @method
2630
2632
  * @name digifinex#fetchLedger
2631
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2633
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2632
2634
  * @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-margin-otc-financial-logs
2633
2635
  * @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#bills
2634
- * @param {string} code unified currency code, default is undefined
2636
+ * @param {string} [code] unified currency code, default is undefined
2635
2637
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2636
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2638
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2637
2639
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2638
2640
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2639
2641
  */