@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
- // Convert target USD to cents, compute unit price in cents
18
- // ethUSDRaw has 8 decimals from Chainlink
19
- // unitPriceCents = (unitPriceWei * ethUSDRaw) / 1e18 / 1e6
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 unitPriceCents = (unitPriceWei * ethUSDRaw) / (10n ** 18n) / (10n ** 6n)
21
+ const denominator = unitPriceWei * ethUSDRaw
22
22
 
23
- if (! unitPriceCents) return amount.value
23
+ if (! denominator) return amount.value
24
24
 
25
- return Math.max(1, Number(targetCents / unitPriceCents))
25
+ return Math.max(1, Number(targetCents * (10n ** 24n) / denominator))
26
26
  })
27
27
 
28
28
  // Persist across navigations so the value survives remounts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visualizevalue/mint-app-base",
3
- "version": "0.1.119",
3
+ "version": "0.1.120",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "dependencies": {