@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/dist/index.cjs +16 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +9 -6
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +16 -6
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +16 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +1 -1
- package/src/swaps-lib/utils/swapUtils.js +18 -8
package/package.json
CHANGED
|
@@ -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.
|
|
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(
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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(
|
|
89
|
-
.toFixed(
|
|
98
|
+
.times(coinToCurrentFiatRate)
|
|
99
|
+
.toFixed(fiatDecimals);
|
|
90
100
|
fiatMax = BigNumber(details?.greatestMax)
|
|
91
|
-
.times(
|
|
92
|
-
.toFixed(
|
|
101
|
+
.times(coinToCurrentFiatRate)
|
|
102
|
+
.toFixed(fiatDecimals);
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
const result = {
|