ccxt 4.2.59 → 4.2.61

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 (184) hide show
  1. package/README.md +103 -102
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +11853 -3790
  4. package/dist/ccxt.browser.min.js +7 -7
  5. package/dist/cjs/ccxt.js +4 -1
  6. package/dist/cjs/src/abstract/hyperliquid.js +9 -0
  7. package/dist/cjs/src/ascendex.js +10 -12
  8. package/dist/cjs/src/base/Exchange.js +22 -1
  9. package/dist/cjs/src/base/functions/encode.js +5 -0
  10. package/dist/cjs/src/base/functions.js +1 -0
  11. package/dist/cjs/src/bingx.js +38 -0
  12. package/dist/cjs/src/bitfinex2.js +20 -3
  13. package/dist/cjs/src/bitget.js +9 -2
  14. package/dist/cjs/src/bitmart.js +41 -23
  15. package/dist/cjs/src/blofin.js +59 -1
  16. package/dist/cjs/src/coinbase.js +108 -103
  17. package/dist/cjs/src/coinex.js +61 -1
  18. package/dist/cjs/src/hitbtc.js +1 -1
  19. package/dist/cjs/src/htx.js +4 -1
  20. package/dist/cjs/src/hyperliquid.js +2035 -0
  21. package/dist/cjs/src/kraken.js +50 -41
  22. package/dist/cjs/src/krakenfutures.js +28 -0
  23. package/dist/cjs/src/kucoinfutures.js +3 -2
  24. package/dist/cjs/src/okx.js +1 -1
  25. package/dist/cjs/src/phemex.js +2 -2
  26. package/dist/cjs/src/pro/binance.js +16 -3
  27. package/dist/cjs/src/pro/bingx.js +1 -0
  28. package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +158 -0
  29. package/dist/cjs/src/static_dependencies/ethers/address/address.js +144 -0
  30. package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +407 -0
  31. package/dist/cjs/src/static_dependencies/ethers/coders/address.js +45 -0
  32. package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +28 -0
  33. package/dist/cjs/src/static_dependencies/ethers/coders/array.js +176 -0
  34. package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +27 -0
  35. package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +52 -0
  36. package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +45 -0
  37. package/dist/cjs/src/static_dependencies/ethers/coders/null.js +30 -0
  38. package/dist/cjs/src/static_dependencies/ethers/coders/number.js +60 -0
  39. package/dist/cjs/src/static_dependencies/ethers/coders/string.js +27 -0
  40. package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +68 -0
  41. package/dist/cjs/src/static_dependencies/ethers/fragments.js +614 -0
  42. package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +492 -0
  43. package/dist/cjs/src/static_dependencies/ethers/index.js +35 -0
  44. package/dist/cjs/src/static_dependencies/ethers/interface.js +44 -0
  45. package/dist/cjs/src/static_dependencies/ethers/typed.js +618 -0
  46. package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +20 -0
  47. package/dist/cjs/src/static_dependencies/ethers/utils/data.js +134 -0
  48. package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +228 -0
  49. package/dist/cjs/src/static_dependencies/ethers/utils/events.js +13 -0
  50. package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +29 -0
  51. package/dist/cjs/src/static_dependencies/ethers/utils/index.js +53 -0
  52. package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +231 -0
  53. package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +47 -0
  54. package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +218 -0
  55. package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +292 -0
  56. package/dist/cjs/src/tokocrypto.js +22 -2
  57. package/dist/cjs/src/wazirx.js +314 -4
  58. package/dist/cjs/src/woo.js +157 -77
  59. package/js/ccxt.d.ts +5 -2
  60. package/js/ccxt.js +4 -2
  61. package/js/src/abstract/blofin.d.ts +1 -0
  62. package/js/src/abstract/coinbase.d.ts +3 -3
  63. package/js/src/abstract/hyperliquid.d.ts +9 -0
  64. package/js/src/abstract/hyperliquid.js +11 -0
  65. package/js/src/abstract/wazirx.d.ts +5 -0
  66. package/js/src/ascendex.d.ts +2 -2
  67. package/js/src/ascendex.js +10 -12
  68. package/js/src/base/Exchange.d.ts +4 -0
  69. package/js/src/base/Exchange.js +13 -1
  70. package/js/src/base/functions/encode.d.ts +2 -1
  71. package/js/src/base/functions/encode.js +5 -1
  72. package/js/src/bingx.d.ts +3 -1
  73. package/js/src/bingx.js +38 -0
  74. package/js/src/bitfinex2.js +20 -3
  75. package/js/src/bitget.js +9 -2
  76. package/js/src/bitmart.d.ts +9 -2
  77. package/js/src/bitmart.js +41 -23
  78. package/js/src/blofin.d.ts +2 -1
  79. package/js/src/blofin.js +59 -1
  80. package/js/src/coinbase.js +108 -103
  81. package/js/src/coinex.d.ts +3 -1
  82. package/js/src/coinex.js +61 -1
  83. package/js/src/hitbtc.js +1 -1
  84. package/js/src/htx.js +4 -1
  85. package/js/src/hyperliquid.d.ts +83 -0
  86. package/js/src/hyperliquid.js +2036 -0
  87. package/js/src/kraken.js +50 -41
  88. package/js/src/krakenfutures.d.ts +2 -1
  89. package/js/src/krakenfutures.js +28 -0
  90. package/js/src/kucoinfutures.js +3 -2
  91. package/js/src/okx.js +1 -1
  92. package/js/src/phemex.js +2 -2
  93. package/js/src/pro/binance.js +16 -3
  94. package/js/src/pro/bingx.js +1 -0
  95. package/js/src/pro/deribit.d.ts +1 -1
  96. package/js/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
  97. package/js/src/static_dependencies/ethers/abi-coder.js +148 -0
  98. package/js/src/static_dependencies/ethers/address/address.d.ts +55 -0
  99. package/js/src/static_dependencies/ethers/address/address.js +162 -0
  100. package/js/src/static_dependencies/ethers/address/checks.d.ts +80 -0
  101. package/js/src/static_dependencies/ethers/address/checks.js +119 -0
  102. package/js/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
  103. package/js/src/static_dependencies/ethers/address/contract-address.js +73 -0
  104. package/js/src/static_dependencies/ethers/address/index.d.ts +48 -0
  105. package/js/src/static_dependencies/ethers/address/index.js +24 -0
  106. package/js/src/static_dependencies/ethers/bytes32.d.ts +14 -0
  107. package/js/src/static_dependencies/ethers/bytes32.js +45 -0
  108. package/js/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
  109. package/js/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
  110. package/js/src/static_dependencies/ethers/coders/address.d.ts +12 -0
  111. package/js/src/static_dependencies/ethers/coders/address.js +34 -0
  112. package/js/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
  113. package/js/src/static_dependencies/ethers/coders/anonymous.js +27 -0
  114. package/js/src/static_dependencies/ethers/coders/array.d.ts +24 -0
  115. package/js/src/static_dependencies/ethers/coders/array.js +162 -0
  116. package/js/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
  117. package/js/src/static_dependencies/ethers/coders/boolean.js +26 -0
  118. package/js/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
  119. package/js/src/static_dependencies/ethers/coders/bytes.js +39 -0
  120. package/js/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
  121. package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
  122. package/js/src/static_dependencies/ethers/coders/null.d.ts +11 -0
  123. package/js/src/static_dependencies/ethers/coders/null.js +29 -0
  124. package/js/src/static_dependencies/ethers/coders/number.d.ts +15 -0
  125. package/js/src/static_dependencies/ethers/coders/number.js +48 -0
  126. package/js/src/static_dependencies/ethers/coders/string.d.ts +12 -0
  127. package/js/src/static_dependencies/ethers/coders/string.js +26 -0
  128. package/js/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
  129. package/js/src/static_dependencies/ethers/coders/tuple.js +67 -0
  130. package/js/src/static_dependencies/ethers/fragments.d.ts +458 -0
  131. package/js/src/static_dependencies/ethers/fragments.js +1252 -0
  132. package/js/src/static_dependencies/ethers/hash/index.d.ts +10 -0
  133. package/js/src/static_dependencies/ethers/hash/index.js +15 -0
  134. package/js/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
  135. package/js/src/static_dependencies/ethers/hash/solidity.js +107 -0
  136. package/js/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
  137. package/js/src/static_dependencies/ethers/hash/typed-data.js +490 -0
  138. package/js/src/static_dependencies/ethers/index.d.ts +19 -0
  139. package/js/src/static_dependencies/ethers/index.js +22 -0
  140. package/js/src/static_dependencies/ethers/interface.d.ts +380 -0
  141. package/js/src/static_dependencies/ethers/interface.js +990 -0
  142. package/js/src/static_dependencies/ethers/typed.d.ts +569 -0
  143. package/js/src/static_dependencies/ethers/typed.js +608 -0
  144. package/js/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
  145. package/js/src/static_dependencies/ethers/utils/base58.js +68 -0
  146. package/js/src/static_dependencies/ethers/utils/base64-browser.d.ts +3 -0
  147. package/js/src/static_dependencies/ethers/utils/base64-browser.js +24 -0
  148. package/js/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
  149. package/js/src/static_dependencies/ethers/utils/base64.js +58 -0
  150. package/js/src/static_dependencies/ethers/utils/data.d.ts +92 -0
  151. package/js/src/static_dependencies/ethers/utils/data.js +175 -0
  152. package/js/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
  153. package/js/src/static_dependencies/ethers/utils/errors.js +227 -0
  154. package/js/src/static_dependencies/ethers/utils/events.d.ts +76 -0
  155. package/js/src/static_dependencies/ethers/utils/events.js +52 -0
  156. package/js/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
  157. package/js/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
  158. package/js/src/static_dependencies/ethers/utils/index.d.ts +30 -0
  159. package/js/src/static_dependencies/ethers/utils/index.js +38 -0
  160. package/js/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
  161. package/js/src/static_dependencies/ethers/utils/maths.js +220 -0
  162. package/js/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
  163. package/js/src/static_dependencies/ethers/utils/properties.js +59 -0
  164. package/js/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
  165. package/js/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
  166. package/js/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
  167. package/js/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
  168. package/js/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
  169. package/js/src/static_dependencies/ethers/utils/rlp.js +14 -0
  170. package/js/src/static_dependencies/ethers/utils/units.d.ts +23 -0
  171. package/js/src/static_dependencies/ethers/utils/units.js +88 -0
  172. package/js/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
  173. package/js/src/static_dependencies/ethers/utils/utf8.js +225 -0
  174. package/js/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
  175. package/js/src/static_dependencies/ethers/utils/uuid.js +35 -0
  176. package/js/src/static_dependencies/messagepack/msgpack.d.ts +2 -0
  177. package/js/src/static_dependencies/messagepack/msgpack.js +572 -0
  178. package/js/src/tokocrypto.js +22 -2
  179. package/js/src/wazirx.d.ts +12 -1
  180. package/js/src/wazirx.js +314 -4
  181. package/js/src/woo.d.ts +8 -0
  182. package/js/src/woo.js +157 -77
  183. package/package.json +1 -1
  184. package/skip-tests.json +60 -16
