@visualizevalue/mint-app-base 0.1.119 → 0.1.120
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.
|
@@ -14,15 +14,15 @@ export const useMintDefault = () => {
|
|
|
14
14
|
// Unit price in wei: basefee * 60_000
|
|
15
15
|
const unitPriceWei = gasPriceWei * 60_000n
|
|
16
16
|
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
17
|
+
// targetCents / unitPriceCents, but computed as a single division
|
|
18
|
+
// to avoid BigInt truncation on the intermediate unitPriceCents:
|
|
19
|
+
// (targetCents * 1e24) / (unitPriceWei * ethUSDRaw)
|
|
20
20
|
const targetCents = BigInt(Math.round(value.value * 100))
|
|
21
|
-
const
|
|
21
|
+
const denominator = unitPriceWei * ethUSDRaw
|
|
22
22
|
|
|
23
|
-
if (!
|
|
23
|
+
if (! denominator) return amount.value
|
|
24
24
|
|
|
25
|
-
return Math.max(1, Number(targetCents /
|
|
25
|
+
return Math.max(1, Number(targetCents * (10n ** 24n) / denominator))
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
// Persist across navigations so the value survives remounts
|