layer5 icon indicating copy to clipboard operation
layer5 copied to clipboard

fix: INR currency rate mismatch in formatPrice()

Open Harishrs2006 opened this issue 5 months ago • 2 comments

Bug Description

In src/utils/currencies.js, the INR currency entry declares rate: 88.32 but formatPrice() hardcodes price * 88 as the multiplier.

This causes all INR prices rendered via formatAndConvertPrice() to be undervalued by ~0.36% compared to the declared rate.

Inconsistency

  • formatPrice() uses price * 88
  • formatSliderPrice() uses price * rate (88.32)
  • EUR.formatPrice() correctly uses price * 0.86 matching its rate: 0.86

So the two INR formatting functions return different values for the same input.

Affected File

src/utils/currencies.js line 36

Fix

Change price * 88 - price * 88.32 to match the declared rate, consistent with how EUR and the formatSliderPrice utility already handle it.

Harishrs2006 avatar Jun 25 '26 15:06 Harishrs2006

Confirmed reproducible on Node 20 + macOS. Interestingly it doesn't happen if you set NODE_OPTIONS=--max-old-space-size=512.

Katomoto avatar Jun 25 '26 23:06 Katomoto

Instead of just changing 88 to 88.32, I'd store the rate in the rate variable that's already defined and have formatPrice multiply by that variable instead of a typed-in number. That way the rate is written in one single place (one source of truth), so the slider and the cards always read the same value and can't drift apart again. Right now the number is written twice, in rate and again inside formatPrice, which is exactly how they got out of sync. Same goes for EUR, it has the same double-written number. Happy to open a PR, could I be assigned?

@Maanvi212006

ayushgade06 avatar Oct 02 '26 07:10 ayushgade06