package/js/src/kraken.js CHANGED
@@ -24,7 +24,10 @@ export default class kraken extends Exchange {
24
24
  'name': 'Kraken',
25
25
  'countries': ['US'],
26
26
  'version': '0',
27
- 'rateLimit': 3000,
27
+ // rate-limits: https://support.kraken.com/hc/en-us/articles/206548367-What-are-the-API-rate-limits-#1
28
+ // for public: 1 req/s
29
+ // for private: every second 0.33 weight added to your allowed capacity (some private endpoints need 1 weight, some need 2)
30
+ 'rateLimit': 1000,
28
31
  'certified': false,
29
32
  'pro': true,
30
33
  'has': {
@@ -154,7 +157,7 @@ export default class kraken extends Exchange {
154
157
  },
155
158
  'public': {
156
159
  'get': {
157
- // public endpoint rate-limits are described in article: https://support.kraken.com/hc/en-us/articles/206548367-What-are-the-API-rate-limits-#1
160
+ // rate-limits explained in comment in the top of this file
158
161
  'Assets': 1,
159
162
  'AssetPairs': 1,
160
163
  'Depth': 1,
@@ -170,48 +173,48 @@ export default class kraken extends Exchange {
170
173
  'post': {
171
174
  'AddOrder': 0,
172
175
  'AddOrderBatch': 0,
173
- 'AddExport': 1,
174
- 'Balance': 1,
175
- 'CancelAll': 1,
176
- 'CancelAllOrdersAfter': 1,
176
+ 'AddExport': 3,
177
+ 'Balance': 3,
178
+ 'CancelAll': 3,
179
+ 'CancelAllOrdersAfter': 3,
177
180
  'CancelOrder': 0,
178
181
  'CancelOrderBatch': 0,
179
- 'ClosedOrders': 1,
180
- 'DepositAddresses': 1,
181
- 'DepositMethods': 1,
182
- 'DepositStatus': 1,
182
+ 'ClosedOrders': 3,
183
+ 'DepositAddresses': 3,
184
+ 'DepositMethods': 3,
185
+ 'DepositStatus': 3,
183
186
  'EditOrder': 0,
184
- 'ExportStatus': 1,
185
- 'GetWebSocketsToken': 1,
186
- 'Ledgers': 2,
187
- 'OpenOrders': 1,
188
- 'OpenPositions': 1,
189
- 'QueryLedgers': 1,
190
- 'QueryOrders': 1,
191
- 'QueryTrades': 1,
192
- 'RetrieveExport': 1,
193
- 'RemoveExport': 1,
194
- 'BalanceEx': 1,
195
- 'TradeBalance': 1,
196
- 'TradesHistory': 2,
197
- 'TradeVolume': 1,
198
- 'Withdraw': 1,
199
- 'WithdrawCancel': 1,
200
- 'WithdrawInfo': 1,
201
- 'WithdrawMethods': 1,
202
- 'WithdrawAddresses': 1,
203
- 'WithdrawStatus': 1,
204
- 'WalletTransfer': 1,
187
+ 'ExportStatus': 3,
188
+ 'GetWebSocketsToken': 3,
189
+ 'Ledgers': 6,
190
+ 'OpenOrders': 3,
191
+ 'OpenPositions': 3,
192
+ 'QueryLedgers': 3,
193
+ 'QueryOrders': 3,
194
+ 'QueryTrades': 3,
195
+ 'RetrieveExport': 3,
196
+ 'RemoveExport': 3,
197
+ 'BalanceEx': 3,
198
+ 'TradeBalance': 3,
199
+ 'TradesHistory': 6,
200
+ 'TradeVolume': 3,
201
+ 'Withdraw': 3,
202
+ 'WithdrawCancel': 3,
203
+ 'WithdrawInfo': 3,
204
+ 'WithdrawMethods': 3,
205
+ 'WithdrawAddresses': 3,
206
+ 'WithdrawStatus': 3,
207
+ 'WalletTransfer': 3,
205
208
  // sub accounts
206
- 'CreateSubaccount': 1,
207
- 'AccountTransfer': 1,
209
+ 'CreateSubaccount': 3,
210
+ 'AccountTransfer': 3,
208
211
  // earn
209
- 'Earn/Allocate': 1,
210
- 'Earn/Deallocate': 1,
211
- 'Earn/AllocateStatus': 1,
212
- 'Earn/DeallocateStatus': 1,
213
- 'Earn/Strategies': 1,
214
- 'Earn/Allocations': 1,
212
+ 'Earn/Allocate': 3,
213
+ 'Earn/Deallocate': 3,
214
+ 'Earn/AllocateStatus': 3,
215
+ 'Earn/DeallocateStatus': 3,
216
+ 'Earn/Strategies': 3,
217
+ 'Earn/Allocations': 3,
215
218
  },
216
219
  },
217
220
  },
@@ -1547,8 +1550,14 @@ export default class kraken extends Exchange {
1547
1550
  // }
1548
1551
  // }
1549
1552
  //
1550
- const description = this.safeValue(order, 'descr', {});
1551
- const orderDescription = this.safeString(description, 'order', description);
1553
+ const description = this.safeDict(order, 'descr', {});
1554
+ let orderDescription = undefined;
1555
+ if (description !== undefined) {
1556
+ orderDescription = this.safeString(description, 'order');
1557
+ }
1558
+ else {
1559
+ orderDescription = this.safeString(order, 'descr');
1560
+ }
1552
1561
  let side = undefined;
1553
1562
  let type = undefined;
1554
1563
  let marketId = undefined;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/krakenfutures.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OrderRequest, Order, Balances, Str, Ticker, OrderBook, Tickers, Strings, Market, Currency, Leverage } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OrderRequest, Order, Balances, Str, Ticker, OrderBook, Tickers, Strings, Market, Currency, Leverage, Leverages } from './base/types.js';
3
3
  /**
4
4
  * @class krakenfutures
5
5
  * @augments Exchange
@@ -94,6 +94,7 @@ export default class krakenfutures extends Exchange {
94
94
  transferOut(code: string, amount: any, params?: {}): Promise<TransferEntry>;
95
95
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
96
96
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
97
+ fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
97
98
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
98
99
  parseLeverage(leverage: any, market?: any): Leverage;
99
100
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
@@ -58,6 +58,7 @@ export default class krakenfutures extends Exchange {
58
58
  'fetchIsolatedBorrowRates': false,
59
59
  'fetchIsolatedPositions': false,
60
60
  'fetchLeverage': true,
61
+ 'fetchLeverages': true,
61
62
  'fetchLeverageTiers': true,
62
63
  'fetchMarketLeverageTiers': 'emulated',
63
64
  'fetchMarkets': true,
@@ -2459,6 +2460,33 @@ export default class krakenfutures extends Exchange {
2459
2460
  //
2460
2461
  return await this.privatePutLeveragepreferences(this.extend(request, params));
2461
2462
  }
2463
+ async fetchLeverages(symbols = undefined, params = {}) {
2464
+ /**
2465
+ * @method
2466
+ * @name krakenfutures#fetchLeverages
2467
+ * @description fetch the set leverage for all contract and margin markets
2468
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-get-the-leverage-setting-for-a-market
2469
+ * @param {string[]} [symbols] a list of unified market symbols
2470
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2471
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2472
+ */
2473
+ await this.loadMarkets();
2474
+ const response = await this.privateGetLeveragepreferences(params);
2475
+ //
2476
+ // {
2477
+ // "result": "success",
2478
+ // "serverTime": "2024-03-06T02:35:46.336Z",
2479
+ // "leveragePreferences": [
2480
+ // {
2481
+ // "symbol": "PF_ETHUSD",
2482
+ // "maxLeverage": 30.00
2483
+ // },
2484
+ // ]
2485
+ // }
2486
+ //
2487
+ const leveragePreferences = this.safeList(response, 'leveragePreferences', []);
2488
+ return this.parseLeverages(leveragePreferences, symbols, 'symbol');
2489
+ }
2462
2490
  async fetchLeverage(symbol, params = {}) {
2463
2491
  /**
2464
2492
  * @method
@@ -36,6 +36,7 @@ export default class kucoinfutures extends kucoin {
36
36
  'addMargin': true,
37
37
  'cancelAllOrders': true,
38
38
  'cancelOrder': true,
39
+ 'closeAllPositions': false,
39
40
  'closePosition': true,
40
41
  'closePositions': false,
41
42
  'createDepositAddress': true,
@@ -2073,8 +2074,8 @@ export default class kucoinfutures extends kucoin {
2073
2074
  // }
2074
2075
  // }
2075
2076
  //
2076
- const data = this.safeValue(response, 'data', {});
2077
- const trades = this.safeValue(data, 'items', {});
2077
+ const data = this.safeDict(response, 'data', {});
2078
+ const trades = this.safeList(data, 'items', []);
2078
2079
  return this.parseTrades(trades, market, since, limit);
2079
2080
  }
2080
2081
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
package/js/src/okx.js CHANGED
@@ -5671,7 +5671,7 @@ export default class okx extends Exchange {
5671
5671
  const fromAccountId = this.safeString(transfer, 'from');
5672
5672
  const toAccountId = this.safeString(transfer, 'to');
5673
5673
  const accountsById = this.safeValue(this.options, 'accountsById', {});
5674
- const timestamp = this.safeInteger(transfer, 'ts', this.milliseconds());
5674
+ const timestamp = this.safeInteger(transfer, 'ts');
5675
5675
  const balanceChange = this.safeString(transfer, 'sz');
5676
5676
  if (balanceChange !== undefined) {
5677
5677
  amount = this.parseNumber(Precise.stringAbs(balanceChange));
package/js/src/phemex.js CHANGED
@@ -3361,7 +3361,7 @@ export default class phemex extends Exchange {
3361
3361
  // ]
3362
3362
  // }
3363
3363
  //
3364
- const data = this.safeValue(response, 'data', {});
3364
+ const data = this.safeList(response, 'data', []);
3365
3365
  return this.parseTransactions(data, currency, since, limit);
3366
3366
  }
3367
3367
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3401,7 +3401,7 @@ export default class phemex extends Exchange {
3401
3401
  // ]
3402
3402
  // }
3403
3403
  //
3404
- const data = this.safeValue(response, 'data', {});
3404
+ const data = this.safeList(response, 'data', []);
3405
3405
  return this.parseTransactions(data, currency, since, limit);
3406
3406
  }
3407
3407
  parseTransactionStatus(status) {
@@ -2602,8 +2602,21 @@ export default class binance extends binanceRest {
2602
2602
  // }
2603
2603
  //
2604
2604
  const marketId = this.safeString(position, 's');
2605
- const positionSide = this.safeStringLower(position, 'ps');
2606
- const hedged = positionSide !== 'both';
2605
+ const contracts = this.safeString(position, 'pa');
2606
+ const contractsAbs = Precise.stringAbs(this.safeString(position, 'pa'));
2607
+ let positionSide = this.safeStringLower(position, 'ps');
2608
+ let hedged = true;
2609
+ if (positionSide === 'both') {
2610
+ hedged = false;
2611
+ if (!Precise.stringEq(contracts, '0')) {
2612
+ if (Precise.stringLt(contracts, '0')) {
2613
+ positionSide = 'short';
2614
+ }
2615
+ else {
2616
+ positionSide = 'long';
2617
+ }
2618
+ }
2619
+ }
2607
2620
  return this.safePosition({
2608
2621
  'info': position,
2609
2622
  'id': undefined,
@@ -2614,7 +2627,7 @@ export default class binance extends binanceRest {
2614
2627
  'entryPrice': this.safeNumber(position, 'ep'),
2615
2628
  'unrealizedPnl': this.safeNumber(position, 'up'),
2616
2629
  'percentage': undefined,
2617
- 'contracts': this.safeNumber(position, 'pa'),
2630
+ 'contracts': this.parseNumber(contractsAbs),
2618
2631
  'contractSize': undefined,
2619
2632
  'markPrice': undefined,
2620
2633
  'side': positionSide,
@@ -559,6 +559,7 @@ export default class bingx extends bingxRest {
559
559
  * @param {object} [params] extra parameters specific to the exchange API endpoint
560
560
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
561
561
  */
562
+ await this.loadMarkets();
562
563
  const market = this.market(symbol);
563
564
  const [marketType, query] = this.handleMarketTypeAndParams('watchOHLCV', market, params);
564
565
  const url = this.safeValue(this.urls['api']['ws'], marketType);
@@ -25,7 +25,7 @@ export default class deribit extends deribitRest {
25
25
  watchOHLCVForSymbols(symbolsAndTimeframes: string[][], since?: Int, limit?: Int, params?: {}): Promise<import("../base/types.js").Dictionary<import("../base/types.js").Dictionary<OHLCV[]>>>;
26
26
  handleOHLCV(client: Client, message: any): void;
27
27
  parseWsOHLCV(ohlcv: any, market?: any): OHLCV;
28
- watchMultipleWrapper(channelName: string, channelDescriptor: string, symbolsArray?: any, params?: {}): Promise<any>;
28
+ watchMultipleWrapper(channelName: string, channelDescriptor: Str, symbolsArray?: any, params?: {}): Promise<any>;
29
29
  handleMessage(client: Client, message: any): void;
30
30
  handleAuthenticationMessage(client: Client, message: any): any;
31
31
  authenticate(params?: {}): Promise<any>;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * When sending values to or receiving values from a [[Contract]], the
3
+ * data is generally encoded using the [ABI standard](link-solc-abi).
4
+ *
5
+ * The AbiCoder provides a utility to encode values to ABI data and
6
+ * decode values from ABI data.
7
+ *
8
+ * Most of the time, developers should favour the [[Contract]] class,
9
+ * which further abstracts a lot of the finer details of ABI data.
10
+ *
11
+ * @_section api/abi/abi-coder:ABI Encoding
12
+ */
13
+ import { Result } from "./coders/abstract-coder.js";
14
+ import { ParamType } from "./fragments.js";
15
+ import type { BytesLike } from "./utils/index.js";
16
+ /**
17
+ * The **AbiCoder** is a low-level class responsible for encoding JavaScript
18
+ * values into binary data and decoding binary data into JavaScript values.
19
+ */
20
+ export declare class AbiCoder {
21
+ #private;
22
+ /**
23
+ * Get the default values for the given %%types%%.
24
+ *
25
+ * For example, a ``uint`` is by default ``0`` and ``bool``
26
+ * is by default ``false``.
27
+ */
28
+ getDefaultValue(types: ReadonlyArray<string | ParamType>): Result;
29
+ /**
30
+ * Encode the %%values%% as the %%types%% into ABI data.
31
+ *
32
+ * @returns DataHexstring
33
+ */
34
+ encode(types: ReadonlyArray<string | ParamType>, values: ReadonlyArray<any>): string;
35
+ /**
36
+ * Decode the ABI %%data%% as the %%types%% into values.
37
+ *
38
+ * If %%loose%% decoding is enabled, then strict padding is
39
+ * not enforced. Some older versions of Solidity incorrectly
40
+ * padded event data emitted from ``external`` functions.
41
+ */
42
+ decode(types: ReadonlyArray<string | ParamType>, data: BytesLike, loose?: boolean): Result;
43
+ static _setDefaultMaxInflation(value: number): void;
44
+ /**
45
+ * Returns the shared singleton instance of a default [[AbiCoder]].
46
+ *
47
+ * On the first call, the instance is created internally.
48
+ */
49
+ static defaultAbiCoder(): AbiCoder;
50
+ }
@@ -0,0 +1,148 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ /**
8
+ * When sending values to or receiving values from a [[Contract]], the
9
+ * data is generally encoded using the [ABI standard](link-solc-abi).
10
+ *
11
+ * The AbiCoder provides a utility to encode values to ABI data and
12
+ * decode values from ABI data.
13
+ *
14
+ * Most of the time, developers should favour the [[Contract]] class,
15
+ * which further abstracts a lot of the finer details of ABI data.
16
+ *
17
+ * @_section api/abi/abi-coder:ABI Encoding
18
+ */
19
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
20
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
21
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
22
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
23
+ };
24
+ var _AbiCoder_instances, _AbiCoder_getCoder;
25
+ // See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI
26
+ import { assertArgumentCount, assertArgument } from "./utils/index.js";
27
+ import { Reader, Writer } from "./coders/abstract-coder.js";
28
+ import { AddressCoder } from "./coders/address.js";
29
+ import { ArrayCoder } from "./coders/array.js";
30
+ import { BooleanCoder } from "./coders/boolean.js";
31
+ import { BytesCoder } from "./coders/bytes.js";
32
+ import { FixedBytesCoder } from "./coders/fixed-bytes.js";
33
+ import { NullCoder } from "./coders/null.js";
34
+ import { NumberCoder } from "./coders/number.js";
35
+ import { StringCoder } from "./coders/string.js";
36
+ import { TupleCoder } from "./coders/tuple.js";
37
+ import { ParamType } from "./fragments.js";
38
+ // https://docs.soliditylang.org/en/v0.8.17/control-structures.html
39
+ const PanicReasons = new Map();
40
+ PanicReasons.set(0x00, "GENERIC_PANIC");
41
+ PanicReasons.set(0x01, "ASSERT_FALSE");
42
+ PanicReasons.set(0x11, "OVERFLOW");
43
+ PanicReasons.set(0x12, "DIVIDE_BY_ZERO");
44
+ PanicReasons.set(0x21, "ENUM_RANGE_ERROR");
45
+ PanicReasons.set(0x22, "BAD_STORAGE_DATA");
46
+ PanicReasons.set(0x31, "STACK_UNDERFLOW");
47
+ PanicReasons.set(0x32, "ARRAY_RANGE_ERROR");
48
+ PanicReasons.set(0x41, "OUT_OF_MEMORY");
49
+ PanicReasons.set(0x51, "UNINITIALIZED_FUNCTION_CALL");
50
+ const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
51
+ const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
52
+ let defaultCoder = null;
53
+ let defaultMaxInflation = 1024;
54
+ /**
55
+ * The **AbiCoder** is a low-level class responsible for encoding JavaScript
56
+ * values into binary data and decoding binary data into JavaScript values.
57
+ */
58
+ export class AbiCoder {
59
+ constructor() {
60
+ _AbiCoder_instances.add(this);
61
+ }
62
+ /**
63
+ * Get the default values for the given %%types%%.
64
+ *
65
+ * For example, a ``uint`` is by default ``0`` and ``bool``
66
+ * is by default ``false``.
67
+ */
68
+ getDefaultValue(types) {
69
+ const coders = types.map((type) => __classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, ParamType.from(type)));
70
+ const coder = new TupleCoder(coders, "_");
71
+ return coder.defaultValue();
72
+ }
73
+ /**
74
+ * Encode the %%values%% as the %%types%% into ABI data.
75
+ *
76
+ * @returns DataHexstring
77
+ */
78
+ encode(types, values) {
79
+ assertArgumentCount(values.length, types.length, "types/values length mismatch");
80
+ const coders = types.map((type) => __classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, ParamType.from(type)));
81
+ const coder = (new TupleCoder(coders, "_"));
82
+ const writer = new Writer();
83
+ coder.encode(writer, values);
84
+ return writer.data;
85
+ }
86
+ /**
87
+ * Decode the ABI %%data%% as the %%types%% into values.
88
+ *
89
+ * If %%loose%% decoding is enabled, then strict padding is
90
+ * not enforced. Some older versions of Solidity incorrectly
91
+ * padded event data emitted from ``external`` functions.
92
+ */
93
+ decode(types, data, loose) {
94
+ const coders = types.map((type) => __classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, ParamType.from(type)));
95
+ const coder = new TupleCoder(coders, "_");
96
+ return coder.decode(new Reader(data, loose, defaultMaxInflation));
97
+ }
98
+ static _setDefaultMaxInflation(value) {
99
+ assertArgument(typeof (value) === "number" && Number.isInteger(value), "invalid defaultMaxInflation factor", "value", value);
100
+ defaultMaxInflation = value;
101
+ }
102
+ /**
103
+ * Returns the shared singleton instance of a default [[AbiCoder]].
104
+ *
105
+ * On the first call, the instance is created internally.
106
+ */
107
+ static defaultAbiCoder() {
108
+ if (defaultCoder == null) {
109
+ defaultCoder = new AbiCoder();
110
+ }
111
+ return defaultCoder;
112
+ }
113
+ }
114
+ _AbiCoder_instances = new WeakSet(), _AbiCoder_getCoder = function _AbiCoder_getCoder(param) {
115
+ if (param.isArray()) {
116
+ return new ArrayCoder(__classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, param.arrayChildren), param.arrayLength, param.name);
117
+ }
118
+ if (param.isTuple()) {
119
+ return new TupleCoder(param.components.map((c) => __classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, c)), param.name);
120
+ }
121
+ switch (param.baseType) {
122
+ case "address":
123
+ return new AddressCoder(param.name);
124
+ case "bool":
125
+ return new BooleanCoder(param.name);
126
+ case "string":
127
+ return new StringCoder(param.name);
128
+ case "bytes":
129
+ return new BytesCoder(param.name);
130
+ case "":
131
+ return new NullCoder(param.name);
132
+ }
133
+ // u?int[0-9]*
134
+ let match = param.type.match(paramTypeNumber);
135
+ if (match) {
136
+ let size = parseInt(match[2] || "256");
137
+ assertArgument(size !== 0 && size <= 256 && (size % 8) === 0, "invalid " + match[1] + " bit length", "param", param);
138
+ return new NumberCoder(size / 8, (match[1] === "int"), param.name);
139
+ }
140
+ // bytes[0-9]+
141
+ match = param.type.match(paramTypeBytes);
142
+ if (match) {
143
+ let size = parseInt(match[1]);
144
+ assertArgument(size !== 0 && size <= 32, "invalid bytes length", "param", param);
145
+ return new FixedBytesCoder(size, param.name);
146
+ }
147
+ assertArgument(false, "invalid type", "type", param.type);
148
+ };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Returns a normalized and checksumed address for %%address%%.
3
+ * This accepts non-checksum addresses, checksum addresses and
4
+ * [[getIcapAddress]] formats.
5
+ *
6
+ * The checksum in Ethereum uses the capitalization (upper-case
7
+ * vs lower-case) of the characters within an address to encode
8
+ * its checksum, which offers, on average, a checksum of 15-bits.
9
+ *
10
+ * If %%address%% contains both upper-case and lower-case, it is
11
+ * assumed to already be a checksum address and its checksum is
12
+ * validated, and if the address fails its expected checksum an
13
+ * error is thrown.
14
+ *
15
+ * If you wish the checksum of %%address%% to be ignore, it should
16
+ * be converted to lower-case (i.e. ``.toLowercase()``) before
17
+ * being passed in. This should be a very rare situation though,
18
+ * that you wish to bypass the safegaurds in place to protect
19
+ * against an address that has been incorrectly copied from another
20
+ * source.
21
+ *
22
+ * @example:
23
+ * // Adds the checksum (via upper-casing specific letters)
24
+ * getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
25
+ * //_result:
26
+ *
27
+ * // Converts ICAP address and adds checksum
28
+ * getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
29
+ * //_result:
30
+ *
31
+ * // Throws an error if an address contains mixed case,
32
+ * // but the checksum fails
33
+ * getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
34
+ * //_error:
35
+ */
36
+ export declare function getAddress(address: string): string;
37
+ /**
38
+ * The [ICAP Address format](link-icap) format is an early checksum
39
+ * format which attempts to be compatible with the banking
40
+ * industry [IBAN format](link-wiki-iban) for bank accounts.
41
+ *
42
+ * It is no longer common or a recommended format.
43
+ *
44
+ * @example:
45
+ * getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
46
+ * //_result:
47
+ *
48
+ * getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
49
+ * //_result:
50
+ *
51
+ * // Throws an error if the ICAP checksum is wrong
52
+ * getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
53
+ * //_error:
54
+ */
55
+ export declare function getIcapAddress(address: string): string;