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
@@ -757,11 +757,10 @@ export default class ascendex extends Exchange {
757
757
  ];
758
758
  }
759
759
  parseBalance(response) {
760
- const timestamp = this.milliseconds();
761
760
  const result = {
762
761
  'info': response,
763
- 'timestamp': timestamp,
764
- 'datetime': this.iso8601(timestamp),
762
+ 'timestamp': undefined,
763
+ 'datetime': undefined,
765
764
  };
766
765
  const balances = this.safeValue(response, 'data', []);
767
766
  for (let i = 0; i < balances.length; i++) {
@@ -775,11 +774,10 @@ export default class ascendex extends Exchange {
775
774
  return this.safeBalance(result);
776
775
  }
777
776
  parseMarginBalance(response) {
778
- const timestamp = this.milliseconds();
779
777
  const result = {
780
778
  'info': response,
781
- 'timestamp': timestamp,
782
- 'datetime': this.iso8601(timestamp),
779
+ 'timestamp': undefined,
780
+ 'datetime': undefined,
783
781
  };
784
782
  const balances = this.safeValue(response, 'data', []);
785
783
  for (let i = 0; i < balances.length; i++) {
@@ -796,11 +794,10 @@ export default class ascendex extends Exchange {
796
794
  return this.safeBalance(result);
797
795
  }
798
796
  parseSwapBalance(response) {
799
- const timestamp = this.milliseconds();
800
797
  const result = {
801
798
  'info': response,
802
- 'timestamp': timestamp,
803
- 'datetime': this.iso8601(timestamp),
799
+ 'timestamp': undefined,
800
+ 'datetime': undefined,
804
801
  };
805
802
  const data = this.safeValue(response, 'data', {});
806
803
  const collaterals = this.safeValue(data, 'collaterals', []);
@@ -822,6 +819,8 @@ export default class ascendex extends Exchange {
822
819
  * @see https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
823
820
  * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
824
821
  * @param {object} [params] extra parameters specific to the exchange API endpoint
822
+ * @param {string} [params.type] wallet type, 'spot', 'margin', or 'swap'
823
+ * @param {string} [params.marginMode] 'cross' or undefined, for spot margin trading, value of 'isolated' is invalid
825
824
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
826
825
  */
827
826
  await this.loadMarkets();
@@ -3184,12 +3183,11 @@ export default class ascendex extends Exchange {
3184
3183
  //
3185
3184
  const status = this.safeInteger(transfer, 'code');
3186
3185
  const currencyCode = this.safeCurrencyCode(undefined, currency);
3187
- const timestamp = this.milliseconds();
3188
3186
  return {
3189
3187
  'info': transfer,
3190
3188
  'id': undefined,
3191
- 'timestamp': timestamp,
3192
- 'datetime': this.iso8601(timestamp),
3189
+ 'timestamp': undefined,
3190
+ 'datetime': undefined,
3193
3191
  'currency': currencyCode,
3194
3192
  'amount': undefined,
3195
3193
  'fromAccount': undefined,
@@ -275,6 +275,7 @@ export default class Exchange {
275
275
  ymd: (timestamp: any, infix: any, fullYear?: boolean) => string;
276
276
  base64ToString: (string: any) => string;
277
277
  crc32: typeof functions.crc32;
278
+ packb: typeof functions.packb;
278
279
  describe(): {
279
280
  id: any;
280
281
  name: any;
@@ -617,6 +618,9 @@ export default class Exchange {
617
618
  setProperty(obj: any, property: any, defaultValue?: any): void;
618
619
  axolotl(payload: any, hexKey: any, ed25519: any): string;
619
620
  fixStringifiedJsonMembers(content: string): any;
621
+ ethAbiEncode(types: any, args: any): Uint8Array;
622
+ ethEncodeStructuredData(domain: any, messageTypes: any, messageData: any): Uint8Array;
623
+ intToBase16(elem: any): string;
620
624
  safeBoolN(dictionaryOrList: any, keys: IndexType[], defaultValue?: boolean): boolean | undefined;
621
625
  safeBool2(dictionary: any, key1: IndexType, key2: IndexType, defaultValue?: boolean): boolean | undefined;
622
626
  safeBool(dictionary: any, key: IndexType, defaultValue?: boolean): boolean | undefined;
@@ -7,7 +7,7 @@
7
7
  // ----------------------------------------------------------------------------
8
8
  /* eslint-disable */
9
9
  import * as functions from './functions.js';
10
- const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, parseDate, ymd, base64ToString, crc32, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS } = functions;
10
+ const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS } = functions;
11
11
  import { keys as keysFunc, values as valuesFunc, vwap as vwapFunc } from './functions.js';
12
12
  // import exceptions from "./errors.js"
13
13
  import { // eslint-disable-line object-curly-newline
@@ -21,6 +21,8 @@ import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './
21
21
  //
22
22
  import { axolotl } from './functions/crypto.js';
23
23
  import totp from './functions/totp.js';
24
+ import ethers from '../static_dependencies/ethers/index.js';
25
+ import { TypedDataEncoder } from '../static_dependencies/ethers/hash/index.js';
24
26
  // ----------------------------------------------------------------------------
25
27
  /**
26
28
  * @class Exchange
@@ -207,6 +209,7 @@ export default class Exchange {
207
209
  this.ymd = ymd;
208
210
  this.base64ToString = base64ToString;
209
211
  this.crc32 = crc32;
212
+ this.packb = packb;
210
213
  this.httpProxyAgentModule = undefined;
211
214
  this.httpsProxyAgentModule = undefined;
212
215
  this.socksProxyAgentModule = undefined;
@@ -1410,6 +1413,15 @@ export default class Exchange {
1410
1413
  modifiedContent = modifiedContent.replaceAll('}"', '}');
1411
1414
  return modifiedContent;
1412
1415
  }
1416
+ ethAbiEncode(types, args) {
1417
+ return this.base16ToBinary(ethers.encode(types, args).slice(2));
1418
+ }
1419
+ ethEncodeStructuredData(domain, messageTypes, messageData) {
1420
+ return this.base16ToBinary(TypedDataEncoder.encode(domain, messageTypes, messageData).slice(-132));
1421
+ }
1422
+ intToBase16(elem) {
1423
+ return elem.toString(16);
1424
+ }
1413
1425
  /* eslint-enable */
1414
1426
  // ------------------------------------------------------------------------
1415
1427
  // ########################################################################
@@ -1,3 +1,4 @@
1
1
  import { concatBytes } from '../../static_dependencies/noble-curves/abstract/utils.js';
2
2
  declare const json: (data: any, params?: any) => string, isJsonEncodedObject: (object: any) => boolean, binaryToString: (data: Uint8Array) => string, stringToBinary: (str: string) => Uint8Array, stringToBase64: (string: any) => string, base64ToString: (string: any) => string, base64ToBinary: (str: string) => Uint8Array, binaryToBase64: (data: Uint8Array) => string, base16ToBinary: (str: string) => Uint8Array, binaryToBase16: (data: Uint8Array) => string, base58ToBinary: (str: string) => Uint8Array, binaryToBase58: (data: Uint8Array) => string, binaryConcat: typeof concatBytes, binaryConcatArray: (arr: any) => Uint8Array, urlencode: (object: any) => string, urlencodeNested: (object: any) => string, urlencodeWithArrayRepeat: (object: any) => string, rawencode: (object: any) => string, encode: (str: string) => Uint8Array, decode: (data: Uint8Array) => string, urlencodeBase64: (base64string: any) => any, numberToLE: (n: number, padding: number) => Uint8Array, numberToBE: (n: number, padding: number) => Uint8Array;
3
- export { json, isJsonEncodedObject, binaryToString, stringToBinary, stringToBase64, base64ToBinary, base64ToString, binaryToBase64, base16ToBinary, binaryToBase16, binaryConcat, binaryConcatArray, urlencode, urlencodeWithArrayRepeat, rawencode, encode, decode, urlencodeBase64, numberToLE, numberToBE, base58ToBinary, binaryToBase58, urlencodeNested };
3
+ declare function packb(req: any): Uint8Array;
4
+ export { json, isJsonEncodedObject, binaryToString, stringToBinary, stringToBase64, base64ToBinary, base64ToString, binaryToBase64, base16ToBinary, binaryToBase16, binaryConcat, binaryConcatArray, urlencode, urlencodeWithArrayRepeat, rawencode, encode, decode, urlencodeBase64, numberToLE, numberToBE, base58ToBinary, binaryToBase58, urlencodeNested, packb };
@@ -8,6 +8,7 @@
8
8
  /* ------------------------------------------------------------------------ */
9
9
  import { base16, base58, base64, utf8 } from "../../static_dependencies/scure-base/index.js";
10
10
  import { numberToBytesBE, numberToBytesLE, concatBytes } from '../../static_dependencies/noble-curves/abstract/utils.js';
11
+ import { serialize } from '../../static_dependencies/messagepack/msgpack.js';
11
12
  import qs from '../../static_dependencies/qs/index.cjs';
12
13
  /* ------------------------------------------------------------------------ */
13
14
  const json = (data, params = undefined) => JSON.stringify(data), isJsonEncodedObject = object => ((typeof object === 'string') &&
@@ -19,7 +20,10 @@ const json = (data, params = undefined) => JSON.stringify(data), isJsonEncodedOb
19
20
  , urlencodeBase64 = base64string => base64string.replace(/[=]+$/, '')
20
21
  .replace(/\+/g, '-')
21
22
  .replace(/\//g, '_'), numberToLE = (n, padding) => numberToBytesLE(BigInt(n), padding), numberToBE = (n, padding) => numberToBytesBE(BigInt(n), padding);
23
+ function packb(req) {
24
+ return serialize(req);
25
+ }
22
26
  export { json, isJsonEncodedObject, binaryToString, stringToBinary, stringToBase64, base64ToBinary, base64ToString, binaryToBase64, base16ToBinary, binaryToBase16, binaryConcat, binaryConcatArray, urlencode, urlencodeWithArrayRepeat, rawencode, encode, decode
23
27
  // Url-safe-base64 without equals signs, with + replaced by - and slashes replaced by underscores
24
- , urlencodeBase64, numberToLE, numberToBE, base58ToBinary, binaryToBase58, urlencodeNested };
28
+ , urlencodeBase64, numberToLE, numberToBE, base58ToBinary, binaryToBase58, urlencodeNested, packb };
25
29
  /* ------------------------------------------------------------------------ */
package/js/src/bingx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bingx.js';
2
- import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Dict, Leverage } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Dict, Leverage, MarginMode } from './base/types.js';
3
3
  /**
4
4
  * @class bingx
5
5
  * @augments Exchange
@@ -139,6 +139,8 @@ export default class bingx extends Exchange {
139
139
  }>;
140
140
  setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<any>;
141
141
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: number, price?: number, params?: {}): Promise<Order>;
142
+ fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
143
+ parseMarginMode(marginMode: any, market?: any): MarginMode;
142
144
  sign(path: any, section?: string, method?: string, params?: {}, headers?: any, body?: any): {
143
145
  url: any;
144
146
  method: string;
package/js/src/bingx.js CHANGED
@@ -62,6 +62,7 @@ export default class bingx extends Exchange {
62
62
  'fetchFundingRates': true,
63
63
  'fetchLeverage': true,
64
64
  'fetchLiquidations': false,
65
+ 'fetchMarginMode': true,
65
66
  'fetchMarkets': true,
66
67
  'fetchMarkOHLCV': true,
67
68
  'fetchMyLiquidations': true,
@@ -4169,6 +4170,43 @@ export default class bingx extends Exchange {
4169
4170
  const data = this.safeDict(response, 'data');
4170
4171
  return this.parseOrder(data, market);
4171
4172
  }
4173
+ async fetchMarginMode(symbol, params = {}) {
4174
+ /**
4175
+ * @method
4176
+ * @name bingx#fetchMarginMode
4177
+ * @description fetches the margin mode of the trading pair
4178
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Mode
4179
+ * @param {string} symbol unified symbol of the market to fetch the margin mode for
4180
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4181
+ * @returns {object} Struct of MarginMode
4182
+ */
4183
+ await this.loadMarkets();
4184
+ const market = this.market(symbol);
4185
+ const request = {
4186
+ 'symbol': market['id'],
4187
+ };
4188
+ const response = await this.swapV2PrivateGetTradeMarginType(this.extend(request, params));
4189
+ //
4190
+ // {
4191
+ // "code": 0,
4192
+ // "msg": "",
4193
+ // "data": {
4194
+ // "marginType": "CROSSED"
4195
+ // }
4196
+ // }
4197
+ //
4198
+ const data = this.safeDict(response, 'data', {});
4199
+ return this.parseMarginMode(data, market);
4200
+ }
4201
+ parseMarginMode(marginMode, market = undefined) {
4202
+ let marginType = this.safeStringLower(marginMode, 'marginType');
4203
+ marginType = (marginType === 'crossed') ? 'cross' : marginType;
4204
+ return {
4205
+ 'info': marginMode,
4206
+ 'symbol': market['symbol'],
4207
+ 'marginMode': marginType,
4208
+ };
4209
+ }
4172
4210
  sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
4173
4211
  const type = section[0];
4174
4212
  const version = section[1];
@@ -30,8 +30,8 @@ export default class bitfinex2 extends Exchange {
30
30
  'spot': true,
31
31
  'margin': true,
32
32
  'swap': true,
33
- 'future': undefined,
34
- 'option': undefined,
33
+ 'future': false,
34
+ 'option': false,
35
35
  'addMargin': false,
36
36
  'borrowCrossMargin': false,
37
37
  'borrowIsolatedMargin': false,
@@ -42,6 +42,7 @@ export default class bitfinex2 extends Exchange {
42
42
  'createLimitOrder': true,
43
43
  'createMarketOrder': true,
44
44
  'createOrder': true,
45
+ 'createPostOnlyOrder': true,
45
46
  'createReduceOnlyOrder': true,
46
47
  'createStopLimitOrder': true,
47
48
  'createStopMarketOrder': true,
@@ -52,8 +53,11 @@ export default class bitfinex2 extends Exchange {
52
53
  'editOrder': true,
53
54
  'fetchBalance': true,
54
55
  'fetchBorrowInterest': false,
56
+ 'fetchBorrowRate': false,
55
57
  'fetchBorrowRateHistories': false,
56
58
  'fetchBorrowRateHistory': false,
59
+ 'fetchBorrowRates': false,
60
+ 'fetchBorrowRatesPerSymbol': false,
57
61
  'fetchClosedOrder': true,
58
62
  'fetchClosedOrders': true,
59
63
  'fetchCrossBorrowRate': false,
@@ -82,6 +86,8 @@ export default class bitfinex2 extends Exchange {
82
86
  'fetchOpenOrder': true,
83
87
  'fetchOpenOrders': true,
84
88
  'fetchOrder': true,
89
+ 'fetchOrderBook': true,
90
+ 'fetchOrderBooks': false,
85
91
  'fetchOrderTrades': true,
86
92
  'fetchPosition': false,
87
93
  'fetchPositionMode': false,
@@ -101,6 +107,8 @@ export default class bitfinex2 extends Exchange {
101
107
  'setMargin': true,
102
108
  'setMarginMode': false,
103
109
  'setPositionMode': false,
110
+ 'signIn': false,
111
+ 'transfer': true,
104
112
  'withdraw': true,
105
113
  },
106
114
  'timeframes': {
@@ -1533,7 +1541,16 @@ export default class bitfinex2 extends Exchange {
1533
1541
  * @param {float} amount how much you want to trade in units of the base currency
1534
1542
  * @param {float} [price] the price of the order, in units of the quote currency, ignored in market orders
1535
1543
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1536
- * @returns {object} request to be sent to the exchange
1544
+ * @param {float} [params.stopPrice] The price at which a trigger order is triggered at
1545
+ * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
1546
+ * @param {bool} [params.postOnly]
1547
+ * @param {bool} [params.reduceOnly] Ensures that the executed order does not flip the opened position.
1548
+ * @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
1549
+ * @param {int} [params.lev] leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
1550
+ * @param {string} [params.price_traling] The trailing price for a trailing stop order
1551
+ * @param {string} [params.price_aux_limit] Order price for stop limit orders
1552
+ * @param {string} [params.price_oco_stop] OCO stop price
1553
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1537
1554
  */
1538
1555
  const market = this.market(symbol);
1539
1556
  let amountString = this.amountToPrecision(symbol, amount);
package/js/src/bitget.js CHANGED
@@ -2931,8 +2931,15 @@ export default class bitget extends Exchange {
2931
2931
  const currencyCode = this.safeCurrencyCode(this.safeString(feeStructure, 'feeCoin'));
2932
2932
  fee = {
2933
2933
  'currency': currencyCode,
2934
- 'cost': Precise.stringAbs(this.safeString(feeStructure, 'totalFee')),
2935
2934
  };
2935
+ const feeCostString = this.safeString(feeStructure, 'totalFee');
2936
+ const deduction = this.safeString(feeStructure, 'deduction') === 'yes' ? true : false;
2937
+ if (deduction) {
2938
+ fee['cost'] = feeCostString;
2939
+ }
2940
+ else {
2941
+ fee['cost'] = Precise.stringNeg(feeCostString);
2942
+ }
2936
2943
  }
2937
2944
  return this.safeTrade({
2938
2945
  'info': trade,
@@ -4031,7 +4038,7 @@ export default class bitget extends Exchange {
4031
4038
  * @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
4032
4039
  * @param {string} symbol unified symbol of the market to create an order in
4033
4040
  * @param {string} type 'market' or 'limit'
4034
- * @param {string} side 'buy' or 'sell' or 'open_long' or 'open_short' or 'close_long' or 'close_short'
4041
+ * @param {string} side 'buy' or 'sell'
4035
4042
  * @param {float} amount how much you want to trade in units of the base currency
4036
4043
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
4037
4044
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -76,13 +76,20 @@ export default class bitmart extends Exchange {
76
76
  fetchCanceledOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
77
77
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
78
78
  fetchDepositAddress(code: string, params?: {}): Promise<{
79
+ info: any;
79
80
  currency: string;
80
81
  address: string;
81
82
  tag: string;
82
83
  network: any;
83
- info: any;
84
84
  }>;
85
- safeNetwork(networkId: any): any;
85
+ parseDepositAddress(depositAddress: any, currency?: any): {
86
+ info: any;
87
+ currency: string;
88
+ address: string;
89
+ tag: string;
90
+ network: any;
91
+ };
92
+ safeNetworkCode(networkId: any, currency?: any): string;
86
93
  withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<any>;
87
94
  fetchTransactionsByType(type: any, code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
88
95
  fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
package/js/src/bitmart.js CHANGED
@@ -515,6 +515,7 @@ export default class bitmart extends Exchange {
515
515
  },
516
516
  'networks': {
517
517
  'ERC20': 'ERC20',
518
+ 'SOL': 'SOL',
518
519
  'BTC': 'BTC',
519
520
  'TRC20': 'TRC20',
520
521
  // todo: should be TRX after unification
@@ -537,7 +538,6 @@ export default class bitmart extends Exchange {
537
538
  'FIO': 'FIO',
538
539
  'SCRT': 'SCRT',
539
540
  'IOTX': 'IOTX',
540
- 'SOL': 'SOL',
541
541
  'ALGO': 'ALGO',
542
542
  'ATOM': 'ATOM',
543
543
  'DOT': 'DOT',
@@ -3090,6 +3090,7 @@ export default class bitmart extends Exchange {
3090
3090
  * @method
3091
3091
  * @name bitmart#fetchDepositAddress
3092
3092
  * @description fetch the deposit address for a currency associated with this account
3093
+ * @see https://developer-pro.bitmart.com/en/spot/#deposit-address-keyed
3093
3094
  * @param {string} code unified currency code
3094
3095
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3095
3096
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -3112,40 +3113,57 @@ export default class bitmart extends Exchange {
3112
3113
  }
3113
3114
  const response = await this.privateGetAccountV1DepositAddress(this.extend(request, params));
3114
3115
  //
3115
- // {
3116
- // "message":"OK",
3117
- // "code":1000,
3118
- // "trace":"0e6edd79-f77f-4251-abe5-83ba75d06c1a",
3119
- // "data":{
3120
- // "currency":"USDT-TRC20",
3121
- // "chain":"USDT-TRC20",
3122
- // "address":"TGR3ghy2b5VLbyAYrmiE15jasR6aPHTvC5",
3123
- // "address_memo":""
3124
- // }
3125
- // }
3116
+ // {
3117
+ // "message": "OK",
3118
+ // "code": 1000,
3119
+ // "trace": "0e6edd79-f77f-4251-abe5-83ba75d06c1a",
3120
+ // "data": {
3121
+ // currency: 'ETH',
3122
+ // chain: 'Ethereum',
3123
+ // address: '0x99B5EEc2C520f86F0F62F05820d28D05D36EccCf',
3124
+ // address_memo: ''
3125
+ // }
3126
+ // }
3126
3127
  //
3127
3128
  const data = this.safeValue(response, 'data', {});
3128
- const address = this.safeString(data, 'address');
3129
- const tag = this.safeString(data, 'address_memo');
3130
- const chain = this.safeString(data, 'chain');
3129
+ return this.parseDepositAddress(data, currency);
3130
+ }
3131
+ parseDepositAddress(depositAddress, currency = undefined) {
3132
+ //
3133
+ // {
3134
+ // currency: 'ETH',
3135
+ // chain: 'Ethereum',
3136
+ // address: '0x99B5EEc2C520f86F0F62F05820d28D05D36EccCf',
3137
+ // address_memo: ''
3138
+ // }
3139
+ //
3140
+ const currencyId = this.safeString(depositAddress, 'currency');
3141
+ const address = this.safeString(depositAddress, 'address');
3142
+ const chain = this.safeString(depositAddress, 'chain');
3131
3143
  let network = undefined;
3144
+ currency = this.safeCurrency(currencyId, currency);
3132
3145
  if (chain !== undefined) {
3133
3146
  const parts = chain.split('-');
3134
- const networkId = this.safeString(parts, 1);
3135
- network = this.safeNetwork(networkId);
3147
+ const partsLength = parts.length;
3148
+ const networkId = this.safeString(parts, partsLength - 1);
3149
+ network = this.safeNetworkCode(networkId, currency);
3136
3150
  }
3137
3151
  this.checkAddress(address);
3138
3152
  return {
3139
- 'currency': code,
3153
+ 'info': depositAddress,
3154
+ 'currency': this.safeString(currency, 'code'),
3140
3155
  'address': address,
3141
- 'tag': tag,
3156
+ 'tag': this.safeString(depositAddress, 'address_memo'),
3142
3157
  'network': network,
3143
- 'info': response,
3144
3158
  };
3145
3159
  }
3146
- safeNetwork(networkId) {
3147
- // TODO: parse
3148
- return networkId;
3160
+ safeNetworkCode(networkId, currency = undefined) {
3161
+ const name = this.safeString(currency, 'name');
3162
+ if (networkId === name) {
3163
+ const code = this.safeString(currency, 'code');
3164
+ return code;
3165
+ }
3166
+ return this.networkIdToCode(networkId);
3149
3167
  }
3150
3168
  async withdraw(code, amount, address, tag = undefined, params = {}) {
3151
3169
  /**
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/blofin.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages } from './base/types.js';
3
3
  /**
4
4
  * @class blofin
5
5
  * @augments Exchange
@@ -110,6 +110,7 @@ export default class blofin extends Exchange {
110
110
  fetchPosition(symbol: string, params?: {}): Promise<Position>;
111
111
  fetchPositions(symbols?: string[], params?: {}): Promise<Position[]>;
112
112
  parsePosition(position: any, market?: Market): Position;
113
+ fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
113
114
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
114
115
  parseLeverage(leverage: any, market?: any): Leverage;
115
116
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
package/js/src/blofin.js CHANGED
@@ -83,6 +83,7 @@ export default class blofin extends Exchange {
83
83
  'fetchLedger': true,
84
84
  'fetchLedgerEntry': undefined,
85
85
  'fetchLeverage': true,
86
+ 'fetchLeverages': true,
86
87
  'fetchLeverageTiers': false,
87
88
  'fetchMarketLeverageTiers': false,
88
89
  'fetchMarkets': true,
@@ -187,6 +188,7 @@ export default class blofin extends Exchange {
187
188
  'account/balance': 1,
188
189
  'account/positions': 1,
189
190
  'account/leverage-info': 1,
191
+ 'account/batch-leverage-info': 1,
190
192
  'trade/orders-tpsl-pending': 1,
191
193
  'trade/orders-history': 1,
192
194
  'trade/orders-tpsl-history': 1,
@@ -1884,12 +1886,68 @@ export default class blofin extends Exchange {
1884
1886
  'takeProfitPrice': undefined,
1885
1887
  });
1886
1888
  }
1889
+ async fetchLeverages(symbols = undefined, params = {}) {
1890
+ /**
1891
+ * @method
1892
+ * @name blofin#fetchLeverages
1893
+ * @description fetch the set leverage for all contract markets
1894
+ * @see https://docs.blofin.com/index.html#get-multiple-leverage
1895
+ * @param {string[]} symbols a list of unified market symbols, required on blofin
1896
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1897
+ * @param {string} [params.marginMode] 'cross' or 'isolated'
1898
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
1899
+ */
1900
+ await this.loadMarkets();
1901
+ if (symbols === undefined) {
1902
+ throw new ArgumentsRequired(this.id + ' fetchLeverages() requires a symbols argument');
1903
+ }
1904
+ let marginMode = undefined;
1905
+ [marginMode, params] = this.handleMarginModeAndParams('fetchLeverages', params);
1906
+ if (marginMode === undefined) {
1907
+ marginMode = this.safeString(params, 'marginMode', 'cross'); // cross as default marginMode
1908
+ }
1909
+ if ((marginMode !== 'cross') && (marginMode !== 'isolated')) {
1910
+ throw new BadRequest(this.id + ' fetchLeverages() requires a marginMode parameter that must be either cross or isolated');
1911
+ }
1912
+ symbols = this.marketSymbols(symbols);
1913
+ let instIds = '';
1914
+ for (let i = 0; i < symbols.length; i++) {
1915
+ const entry = symbols[i];
1916
+ const entryMarket = this.market(entry);
1917
+ if (i > 0) {
1918
+ instIds = instIds + ',' + entryMarket['id'];
1919
+ }
1920
+ else {
1921
+ instIds = instIds + entryMarket['id'];
1922
+ }
1923
+ }
1924
+ const request = {
1925
+ 'instId': instIds,
1926
+ 'marginMode': marginMode,
1927
+ };
1928
+ const response = await this.privateGetAccountBatchLeverageInfo(this.extend(request, params));
1929
+ //
1930
+ // {
1931
+ // "code": "0",
1932
+ // "msg": "success",
1933
+ // "data": [
1934
+ // {
1935
+ // "leverage": "3",
1936
+ // "marginMode": "cross",
1937
+ // "instId": "BTC-USDT"
1938
+ // },
1939
+ // ]
1940
+ // }
1941
+ //
1942
+ const leverages = this.safeList(response, 'data', []);
1943
+ return this.parseLeverages(leverages, symbols, 'instId');
1944
+ }
1887
1945
  async fetchLeverage(symbol, params = {}) {
1888
1946
  /**
1889
1947
  * @method
1890
1948
  * @name blofin#fetchLeverage
1891
1949
  * @description fetch the set leverage for a market
1892
- * @see https://blofin.com/docs#set-leverage
1950
+ * @see https://docs.blofin.com/index.html#get-leverage
1893
1951
  * @param {string} symbol unified market symbol
1894
1952
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1895
1953
  * @param {string} [params.marginMode] 'cross' or 'isolated'