ccxt 4.2.88 → 4.2.90

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 (164) hide show
  1. package/README.md +3 -3
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +1062 -241
  4. package/dist/ccxt.browser.min.js +6 -4
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/ascendex.js +3 -0
  7. package/dist/cjs/src/base/Exchange.js +53 -7
  8. package/dist/cjs/src/base/functions/crypto.js +37 -0
  9. package/dist/cjs/src/base/functions/rsa.js +19 -4
  10. package/dist/cjs/src/binance.js +92 -9
  11. package/dist/cjs/src/bingx.js +101 -1
  12. package/dist/cjs/src/bitfinex2.js +1 -0
  13. package/dist/cjs/src/bitflyer.js +2 -0
  14. package/dist/cjs/src/bitget.js +9 -1
  15. package/dist/cjs/src/bitmart.js +2 -0
  16. package/dist/cjs/src/bitmex.js +1 -0
  17. package/dist/cjs/src/bitrue.js +1 -0
  18. package/dist/cjs/src/bitstamp.js +83 -99
  19. package/dist/cjs/src/blofin.js +2 -0
  20. package/dist/cjs/src/bybit.js +63 -0
  21. package/dist/cjs/src/coinbase.js +48 -24
  22. package/dist/cjs/src/coinbaseinternational.js +1 -0
  23. package/dist/cjs/src/coinex.js +102 -8
  24. package/dist/cjs/src/coinsph.js +2 -0
  25. package/dist/cjs/src/cryptocom.js +1 -0
  26. package/dist/cjs/src/delta.js +1 -0
  27. package/dist/cjs/src/digifinex.js +3 -0
  28. package/dist/cjs/src/exmo.js +1 -0
  29. package/dist/cjs/src/gate.js +4 -0
  30. package/dist/cjs/src/gemini.js +10 -9
  31. package/dist/cjs/src/hitbtc.js +3 -0
  32. package/dist/cjs/src/htx.js +3 -0
  33. package/dist/cjs/src/hyperliquid.js +1 -0
  34. package/dist/cjs/src/kucoin.js +40 -15
  35. package/dist/cjs/src/kucoinfutures.js +34 -3
  36. package/dist/cjs/src/latoken.js +4 -0
  37. package/dist/cjs/src/lbank.js +3 -1
  38. package/dist/cjs/src/luno.js +2 -0
  39. package/dist/cjs/src/mexc.js +55 -6
  40. package/dist/cjs/src/okx.js +159 -8
  41. package/dist/cjs/src/phemex.js +1 -0
  42. package/dist/cjs/src/pro/bitget.js +2 -0
  43. package/dist/cjs/src/static_dependencies/noble-curves/p256.js +48 -0
  44. package/dist/cjs/src/timex.js +2 -0
  45. package/dist/cjs/src/woo.js +1 -0
  46. package/js/ccxt.d.ts +1 -1
  47. package/js/ccxt.js +1 -1
  48. package/js/src/abstract/bingx.d.ts +2 -0
  49. package/js/src/abstract/bybit.d.ts +2 -0
  50. package/js/src/ascendex.d.ts +3 -3
  51. package/js/src/ascendex.js +3 -0
  52. package/js/src/base/Exchange.d.ts +13 -8
  53. package/js/src/base/Exchange.js +53 -7
  54. package/js/src/base/functions/crypto.js +37 -0
  55. package/js/src/base/functions/rsa.d.ts +1 -1
  56. package/js/src/base/functions/rsa.js +21 -5
  57. package/js/src/base/types.d.ts +35 -1
  58. package/js/src/bigone.d.ts +2 -2
  59. package/js/src/binance.d.ts +6 -15
  60. package/js/src/binance.js +92 -9
  61. package/js/src/bingx.d.ts +3 -2
  62. package/js/src/bingx.js +101 -1
  63. package/js/src/bit2c.d.ts +2 -2
  64. package/js/src/bitbank.d.ts +2 -2
  65. package/js/src/bitfinex.d.ts +2 -2
  66. package/js/src/bitfinex2.d.ts +3 -3
  67. package/js/src/bitfinex2.js +1 -0
  68. package/js/src/bitflyer.d.ts +2 -7
  69. package/js/src/bitflyer.js +2 -0
  70. package/js/src/bitget.d.ts +6 -9
  71. package/js/src/bitget.js +9 -1
  72. package/js/src/bitmart.d.ts +4 -14
  73. package/js/src/bitmart.js +2 -0
  74. package/js/src/bitmex.d.ts +2 -2
  75. package/js/src/bitmex.js +1 -0
  76. package/js/src/bitopro.d.ts +3 -3
  77. package/js/src/bitrue.d.ts +2 -2
  78. package/js/src/bitrue.js +1 -0
  79. package/js/src/bitso.d.ts +2 -2
  80. package/js/src/bitstamp.d.ts +7 -19
  81. package/js/src/bitstamp.js +83 -99
  82. package/js/src/bitteam.d.ts +2 -2
  83. package/js/src/bitvavo.d.ts +3 -3
  84. package/js/src/bl3p.d.ts +2 -2
  85. package/js/src/blockchaincom.d.ts +2 -2
  86. package/js/src/blofin.d.ts +2 -7
  87. package/js/src/blofin.js +2 -0
  88. package/js/src/bybit.d.ts +7 -15
  89. package/js/src/bybit.js +63 -0
  90. package/js/src/cex.d.ts +3 -3
  91. package/js/src/coinbase.d.ts +2 -2
  92. package/js/src/coinbase.js +48 -24
  93. package/js/src/coinbaseinternational.d.ts +2 -2
  94. package/js/src/coinbaseinternational.js +1 -0
  95. package/js/src/coinbasepro.d.ts +3 -3
  96. package/js/src/coincheck.d.ts +2 -2
  97. package/js/src/coinex.d.ts +7 -19
  98. package/js/src/coinex.js +102 -8
  99. package/js/src/coinlist.d.ts +3 -3
  100. package/js/src/coinmate.d.ts +2 -9
  101. package/js/src/coinmetro.d.ts +2 -2
  102. package/js/src/coinone.d.ts +2 -2
  103. package/js/src/coinsph.d.ts +4 -14
  104. package/js/src/coinsph.js +2 -0
  105. package/js/src/cryptocom.js +1 -0
  106. package/js/src/currencycom.d.ts +3 -3
  107. package/js/src/delta.d.ts +2 -2
  108. package/js/src/delta.js +1 -0
  109. package/js/src/deribit.d.ts +3 -3
  110. package/js/src/digifinex.d.ts +4 -14
  111. package/js/src/digifinex.js +3 -0
  112. package/js/src/exmo.d.ts +3 -3
  113. package/js/src/exmo.js +1 -0
  114. package/js/src/gate.d.ts +6 -9
  115. package/js/src/gate.js +4 -0
  116. package/js/src/gemini.d.ts +3 -3
  117. package/js/src/gemini.js +10 -9
  118. package/js/src/hitbtc.d.ts +5 -15
  119. package/js/src/hitbtc.js +3 -0
  120. package/js/src/hollaex.d.ts +3 -3
  121. package/js/src/htx.d.ts +4 -14
  122. package/js/src/htx.js +3 -0
  123. package/js/src/huobijp.d.ts +2 -2
  124. package/js/src/hyperliquid.d.ts +2 -2
  125. package/js/src/hyperliquid.js +1 -0
  126. package/js/src/idex.d.ts +3 -3
  127. package/js/src/independentreserve.d.ts +2 -2
  128. package/js/src/kraken.d.ts +3 -10
  129. package/js/src/kucoin.d.ts +3 -10
  130. package/js/src/kucoin.js +40 -15
  131. package/js/src/kucoinfutures.d.ts +2 -9
  132. package/js/src/kucoinfutures.js +34 -3
  133. package/js/src/kuna.d.ts +2 -2
  134. package/js/src/latoken.d.ts +7 -8
  135. package/js/src/latoken.js +4 -0
  136. package/js/src/lbank.d.ts +4 -9
  137. package/js/src/lbank.js +3 -1
  138. package/js/src/luno.d.ts +2 -7
  139. package/js/src/luno.js +2 -0
  140. package/js/src/lykke.d.ts +2 -2
  141. package/js/src/mexc.d.ts +3 -3
  142. package/js/src/mexc.js +55 -6
  143. package/js/src/ndax.d.ts +2 -2
  144. package/js/src/oceanex.d.ts +2 -2
  145. package/js/src/okcoin.d.ts +2 -2
  146. package/js/src/okx.d.ts +5 -14
  147. package/js/src/okx.js +159 -8
  148. package/js/src/onetrading.d.ts +3 -3
  149. package/js/src/phemex.d.ts +2 -2
  150. package/js/src/phemex.js +1 -0
  151. package/js/src/poloniex.d.ts +3 -3
  152. package/js/src/pro/bitget.js +2 -0
  153. package/js/src/pro/bitvavo.d.ts +2 -2
  154. package/js/src/probit.d.ts +2 -2
  155. package/js/src/timex.d.ts +4 -14
  156. package/js/src/timex.js +2 -0
  157. package/js/src/upbit.d.ts +2 -9
  158. package/js/src/wazirx.d.ts +2 -2
  159. package/js/src/whitebit.d.ts +3 -3
  160. package/js/src/woo.d.ts +3 -3
  161. package/js/src/woo.js +1 -0
  162. package/js/src/yobit.d.ts +2 -2
  163. package/package.json +1 -1
  164. package/skip-tests.json +6 -1
