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
@@ -990,11 +990,11 @@ class luno extends luno$1 {
990
990
  /**
991
991
  * @method
992
992
  * @name luno#fetchLedger
993
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
993
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
994
994
  * @see https://www.luno.com/en/developers/api#tag/Accounts/operation/ListTransactions
995
- * @param {string} code unified currency code, default is undefined
995
+ * @param {string} [code] unified currency code, default is undefined
996
996
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
997
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
997
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
998
998
  * @param {object} [params] extra parameters specific to the exchange API endpoint
999
999
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1000
1000
  */
@@ -1081,6 +1081,7 @@ class luno extends luno$1 {
1081
1081
  const timestamp = this.safeInteger(entry, 'timestamp');
1082
1082
  const currencyId = this.safeString(entry, 'currency');
1083
1083
  const code = this.safeCurrencyCode(currencyId, currency);
1084
+ currency = this.safeCurrency(currencyId, currency);
1084
1085
  const available_delta = this.safeString(entry, 'available_delta');
1085
1086
  const balance_delta = this.safeString(entry, 'balance_delta');
1086
1087
  const after = this.safeString(entry, 'balance');
@@ -1111,7 +1112,8 @@ class luno extends luno$1 {
1111
1112
  else if (Precise["default"].stringLt(balance_delta, '0') || Precise["default"].stringLt(available_delta, '0')) {
1112
1113
  direction = 'out';
1113
1114
  }
1114
- return {
1115
+ return this.safeLedgerEntry({
1116
+ 'info': entry,
1115
1117
  'id': id,
1116
1118
  'direction': direction,
1117
1119
  'account': account_id,
@@ -1119,15 +1121,14 @@ class luno extends luno$1 {
1119
1121
  'referenceAccount': undefined,
1120
1122
  'type': type,
1121
1123
  'currency': code,
1122
- 'amount': this.parseNumber(amount),
1124
+ 'amount': this.parseToNumeric(amount),
1123
1125
  'timestamp': timestamp,
1124
1126
  'datetime': this.iso8601(timestamp),
1125
- 'before': this.parseNumber(before),
1126
- 'after': this.parseNumber(after),
1127
+ 'before': this.parseToNumeric(before),
1128
+ 'after': this.parseToNumeric(after),
1127
1129
  'status': status,
1128
1130
  'fee': undefined,
1129
- 'info': entry,
1130
- };
1131
+ }, currency);
1131
1132
  }
1132
1133
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1133
1134
  let url = this.urls['api'][api] + '/' + this.version + '/' + this.implodeParams(path, params);
@@ -678,9 +678,9 @@ class lykke extends lykke$1 {
678
678
  const currencyId = this.safeString(balance, 'assetId');
679
679
  const code = this.safeCurrencyCode(currencyId);
680
680
  const account = this.account();
681
- const free = this.safeString(balance, 'available');
681
+ const total = this.safeString(balance, 'available');
682
682
  const used = this.safeString(balance, 'reserved');
683
- account['free'] = free;
683
+ account['total'] = total;
684
684
  account['used'] = used;
685
685
  result[code] = account;
686
686
  }
@@ -89,7 +89,7 @@ class mexc extends mexc$1 {
89
89
  'fetchOrderBooks': undefined,
90
90
  'fetchOrders': true,
91
91
  'fetchOrderTrades': true,
92
- 'fetchPosition': true,
92
+ 'fetchPosition': 'emulated',
93
93
  'fetchPositionHistory': 'emulated',
94
94
  'fetchPositionMode': true,
95
95
  'fetchPositions': true,
@@ -1014,8 +1014,9 @@ class mexc extends mexc$1 {
1014
1014
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1015
1015
  * @returns {object[]} an array of objects representing market data
1016
1016
  */
1017
- const spotMarket = await this.fetchSpotMarkets(params);
1018
- const swapMarket = await this.fetchSwapMarkets(params);
1017
+ const spotMarketPromise = this.fetchSpotMarkets(params);
1018
+ const swapMarketPromise = this.fetchSwapMarkets(params);
1019
+ const [spotMarket, swapMarket] = await Promise.all([spotMarketPromise, swapMarketPromise]);
1019
1020
  return this.arrayConcat(spotMarket, swapMarket);
1020
1021
  }
1021
1022
  async fetchSpotMarkets(params = {}) {
@@ -1154,7 +1155,10 @@ class mexc extends mexc$1 {
1154
1155
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1155
1156
  * @returns {object[]} an array of objects representing market data
1156
1157
  */
1158
+ const currentRl = this.rateLimit;
1159
+ this.setProperty(this, 'rateLimit', 10); // see comment: https://github.com/ccxt/ccxt/pull/23698
1157
1160
  const response = await this.contractPublicGetDetail(params);
1161
+ this.setProperty(this, 'rateLimit', currentRl);
1158
1162
  //
1159
1163
  // {
1160
1164
  // "success":true,
@@ -2910,6 +2914,9 @@ class mexc extends mexc$1 {
2910
2914
  * @method
2911
2915
  * @name mexc#cancelOrder
2912
2916
  * @description cancels an open order
2917
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-order
2918
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
2919
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-stop-limit-trigger-order-under-maintenance
2913
2920
  * @param {string} id order id
2914
2921
  * @param {string} symbol unified symbol of the market the order was made in
2915
2922
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3026,6 +3033,7 @@ class mexc extends mexc$1 {
3026
3033
  * @method
3027
3034
  * @name mexc#cancelOrders
3028
3035
  * @description cancel multiple orders
3036
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
3029
3037
  * @param {string[]} ids order ids
3030
3038
  * @param {string} symbol unified market symbol, default is undefined
3031
3039
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3061,6 +3069,9 @@ class mexc extends mexc$1 {
3061
3069
  * @method
3062
3070
  * @name mexc#cancelAllOrders
3063
3071
  * @description cancel all open orders
3072
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-all-open-orders-on-a-symbol
3073
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-orders-under-a-contract-under-maintenance
3074
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-trigger-orders-under-maintenance
3064
3075
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
3065
3076
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3066
3077
  * @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
@@ -3464,6 +3475,8 @@ class mexc extends mexc$1 {
3464
3475
  * @method
3465
3476
  * @name mexc#fetchAccounts
3466
3477
  * @description fetch all the accounts associated with a profile
3478
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3479
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3467
3480
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3468
3481
  * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
3469
3482
  */
@@ -3491,6 +3504,8 @@ class mexc extends mexc$1 {
3491
3504
  * @method
3492
3505
  * @name mexc#fetchTradingFees
3493
3506
  * @description fetch the trading fees for multiple markets
3507
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3508
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3494
3509
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3495
3510
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
3496
3511
  */
@@ -3776,6 +3791,8 @@ class mexc extends mexc$1 {
3776
3791
  * @method
3777
3792
  * @name mexc#fetchMyTrades
3778
3793
  * @description fetch all trades made by the user
3794
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3795
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order
3779
3796
  * @param {string} symbol unified market symbol
3780
3797
  * @param {int} [since] the earliest time in ms to fetch trades for
3781
3798
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -3866,6 +3883,8 @@ class mexc extends mexc$1 {
3866
3883
  * @method
3867
3884
  * @name mexc#fetchOrderTrades
3868
3885
  * @description fetch all the trades made from a single order
3886
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3887
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
3869
3888
  * @param {string} id order id
3870
3889
  * @param {string} symbol unified market symbol
3871
3890
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -3964,6 +3983,7 @@ class mexc extends mexc$1 {
3964
3983
  * @method
3965
3984
  * @name mexc#reduceMargin
3966
3985
  * @description remove margin from a position
3986
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
3967
3987
  * @param {string} symbol unified market symbol
3968
3988
  * @param {float} amount the amount of margin to remove
3969
3989
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3976,6 +3996,7 @@ class mexc extends mexc$1 {
3976
3996
  * @method
3977
3997
  * @name mexc#addMargin
3978
3998
  * @description add margin
3999
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
3979
4000
  * @param {string} symbol unified market symbol
3980
4001
  * @param {float} amount amount of margin to add
3981
4002
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3988,6 +4009,7 @@ class mexc extends mexc$1 {
3988
4009
  * @method
3989
4010
  * @name mexc#setLeverage
3990
4011
  * @description set the level of leverage for a market
4012
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
3991
4013
  * @param {float} leverage the rate of leverage
3992
4014
  * @param {string} symbol unified market symbol
3993
4015
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4021,6 +4043,7 @@ class mexc extends mexc$1 {
4021
4043
  * @method
4022
4044
  * @name mexc#fetchFundingHistory
4023
4045
  * @description fetch the history of funding payments paid and received on this account
4046
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-details-of-user-s-funding-rate
4024
4047
  * @param {string} symbol unified market symbol
4025
4048
  * @param {int} [since] the earliest time in ms to fetch funding history for
4026
4049
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -4136,6 +4159,7 @@ class mexc extends mexc$1 {
4136
4159
  * @method
4137
4160
  * @name mexc#fetchFundingRate
4138
4161
  * @description fetch the current funding rate
4162
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
4139
4163
  * @param {string} symbol unified market symbol
4140
4164
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4141
4165
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -4169,6 +4193,7 @@ class mexc extends mexc$1 {
4169
4193
  * @method
4170
4194
  * @name mexc#fetchFundingRateHistory
4171
4195
  * @description fetches historical funding rate prices
4196
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate-history
4172
4197
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
4173
4198
  * @param {int} [since] not used by mexc, but filtered internally by ccxt
4174
4199
  * @param {int} [limit] mexc limit is page_size default 20, maximum is 100
@@ -4742,6 +4767,7 @@ class mexc extends mexc$1 {
4742
4767
  * @method
4743
4768
  * @name mexc#fetchPosition
4744
4769
  * @description fetch data on a single open contract trade position
4770
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
4745
4771
  * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
4746
4772
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4747
4773
  * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -4759,6 +4785,7 @@ class mexc extends mexc$1 {
4759
4785
  * @method
4760
4786
  * @name mexc#fetchPositions
4761
4787
  * @description fetch all open positions
4788
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
4762
4789
  * @param {string[]|undefined} symbols list of unified market symbols
4763
4790
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4764
4791
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -4902,6 +4929,16 @@ class mexc extends mexc$1 {
4902
4929
  });
4903
4930
  }
4904
4931
  async fetchTransfer(id, code = undefined, params = {}) {
4932
+ /**
4933
+ * @method
4934
+ * @name mexc#fetchTransfer
4935
+ * @description fetches a transfer
4936
+ * @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#internal-assets-transfer-order-inquiry
4937
+ * @param {string} id transfer id
4938
+ * @param {string} [code] not used by mexc fetchTransfer
4939
+ * @param {object} params extra parameters specific to the exchange api endpoint
4940
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
4941
+ */
4905
4942
  const [marketType, query] = this.handleMarketTypeAndParams('fetchTransfer', undefined, params);
4906
4943
  await this.loadMarkets();
4907
4944
  if (marketType === 'spot') {
@@ -4935,6 +4972,8 @@ class mexc extends mexc$1 {
4935
4972
  * @method
4936
4973
  * @name mexc#fetchTransfers
4937
4974
  * @description fetch a history of internal transfers made on an account
4975
+ * @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
4976
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
4938
4977
  * @param {string} code unified currency code of the currency transferred
4939
4978
  * @param {int} [since] the earliest time in ms to fetch transfers for
4940
4979
  * @param {int} [limit] the maximum number of transfers structures to retrieve
@@ -1138,6 +1138,7 @@ class ndax extends ndax$1 {
1138
1138
  // }
1139
1139
  //
1140
1140
  const currencyId = this.safeString(item, 'ProductId');
1141
+ currency = this.safeCurrency(currencyId, currency);
1141
1142
  const credit = this.safeString(item, 'CR');
1142
1143
  const debit = this.safeString(item, 'DR');
1143
1144
  let amount = undefined;
@@ -1159,7 +1160,7 @@ class ndax extends ndax$1 {
1159
1160
  before = Precise["default"].stringMax('0', Precise["default"].stringSub(after, amount));
1160
1161
  }
1161
1162
  const timestamp = this.safeInteger(item, 'TimeStamp');
1162
- return {
1163
+ return this.safeLedgerEntry({
1163
1164
  'info': item,
1164
1165
  'id': this.safeString(item, 'TransactionId'),
1165
1166
  'direction': direction,
@@ -1175,17 +1176,17 @@ class ndax extends ndax$1 {
1175
1176
  'timestamp': timestamp,
1176
1177
  'datetime': this.iso8601(timestamp),
1177
1178
  'fee': undefined,
1178
- };
1179
+ }, currency);
1179
1180
  }
1180
1181
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1181
1182
  /**
1182
1183
  * @method
1183
1184
  * @name ndax#fetchLedger
1184
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1185
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1185
1186
  * @see https://apidoc.ndax.io/#getaccounttransactions
1186
- * @param {string} code unified currency code, default is undefined
1187
+ * @param {string} [code] unified currency code, default is undefined
1187
1188
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1188
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1189
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1189
1190
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1190
1191
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1191
1192
  */
@@ -2858,13 +2858,13 @@ class okcoin extends okcoin$1 {
2858
2858
  /**
2859
2859
  * @method
2860
2860
  * @name okcoin#fetchLedger
2861
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2861
2862
  * @see https://www.okcoin.com/docs-v5/en/#rest-api-funding-asset-bills-details
2862
2863
  * @see https://www.okcoin.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days
2863
2864
  * @see https://www.okcoin.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months
2864
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2865
- * @param {string} code unified currency code, default is undefined
2865
+ * @param {string} [code] unified currency code, default is undefined
2866
2866
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2867
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2867
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2868
2868
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2869
2869
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2870
2870
  */
@@ -3006,46 +3006,37 @@ class okcoin extends okcoin$1 {
3006
3006
  // "ts": "1597026383085"
3007
3007
  // }
3008
3008
  //
3009
- const id = this.safeString(item, 'billId');
3010
- const account = undefined;
3011
- const referenceId = this.safeString(item, 'ordId');
3012
- const referenceAccount = undefined;
3013
- const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
3014
- const code = this.safeCurrencyCode(this.safeString(item, 'ccy'), currency);
3015
- const amountString = this.safeString(item, 'balChg');
3016
- const amount = this.parseNumber(amountString);
3009
+ const currencyId = this.safeString(item, 'ccy');
3010
+ const code = this.safeCurrencyCode(currencyId, currency);
3011
+ currency = this.safeCurrency(currencyId, currency);
3017
3012
  const timestamp = this.safeInteger(item, 'ts');
3018
3013
  const feeCostString = this.safeString(item, 'fee');
3019
3014
  let fee = undefined;
3020
3015
  if (feeCostString !== undefined) {
3021
3016
  fee = {
3022
- 'cost': this.parseNumber(Precise["default"].stringNeg(feeCostString)),
3017
+ 'cost': this.parseToNumeric(Precise["default"].stringNeg(feeCostString)),
3023
3018
  'currency': code,
3024
3019
  };
3025
3020
  }
3026
- const before = undefined;
3027
- const afterString = this.safeString(item, 'bal');
3028
- const after = this.parseNumber(afterString);
3029
- const status = 'ok';
3030
3021
  const marketId = this.safeString(item, 'instId');
3031
3022
  const symbol = this.safeSymbol(marketId, undefined, '-');
3032
- return {
3033
- 'id': id,
3023
+ return this.safeLedgerEntry({
3034
3024
  'info': item,
3025
+ 'id': this.safeString(item, 'billId'),
3035
3026
  'timestamp': timestamp,
3036
3027
  'datetime': this.iso8601(timestamp),
3037
- 'account': account,
3038
- 'referenceId': referenceId,
3039
- 'referenceAccount': referenceAccount,
3040
- 'type': type,
3028
+ 'account': undefined,
3029
+ 'referenceId': this.safeString(item, 'ordId'),
3030
+ 'referenceAccount': undefined,
3031
+ 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
3041
3032
  'currency': code,
3042
3033
  'symbol': symbol,
3043
- 'amount': amount,
3044
- 'before': before,
3045
- 'after': after,
3046
- 'status': status,
3034
+ 'amount': this.safeNumber(item, 'balChg'),
3035
+ 'before': undefined,
3036
+ 'after': this.safeNumber(item, 'bal'),
3037
+ 'status': 'ok',
3047
3038
  'fee': fee,
3048
- };
3039
+ }, currency);
3049
3040
  }
3050
3041
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3051
3042
  const isArray = Array.isArray(params);
@@ -790,6 +790,7 @@ class okx extends okx$1 {
790
790
  // SPOT/MARGIN error codes 54000-54999
791
791
  '54000': errors.ExchangeError,
792
792
  '54001': errors.ExchangeError,
793
+ '54011': errors.InvalidOrder,
793
794
  // Trading bot Error Code from 55100 to 55999
794
795
  '55100': errors.InvalidOrder,
795
796
  '55101': errors.InvalidOrder,
@@ -4471,13 +4472,13 @@ class okx extends okx$1 {
4471
4472
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days
4472
4473
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months
4473
4474
  * @see https://www.okx.com/docs-v5/en/#rest-api-funding-asset-bills-details
4474
- * @param {string} code unified currency code, default is undefined
4475
+ * @param {string} [code] unified currency code, default is undefined
4475
4476
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
4476
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
4477
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
4477
4478
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4478
4479
  * @param {string} [params.marginMode] 'cross' or 'isolated'
4479
4480
  * @param {int} [params.until] the latest time in ms to fetch entries for
4480
- * @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)
4481
+ * @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)
4481
4482
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
4482
4483
  */
4483
4484
  await this.loadMarkets();
@@ -4640,14 +4641,9 @@ class okx extends okx$1 {
4640
4641
  // "ts": "1597026383085"
4641
4642
  // }
4642
4643
  //
4643
- const id = this.safeString(item, 'billId');
4644
- const account = undefined;
4645
- const referenceId = this.safeString(item, 'ordId');
4646
- const referenceAccount = undefined;
4647
- const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
4648
- const code = this.safeCurrencyCode(this.safeString(item, 'ccy'), currency);
4649
- const amountString = this.safeString(item, 'balChg');
4650
- const amount = this.parseNumber(amountString);
4644
+ const currencyId = this.safeString(item, 'ccy');
4645
+ const code = this.safeCurrencyCode(currencyId, currency);
4646
+ currency = this.safeCurrency(currencyId, currency);
4651
4647
  const timestamp = this.safeInteger(item, 'ts');
4652
4648
  const feeCostString = this.safeString(item, 'fee');
4653
4649
  let fee = undefined;
@@ -4657,29 +4653,25 @@ class okx extends okx$1 {
4657
4653
  'currency': code,
4658
4654
  };
4659
4655
  }
4660
- const before = undefined;
4661
- const afterString = this.safeString(item, 'bal');
4662
- const after = this.parseNumber(afterString);
4663
- const status = 'ok';
4664
4656
  const marketId = this.safeString(item, 'instId');
4665
4657
  const symbol = this.safeSymbol(marketId, undefined, '-');
4666
- return {
4667
- 'id': id,
4658
+ return this.safeLedgerEntry({
4668
4659
  'info': item,
4660
+ 'id': this.safeString(item, 'billId'),
4669
4661
  'timestamp': timestamp,
4670
4662
  'datetime': this.iso8601(timestamp),
4671
- 'account': account,
4672
- 'referenceId': referenceId,
4673
- 'referenceAccount': referenceAccount,
4674
- 'type': type,
4663
+ 'account': undefined,
4664
+ 'referenceId': this.safeString(item, 'ordId'),
4665
+ 'referenceAccount': undefined,
4666
+ 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
4675
4667
  'currency': code,
4676
4668
  'symbol': symbol,
4677
- 'amount': amount,
4678
- 'before': before,
4679
- 'after': after,
4680
- 'status': status,
4669
+ 'amount': this.safeNumber(item, 'balChg'),
4670
+ 'before': undefined,
4671
+ 'after': this.safeNumber(item, 'bal'),
4672
+ 'status': 'ok',
4681
4673
  'fee': fee,
4682
- };
4674
+ }, currency);
4683
4675
  }
4684
4676
  parseDepositAddress(depositAddress, currency = undefined) {
4685
4677
  //
@@ -474,7 +474,7 @@ class p2b extends p2b$1 {
474
474
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
475
475
  /**
476
476
  * @method
477
- * @name p2bfutures#fetchOrderBook
477
+ * @name p2b#fetchOrderBook
478
478
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
479
479
  * @see https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#depth-result
480
480
  * @param {string} symbol unified symbol of the market to fetch the order book for
@@ -643,7 +643,7 @@ class p2b extends p2b$1 {
643
643
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
644
644
  /**
645
645
  * @method
646
- * @name poloniexfutures#fetchOHLCV
646
+ * @name p2b#fetchOHLCV
647
647
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
648
648
  * @see https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#kline
649
649
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
@@ -657,7 +657,7 @@ class paradex extends paradex$1 {
657
657
  'low': undefined,
658
658
  'bid': this.safeString(ticker, 'bid'),
659
659
  'bidVolume': undefined,
660
- 'ask': this.safeString(ticker, 'sdk'),
660
+ 'ask': this.safeString(ticker, 'ask'),
661
661
  'askVolume': undefined,
662
662
  'vwap': undefined,
663
663
  'open': undefined,
@@ -13,7 +13,11 @@ var ed25519 = require('../static_dependencies/noble-curves/ed25519.js');
13
13
  // -----------------------------------------------------------------------------
14
14
  class binance extends binance$1 {
15
15
  describe() {
16
- return this.deepExtend(super.describe(), {
16
+ const superDescribe = super.describe();
17
+ return this.deepExtend(superDescribe, this.describeData());
18
+ }
19
+ describeData() {
20
+ return {
17
21
  'has': {
18
22
  'ws': true,
19
23
  'watchBalance': true,
@@ -155,7 +159,7 @@ class binance extends binance$1 {
155
159
  'bookTicker': 'bookTicker',
156
160
  },
157
161
  },
158
- });
162
+ };
159
163
  }
160
164
  requestId(url) {
161
165
  const options = this.safeDict(this.options, 'requestId', this.createSafeDictionary());
@@ -10,7 +10,8 @@ class binanceus extends binance {
10
10
  // eslint-disable-next-line new-cap
11
11
  const restInstance = new binanceus$1();
12
12
  const restDescribe = restInstance.describe();
13
- const extended = this.deepExtend(restDescribe, super.describe());
13
+ const parentWsDescribe = super.describeData();
14
+ const extended = this.deepExtend(restDescribe, parentWsDescribe);
14
15
  return this.deepExtend(extended, {
15
16
  'id': 'binanceus',
16
17
  'name': 'Binance US',
@@ -22,6 +22,7 @@ class bybit extends bybit$1 {
22
22
  'fetchTradesWs': false,
23
23
  'fetchBalanceWs': false,
24
24
  'watchBalance': true,
25
+ 'watchBidsAsks': true,
25
26
  'watchLiquidations': true,
26
27
  'watchLiquidationsForSymbols': false,
27
28
  'watchMyLiquidations': false,
@@ -578,6 +579,52 @@ class bybit extends bybit$1 {
578
579
  const messageHash = 'ticker:' + symbol;
579
580
  client.resolve(this.tickers[symbol], messageHash);
580
581
  }
582
+ async watchBidsAsks(symbols = undefined, params = {}) {
583
+ /**
584
+ * @method
585
+ * @name bybit#watchBidsAsks
586
+ * @description watches best bid & ask for symbols
587
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/orderbook
588
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
589
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
590
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
591
+ */
592
+ await this.loadMarkets();
593
+ symbols = this.marketSymbols(symbols, undefined, false);
594
+ const messageHashes = [];
595
+ const url = await this.getUrlByMarketType(symbols[0], false, 'watchBidsAsks', params);
596
+ params = this.cleanParams(params);
597
+ const marketIds = this.marketIds(symbols);
598
+ const topics = [];
599
+ for (let i = 0; i < marketIds.length; i++) {
600
+ const marketId = marketIds[i];
601
+ const topic = 'orderbook.1.' + marketId;
602
+ topics.push(topic);
603
+ messageHashes.push('bidask:' + symbols[i]);
604
+ }
605
+ const ticker = await this.watchTopics(url, messageHashes, topics, params);
606
+ if (this.newUpdates) {
607
+ return ticker;
608
+ }
609
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
610
+ }
611
+ parseWsBidAsk(orderbook, market = undefined) {
612
+ const timestamp = this.safeInteger(orderbook, 'timestamp');
613
+ const bids = this.sortBy(this.aggregate(orderbook['bids']), 0);
614
+ const asks = this.sortBy(this.aggregate(orderbook['asks']), 0);
615
+ const bestBid = this.safeList(bids, 0, []);
616
+ const bestAsk = this.safeList(asks, 0, []);
617
+ return this.safeTicker({
618
+ 'symbol': market['symbol'],
619
+ 'timestamp': timestamp,
620
+ 'datetime': this.iso8601(timestamp),
621
+ 'ask': this.safeNumber(bestAsk, 0),
622
+ 'askVolume': this.safeNumber(bestAsk, 1),
623
+ 'bid': this.safeNumber(bestBid, 0),
624
+ 'bidVolume': this.safeNumber(bestBid, 1),
625
+ 'info': orderbook,
626
+ }, market);
627
+ }
581
628
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
582
629
  /**
583
630
  * @method
@@ -902,6 +949,8 @@ class bybit extends bybit$1 {
902
949
  // }
903
950
  // }
904
951
  //
952
+ const topic = this.safeString(message, 'topic');
953
+ const limit = topic.split('.')[1];
905
954
  const isSpot = client.url.indexOf('spot') >= 0;
906
955
  const type = this.safeString(message, 'type');
907
956
  const isSnapshot = (type === 'snapshot');
@@ -930,6 +979,13 @@ class bybit extends bybit$1 {
930
979
  const messageHash = 'orderbook' + ':' + symbol;
931
980
  this.orderbooks[symbol] = orderbook;
932
981
  client.resolve(orderbook, messageHash);
982
+ if (limit === '1') {
983
+ const bidask = this.parseWsBidAsk(this.orderbooks[symbol], market);
984
+ const newBidsAsks = {};
985
+ newBidsAsks[symbol] = bidask;
986
+ this.bidsasks[symbol] = bidask;
987
+ client.resolve(newBidsAsks, 'bidask:' + symbol);
988
+ }
933
989
  }
934
990
  handleDelta(bookside, delta) {
935
991
  const bidAsk = this.parseBidAsk(delta, 0, 1);
@@ -19,7 +19,7 @@ class hyperliquid extends hyperliquid$1 {
19
19
  'watchOHLCV': true,
20
20
  'watchOrderBook': true,
21
21
  'watchOrders': true,
22
- 'watchTicker': false,
22
+ 'watchTicker': true,
23
23
  'watchTickers': true,
24
24
  'watchTrades': true,
25
25
  'watchTradesForSymbols': false,
@@ -235,6 +235,21 @@ class hyperliquid extends hyperliquid$1 {
235
235
  const messageHash = 'orderbook:' + symbol;
236
236
  client.resolve(orderbook, messageHash);
237
237
  }
238
+ async watchTicker(symbol, params = {}) {
239
+ /**
240
+ * @method
241
+ * @name hyperliquid#watchTicker
242
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
243
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
244
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
245
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
246
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
247
+ */
248
+ const market = this.market(symbol);
249
+ symbol = market['symbol'];
250
+ const tickers = await this.watchTickers([symbol], params);
251
+ return tickers[symbol];
252
+ }
238
253
  async watchTickers(symbols = undefined, params = {}) {
239
254
  /**
240
255
  * @method