ccxt 4.5.18 → 4.5.20

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 (152) hide show
  1. package/README.md +7 -6
  2. package/dist/ccxt.browser.min.js +40 -16
  3. package/dist/cjs/_virtual/index.cjs.js +1459 -9
  4. package/dist/cjs/ccxt.js +8 -2
  5. package/dist/cjs/src/abstract/dydx.js +11 -0
  6. package/dist/cjs/src/base/Exchange.js +164 -10
  7. package/dist/cjs/src/base/ws/Client.js +3 -1
  8. package/dist/cjs/src/binance.js +8 -1
  9. package/dist/cjs/src/bingx.js +20 -0
  10. package/dist/cjs/src/bitget.js +43 -41
  11. package/dist/cjs/src/bybit.js +21 -23
  12. package/dist/cjs/src/deribit.js +6 -0
  13. package/dist/cjs/src/dydx.js +2454 -0
  14. package/dist/cjs/src/gate.js +4 -4
  15. package/dist/cjs/src/hibachi.js +1 -1
  16. package/dist/cjs/src/hyperliquid.js +207 -9
  17. package/dist/cjs/src/kucoin.js +711 -109
  18. package/dist/cjs/src/mexc.js +2 -3
  19. package/dist/cjs/src/pro/binance.js +59 -144
  20. package/dist/cjs/src/pro/dydx.js +418 -0
  21. package/dist/cjs/src/pro/kraken.js +4 -3
  22. package/dist/cjs/src/pro/xt.js +218 -4
  23. package/dist/cjs/src/protobuf/mexc/compiled.cjs.js +1 -0
  24. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +56 -0
  25. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +56 -0
  26. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +48 -0
  27. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +343 -0
  28. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +717 -0
  29. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +60 -0
  30. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +45 -0
  31. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +380 -0
  32. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +72 -0
  33. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +211 -0
  34. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +195 -0
  35. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +49 -0
  36. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +57 -0
  37. package/dist/cjs/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +56 -0
  38. package/dist/cjs/src/static_dependencies/dydx-v4-client/helpers.js +79 -0
  39. package/dist/cjs/src/static_dependencies/dydx-v4-client/long/index.cjs.js +9 -0
  40. package/dist/cjs/src/static_dependencies/dydx-v4-client/onboarding.js +59 -0
  41. package/dist/cjs/src/static_dependencies/dydx-v4-client/registry.js +39 -0
  42. package/dist/cjs/src/static_dependencies/noble-hashes/pbkdf2.js +69 -0
  43. package/dist/cjs/src/static_dependencies/noble-hashes/ripemd160.js +108 -0
  44. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +50 -1
  45. package/dist/cjs/src/static_dependencies/scure-base/index.js +29 -0
  46. package/dist/cjs/src/static_dependencies/scure-bip32/index.js +278 -0
  47. package/dist/cjs/src/static_dependencies/scure-bip39/index.js +97 -0
  48. package/dist/cjs/src/static_dependencies/scure-bip39/wordlists/english.js +2060 -0
  49. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2 -0
  50. package/dist/cjs/src/toobit.js +2 -1
  51. package/js/ccxt.d.ts +8 -2
  52. package/js/ccxt.js +6 -2
  53. package/js/src/abstract/binance.d.ts +7 -0
  54. package/js/src/abstract/binancecoinm.d.ts +7 -0
  55. package/js/src/abstract/binanceus.d.ts +7 -0
  56. package/js/src/abstract/binanceusdm.d.ts +7 -0
  57. package/js/src/abstract/bitget.d.ts +1 -0
  58. package/js/src/abstract/dydx.d.ts +61 -0
  59. package/js/src/abstract/dydx.js +11 -0
  60. package/js/src/abstract/kucoin.d.ts +1 -1
  61. package/js/src/abstract/kucoinfutures.d.ts +1 -1
  62. package/js/src/base/Exchange.d.ts +7 -0
  63. package/js/src/base/Exchange.js +163 -10
  64. package/js/src/base/ws/Client.js +3 -1
  65. package/js/src/binance.js +8 -1
  66. package/js/src/bingx.js +20 -0
  67. package/js/src/bitget.d.ts +3 -3
  68. package/js/src/bitget.js +43 -41
  69. package/js/src/bybit.d.ts +3 -3
  70. package/js/src/bybit.js +21 -23
  71. package/js/src/deribit.js +6 -0
  72. package/js/src/dydx.d.ts +364 -0
  73. package/js/src/dydx.js +2453 -0
  74. package/js/src/gate.d.ts +2 -2
  75. package/js/src/gate.js +4 -4
  76. package/js/src/hibachi.js +1 -1
  77. package/js/src/hyperliquid.d.ts +17 -0
  78. package/js/src/hyperliquid.js +207 -9
  79. package/js/src/kucoin.d.ts +48 -1
  80. package/js/src/kucoin.js +711 -109
  81. package/js/src/mexc.js +2 -3
  82. package/js/src/pro/binance.d.ts +2 -2
  83. package/js/src/pro/binance.js +59 -144
  84. package/js/src/pro/dydx.d.ts +81 -0
  85. package/js/src/pro/dydx.js +417 -0
  86. package/js/src/pro/kraken.js +4 -3
  87. package/js/src/pro/xt.d.ts +85 -2
  88. package/js/src/pro/xt.js +218 -4
  89. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.d.ts +90 -0
  90. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +163 -0
  91. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.d.ts +26 -0
  92. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +51 -0
  93. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.d.ts +48 -0
  94. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +85 -0
  95. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.d.ts +40 -0
  96. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +77 -0
  97. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.d.ts +162 -0
  98. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +329 -0
  99. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.d.ts +460 -0
  100. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +698 -0
  101. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.d.ts +127 -0
  102. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +286 -0
  103. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.d.ts +66 -0
  104. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +109 -0
  105. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.d.ts +127 -0
  106. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +257 -0
  107. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.d.ts +48 -0
  108. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +93 -0
  109. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.d.ts +23 -0
  110. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +43 -0
  111. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.d.ts +92 -0
  112. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +164 -0
  113. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.d.ts +124 -0
  114. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +196 -0
  115. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.d.ts +159 -0
  116. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +324 -0
  117. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.d.ts +546 -0
  118. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +872 -0
  119. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.d.ts +84 -0
  120. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +181 -0
  121. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.d.ts +397 -0
  122. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +757 -0
  123. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.d.ts +120 -0
  124. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +246 -0
  125. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.d.ts +79 -0
  126. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +147 -0
  127. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.d.ts +32 -0
  128. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +59 -0
  129. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.d.ts +34 -0
  130. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +66 -0
  131. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.d.ts +62 -0
  132. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +111 -0
  133. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.d.ts +207 -0
  134. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +50 -0
  135. package/js/src/static_dependencies/dydx-v4-client/helpers.d.ts +82 -0
  136. package/js/src/static_dependencies/dydx-v4-client/helpers.js +172 -0
  137. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +1473 -0
  138. package/js/src/static_dependencies/dydx-v4-client/long/index.d.cts +2 -0
  139. package/js/src/static_dependencies/dydx-v4-client/onboarding.d.ts +35 -0
  140. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +56 -0
  141. package/js/src/static_dependencies/dydx-v4-client/registry.d.ts +7 -0
  142. package/js/src/static_dependencies/dydx-v4-client/registry.js +36 -0
  143. package/js/src/static_dependencies/noble-hashes/utils.d.ts +1 -0
  144. package/js/src/static_dependencies/noble-hashes/utils.js +4 -0
  145. package/js/src/static_dependencies/scure-bip32/index.d.ts +49 -0
  146. package/js/src/static_dependencies/scure-bip32/index.js +295 -0
  147. package/js/src/static_dependencies/scure-bip39/index.d.ts +54 -0
  148. package/js/src/static_dependencies/scure-bip39/index.js +140 -0
  149. package/js/src/static_dependencies/scure-bip39/wordlists/english.d.ts +1 -0
  150. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +2054 -0
  151. package/js/src/toobit.js +2 -1
  152. package/package.json +9 -3
