ccxt 4.5.8 → 4.5.9

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 (95) hide show
  1. package/README.md +4 -7
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +111 -17
  5. package/dist/cjs/src/base/ws/Client.js +4 -0
  6. package/dist/cjs/src/bitget.js +59 -72
  7. package/dist/cjs/src/coinbaseexchange.js +15 -0
  8. package/dist/cjs/src/hyperliquid.js +0 -3
  9. package/dist/cjs/src/latoken.js +1 -0
  10. package/dist/cjs/src/phemex.js +15 -6
  11. package/dist/cjs/src/pro/alpaca.js +1 -1
  12. package/dist/cjs/src/pro/apex.js +4 -4
  13. package/dist/cjs/src/pro/binance.js +2 -1
  14. package/dist/cjs/src/pro/bitfinex.js +1 -1
  15. package/dist/cjs/src/pro/bitget.js +1 -1
  16. package/dist/cjs/src/pro/bitmart.js +1 -1
  17. package/dist/cjs/src/pro/bitmex.js +1 -1
  18. package/dist/cjs/src/pro/bitvavo.js +6 -6
  19. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  20. package/dist/cjs/src/pro/bybit.js +2 -1
  21. package/dist/cjs/src/pro/cex.js +2 -2
  22. package/dist/cjs/src/pro/coincatch.js +1 -1
  23. package/dist/cjs/src/pro/coinex.js +3 -3
  24. package/dist/cjs/src/pro/cryptocom.js +1 -1
  25. package/dist/cjs/src/pro/derive.js +1 -1
  26. package/dist/cjs/src/pro/gate.js +1 -1
  27. package/dist/cjs/src/pro/hitbtc.js +1 -1
  28. package/dist/cjs/src/pro/htx.js +2 -2
  29. package/dist/cjs/src/pro/kraken.js +8 -8
  30. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  31. package/dist/cjs/src/pro/kucoin.js +4 -4
  32. package/dist/cjs/src/pro/kucoinfutures.js +4 -4
  33. package/dist/cjs/src/pro/mexc.js +6 -1
  34. package/dist/cjs/src/pro/modetrade.js +2 -2
  35. package/dist/cjs/src/pro/okx.js +4 -2
  36. package/dist/cjs/src/pro/onetrading.js +1 -1
  37. package/dist/cjs/src/pro/oxfun.js +1 -1
  38. package/dist/cjs/src/pro/toobit.js +1 -1
  39. package/dist/cjs/src/pro/whitebit.js +1 -1
  40. package/dist/cjs/src/pro/woo.js +1 -1
  41. package/dist/cjs/src/pro/woofipro.js +2 -2
  42. package/js/ccxt.d.ts +1 -1
  43. package/js/ccxt.js +1 -1
  44. package/js/src/abstract/coinbaseexchange.d.ts +15 -0
  45. package/js/src/base/Exchange.d.ts +13 -5
  46. package/js/src/base/Exchange.js +111 -17
  47. package/js/src/base/ws/Client.d.ts +1 -0
  48. package/js/src/base/ws/Client.js +4 -0
  49. package/js/src/bitget.js +59 -72
  50. package/js/src/coinbaseexchange.js +15 -0
  51. package/js/src/hyperliquid.js +0 -3
  52. package/js/src/latoken.js +1 -0
  53. package/js/src/phemex.js +15 -6
  54. package/js/src/pro/alpaca.js +1 -1
  55. package/js/src/pro/apex.js +4 -4
  56. package/js/src/pro/binance.d.ts +1 -1
  57. package/js/src/pro/binance.js +2 -1
  58. package/js/src/pro/bitfinex.js +1 -1
  59. package/js/src/pro/bitget.js +1 -1
  60. package/js/src/pro/bitmart.js +1 -1
  61. package/js/src/pro/bitmex.js +1 -1
  62. package/js/src/pro/bitvavo.d.ts +3 -3
  63. package/js/src/pro/bitvavo.js +6 -6
  64. package/js/src/pro/blockchaincom.js +1 -1
  65. package/js/src/pro/bybit.js +2 -1
  66. package/js/src/pro/cex.js +2 -2
  67. package/js/src/pro/coincatch.js +1 -1
  68. package/js/src/pro/coinex.js +3 -3
  69. package/js/src/pro/cryptocom.d.ts +1 -1
  70. package/js/src/pro/cryptocom.js +1 -1
  71. package/js/src/pro/derive.js +1 -1
  72. package/js/src/pro/gate.d.ts +1 -1
  73. package/js/src/pro/gate.js +1 -1
  74. package/js/src/pro/hitbtc.d.ts +1 -1
  75. package/js/src/pro/hitbtc.js +1 -1
  76. package/js/src/pro/htx.js +2 -2
  77. package/js/src/pro/hyperliquid.d.ts +1 -1
  78. package/js/src/pro/kraken.d.ts +2 -2
  79. package/js/src/pro/kraken.js +8 -8
  80. package/js/src/pro/krakenfutures.js +1 -1
  81. package/js/src/pro/kucoin.js +4 -4
  82. package/js/src/pro/kucoinfutures.js +4 -4
  83. package/js/src/pro/mexc.js +6 -1
  84. package/js/src/pro/modetrade.js +2 -2
  85. package/js/src/pro/okx.d.ts +2 -2
  86. package/js/src/pro/okx.js +4 -2
  87. package/js/src/pro/onetrading.js +1 -1
  88. package/js/src/pro/oxfun.d.ts +1 -1
  89. package/js/src/pro/oxfun.js +1 -1
  90. package/js/src/pro/poloniex.d.ts +2 -2
  91. package/js/src/pro/toobit.js +1 -1
  92. package/js/src/pro/whitebit.js +1 -1
  93. package/js/src/pro/woo.js +1 -1
  94. package/js/src/pro/woofipro.js +2 -2
  95. package/package.json +21 -10