@@ -84,6 +84,7 @@ class okx extends okx$1 {
84
84
  'fetchLedgerEntry': undefined,
85
85
  'fetchLeverage': true,
86
86
  'fetchLeverageTiers': false,
87
+ 'fetchMarginAdjustmentHistory': true,
87
88
  'fetchMarketLeverageTiers': true,
88
89
  'fetchMarkets': true,
89
90
  'fetchMarkOHLCV': true,
@@ -2354,6 +2355,8 @@ class okx extends okx$1 {
2354
2355
  // OKX returns the fees as negative values opposed to other exchanges, so the sign needs to be flipped
2355
2356
  'maker': this.parseNumber(Precise["default"].stringNeg(this.safeString2(fee, 'maker', 'makerU'))),
2356
2357
  'taker': this.parseNumber(Precise["default"].stringNeg(this.safeString2(fee, 'taker', 'takerU'))),
2358
+ 'percentage': undefined,
2359
+ 'tierBased': undefined,
2357
2360
  };
2358
2361
  }
2359
2362
  async fetchTradingFee(symbol, params = {}) {
@@ -6461,9 +6464,9 @@ class okx extends okx$1 {
6461
6464
  // }
6462
6465
  //
6463
6466
  const data = this.safeList(response, 'data', []);
6467
+ const entry = this.safeDict(data, 0, {});
6464
6468
  const errorCode = this.safeString(response, 'code');
6465
- const item = this.safeDict(data, 0, {});
6466
- return this.extend(this.parseMarginModification(item, market), {
6469
+ return this.extend(this.parseMarginModification(entry, market), {
6467
6470
  'status': (errorCode === '0') ? 'ok' : 'failed',
6468
6471
  });
6469
6472
  }
@@ -6478,22 +6481,68 @@ class okx extends okx$1 {
6478
6481
  // "type": "reduce"
6479
6482
  // }
6480
6483
  //
6481
- const amountRaw = this.safeNumber(data, 'amt');
6484
+ // fetchMarginAdjustmentHistory
6485
+ //
6486
+ // {
6487
+ // bal: '67621.4325135010619812',
6488
+ // balChg: '-10.0000000000000000',
6489
+ // billId: '691293628710342659',
6490
+ // ccy: 'USDT',
6491
+ // clOrdId: '',
6492
+ // execType: '',
6493
+ // fee: '0',
6494
+ // fillFwdPx: '',
6495
+ // fillIdxPx: '',
6496
+ // fillMarkPx: '',
6497
+ // fillMarkVol: '',
6498
+ // fillPxUsd: '',
6499
+ // fillPxVol: '',
6500
+ // fillTime: '1711089244850',
6501
+ // from: '',
6502
+ // instId: 'XRP-USDT-SWAP',
6503
+ // instType: 'SWAP',
6504
+ // interest: '0',
6505
+ // mgnMode: 'isolated',
6506
+ // notes: '',
6507
+ // ordId: '',
6508
+ // pnl: '0',
6509
+ // posBal: '73.12',
6510
+ // posBalChg: '10.00',
6511
+ // px: '',
6512
+ // subType: '160',
6513
+ // sz: '10',
6514
+ // tag: '',
6515
+ // to: '',
6516
+ // tradeId: '0',
6517
+ // ts: '1711089244699',
6518
+ // type: '6'
6519
+ // }
6520
+ //
6521
+ const amountRaw = this.safeString2(data, 'amt', 'posBalChg');
6482
6522
  const typeRaw = this.safeString(data, 'type');
6483
- const type = (typeRaw === 'reduce') ? 'reduce' : 'add';
6523
+ let type = undefined;
6524
+ if (typeRaw === '6') {
6525
+ type = Precise["default"].stringGt(amountRaw, '0') ? 'add' : 'reduce';
6526
+ }
6527
+ else {
6528
+ type = typeRaw;
6529
+ }
6530
+ const amount = Precise["default"].stringAbs(amountRaw);
6484
6531
  const marketId = this.safeString(data, 'instId');
6485
6532
  const responseMarket = this.safeMarket(marketId, market);
6486
6533
  const code = responseMarket['inverse'] ? responseMarket['base'] : responseMarket['quote'];
6534
+ const timestamp = this.safeInteger(data, 'ts');
6487
6535
  return {
6488
6536
  'info': data,
6489
6537
  'symbol': responseMarket['symbol'],
6490
6538
  'type': type,
6491
- 'amount': amountRaw,
6492
- 'total': undefined,
6539
+ 'marginMode': 'isolated',
6540
+ 'amount': this.parseNumber(amount),
6493
6541
  'code': code,
6542
+ 'total': undefined,
6494
6543
  'status': undefined,
6495
- 'timestamp': undefined,
6496
- 'datetime': undefined,
6544
+ 'timestamp': timestamp,
6545
+ 'datetime': this.iso8601(timestamp),
6497
6546
  };
6498
6547
  }
6499
6548
  async reduceMargin(symbol, amount, params = {}) {
@@ -7595,6 +7644,108 @@ class okx extends okx$1 {
7595
7644
  }
7596
7645
  return undefined;
7597
7646
  }
7647
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
7648
+ /**
7649
+ * @method
7650
+ * @name okx#fetchMarginAdjustmentHistory
7651
+ * @description fetches the history of margin added or reduced from contract isolated positions
7652
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-7-days
7653
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months
7654
+ * @param {string} [symbol] not used by okx fetchMarginAdjustmentHistory
7655
+ * @param {string} [type] "add" or "reduce"
7656
+ * @param {object} params extra parameters specific to the exchange api endpoint
7657
+ * @param {boolean} [params.auto] true if fetching auto margin increases
7658
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
7659
+ */
7660
+ await this.loadMarkets();
7661
+ const auto = this.safeBool(params, 'auto');
7662
+ if (type === undefined) {
7663
+ throw new errors.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory () requires a type argument');
7664
+ }
7665
+ const isAdd = type === 'add';
7666
+ let subType = isAdd ? '160' : '161';
7667
+ if (auto) {
7668
+ if (isAdd) {
7669
+ subType = '162';
7670
+ }
7671
+ else {
7672
+ throw new errors.BadRequest(this.id + ' cannot fetch margin adjustments for type ' + type);
7673
+ }
7674
+ }
7675
+ const request = {
7676
+ 'subType': subType,
7677
+ 'mgnMode': 'isolated',
7678
+ };
7679
+ const until = this.safeInteger(params, 'until');
7680
+ params = this.omit(params, 'until');
7681
+ if (since !== undefined) {
7682
+ request['startTime'] = since;
7683
+ }
7684
+ if (limit !== undefined) {
7685
+ request['limit'] = limit;
7686
+ }
7687
+ if (until !== undefined) {
7688
+ request['endTime'] = until;
7689
+ }
7690
+ let response = undefined;
7691
+ const now = this.milliseconds();
7692
+ const oneWeekAgo = now - 604800000;
7693
+ const threeMonthsAgo = now - 7776000000;
7694
+ if ((since === undefined) || (since > oneWeekAgo)) {
7695
+ response = await this.privateGetAccountBills(this.extend(request, params));
7696
+ }
7697
+ else if (since > threeMonthsAgo) {
7698
+ response = await this.privateGetAccountBillsArchive(this.extend(request, params));
7699
+ }
7700
+ else {
7701
+ throw new errors.BadRequest(this.id + ' fetchMarginAdjustmentHistory () cannot fetch margin adjustments older than 3 months');
7702
+ }
7703
+ //
7704
+ // {
7705
+ // code: '0',
7706
+ // data: [
7707
+ // {
7708
+ // bal: '67621.4325135010619812',
7709
+ // balChg: '-10.0000000000000000',
7710
+ // billId: '691293628710342659',
7711
+ // ccy: 'USDT',
7712
+ // clOrdId: '',
7713
+ // execType: '',
7714
+ // fee: '0',
7715
+ // fillFwdPx: '',
7716
+ // fillIdxPx: '',
7717
+ // fillMarkPx: '',
7718
+ // fillMarkVol: '',
7719
+ // fillPxUsd: '',
7720
+ // fillPxVol: '',
7721
+ // fillTime: '1711089244850',
7722
+ // from: '',
7723
+ // instId: 'XRP-USDT-SWAP',
7724
+ // instType: 'SWAP',
7725
+ // interest: '0',
7726
+ // mgnMode: 'isolated',
7727
+ // notes: '',
7728
+ // ordId: '',
7729
+ // pnl: '0',
7730
+ // posBal: '73.12',
7731
+ // posBalChg: '10.00',
7732
+ // px: '',
7733
+ // subType: '160',
7734
+ // sz: '10',
7735
+ // tag: '',
7736
+ // to: '',
7737
+ // tradeId: '0',
7738
+ // ts: '1711089244699',
7739
+ // type: '6'
7740
+ // }
7741
+ // ],
7742
+ // msg: ''
7743
+ // }
7744
+ //
7745
+ const data = this.safeList(response, 'data');
7746
+ const modifications = this.parseMarginModifications(data);
7747
+ return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
7748
+ }
7598
7749
  }
7599
7750
 
7600
7751
  module.exports = okx;
@@ -4062,6 +4062,7 @@ class phemex extends phemex$1 {
4062
4062
  'info': data,
4063
4063
  'symbol': this.safeSymbol(undefined, market),
4064
4064
  'type': 'set',
4065
+ 'marginMode': 'isolated',
4065
4066
  'amount': undefined,
4066
4067
  'total': undefined,
4067
4068
  'code': market[codeCurrency],
@@ -1722,6 +1722,8 @@ class bitget extends bitget$1 {
1722
1722
  'ordersAlgo': this.handleOrder,
1723
1723
  'account': this.handleBalance,
1724
1724
  'positions': this.handlePositions,
1725
+ 'account-isolated': this.handleBalance,
1726
+ 'account-crossed': this.handleBalance,
1725
1727
  };
1726
1728
  const arg = this.safeValue(message, 'arg', {});
1727
1729
  const topic = this.safeValue(arg, 'channel', '');
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _shortw_utils = require('./_shortw_utils.js');
6
+ var sha256 = require('../noble-hashes/sha256.js');
7
+ var modular = require('./abstract/modular.js');
8
+ var weierstrass = require('./abstract/weierstrass.js');
9
+ var hashToCurve = require('./abstract/hash-to-curve.js');
10
+
11
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
12
+ // NIST secp256r1 aka P256
13
+ // https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256
14
+ // Field over which we'll do calculations; 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n
15
+ const Fp = modular.Fp(BigInt('0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff'));
16
+ const CURVE_A = Fp.create(BigInt('-3'));
17
+ const CURVE_B = BigInt('0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b');
18
+ const mapSWU = weierstrass.mapToCurveSimpleSWU(Fp, {
19
+ A: CURVE_A,
20
+ B: CURVE_B,
21
+ Z: Fp.create(BigInt('-10')),
22
+ });
23
+ const P256 = _shortw_utils.createCurve({
24
+ // Params: a, b
25
+ a: CURVE_A,
26
+ b: CURVE_B,
27
+ Fp,
28
+ // Curve order, total count of valid points in the field
29
+ n: BigInt('0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551'),
30
+ // Base point (x, y) aka generator point
31
+ Gx: BigInt('0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296'),
32
+ Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'),
33
+ h: BigInt(1),
34
+ lowS: false,
35
+ }, sha256.sha256);
36
+ const secp256r1 = P256;
37
+ hashToCurve.createHasher(secp256r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
38
+ DST: 'P256_XMD:SHA-256_SSWU_RO_',
39
+ encodeDST: 'P256_XMD:SHA-256_SSWU_NU_',
40
+ p: Fp.ORDER,
41
+ m: 1,
42
+ k: 128,
43
+ expand: 'xmd',
44
+ hash: sha256.sha256,
45
+ });
46
+
47
+ exports.P256 = P256;
48
+ exports.secp256r1 = secp256r1;
@@ -1161,6 +1161,8 @@ class timex extends timex$1 {
1161
1161
  'symbol': this.safeSymbol(marketId, market),
1162
1162
  'maker': rate,
1163
1163
  'taker': rate,
1164
+ 'percentage': undefined,
1165
+ 'tierBased': undefined,
1164
1166
  };
1165
1167
  }