package/dist/cjs/ccxt.js CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ require('./_virtual/_commonjsHelpers.js');
6
+ require('./_virtual/index.cjs.js');
5
7
  var Exchange = require('./src/base/Exchange.js');
6
8
  var Precise = require('./src/base/Precise.js');
7
9
  var functions = require('./src/base/functions.js');
@@ -62,6 +64,7 @@ var delta = require('./src/delta.js');
62
64
  var deribit = require('./src/deribit.js');
63
65
  var derive = require('./src/derive.js');
64
66
  var digifinex = require('./src/digifinex.js');
67
+ var dydx = require('./src/dydx.js');
65
68
  var exmo = require('./src/exmo.js');
66
69
  var fmfwio = require('./src/fmfwio.js');
67
70
  var foxbit = require('./src/foxbit.js');
@@ -151,6 +154,7 @@ var deepcoin$1 = require('./src/pro/deepcoin.js');
151
154
  var defx$1 = require('./src/pro/defx.js');
152
155
  var deribit$1 = require('./src/pro/deribit.js');
153
156
  var derive$1 = require('./src/pro/derive.js');
157
+ var dydx$1 = require('./src/pro/dydx.js');
154
158
  var exmo$1 = require('./src/pro/exmo.js');
155
159
  var gate$1 = require('./src/pro/gate.js');
156
160
  var gateio$1 = require('./src/pro/gateio.js');
