@rabbitio/ui-kit 1.0.0-beta.24 → 1.0.0-beta.26

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabbitio/ui-kit",
3
- "version": "1.0.0-beta.24",
3
+ "version": "1.0.0-beta.26",
4
4
  "description": "Rabbit.io react.js components kit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -265,7 +265,7 @@ export class SwapspaceSwapProvider extends SwapProvider {
265
265
  }
266
266
 
267
267
  // This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
268
- const standardSwapspaceFeeMultiplier = 1.002; // usually 0.2%
268
+ const standardSwapspaceFeeMultiplier = 1.004; // usually 0.2%
269
269
  const rate = BigNumber(1)
270
270
  .div(
271
271
  BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)
@@ -22,6 +22,8 @@ export class SwapUtils {
22
22
  * @param swapProvider {SwapProvider}
23
23
  * @param fromCoin {Coin} enabled coin (to swap amount from)
24
24
  * @param toCoin {Coin}
25
+ * @param coinToCurrentFiatRate {string|null}
26
+ * @param fiatCurrencyDecimals {number|null}
25
27
  * @return {Promise<{
26
28
  * result: true,
27
29
  * min: string,
@@ -34,7 +36,13 @@ export class SwapUtils {
34
36
  * reason: string
35
37
  * }>}
36
38
  */
37
- static async getInitialSwapData(swapProvider, fromCoin, toCoin) {
39
+ static async getInitialSwapData(
40
+ swapProvider,
41
+ fromCoin,
42
+ toCoin,
43
+ coinToCurrentFiatRate = null,
44
+ fiatCurrencyDecimals = null
45
+ ) {
38
46
  const loggerSource = "getInitialSwapData";
39
47
  try {
40
48
  /* We use some amount here that should fit at least some of the limits of the swap providers.
@@ -81,15 +89,17 @@ export class SwapUtils {
81
89
  }
82
90
  let fiatMin = null;
83
91
  let fiatMax = null;
84
- if (coinUsdRate?.rate != null) {
85
- const usdDecimals =
86
- FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
92
+ const fiatRate = coinToCurrentFiatRate ?? coinUsdRate?.rate;
93
+ const fiatDecimals =
94
+ fiatCurrencyDecimals ??
95
+ FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
96
+ if (fiatRate != null) {
87
97
  fiatMin = BigNumber(details?.smallestMin)
88
- .times(coinUsdRate.rate)
89
- .toFixed(usdDecimals);
98
+ .times(coinToCurrentFiatRate)
99
+ .toFixed(fiatDecimals);
90
100
  fiatMax = BigNumber(details?.greatestMax)
91
- .times(coinUsdRate.rate)
92
- .toFixed(usdDecimals);
101
+ .times(coinToCurrentFiatRate)
102
+ .toFixed(fiatDecimals);
93
103
  }
94
104
 
95
105
  const result = {