1166
1168
  async fetchTradingFee(symbol, params = {}) {
@@ -68,6 +68,7 @@ class woo extends woo$1 {
68
68
  'fetchIndexOHLCV': false,
69
69
  'fetchLedger': true,
70
70
  'fetchLeverage': true,
71
+ 'fetchMarginAdjustmentHistory': false,
71
72
  'fetchMarginMode': false,
72
73
  'fetchMarkets': true,
73
74
  'fetchMarkOHLCV': false,
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser } from './src/base/errors.js';
7
- declare const version = "4.2.87";
7
+ declare const version = "4.2.89";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.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, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.88';
41
+ const version = '4.2.90';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -29,6 +29,7 @@ interface Exchange {
29
29
  swapV1PrivateGetPositionSideDual(params?: {}): Promise<implicitReturnType>;
30
30
  swapV1PrivateGetMarketMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
31
31
  swapV1PrivateGetTradeBatchCancelReplace(params?: {}): Promise<implicitReturnType>;
32
+ swapV1PrivateGetTradeFullOrder(params?: {}): Promise<implicitReturnType>;
32
33
  swapV1PrivatePostTradeCancelReplace(params?: {}): Promise<implicitReturnType>;
33
34
  swapV1PrivatePostPositionSideDual(params?: {}): Promise<implicitReturnType>;
34
35
  swapV1PrivatePostTradeClosePosition(params?: {}): Promise<implicitReturnType>;
@@ -96,6 +97,7 @@ interface Exchange {
96
97
  copyTradingV1PrivateGetSwapTraceCurrentTrack(params?: {}): Promise<implicitReturnType>;
97
98
  copyTradingV1PrivatePostSwapTraceCloseTrackOrder(params?: {}): Promise<implicitReturnType>;
98
99
  copyTradingV1PrivatePostSwapTraceSetTPSL(params?: {}): Promise<implicitReturnType>;
100
+ copyTradingV1PrivatePostSpotTraderSellOrder(params?: {}): Promise<implicitReturnType>;
99
101
  apiV3PrivateGetAssetTransfer(params?: {}): Promise<implicitReturnType>;
100
102
  apiV3PrivateGetCapitalDepositHisrec(params?: {}): Promise<implicitReturnType>;
101
103
  apiV3PrivateGetCapitalWithdrawHistory(params?: {}): Promise<implicitReturnType>;
@@ -154,6 +154,7 @@ interface Exchange {
154
154
  privateGetV5UserGetMemberType(params?: {}): Promise<implicitReturnType>;
155
155
  privateGetV5UserAffCustomerInfo(params?: {}): Promise<implicitReturnType>;
156
156
  privateGetV5UserDelSubmember(params?: {}): Promise<implicitReturnType>;
157
+ privateGetV5UserSubmembers(params?: {}): Promise<implicitReturnType>;
157
158
  privateGetV5SpotLeverTokenOrderRecord(params?: {}): Promise<implicitReturnType>;
158
159
  privateGetV5SpotMarginTradeState(params?: {}): Promise<implicitReturnType>;
159
160
  privateGetV5SpotCrossMarginTradeLoanInfo(params?: {}): Promise<implicitReturnType>;
@@ -290,6 +291,7 @@ interface Exchange {
290
291
  privatePostV5LendingRedeemCancel(params?: {}): Promise<implicitReturnType>;
291
292
  privatePostV5AccountSetCollateralSwitch(params?: {}): Promise<implicitReturnType>;
292
293
  privatePostV5AccountSetCollateralSwitchBatch(params?: {}): Promise<implicitReturnType>;
294
+ privatePostV5AccountDemoApplyMoney(params?: {}): Promise<implicitReturnType>;
293
295
  }
294
296
  declare abstract class Exchange extends _Exchange {
295
297
  }
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/ascendex.js';
2
- import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Strings, Num, Currency, Market, Leverage, Leverages, Account, MarginModes, MarginMode, MarginModification } from './base/types.js';
2
+ import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Strings, Num, Currency, Market, Leverage, Leverages, Account, MarginModes, MarginMode, MarginModification, Currencies, TradingFees } from './base/types.js';
3
3
  /**
4
4
  * @class ascendex
5
5
  * @augments Exchange
@@ -7,7 +7,7 @@ import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, Order
7
7
  export default class ascendex extends Exchange {
8
8
  describe(): any;
9
9
  getAccount(params?: {}): string;
10
- fetchCurrencies(params?: {}): Promise<{}>;
10
+ fetchCurrencies(params?: {}): Promise<Currencies>;
11
11
  fetchMarkets(params?: {}): Promise<Market[]>;
12
12
  fetchTime(params?: {}): Promise<number>;
13
13
  fetchAccounts(params?: {}): Promise<Account[]>;
@@ -25,7 +25,7 @@ export default class ascendex extends Exchange {
25
25
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
26
26
  parseOrderStatus(status: any): string;
27
27
  parseOrder(order: any, market?: Market): Order;
28
- fetchTradingFees(params?: {}): Promise<{}>;
28
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
29
29
  createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): any;
30
30
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
31
31
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
@@ -1486,6 +1486,8 @@ export default class ascendex extends Exchange {
1486
1486
  'symbol': symbol,
1487
1487
  'maker': this.safeNumber(takerMaker, 'maker'),
1488
1488
  'taker': this.safeNumber(takerMaker, 'taker'),
1489
+ 'percentage': undefined,
1490
+ 'tierBased': undefined,
1489
1491
  };
1490
1492
  }
1491
1493
  return result;
@@ -2889,6 +2891,7 @@ export default class ascendex extends Exchange {
2889
2891
  'info': data,
2890
2892
  'symbol': market['symbol'],
2891
2893
  'type': undefined,
2894
+ 'marginMode': 'isolated',
2892
2895
  'amount': undefined,
2893
2896
  'total': undefined,
2894
2897
  'code': market['quote'],
@@ -3,7 +3,7 @@ import { // eslint-disable-line object-curly-newline
3
3
  ExchangeError, AuthenticationError, DDoSProtection, RequestTimeout, ExchangeNotAvailable, RateLimitExceeded } from "./errors.js";
4
4
  import WsClient from './ws/WsClient.js';
5
5
  import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
6
- import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, MarginModification } from './types.js';
6
+ import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, MarginModification, TradingFeeInterface, Currencies, TradingFees } from './types.js';
7
7
  export type { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, BorrowRate, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings } from './types.js';
8
8
  import { ArrayCache, ArrayCacheByTimestamp } from './ws/Cache.js';
9
9
  import { OrderBook as Ob } from './ws/OrderBook.js';
@@ -141,7 +141,7 @@ export default class Exchange {
141
141
  markets_by_id: Dictionary<any>;
142
142
  symbols: string[];
143
143
  ids: string[];
144
- currencies: Dictionary<Currency>;
144
+ currencies: Currencies;
145
145
  baseCurrencies: any;
146
146
  quoteCurrencies: any;
147
147
  currencies_by_id: any;
@@ -369,6 +369,7 @@ export default class Exchange {
369
369
  fetchIndexOHLCV: any;
370
370
  fetchIsolatedBorrowRate: any;
371
371
  fetchIsolatedBorrowRates: any;
372
+ fetchMarginAdjustmentHistory: any;
372
373
  fetchIsolatedPositions: any;
373
374
  fetchL2OrderBook: boolean;
374
375
  fetchL3OrderBook: any;
@@ -588,7 +589,7 @@ export default class Exchange {
588
589
  onJsonResponse(responseBody: any): any;
589
590
  loadMarketsHelper(reload?: boolean, params?: {}): Promise<Dictionary<any>>;
590
591
  loadMarkets(reload?: boolean, params?: {}): Promise<Dictionary<Market>>;
591
- fetchCurrencies(params?: {}): Promise<unknown>;
592
+ fetchCurrencies(params?: {}): Promise<Currencies>;
592
593
  fetchCurrenciesWs(params?: {}): Promise<unknown>;
593
594
  fetchMarkets(params?: {}): Promise<Market[]>;
594
595
  fetchMarketsWs(params?: {}): Promise<Market[]>;
@@ -625,6 +626,7 @@ export default class Exchange {
625
626
  intToBase16(elem: any): string;
626
627
  extendExchangeOptions(newOptions: any): void;
627
628
  createSafeDictionary(): {};
629
+ randomBytes(length: any): string;
628
630
  safeBoolN(dictionaryOrList: any, keys: IndexType[], defaultValue?: boolean): boolean | undefined;
629
631
  safeBool2(dictionary: any, key1: IndexType, key2: IndexType, defaultValue?: boolean): boolean | undefined;
630
632
  safeBool(dictionary: any, key: IndexType, defaultValue?: boolean): boolean | undefined;
@@ -700,6 +702,7 @@ export default class Exchange {
700
702
  addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
701
703
  reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
702
704
  setMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
705
+ fetchMarginAdjustmentHistory(symbol?: Str, type?: Str, since?: Num, limit?: Num, params?: {}): Promise<MarginModification[]>;
703
706
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<{}>;
704
707
  fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
705
708
  fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
@@ -741,7 +744,7 @@ export default class Exchange {
741
744
  fee: any;
742
745
  info: Dictionary<any>;
743
746
  };
744
- safeCurrencyStructure(currency: object): any;
747
+ safeCurrencyStructure(currency: object): CurrencyInterface;
745
748
  safeMarketStructure(market?: any): MarketInterface;
746
749
  setMarkets(markets: any, currencies?: any): Dictionary<any>;
747
750
  getDescribeForExtendedWsExchange(currentRestInstance: any, parentRestInstance: any, wsBaseDescribe: Dictionary<any>): any;
@@ -920,7 +923,7 @@ export default class Exchange {
920
923
  parseLastPrice(price: any, market?: Market): LastPrice;
921
924
  fetchDepositAddress(code: string, params?: {}): Promise<any>;
922
925
  account(): BalanceAccount;
923
- commonCurrencyCode(currency: string): string;
926
+ commonCurrencyCode(code: string): string;
924
927
  currency(code: string): any;
925
928
  market(symbol: string): MarketInterface;
926
929
  createExpiredOptionMarket(symbol: string): MarketInterface;
@@ -968,9 +971,9 @@ export default class Exchange {
968
971
  isPostOnly(isMarketOrder: boolean, exchangeSpecificParam: any, params?: {}): boolean;
969
972
  handlePostOnly(isMarketOrder: boolean, exchangeSpecificPostOnlyOption: boolean, params?: any): any[];
970
973
  fetchLastPrices(symbols?: string[], params?: {}): Promise<LastPrices>;
971
- fetchTradingFees(params?: {}): Promise<{}>;
972
- fetchTradingFeesWs(params?: {}): Promise<{}>;
973
- fetchTradingFee(symbol: string, params?: {}): Promise<{}>;
974
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
975
+ fetchTradingFeesWs(params?: {}): Promise<TradingFees>;
976
+ fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
974
977
  parseOpenInterest(interest: any, market?: Market): OpenInterest;
975
978
  parseOpenInterests(response: any, market?: any, since?: Int, limit?: Int): OpenInterest[];
976
979
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
@@ -1015,5 +1018,7 @@ export default class Exchange {
1015
1018
  convertExpireDate(date: string): string;
1016
1019
  convertExpireDateToMarketIdDate(date: string): string;
1017
1020
  convertMarketIdExpireDate(date: string): string;
1021
+ parseMarginModification(data: any, market?: Market): MarginModification;
1022
+ parseMarginModifications(response: object[], symbols?: string[], symbolKey?: Str, marketType?: MarketType): MarginModification[];
1018
1023
  }
1019
1024
  export { Exchange, };
@@ -23,6 +23,7 @@ import { axolotl } from './functions/crypto.js';
23
23
  import totp from './functions/totp.js';
24
24
  import ethers from '../static_dependencies/ethers/index.js';
25
25
  import { TypedDataEncoder } from '../static_dependencies/ethers/hash/index.js';
26
+ import { SecureRandom } from "../static_dependencies/jsencrypt/lib/jsbn/rng.js";
26
27
  // ----------------------------------------------------------------------------
27
28
  /**
28
29
  * @class Exchange
@@ -88,7 +89,7 @@ export default class Exchange {
88
89
  this.markets_by_id = undefined;
89
90
  this.symbols = undefined;
90
91
  this.ids = undefined;
91
- this.currencies = undefined;
92
+ this.currencies = {};
92
93
  this.baseCurrencies = undefined;
93
94
  this.quoteCurrencies = undefined;
94
95
  this.currencies_by_id = undefined;
@@ -426,6 +427,7 @@ export default class Exchange {
426
427
  'fetchIndexOHLCV': undefined,
427
428
  'fetchIsolatedBorrowRate': undefined,
428
429
  'fetchIsolatedBorrowRates': undefined,
430
+ 'fetchMarginAdjustmentHistory': undefined,
429
431
  'fetchIsolatedPositions': undefined,
430
432
  'fetchL2OrderBook': true,
431
433
  'fetchL3OrderBook': undefined,
@@ -1432,6 +1434,13 @@ export default class Exchange {
1432
1434
  createSafeDictionary() {
1433
1435
  return {};
1434
1436
  }
1437
+ randomBytes(length) {
1438
+ const rng = new SecureRandom();
1439
+ const x = [];
1440
+ x.length = length;
1441
+ rng.nextBytes(x);
1442
+ return Buffer.from(x).toString('hex');
1443
+ }
1435
1444
  /* eslint-enable */
1436
1445
  // ------------------------------------------------------------------------
1437
1446
  // ########################################################################
@@ -2038,6 +2047,20 @@ export default class Exchange {
2038
2047
  async setMargin(symbol, amount, params = {}) {
2039
2048
  throw new NotSupported(this.id + ' setMargin() is not supported yet');
2040
2049
  }
2050
+ async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
2051
+ /**
2052
+ * @method
2053
+ * @name exchange#fetchMarginAdjustmentHistory
2054
+ * @description fetches the history of margin added or reduced from contract isolated positions
2055
+ * @param {string} [symbol] unified market symbol
2056
+ * @param {string} [type] "add" or "reduce"
2057
+ * @param {int} [since] timestamp in ms of the earliest change to fetch
2058
+ * @param {int} [limit] the maximum amount of changes to fetch
2059
+ * @param {object} params extra parameters specific to the exchange api endpoint
2060
+ * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
2061
+ */
2062
+ throw new NotSupported(this.id + ' fetchMarginAdjustmentHistory() is not supported yet');
2063
+ }
2041
2064
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
2042
2065
  throw new NotSupported(this.id + ' setMarginMode() is not supported yet');
2043
2066
  }
@@ -3775,11 +3798,11 @@ export default class Exchange {
3775
3798
  if (currencyId !== undefined) {
3776
3799
  code = this.commonCurrencyCode(currencyId.toUpperCase());
3777
3800
  }
3778
- return {
3801
+ return this.safeCurrencyStructure({
3779
3802
  'id': currencyId,
3780
3803
  'code': code,
3781
3804
  'precision': undefined,
3782
- };
3805
+ });
3783
3806
  }
3784
3807
  safeMarket(marketId, market = undefined, delimiter = undefined, marketType = undefined) {
3785
3808
  const result = this.safeMarketStructure({
@@ -4548,11 +4571,18 @@ export default class Exchange {
4548
4571
  'total': undefined,
4549
4572
  };
4550
4573
  }
4551
- commonCurrencyCode(currency) {
4574
+ commonCurrencyCode(code) {
4552
4575
  if (!this.substituteCommonCurrencyCodes) {
4553
- return currency;
4576
+ return code;
4577
+ }
4578
+ // if the provided code already exists as a value in commonCurrencies dict, then we should not again transform it
4579
+ // more details at: https://github.com/ccxt/ccxt/issues/21112#issuecomment-2031293691
4580
+ const commonCurrencies = Object.values(this.commonCurrencies);
4581
+ const exists = this.inArray(code, commonCurrencies);
4582
+ if (exists) {
4583
+ return code;
4554
4584
  }
4555
- return this.safeString(this.commonCurrencies, currency, currency);
4585
+ return this.safeString(this.commonCurrencies, code, code);
4556
4586
  }
4557
4587
  currency(code) {
4558
4588
  if (this.currencies === undefined) {
@@ -5015,7 +5045,8 @@ export default class Exchange {
5015
5045
  if (!this.has['fetchTradingFees']) {
5016
5046
  throw new NotSupported(this.id + ' fetchTradingFee() is not supported yet');
5017
5047
  }
5018
- return await this.fetchTradingFees(params);
5048
+ const fees = await this.fetchTradingFees(params);
5049
+ return this.safeDict(fees, symbol);
5019
5050
  }
5020
5051
  parseOpenInterest(interest, market = undefined) {
5021
5052
  throw new NotSupported(this.id + ' parseOpenInterest () is not supported yet');
@@ -5793,5 +5824,20 @@ export default class Exchange {
5793
5824
  const reconstructedDate = day + month + year;
5794
5825
  return reconstructedDate;
5795
5826
  }
5827
+ parseMarginModification(data, market = undefined) {
5828
+ throw new NotSupported(this.id + ' parseMarginModification() is not supported yet');
5829
+ }
5830
+ parseMarginModifications(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
5831
+ const marginModifications = [];
5832
+ for (let i = 0; i < response.length; i++) {
5833
+ const info = response[i];
5834
+ const marketId = this.safeString(info, symbolKey);
5835
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
5836
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
5837
+ marginModifications.push(this.parseMarginModification(info, market));
5838
+ }
5839
+ }
5840
+ return marginModifications;
5841
+ }
5796
5842
  }
5797
5843
  export { Exchange, };