@@ -150,7 +150,7 @@ class coinex extends coinex$1["default"] {
150
150
  const defaultType = this.safeString(this.options, 'defaultType');
151
151
  const data = this.safeDict(message, 'data', {});
152
152
  const rawTickers = this.safeList(data, 'state_list', []);
153
- const newTickers = [];
153
+ const newTickers = {};
154
154
  for (let i = 0; i < rawTickers.length; i++) {
155
155
  const entry = rawTickers[i];
156
156
  const marketId = this.safeString(entry, 'market');
@@ -158,7 +158,7 @@ class coinex extends coinex$1["default"] {
158
158
  const market = this.safeMarket(marketId, undefined, undefined, defaultType);
159
159
  const parsedTicker = this.parseWSTicker(entry, market);
160
160
  this.tickers[symbol] = parsedTicker;
161
- newTickers.push(parsedTicker);
161
+ newTickers[symbol] = parsedTicker;
162
162
  }
163
163
  const messageHashes = this.findMessageHashes(client, 'tickers::');
164
164
  for (let i = 0; i < messageHashes.length; i++) {
@@ -1398,7 +1398,7 @@ class coinex extends coinex$1["default"] {
1398
1398
  const time = this.milliseconds();
1399
1399
  const timestamp = time.toString();
1400
1400
  const messageHash = 'authenticated';
1401
- const future = client.future(messageHash);
1401
+ const future = client.reusableFuture(messageHash);
1402
1402
  const authenticated = this.safeValue(client.subscriptions, messageHash);
1403
1403
  if (authenticated !== undefined) {
1404
1404
  return await future;
@@ -1355,7 +1355,7 @@ class cryptocom extends cryptocom$1["default"] {
1355
1355
  const url = this.urls['api']['ws']['private'];
1356
1356
  const client = this.client(url);
1357
1357
  const messageHash = 'authenticated';
1358
- const future = client.future(messageHash);
1358
+ const future = client.reusableFuture(messageHash);
1359
1359
  const authenticated = this.safeValue(client.subscriptions, messageHash);
1360
1360
  if (authenticated === undefined) {
1361
1361
  const method = 'public/auth';
@@ -423,7 +423,7 @@ class derive extends derive$1["default"] {
423
423
  const url = this.urls['api']['ws'];
424
424
  const client = this.client(url);
425
425
  const messageHash = 'authenticated';
426
- const future = client.future(messageHash);
426
+ const future = client.reusableFuture(messageHash);
427
427
  const authenticated = this.safeValue(client.subscriptions, messageHash);
428
428
  if (authenticated === undefined) {
429
429
  const requestId = this.requestId(url);
@@ -2025,7 +2025,7 @@ class gate extends gate$1["default"] {
2025
2025
  const channel = messageType + '.login';
2026
2026
  const client = this.client(url);
2027
2027
  const messageHash = 'authenticated';
2028
- const future = client.future(messageHash);
2028
+ const future = client.reusableFuture(messageHash);
2029
2029
  const authenticated = this.safeValue(client.subscriptions, messageHash);
2030
2030
  if (authenticated === undefined) {
2031
2031
  return await this.requestPrivate(url, {}, channel, messageHash);
@@ -87,7 +87,7 @@ class hitbtc extends hitbtc$1["default"] {
87
87
  const url = this.urls['api']['ws']['private'];
88
88
  const messageHash = 'authenticated';
89
89
  const client = this.client(url);
90
- const future = client.future(messageHash);
90
+ const future = client.reusableFuture(messageHash);
91
91
  const authenticated = this.safeValue(client.subscriptions, messageHash);
92
92
  if (authenticated === undefined) {
93
93
  const timestamp = this.milliseconds();
@@ -2492,7 +2492,7 @@ class htx extends htx$1["default"] {
2492
2492
  const messageHash = 'auth';
2493
2493
  const relativePath = url.replace('wss://' + hostname, '');
2494
2494
  const client = this.client(url);
2495
- const future = client.future(messageHash);
2495
+ const future = client.reusableFuture(messageHash);
2496
2496
  const authenticated = this.safeValue(client.subscriptions, messageHash);
2497
2497
  if (authenticated === undefined) {
2498
2498
  const timestamp = this.ymdhms(this.milliseconds(), 'T');
@@ -2514,7 +2514,7 @@ class htx extends htx$1["default"] {
2514
2514
  };
2515
2515
  }
2516
2516
  signatureParams = this.keysort(signatureParams);
2517
- const auth = this.urlencode(signatureParams);
2517
+ const auth = this.urlencode(signatureParams, true); // true required in go
2518
2518
  const payload = ['GET', hostname, relativePath, auth].join("\n"); // eslint-disable-line quotes
2519
2519
  const signature = this.hmac(this.encode(payload), this.encode(this.secret), sha256.sha256, 'base64');
2520
2520
  let request = undefined;
@@ -298,7 +298,7 @@ class kraken extends kraken$1["default"] {
298
298
  const market = this.market(symbol);
299
299
  const url = this.urls['api']['ws']['privateV2'];
300
300
  const requestId = this.requestId();
301
- const messageHash = requestId;
301
+ const messageHash = this.numberToString(requestId);
302
302
  let request = {
303
303
  'method': 'add_order',
304
304
  'params': {
@@ -342,7 +342,7 @@ class kraken extends kraken$1["default"] {
342
342
  //
343
343
  const result = this.safeDict(message, 'result', {});
344
344
  const order = this.parseOrder(result);
345
- const messageHash = this.safeValue2(message, 'reqid', 'req_id');
345
+ const messageHash = this.safeString2(message, 'reqid', 'req_id');
346
346
  client.resolve(order, messageHash);
347
347
  }
348
348
  /**
@@ -364,7 +364,7 @@ class kraken extends kraken$1["default"] {
364
364
  const token = await this.authenticate();
365
365
  const url = this.urls['api']['ws']['privateV2'];
366
366
  const requestId = this.requestId();
367
- const messageHash = requestId;
367
+ const messageHash = this.numberToString(requestId);
368
368
  let request = {
369
369
  'method': 'amend_order',
370
370
  'params': {
@@ -395,7 +395,7 @@ class kraken extends kraken$1["default"] {
395
395
  const token = await this.authenticate();
396
396
  const url = this.urls['api']['ws']['privateV2'];
397
397
  const requestId = this.requestId();
398
- const messageHash = requestId;
398
+ const messageHash = this.numberToString(requestId);
399
399
  const request = {
400
400
  'method': 'cancel_order',
401
401
  'params': {
@@ -424,7 +424,7 @@ class kraken extends kraken$1["default"] {
424
424
  const token = await this.authenticate();
425
425
  const url = this.urls['api']['ws']['privateV2'];
426
426
  const requestId = this.requestId();
427
- const messageHash = requestId;
427
+ const messageHash = this.numberToString(requestId);
428
428
  const request = {
429
429
  'method': 'cancel_order',
430
430
  'params': {
@@ -448,7 +448,7 @@ class kraken extends kraken$1["default"] {
448
448
  // "time_out": "2023-09-21T14:36:57.437952Z"
449
449
  // }
450
450
  //
451
- const reqId = this.safeValue(message, 'req_id');
451
+ const reqId = this.safeString(message, 'req_id');
452
452
  client.resolve(message, reqId);
453
453
  }
454
454
  /**
@@ -468,7 +468,7 @@ class kraken extends kraken$1["default"] {
468
468
  const token = await this.authenticate();
469
469
  const url = this.urls['api']['ws']['privateV2'];
470
470
  const requestId = this.requestId();
471
- const messageHash = requestId;
471
+ const messageHash = this.numberToString(requestId);
472
472
  const request = {
473
473
  'method': 'cancel_all',
474
474
  'params': {
@@ -491,7 +491,7 @@ class kraken extends kraken$1["default"] {
491
491
  // "time_out": "2023-09-21T14:36:57.437952Z"
492
492
  // }
493
493
  //
494
- const reqId = this.safeValue(message, 'req_id');
494
+ const reqId = this.safeString(message, 'req_id');
495
495
  client.resolve(message, reqId);
496
496
  }
497
497
  handleTicker(client, message) {
@@ -78,7 +78,7 @@ class krakenfutures extends krakenfutures$1["default"] {
78
78
  const url = this.urls['api']['ws'];
79
79
  const messageHash = 'challenge';
80
80
  const client = this.client(url);
81
- const future = client.future(messageHash);
81
+ const future = client.reusableFuture(messageHash);
82
82
  const authenticated = this.safeValue(client.subscriptions, messageHash);
83
83
  if (authenticated === undefined) {
84
84
  const request = {
@@ -62,16 +62,16 @@ class kucoin extends kucoin$1["default"] {
62
62
  async negotiate(privateChannel, params = {}) {
63
63
  const connectId = privateChannel ? 'private' : 'public';
64
64
  const urls = this.safeValue(this.options, 'urls', {});
65
- const spawaned = this.safeValue(urls, connectId);
66
- if (spawaned !== undefined) {
67
- return await spawaned;
65
+ let future = this.safeValue(urls, connectId);
66
+ if (future !== undefined) {
67
+ return await future;
68
68
  }
69
69
  // we store an awaitable to the url
70
70
  // so that multiple calls don't asynchronously
71
71
  // fetch different urls and overwrite each other
72
72
  urls[connectId] = this.spawn(this.negotiateHelper, privateChannel, params);
73
73
  this.options['urls'] = urls;
74
- const future = urls[connectId];
74
+ future = urls[connectId];
75
75
  return await future;
76
76
  }
77
77
  async negotiateHelper(privateChannel, params = {}) {
@@ -81,16 +81,16 @@ class kucoinfutures extends kucoinfutures$1["default"] {
81
81
  async negotiate(privateChannel, params = {}) {
82
82
  const connectId = privateChannel ? 'private' : 'public';
83
83
  const urls = this.safeValue(this.options, 'urls', {});
84
- const spawaned = this.safeValue(urls, connectId);
85
- if (spawaned !== undefined) {
86
- return await spawaned;
84
+ let future = this.safeValue(urls, connectId);
85
+ if (future !== undefined) {
86
+ return await future;
87
87
  }
88
88
  // we store an awaitable to the url
89
89
  // so that multiple calls don't asynchronously
90
90
  // fetch different urls and overwrite each other
91
91
  urls[connectId] = this.spawn(this.negotiateHelper, privateChannel, params); // we have to wait here otherwsie in c# will not work
92
92
  this.options['urls'] = urls;
93
- const future = urls[connectId];
93
+ future = urls[connectId];
94
94
  return await future;
95
95
  }
96
96
  async negotiateHelper(privateChannel, params = {}) {
@@ -865,6 +865,7 @@ class mexc extends mexc$1["default"] {
865
865
  }
866
866
  const storedOrderBook = this.orderbooks[symbol];
867
867
  const nonce = this.safeInteger(storedOrderBook, 'nonce');
868
+ let shouldReturn = false;
868
869
  if (nonce === undefined) {
869
870
  const cacheLength = storedOrderBook.cache.length;
870
871
  const snapshotDelay = this.handleOption('watchOrderBook', 'snapshotDelay', 25);
@@ -883,7 +884,11 @@ class mexc extends mexc$1["default"] {
883
884
  catch (e) {
884
885
  delete client.subscriptions[messageHash];
885
886
  client.reject(e, messageHash);
886
- return;
887
+ // return;
888
+ shouldReturn = true;
889
+ }
890
+ if (shouldReturn) {
891
+ return; // go requirement
887
892
  }
888
893
  client.resolve(storedOrderBook, messageHash);
889
894
  }
@@ -79,7 +79,7 @@ class modetrade extends modetrade$1["default"] {
79
79
  async watchPublic(messageHash, message) {
80
80
  // the default id
81
81
  let id = 'OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY';
82
- if (this.accountId !== undefined) {
82
+ if (this.accountId !== undefined && this.accountId !== '') {
83
83
  id = this.accountId;
84
84
  }
85
85
  const url = this.urls['api']['ws']['public'] + '/' + id;
@@ -594,7 +594,7 @@ class modetrade extends modetrade$1["default"] {
594
594
  const client = this.client(url);
595
595
  const messageHash = 'authenticated';
596
596
  const event = 'auth';
597
- const future = client.future(messageHash);
597
+ const future = client.reusableFuture(messageHash);
598
598
  const authenticated = this.safeValue(client.subscriptions, messageHash);
599
599
  if (authenticated === undefined) {
600
600
  const ts = this.nonce().toString();
@@ -1346,7 +1346,9 @@ class okx extends okx$1["default"] {
1346
1346
  }
1347
1347
  if (error !== undefined) {
1348
1348
  delete client.subscriptions[messageHash];
1349
- delete this.orderbooks[symbol];
1349
+ if (symbol !== undefined) {
1350
+ delete this.orderbooks[symbol];
1351
+ }
1350
1352
  client.reject(error, messageHash);
1351
1353
  }
1352
1354
  }
@@ -1500,7 +1502,7 @@ class okx extends okx$1["default"] {
1500
1502
  const url = this.getUrl('users', access);
1501
1503
  const messageHash = 'authenticated';
1502
1504
  const client = this.client(url);
1503
- const future = client.future(messageHash);
1505
+ const future = client.reusableFuture(messageHash);
1504
1506
  const authenticated = this.safeValue(client.subscriptions, messageHash);
1505
1507
  if (authenticated === undefined) {
1506
1508
  const timestamp = this.seconds().toString();
@@ -1327,7 +1327,7 @@ class onetrading extends onetrading$1["default"] {
1327
1327
  const url = this.urls['api']['ws'];
1328
1328
  const client = this.client(url);
1329
1329
  const messageHash = 'authenticated';
1330
- const future = client.future('authenticated');
1330
+ const future = client.reusableFuture('authenticated');
1331
1331
  const authenticated = this.safeValue(client.subscriptions, messageHash);
1332
1332
  if (authenticated === undefined) {
1333
1333
  this.checkRequiredCredentials();
@@ -1022,7 +1022,7 @@ class oxfun extends oxfun$1["default"] {
1022
1022
  const url = this.urls['api']['ws'];
1023
1023
  const client = this.client(url);
1024
1024
  const messageHash = 'authenticated';
1025
- const future = client.future(messageHash);
1025
+ const future = client.reusableFuture(messageHash);
1026
1026
  const authenticated = this.safeDict(client.subscriptions, messageHash);
1027
1027
  if (authenticated === undefined) {
1028
1028
  this.checkRequiredCredentials();
@@ -1082,7 +1082,7 @@ class toobit extends toobit$1["default"] {
1082
1082
  async authenticate(params = {}) {
1083
1083
  const client = this.client(this.getUserStreamUrl());
1084
1084
  const messageHash = 'authenticated';
1085
- const future = client.future(messageHash);
1085
+ const future = client.reusableFuture(messageHash);
1086
1086
  const authenticated = this.safeValue(client.subscriptions, messageHash);
1087
1087
  if (authenticated === undefined) {
1088
1088
  this.checkRequiredCredentials();
@@ -831,7 +831,7 @@ class whitebit extends whitebit$1["default"] {
831
831
  const url = this.urls['api']['ws'];
832
832
  const messageHash = 'authenticated';
833
833
  const client = this.client(url);
834
- const future = client.future('authenticated');
834
+ const future = client.reusableFuture('authenticated');
835
835
  const authenticated = this.safeValue(client.subscriptions, messageHash);
836
836
  if (authenticated === undefined) {
837
837
  const authToken = await this.v4PrivatePostProfileWebsocketToken();
@@ -842,7 +842,7 @@ class woo extends woo$1["default"] {
842
842
  const client = this.client(url);
843
843
  const messageHash = 'authenticated';
844
844
  const event = 'auth';
845
- const future = client.future(messageHash);
845
+ const future = client.reusableFuture(messageHash);
846
846
  const authenticated = this.safeValue(client.subscriptions, messageHash);
847
847
  if (authenticated === undefined) {
848
848
  const ts = this.nonce().toString();
@@ -79,7 +79,7 @@ class woofipro extends woofipro$1["default"] {
79
79
  async watchPublic(messageHash, message) {
80
80
  // the default id
81
81
  let id = 'OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY';
82
- if (this.accountId !== undefined) {
82
+ if (this.accountId !== undefined && this.accountId !== '') {
83
83
  id = this.accountId;
84
84
  }
85
85
  const url = this.urls['api']['ws']['public'] + '/' + id;
@@ -594,7 +594,7 @@ class woofipro extends woofipro$1["default"] {
594
594
  const client = this.client(url);
595
595
  const messageHash = 'authenticated';
596
596
  const event = 'auth';
597
- const future = client.future(messageHash);
597
+ const future = client.reusableFuture(messageHash);
598
598
  const authenticated = this.safeValue(client.subscriptions, messageHash);
599
599
  if (authenticated === undefined) {
600
600
  const ts = this.nonce().toString();
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OrderBooks, OpenInterests, ConstructorArgs } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, RestrictedLocation, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.5.7";
7
+ declare const version = "4.5.8";
8
8
  import alpaca from './src/alpaca.js';
9
9
  import apex from './src/apex.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, RestrictedLocation, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.5.7';
41
+ const version = '4.5.8';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import alpaca from './src/alpaca.js';
@@ -47,7 +47,19 @@ interface Exchange {
47
47
  privateGetUsersSelfTrailingVolume(params?: {}): Promise<implicitReturnType>;
48
48
  privateGetWithdrawalsFeeEstimate(params?: {}): Promise<implicitReturnType>;
49
49
  privateGetConversionsConversionId(params?: {}): Promise<implicitReturnType>;
50
+ privateGetConversions(params?: {}): Promise<implicitReturnType>;
50
51
  privateGetConversionsFees(params?: {}): Promise<implicitReturnType>;
52
+ privateGetLoansLendingOverview(params?: {}): Promise<implicitReturnType>;
53
+ privateGetLoansLendingOverviewXm(params?: {}): Promise<implicitReturnType>;
54
+ privateGetLoansLoanPreview(params?: {}): Promise<implicitReturnType>;
55
+ privateGetLoansLoanPreviewXm(params?: {}): Promise<implicitReturnType>;
56
+ privateGetLoansRepaymentPreview(params?: {}): Promise<implicitReturnType>;
57
+ privateGetLoansRepaymentPreviewXm(params?: {}): Promise<implicitReturnType>;
58
+ privateGetLoansInterestLoanId(params?: {}): Promise<implicitReturnType>;
59
+ privateGetLoansInterestHistoryLoanId(params?: {}): Promise<implicitReturnType>;
60
+ privateGetLoansInterest(params?: {}): Promise<implicitReturnType>;
61
+ privateGetLoansAssets(params?: {}): Promise<implicitReturnType>;
62
+ privateGetLoans(params?: {}): Promise<implicitReturnType>;
51
63
  privatePostConversions(params?: {}): Promise<implicitReturnType>;
52
64
  privatePostDepositsCoinbaseAccount(params?: {}): Promise<implicitReturnType>;
53
65
  privatePostDepositsPaymentMethod(params?: {}): Promise<implicitReturnType>;
@@ -62,6 +74,9 @@ interface Exchange {
62
74
  privatePostWithdrawalsCoinbaseAccount(params?: {}): Promise<implicitReturnType>;
63
75
  privatePostWithdrawalsCrypto(params?: {}): Promise<implicitReturnType>;
64
76
  privatePostWithdrawalsPaymentMethod(params?: {}): Promise<implicitReturnType>;
77
+ privatePostLoansOpen(params?: {}): Promise<implicitReturnType>;
78
+ privatePostLoansRepayInterest(params?: {}): Promise<implicitReturnType>;
79
+ privatePostLoansRepayPrincipal(params?: {}): Promise<implicitReturnType>;
65
80
  privateDeleteOrders(params?: {}): Promise<implicitReturnType>;
66
81
  privateDeleteOrdersClientClientOid(params?: {}): Promise<implicitReturnType>;
67
82
  privateDeleteOrdersId(params?: {}): Promise<implicitReturnType>;
@@ -535,8 +535,8 @@ export default class Exchange {
535
535
  initRestRateLimiter(): void;
536
536
  featuresGenerator(): void;
537
537
  featuresMapper(initialFeatures: any, marketType: Str, subType?: Str): any;
538
- featureValue(symbol: string, methodName?: Str, paramName?: Str, subParamName?: Str, defaultValue?: any): any;
539
- featureValueByType(marketType: string, subType: Str, methodName?: Str, paramName?: Str, subParamName?: Str, defaultValue?: any): any;
538
+ featureValue(symbol: string, methodName?: Str, paramName?: Str, defaultValue?: any): any;
539
+ featureValueByType(marketType: string, subType: Str, methodName?: Str, paramName?: Str, defaultValue?: any): any;
540
540
  orderbookChecksumMessage(symbol: Str): string;
541
541
  createNetworksByIdObject(): void;
542
542
  getDefaultOptions(): {
@@ -766,12 +766,12 @@ export default class Exchange {
766
766
  editOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
767
767
  createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
768
768
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
769
- cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<{}>;
770
- cancelOrdersWs(ids: string[], symbol?: Str, params?: {}): Promise<{}>;
769
+ cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
770
+ cancelOrdersWs(ids: string[], symbol?: Str, params?: {}): Promise<Order[]>;
771
771
  cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
772
772
  cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<{}>;
773
773
  cancelOrdersForSymbols(orders: CancellationRequest[], params?: {}): Promise<Order[]>;
774
- cancelAllOrdersWs(symbol?: Str, params?: {}): Promise<{}>;
774
+ cancelAllOrdersWs(symbol?: Str, params?: {}): Promise<Order[]>;
775
775
  cancelUnifiedOrder(order: any, params?: {}): Promise<{}>;
776
776
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
777
777
  fetchOrdersWs(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
@@ -934,6 +934,14 @@ export default class Exchange {
934
934
  parseMarginModifications(response: object[], symbols?: Strings, symbolKey?: Str, marketType?: MarketType): MarginModification[];
935
935
  fetchTransfer(id: string, code?: Str, params?: {}): Promise<TransferEntry>;
936
936
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
937
+ unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<any>;
938
+ watchMarkPrice(symbol: string, params?: {}): Promise<Ticker>;
939
+ watchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
940
+ withdrawWs(code: string, amount: number, address: string, tag?: Str, params?: {}): Promise<{}>;
941
+ unWatchMyTrades(symbol?: Str, params?: {}): Promise<any>;
942
+ createOrdersWs(orders: OrderRequest[], params?: {}): Promise<Order[]>;
943
+ fetchOrdersByStatusWs(status: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
944
+ unWatchBidsAsks(symbols?: Strings, params?: {}): Promise<any>;
937
945
  cleanUnsubscription(client: any, subHash: string, unsubHash: string, subHashIsPrefix?: boolean): void;
938
946
  cleanCache(subscription: Dict): void;
939
947
  }
@@ -1300,7 +1300,7 @@ export default class Exchange {
1300
1300
  }
1301
1301
  starknetSign(msgHash, pri) {
1302
1302
  // TODO: unify to ecdsa
1303
- const signature = starknetCurveSign(msgHash.replace('0x', ''), pri.slice(-64));
1303
+ const signature = starknetCurveSign(msgHash.replace('0x', ''), pri.replace('0x', ''));
1304
1304
  return this.json([signature.r.toString(), signature.s.toString()]);
1305
1305
  }
1306
1306
  async getZKContractSignatureObj(seed, params = {}) {
@@ -2633,22 +2633,21 @@ export default class Exchange {
2633
2633
  }
2634
2634
  return featuresObj;
2635
2635
  }
2636
- featureValue(symbol, methodName = undefined, paramName = undefined, subParamName = undefined, defaultValue = undefined) {
2636
+ featureValue(symbol, methodName = undefined, paramName = undefined, defaultValue = undefined) {
2637
2637
  /**
2638
2638
  * @method
2639
2639
  * @name exchange#featureValue
2640
2640
  * @description this method is a very deterministic to help users to know what feature is supported by the exchange
2641
2641
  * @param {string} [symbol] unified symbol
2642
2642
  * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/#/README?id=features
2643
- * @param {string} [paramName] unified param value (check docs for supported param names)
2644
- * @param {string} [subParamName] unified sub-param value (eg. stopLoss->triggerPriceType)
2643
+ * @param {string} [paramName] unified param value, like: `triggerPrice`, `stopLoss.triggerPrice` (check docs for supported param names)
2645
2644
  * @param {object} [defaultValue] return default value if no result found
2646
2645
  * @returns {object} returns feature value
2647
2646
  */
2648
2647
  const market = this.market(symbol);
2649
- return this.featureValueByType(market['type'], market['subType'], methodName, paramName, subParamName, defaultValue);
2648
+ return this.featureValueByType(market['type'], market['subType'], methodName, paramName, defaultValue);
2650
2649
  }
2651
- featureValueByType(marketType, subType, methodName = undefined, paramName = undefined, subParamName = undefined, defaultValue = undefined) {
2650
+ featureValueByType(marketType, subType, methodName = undefined, paramName = undefined, defaultValue = undefined) {
2652
2651
  /**
2653
2652
  * @method
2654
2653
  * @name exchange#featureValueByType
@@ -2657,7 +2656,6 @@ export default class Exchange {
2657
2656
  * @param {string} [subType] supported only: "linear", "inverse"
2658
2657
  * @param {string} [methodName] view currently supported methods: https://docs.ccxt.com/#/README?id=features
2659
2658
  * @param {string} [paramName] unified param value (check docs for supported param names)
2660
- * @param {string} [subParamName] unified sub-param value (eg. stopLoss->triggerPriceType)
2661
2659
  * @param {object} [defaultValue] return default value if no result found
2662
2660
  * @returns {object} returns feature value
2663
2661
  */
@@ -2704,24 +2702,27 @@ export default class Exchange {
2704
2702
  if (paramName === undefined) {
2705
2703
  return methodDict;
2706
2704
  }
2707
- if (!(paramName in methodDict)) {
2705
+ const splited = paramName.split('.'); // can be only parent key (`stopLoss`) or with child (`stopLoss.triggerPrice`)
2706
+ const parentKey = splited[0];
2707
+ const subKey = this.safeString(splited, 1);
2708
+ if (!(parentKey in methodDict)) {
2708
2709
  return defaultValue; // unsupported paramName, check "exchange.features" for details');
2709
2710
  }
2710
- const dictionary = this.safeDict(methodDict, paramName);
2711
+ const dictionary = this.safeDict(methodDict, parentKey);
2711
2712
  if (dictionary === undefined) {
2712
2713
  // if the value is not dictionary but a scalar value (or undefined), return as is
2713
- return methodDict[paramName];
2714
+ return methodDict[parentKey];
2714
2715
  }
2715
2716
  else {
2716
- // return as is, when calling without `subParamName` eg: featureValueByType('spot', undefined, 'createOrder', 'stopLoss')
2717
- if (subParamName === undefined) {
2718
- return methodDict[paramName];
2717
+ // return as is, when calling without subKey eg: featureValueByType('spot', undefined, 'createOrder', 'stopLoss')
2718
+ if (subKey === undefined) {
2719
+ return methodDict[parentKey];
2719
2720
  }
2720
- // throw an exception for unsupported subParamName
2721
- if (!(subParamName in methodDict[paramName])) {
2722
- return defaultValue; // unsupported subParamName, check "exchange.features" for details
2721
+ // throw an exception for unsupported subKey
2722
+ if (!(subKey in methodDict[parentKey])) {
2723
+ return defaultValue; // unsupported subKey, check "exchange.features" for details
2723
2724
  }
2724
- return methodDict[paramName][subParamName];
2725
+ return methodDict[parentKey][subKey];
2725
2726
  }
2726
2727
  }
2727
2728
  orderbookChecksumMessage(symbol) {
@@ -7543,6 +7544,99 @@ export default class Exchange {
7543
7544
  */
7544
7545
  throw new NotSupported(this.id + ' fetchTransfers () is not supported yet');
7545
7546
  }
7547
+ async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
7548
+ /**
7549
+ * @method
7550
+ * @name exchange#unWatchOHLCV
7551
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
7552
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
7553
+ * @param {string} timeframe the length of time each candle represents
7554
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7555
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
7556
+ */
7557
+ throw new NotSupported(this.id + ' unWatchOHLCV () is not supported yet');
7558
+ }
7559
+ async watchMarkPrice(symbol, params = {}) {
7560
+ /**
7561
+ * @method
7562
+ * @name exchange#watchMarkPrice
7563
+ * @description watches a mark price for a specific market
7564
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
7565
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7566
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
7567
+ */
7568
+ throw new NotSupported(this.id + ' watchMarkPrice () is not supported yet');
7569
+ }
7570
+ async watchMarkPrices(symbols = undefined, params = {}) {
7571
+ /**
7572
+ * @method
7573
+ * @name exchange#watchMarkPrices
7574
+ * @description watches the mark price for all markets
7575
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
7576
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7577
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
7578
+ */
7579
+ throw new NotSupported(this.id + ' watchMarkPrices () is not supported yet');
7580
+ }
7581
+ async withdrawWs(code, amount, address, tag = undefined, params = {}) {
7582
+ /**
7583
+ * @method
7584
+ * @name exchange#withdrawWs
7585
+ * @description make a withdrawal
7586
+ * @param {string} code unified currency code
7587
+ * @param {float} amount the amount to withdraw
7588
+ * @param {string} address the address to withdraw to
7589
+ * @param {string} tag
7590
+ * @param {object} [params] extra parameters specific to the bitvavo api endpoint
7591
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
7592
+ */
7593
+ throw new NotSupported(this.id + ' withdrawWs () is not supported yet');
7594
+ }
7595
+ async unWatchMyTrades(symbol = undefined, params = {}) {
7596
+ /**
7597
+ * @method
7598
+ * @name exchange#unWatchMyTrades
7599
+ * @description unWatches information on multiple trades made by the user
7600
+ * @param {string} symbol unified market symbol of the market orders were made in
7601
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7602
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
7603
+ */
7604
+ throw new NotSupported(this.id + ' unWatchMyTrades () is not supported yet');
7605
+ }
7606
+ async createOrdersWs(orders, params = {}) {
7607
+ /**
7608
+ * @method
7609
+ * @name exchange#createOrdersWs
7610
+ * @description create a list of trade orders
7611
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
7612
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7613
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
7614
+ */
7615
+ throw new NotSupported(this.id + ' createOrdersWs () is not supported yet');
7616
+ }
7617
+ async fetchOrdersByStatusWs(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
7618
+ /**
7619
+ * @method
7620
+ * @name exchange#fetchOrdersByStatusWs
7621
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
7622
+ * @param {string} symbol unified symbol of the market to fetch the order book for
7623
+ * @param {int} [limit] the maximum amount of order book entries to return
7624
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7625
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
7626
+ */
7627
+ throw new NotSupported(this.id + ' fetchOrdersByStatusWs () is not supported yet');
7628
+ }
7629
+ async unWatchBidsAsks(symbols = undefined, params = {}) {
7630
+ /**
7631
+ * @method
7632
+ * @name exchange#unWatchBidsAsks
7633
+ * @description unWatches best bid & ask for symbols
7634
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
7635
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7636
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
7637
+ */
7638
+ throw new NotSupported(this.id + ' unWatchBidsAsks () is not supported yet');
7639
+ }
7546
7640
  cleanUnsubscription(client, subHash, unsubHash, subHashIsPrefix = false) {
7547
7641
  if (unsubHash in client.subscriptions) {
7548
7642
  delete client.subscriptions[unsubHash];
@@ -28,6 +28,7 @@ export default class Client {
28
28
  throttle: any;
29
29
  decompressBinary: boolean;
30
30
  constructor(url: string, onMessageCallback: Function | undefined, onErrorCallback: Function | undefined, onCloseCallback: Function | undefined, onConnectedCallback: Function | undefined, config?: {});
31
+ reusableFuture(messageHash: string): any;
31
32
  future(messageHash: string): any;
32
33
  resolve(result: any, messageHash: Str): any;
33
34
  reject(result: any, messageHash?: Str): any;