RubyMoney/money

Incorrect Number of Decimals in USDC Currency

brent-cybrid opened this issue · 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.

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

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?

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

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.

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

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

Sure. Done.

checking in on status

Confirm that I will have time during this weekend