@@ -188,10 +192,9 @@ var woo$1 = require('./src/pro/woo.js');
188
192
  var woofipro$1 = require('./src/pro/woofipro.js');
189
193
  var xt$1 = require('./src/pro/xt.js');
190
194
 
191
- // ----------------------------------------------------------------------------
192
195
  //-----------------------------------------------------------------------------
193
196
  // this is updated by vss.js when building
194
- const version = '4.5.18';
197
+ const version = '4.5.20';
195
198
  Exchange["default"].ccxtVersion = version;
196
199
  const exchanges = {
197
200
  'alpaca': alpaca["default"],
@@ -250,6 +253,7 @@ const exchanges = {
250
253
  'deribit': deribit["default"],
251
254
  'derive': derive["default"],
252
255
  'digifinex': digifinex["default"],
256
+ 'dydx': dydx["default"],
253
257
  'exmo': exmo["default"],
254
258
  'fmfwio': fmfwio["default"],
255
259
  'foxbit': foxbit["default"],
@@ -341,6 +345,7 @@ const pro = {
341
345
  'defx': defx$1["default"],
342
346
  'deribit': deribit$1["default"],
343
347
  'derive': derive$1["default"],
348
+ 'dydx': dydx$1["default"],
344
349
  'exmo': exmo$1["default"],
345
350
  'gate': gate$1["default"],
346
351
  'gateio': gateio$1["default"],
@@ -485,6 +490,7 @@ exports.delta = delta["default"];
485
490
  exports.deribit = deribit["default"];
486
491
  exports.derive = derive["default"];
487
492
  exports.digifinex = digifinex["default"];
493
+ exports.dydx = dydx["default"];
488
494
  exports.exmo = exmo["default"];
489
495
  exports.fmfwio = fmfwio["default"];
490
496
  exports.foxbit = foxbit["default"];
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Exchange$1 = require('../base/Exchange.js');
6
+
7
+ // ----------------------------------------------------------------------------
8
+ class Exchange extends Exchange$1["default"] {
9
+ }
10
+
11
+ exports["default"] = Exchange;
@@ -29,8 +29,12 @@ var selector = require('../static_dependencies/starknet/utils/selector.js');
29
29
  var classHash = require('../static_dependencies/starknet/utils/hash/classHash.js');
30
30
  var index$2 = require('../static_dependencies/starknet/utils/calldata/index.js');
31
31
  var typedData$1 = require('../static_dependencies/starknet/utils/typedData.js');
32
+ var sha1 = require('../static_dependencies/noble-hashes/sha1.js');
33
+ var onboarding = require('../static_dependencies/dydx-v4-client/onboarding.js');
34
+ require('../static_dependencies/dydx-v4-client/helpers.js');
32
35
  var generic = require('./functions/generic.js');
33
36
  var misc = require('./functions/misc.js');
37
+ var index$3 = require('../static_dependencies/dydx-v4-client/long/index.cjs.js');
34
38
 
35
39
  function _interopNamespace(e) {
36
40
  if (e && e.__esModule) return e;
@@ -56,11 +60,18 @@ const { isNode, selfIsDefined, deepExtend, extend, clone, flatten, unique, index
56
60
  arrayConcat, encode, urlencode, hmac, numberToString, roundTimeframe, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, sort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep, } = functions;
57
61
  // ----------------------------------------------------------------------------
58
62
  let protobufMexc = undefined;
63
+ let encodeAsAny = undefined;
64
+ let AuthInfo = undefined;
65
+ let Tx = undefined;
66
+ let TxBody = undefined;
67
+ let TxRaw = undefined;
68
+ let SignDoc = undefined;
69
+ let SignMode = undefined;
59
70
  (async () => {
60
71
  try {
61
72
  protobufMexc = await Promise.resolve().then(function () { return require('../protobuf/mexc/compiled.cjs.js'); });
62
73
  }
63
- catch {
74
+ catch (e) {
64
75
  // TODO: handle error
65
76
  }
66
77
  })();
@@ -386,6 +397,29 @@ class Exchange {
386
397
  this.setSandboxMode(true);
387
398
  }
388
399
  }
400
+ uuid5(namespace, name) {
401
+ const nsBytes = namespace
402
+ .replace(/-/g, '')
403
+ .match(/.{1,2}/g)
404
+ .map((byte) => parseInt(byte, 16));
405
+ const nameBytes = new TextEncoder().encode(name);
406
+ const data = new Uint8Array([...nsBytes, ...nameBytes]);
407
+ const nsHash = sha1.sha1(data);
408
+ // eslint-disable-next-line
409
+ nsHash[6] = (nsHash[6] & 0x0f) | 0x50;
410
+ // eslint-disable-next-line
411
+ nsHash[8] = (nsHash[8] & 0x3f) | 0x80;
412
+ const hex = [...nsHash.slice(0, 16)]
413
+ .map((b) => b.toString(16).padStart(2, '0'))
414
+ .join('');
415
+ return [
416
+ hex.substring(0, 8),
417
+ hex.substring(8, 12),
418
+ hex.substring(12, 16),
419
+ hex.substring(16, 20),
420
+ hex.substring(20, 32),
421
+ ].join('-');
422
+ }
389
423
  encodeURIComponent(...args) {
390
424
  // @ts-expect-error
391
425
  return encodeURIComponent(...args);
@@ -1357,6 +1391,128 @@ class Exchange {
1357
1391
  const zkSign = tx?.signature?.signature;
1358
1392
  return zkSign;
1359
1393
  }
1394
+ async loadDydxProtos() {
1395
+ // load dydx protos
1396
+ const tasks = [
1397
+ Promise.resolve().then(function () { return require('../static_dependencies/dydx-v4-client/registry.js'); }),
1398
+ Promise.resolve().then(function () { return require('../static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js'); }),
1399
+ Promise.resolve().then(function () { return require('../static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js'); }),
1400
+ ];
1401
+ const modules = await Promise.all(tasks);
1402
+ encodeAsAny = modules[0].encodeAsAny;
1403
+ AuthInfo = modules[1].AuthInfo;
1404
+ Tx = modules[1].Tx;
1405
+ TxBody = modules[1].TxBody;
1406
+ TxRaw = modules[1].TxRaw;
1407
+ SignDoc = modules[1].SignDoc;
1408
+ SignMode = modules[2].SignMode;
1409
+ }
1410
+ toDydxLong(numStr) {
1411
+ return index$3["default"].fromString(numStr);
1412
+ }
1413
+ retrieveDydxCredentials(entropy) {
1414
+ let credentials = undefined;
1415
+ if (entropy.indexOf(' ') > 0) {
1416
+ credentials = onboarding.deriveHDKeyFromMnemonic(entropy);
1417
+ credentials['mnemonic'] = entropy;
1418
+ return credentials;
1419
+ }
1420
+ credentials = onboarding.exportMnemonicAndPrivateKey(this.base16ToBinary(entropy));
1421
+ return credentials;
1422
+ }
1423
+ encodeDydxTxForSimulation(message, memo, sequence, publicKey) {
1424
+ if (!encodeAsAny) {
1425
+ throw new errors.NotSupported(this.id + ' requires protobuf to encode messages, please install it with `npm install protobufjs`');
1426
+ }
1427
+ if (!publicKey) {
1428
+ throw new Error('Public key cannot be undefined');
1429
+ }
1430
+ const messages = [message];
1431
+ const encodedMessages = messages.map((msg) => encodeAsAny(msg));
1432
+ const tx = Tx.fromPartial({
1433
+ 'body': TxBody.fromPartial({
1434
+ 'messages': encodedMessages,
1435
+ 'memo': memo,
1436
+ }),
1437
+ 'authInfo': AuthInfo.fromPartial({
1438
+ 'fee': {},
1439
+ 'signerInfos': [
1440
+ {
1441
+ 'publicKey': encodeAsAny({
1442
+ 'typeUrl': '/cosmos.crypto.secp256k1.PubKey',
1443
+ 'value': publicKey,
1444
+ }),
1445
+ 'sequence': sequence,
1446
+ 'modeInfo': { 'single': { 'mode': SignMode.SIGN_MODE_UNSPECIFIED } },
1447
+ },
1448
+ ],
1449
+ }),
1450
+ 'signatures': [new Uint8Array()],
1451
+ });
1452
+ return this.binaryToBase64(Tx.encode(tx).finish());
1453
+ }
1454
+ encodeDydxTxForSigning(message, memo, chainId, account, authenticators, fee = undefined) {
1455
+ if (!encodeAsAny) {
1456
+ throw new errors.NotSupported(this.id + ' requires protobuf to encode messages, please install it with `npm install protobufjs`');
1457
+ }
1458
+ if (!account.pub_key) {
1459
+ throw new Error('Public key cannot be undefined');
1460
+ }
1461
+ const messages = [message];
1462
+ const sequence = this.milliseconds();
1463
+ if (fee === undefined) {
1464
+ fee = {
1465
+ 'amount': [],
1466
+ 'gasLimit': 1000000,
1467
+ };
1468
+ }
1469
+ const encodedMessages = messages.map((msg) => encodeAsAny(msg));
1470
+ const nonCriticalExtensionOptions = [
1471
+ encodeAsAny({
1472
+ 'typeUrl': '/dydxprotocol.accountplus.TxExtension',
1473
+ 'value': {
1474
+ 'selectedAuthenticators': authenticators ?? [],
1475
+ },
1476
+ }),
1477
+ ];
1478
+ const txBodyBytes = TxBody.encode(TxBody.fromPartial({
1479
+ 'messages': encodedMessages,
1480
+ 'memo': memo,
1481
+ 'extensionOptions': [],
1482
+ 'nonCriticalExtensionOptions': nonCriticalExtensionOptions,
1483
+ })).finish();
1484
+ const authInfoBytes = AuthInfo.encode(AuthInfo.fromPartial({
1485
+ 'fee': fee,
1486
+ 'signerInfos': [
1487
+ {
1488
+ 'publicKey': encodeAsAny({
1489
+ 'typeUrl': '/cosmos.crypto.secp256k1.PubKey',
1490
+ 'value': account.pub_key,
1491
+ }),
1492
+ 'sequence': sequence,
1493
+ 'modeInfo': { 'single': { 'mode': SignMode.SIGN_MODE_DIRECT } },
1494
+ },
1495
+ ],
1496
+ })).finish();
1497
+ const signDoc = SignDoc.fromPartial({
1498
+ 'accountNumber': account.account_number,
1499
+ 'authInfoBytes': authInfoBytes,
1500
+ 'bodyBytes': txBodyBytes,
1501
+ 'chainId': chainId,
1502
+ });
1503
+ const signingHash = this.hash(SignDoc.encode(signDoc).finish(), sha256.sha256, 'hex');
1504
+ return [signingHash, signDoc];
1505
+ }
1506
+ encodeDydxTxRaw(signDoc, signature) {
1507
+ if (!encodeAsAny) {
1508
+ throw new errors.NotSupported(this.id + ' requires protobuf to encode messages, please install it with `npm install protobufjs`');
1509
+ }
1510
+ return '0x' + this.binaryToBase16(TxRaw.encode(TxRaw.fromPartial({
1511
+ 'bodyBytes': signDoc.bodyBytes,
1512
+ 'authInfoBytes': signDoc.authInfoBytes,
1513
+ 'signatures': [this.base16ToBinary(signature)],
1514
+ })).finish());
1515
+ }
1360
1516
  intToBase16(elem) {
1361
1517
  return elem.toString(16);
1362
1518
  }
@@ -3138,6 +3294,7 @@ class Exchange {
3138
3294
  this.symbols = sourceExchange.symbols;
3139
3295
  this.ids = sourceExchange.ids;
3140
3296
  this.currencies = sourceExchange.currencies;
3297
+ this.currencies_by_id = sourceExchange.currencies_by_id;
3141
3298
  this.baseCurrencies = sourceExchange.baseCurrencies;
3142
3299
  this.quoteCurrencies = sourceExchange.quoteCurrencies;
3143
3300
  this.codes = sourceExchange.codes;
@@ -4864,10 +5021,6 @@ class Exchange {
4864
5021
  });
4865
5022
  }
4866
5023
  safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
4867
- const result = this.safeMarketStructure({
4868
- 'symbol': marketId,
4869
- 'marketId': marketId,
4870
- });
4871
5024
  if (marketId !== undefined) {
4872
5025
  if ((this.markets_by_id !== undefined) && (marketId in this.markets_by_id)) {
4873
5026
  const markets = this.markets_by_id[marketId];
@@ -4895,23 +5048,24 @@ class Exchange {
4895
5048
  else if (delimiter !== undefined && delimiter !== '') {
4896
5049
  const parts = marketId.split(delimiter);
4897
5050
  const partsLength = parts.length;
5051
+ const result = this.safeMarketStructure({
5052
+ 'symbol': marketId,
5053
+ 'marketId': marketId,
5054
+ });
4898
5055
  if (partsLength === 2) {
4899
5056
  result['baseId'] = this.safeString(parts, 0);
4900
5057
  result['quoteId'] = this.safeString(parts, 1);
4901
5058
  result['base'] = this.safeCurrencyCode(result['baseId']);
4902
5059
  result['quote'] = this.safeCurrencyCode(result['quoteId']);
4903
5060
  result['symbol'] = result['base'] + '/' + result['quote'];
4904
- return result;
4905
- }
4906
- else {
4907
- return result;
4908
5061
  }
5062
+ return result;
4909
5063
  }
4910
5064
  }
4911
5065
  if (market !== undefined) {
4912
5066
  return market;
4913
5067
  }
4914
- return result;
5068
+ return this.safeMarketStructure({ 'symbol': marketId, 'marketId': marketId });
4915
5069
  }
4916
5070
  marketOrNull(symbol) {
4917
5071
  if (symbol === undefined) {
@@ -157,7 +157,9 @@ class Client {
157
157
  if (this.ping) {
158
158
  message = this.ping(this);
159
159
  }
160
- this.log(new Date(), 'OnPingInterval', this.url);
160
+ if (this.verbose) {
161
+ this.log(new Date(), 'onPingInterval', '|', this.url);
162
+ }
161
163
  if (message) {
162
164
  this.send(message).catch((error) => {
163
165
  this.onError(error);
@@ -902,6 +902,9 @@ class binance extends binance$1["default"] {
902
902
  'symbolConfig': 5,
903
903
  'accountConfig': 5,
904
904
  'convert/orderStatus': 5,
905
+ 'algoOrder': 1,
906
+ 'openAlgoOrders': 1,
907
+ 'allAlgoOrders': 5,
905
908
  },
906
909
  'post': {
907
910
  'batchOrders': 5,
@@ -909,6 +912,7 @@ class binance extends binance$1["default"] {
909
912
  'positionMargin': 1,
910
913
  'marginType': 1,
911
914
  'order': 4,
915
+ 'order/test': 1,
912
916
  'leverage': 1,
913
917
  'listenKey': 1,
914
918
  'countdownCancelAll': 10,
@@ -919,6 +923,7 @@ class binance extends binance$1["default"] {
919
923
  'feeBurn': 1,
920
924
  'convert/getQuote': 200,
921
925
  'convert/acceptQuote': 20,
926
+ 'algoOrder': 1,
922
927
  },
923
928
  'put': {
924
929
  'listenKey': 1,
@@ -930,6 +935,8 @@ class binance extends binance$1["default"] {
930
935
  'order': 1,
931
936
  'allOpenOrders': 1,
932
937
  'listenKey': 1,
938
+ 'algoOrder': 1,
939
+ 'algoOpenOrders': 1,
933
940
  },
934
941
  },
935
942
  'fapiPublicV2': {
@@ -4060,7 +4067,7 @@ class binance extends binance$1["default"] {
4060
4067
  //
4061
4068
  // {
4062
4069
  // "symbol": "BTCUSDT",
4063
- // "markPrice": "11793.63104561", // mark price
4070
+ // "markPrice": "11793.63104562", // mark price
4064
4071
  // "indexPrice": "11781.80495970", // index price
4065
4072
  // "estimatedSettlePrice": "11781.16138815", // Estimated Settle Price, only useful in the last hour before the settlement starts
4066
4073
  // "lastFundingRate": "0.00038246", // This is the lastest estimated funding rate
@@ -32,6 +32,9 @@ class bingx extends bingx$1["default"] {
32
32
  'future': false,
33
33
  'option': false,
34
34
  'addMargin': true,
35
+ 'borrowCrossMargin': false,
36
+ 'borrowIsolatedMargin': false,
37
+ 'borrowMargin': false,
35
38
  'cancelAllOrders': true,
36
39
  'cancelAllOrdersAfter': true,
37
40
  'cancelOrder': true,
@@ -52,9 +55,18 @@ class bingx extends bingx$1["default"] {
52
55
  'createTrailingPercentOrder': true,
53
56
  'createTriggerOrder': true,
54
57
  'editOrder': true,
58
+ 'fetchAllGreeks': false,
55
59
  'fetchBalance': true,
60
+ 'fetchBorrowInterest': false,
61
+ 'fetchBorrowRate': false,
62
+ 'fetchBorrowRateHistories': false,
63
+ 'fetchBorrowRateHistory': false,
64
+ 'fetchBorrowRates': false,
65
+ 'fetchBorrowRatesPerSymbol': false,
56
66
  'fetchCanceledOrders': true,
57
67
  'fetchClosedOrders': true,
68
+ 'fetchCrossBorrowRate': false,
69
+ 'fetchCrossBorrowRates': false,
58
70
  'fetchCurrencies': true,
59
71
  'fetchDepositAddress': true,
60
72
  'fetchDepositAddresses': false,
@@ -65,6 +77,9 @@ class bingx extends bingx$1["default"] {
65
77
  'fetchFundingRate': true,
66
78
  'fetchFundingRateHistory': true,
67
79
  'fetchFundingRates': true,
80
+ 'fetchGreeks': false,
81
+ 'fetchIsolatedBorrowRate': false,
82
+ 'fetchIsolatedBorrowRates': false,
68
83
  'fetchLeverage': true,
69
84
  'fetchLiquidations': false,
70
85
  'fetchMarginAdjustmentHistory': false,
@@ -78,6 +93,8 @@ class bingx extends bingx$1["default"] {
78
93
  'fetchOHLCV': true,
79
94
  'fetchOpenInterest': true,
80
95
  'fetchOpenOrders': true,
96
+ 'fetchOption': false,
97
+ 'fetchOptionChain': false,
81
98
  'fetchOrder': true,
82
99
  'fetchOrderBook': true,
83
100
  'fetchOrders': true,
@@ -92,8 +109,11 @@ class bingx extends bingx$1["default"] {
92
109
  'fetchTrades': true,
93
110
  'fetchTradingFee': true,
94
111
  'fetchTransfers': true,
112
+ 'fetchVolatilityHistory': false,
95
113
  'fetchWithdrawals': true,
96
114
  'reduceMargin': true,
115
+ 'repayCrossMargin': false,
116
+ 'repayIsolatedMargin': false,
97
117
  'sandbox': true,
98
118
  'setLeverage': true,
99
119
  'setMargin': true,
@@ -407,6 +407,7 @@ class bitget extends bitget$1["default"] {
407
407
  'v2/spot/trade/place-plan-order': 1,
408
408
  'v2/spot/trade/modify-plan-order': 1,
409
409
  'v2/spot/trade/cancel-plan-order': 1,
410
+ 'v2/spot/trade/cancel-replace-order': 2,
410
411
  'v2/spot/trade/batch-cancel-plan-order': 2,
411
412
  'v2/spot/wallet/transfer': 2,
412
413
  'v2/spot/wallet/subaccount-transfer': 2,
@@ -1413,6 +1414,7 @@ class bitget extends bitget$1["default"] {
1413
1414
  'spot': {
1414
1415
  '1m': '1min',
1415
1416
  '5m': '5min',
1417
+ '3m': '3min',
1416
1418
  '15m': '15min',
1417
1419
  '30m': '30min',
1418
1420
  '1h': '1h',
@@ -1475,6 +1477,7 @@ class bitget extends bitget$1["default"] {
1475
1477
  '15m': 30,
1476
1478
  '30m': 30,
1477
1479
  '1h': 60,
1480
+ '2h': 120,
1478
1481
  '4h': 240,
1479
1482
  '6h': 360,
1480
1483
  '12h': 720,
@@ -4245,11 +4248,17 @@ class bitget extends bitget$1["default"] {
4245
4248
  request['startTime'] = since;
4246
4249
  if (!untilDefined) {
4247
4250
  calculatedEndTime = this.sum(calculatedStartTime, limitMultipliedDuration);
4251
+ if (calculatedEndTime > now) {
4252
+ calculatedEndTime = now;
4253
+ }
4248
4254
  request['endTime'] = calculatedEndTime;
4249
4255
  }
4250
4256
  }
4251
4257
  if (untilDefined) {
4252
4258
  calculatedEndTime = until;
4259
+ if (calculatedEndTime > now) {
4260
+ calculatedEndTime = now;
4261
+ }
4253
4262
  request['endTime'] = calculatedEndTime;
4254
4263
  if (!sinceDefined) {
4255
4264
  calculatedStartTime = calculatedEndTime - limitMultipliedDuration;
@@ -5651,6 +5660,7 @@ class bitget extends bitget$1["default"] {
5651
5660
  * @name bitget#editOrder
5652
5661
  * @description edit a trade order
5653
5662
  * @see https://www.bitget.com/api-doc/spot/plan/Modify-Plan-Order
5663
+ * @see https://www.bitget.com/api-doc/spot/trade/Cancel-Replace-Order
5654
5664
  * @see https://www.bitget.com/api-doc/contract/trade/Modify-Order
5655
5665
  * @see https://www.bitget.com/api-doc/contract/plan/Modify-Tpsl-Order
5656
5666
  * @see https://www.bitget.com/api-doc/contract/plan/Modify-Plan-Order
@@ -5684,8 +5694,16 @@ class bitget extends bitget$1["default"] {
5684
5694
  await this.loadMarkets();
5685
5695
  const market = this.market(symbol);
5686
5696
  const request = {
5687
- 'orderId': id,
5697
+ // 'orderId': id,
5688
5698
  };
5699
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'clientOid');
5700
+ if (clientOrderId !== undefined) {
5701
+ params = this.omit(params, ['clientOrderId']);
5702
+ request['clientOid'] = clientOrderId;
5703
+ }
5704
+ else {
5705
+ request['orderId'] = id;
5706
+ }
5689
5707
  const isMarketOrder = type === 'market';
5690
5708
  const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
5691
5709
  const isTriggerOrder = triggerPrice !== undefined;
@@ -5703,10 +5721,6 @@ class bitget extends bitget$1["default"] {
5703
5721
  if (this.sum(isTriggerOrder, isStopLossOrder, isTakeProfitOrder, isTrailingPercentOrder) > 1) {
5704
5722
  throw new errors.ExchangeError(this.id + ' editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent');
5705
5723
  }
5706
- const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
5707
- if (clientOrderId !== undefined) {
5708
- request['clientOid'] = clientOrderId;
5709
- }
5710
5724
  params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId', 'trailingTriggerPrice', 'trailingPercent']);
5711
5725
  let response = undefined;
5712
5726
  let productType = undefined;
@@ -5753,28 +5767,38 @@ class bitget extends bitget$1["default"] {
5753
5767
  }
5754
5768
  }
5755
5769
  else if (market['spot']) {
5756
- if (triggerPrice === undefined) {
5757
- throw new errors.NotSupported(this.id + ' editOrder() only supports plan/trigger spot orders');
5758
- }
5770
+ const cost = this.safeString(params, 'cost');
5771
+ params = this.omit(params, 'cost');
5759
5772
  const editMarketBuyOrderRequiresPrice = this.safeBool(this.options, 'editMarketBuyOrderRequiresPrice', true);
5760
- if (editMarketBuyOrderRequiresPrice && isMarketOrder && (side === 'buy')) {
5761
- if (price === undefined) {
5762
- throw new errors.InvalidOrder(this.id + ' editOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the editMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
5773
+ if ((editMarketBuyOrderRequiresPrice || (cost !== undefined)) && isMarketOrder && (side === 'buy')) {
5774
+ if (price === undefined && cost === undefined) {
5775
+ throw new errors.InvalidOrder(this.id + ' editOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively provide `cost` in the params');
5763
5776
  }
5764
5777
  else {
5765
5778
  const amountString = this.numberToString(amount);
5766
5779
  const priceString = this.numberToString(price);
5767
- const cost = this.parseNumber(Precise["default"].stringMul(amountString, priceString));
5768
- request['size'] = this.priceToPrecision(symbol, cost);
5780
+ const finalCost = (cost === undefined) ? (Precise["default"].stringMul(amountString, priceString)) : cost;
5781
+ request['size'] = this.priceToPrecision(symbol, finalCost);
5769
5782
  }
5770
5783
  }
5771
5784
  else {
5772
5785
  request['size'] = this.amountToPrecision(symbol, amount);
5773
5786
  }
5774
5787
  request['orderType'] = type;
5775
- request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
5776
- request['executePrice'] = this.priceToPrecision(symbol, price);
5777
- response = await this.privateSpotPostV2SpotTradeModifyPlanOrder(this.extend(request, params));
5788
+ if (triggerPrice !== undefined) {
5789
+ request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
5790
+ request['executePrice'] = this.priceToPrecision(symbol, price);
5791
+ }
5792
+ else {
5793
+ request['price'] = this.priceToPrecision(symbol, price);
5794
+ }
5795
+ if (triggerPrice !== undefined) {
5796
+ response = await this.privateSpotPostV2SpotTradeModifyPlanOrder(this.extend(request, params));
5797
+ }
5798
+ else {
5799
+ request['symbol'] = market['id'];
5800
+ response = await this.privateSpotPostV2SpotTradeCancelReplaceOrder(this.extend(request, params));
5801
+ }
5778
5802
  }
5779
5803
  else {
5780
5804
  if ((!market['swap']) && (!market['future'])) {
@@ -6177,9 +6201,8 @@ class bitget extends bitget$1["default"] {
6177
6201
  * @see https://www.bitget.com/api-doc/spot/trade/Cancel-Symbol-Orders
6178
6202
  * @see https://www.bitget.com/api-doc/spot/plan/Batch-Cancel-Plan-Order
6179
6203
  * @see https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
6180
- * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-cancel-orders
6181
- * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-cancel-order
6182
- * @see https://www.bitget.com/api-doc/uta/trade/Cancel-All-Order
6204
+ * @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Cancel-Order
6205
+ * @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Cancel-Orders
6183
6206
  * @param {string} symbol unified market symbol
6184
6207
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6185
6208
  * @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
@@ -6231,28 +6254,7 @@ class bitget extends bitget$1["default"] {
6231
6254
  }
6232
6255
  else if (market['spot']) {
6233
6256
  if (marginMode !== undefined) {
6234
- if (marginMode === 'cross') {
6235
- response = await this.privateMarginPostMarginV1CrossOrderBatchCancelOrder(this.extend(request, params));
6236
- }
6237
- else {
6238
- response = await this.privateMarginPostMarginV1IsolatedOrderBatchCancelOrder(this.extend(request, params));
6239
- }
6240
- //
6241
- // {
6242
- // "code": "00000",
6243
- // "msg": "success",
6244
- // "requestTime": 1700717155622,
6245
- // "data": {
6246
- // "resultList": [
6247
- // {
6248
- // "orderId": "1111453253721796609",
6249
- // "clientOid": "2ae7fc8a4ff949b6b60d770ca3950e2d"
6250
- // },
6251
- // ],
6252
- // "failure": []
6253
- // }
6254
- // }
6255
- //
6257
+ throw new errors.NotSupported(this.id + ' cancelAllOrders() does not support margin markets, you can use cancelOrders() instead');
6256
6258
  }
6257
6259
  else {
6258
6260
  if (trigger) {