money icon indicating copy to clipboard operation
money copied to clipboard

Incorrect Number of Decimals in USDC Currency

Open brent-cybrid opened this issue 2 years ago • 9 comments

In config/currency_non_iso.json, the currency configuration for usdc is configured for "subunit_to_unit": 100, however, USDC supports six decimal places of precision, not 2.

The configuration for usdc should show "subunit_to_unit": 1000000.

brent-cybrid avatar Mar 05 '24 10:03 brent-cybrid

Hi, it is pretty clear that USDC has 6 decimal places, but is there an official reference? Also, I guess the subunit definition is also wrong should not be Cent anymore after this change

tagliala avatar Mar 08 '24 14:03 tagliala

The official reference would probably be to check the decimals() on the USDC contract, depending on the chain you are on, e.g. USDC on Ethereum: https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48#readProxyContract

-> decimals = 6

--

Another related question: If I'd save USDC with "subunit_to_unit": 1000000 then Money.from_cents(2345678, "USDC") => 2.345678 USDC

How can I now use .format to only display a rounded 2 decimals? => 2.35 USDC Any way to do this and define precision on format?

stebo avatar Mar 11 '24 11:03 stebo

What about the subunit name? I guess that cents would not apply anymore since they are not cents anymore. BTC are using Satoshis as subunit name

tagliala avatar Mar 11 '24 11:03 tagliala

What about the subunit name? I guess that cents would not apply anymore since they are not cents anymore. BTC are using Satoshis as subunit name

You can change the migrations and just use whatever column name suits your case better then _cents monetize :prize_satoshis

I usually just continue using _cents, although I have BTC, ETH & other crypto coins (which all have other subunit names). There is also probably a couple of fiat currencies that do not really have cents.

stebo avatar Mar 12 '24 08:03 stebo

welcome a PR, to update this. just not something we actively monitor ourselves.

semmons99 avatar Mar 13 '24 13:03 semmons99

I can work on this (at the end of next week), can you please reopen for tracking purposes?

tagliala avatar Mar 13 '24 14:03 tagliala

Sure. Done.

semmons99 avatar Mar 13 '24 15:03 semmons99

checking in on status

semmons99 avatar Mar 18 '24 12:03 semmons99

Confirm that I will have time during this weekend

tagliala avatar Mar 20 '24 15:03 tagliala