Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the precision of exchangeRate #156

Open
axic opened this issue Sep 2, 2021 · 1 comment
Open

Clarify the precision of exchangeRate #156

axic opened this issue Sep 2, 2021 · 1 comment

Comments

@axic
Copy link

axic commented Sep 2, 2021

The documentation in https://compound.finance/docs/ctokens#exchange-rate states the following:

Screenshot

However the source code at CToken intialExchangeRateMantissa, CToken and CErc20Delegator states it is fixed at 18 decimal digits.

exchangeRateStoredInternal does not seem to take the underlying asset into account (it uses Exponential.getExp, but that also states 18 decimal precision). Is the documentation just wrong or am I misunderstanding something?

@mijovic
Copy link

mijovic commented Sep 15, 2021

To make the answer short, documentation is correct here.

To clarify, for the case of DAI/cDAI exchangeRateCurrent() is 28 decimal fixed-point number
18 - 8 + 18 = 28 as in this case Underlying Token Decimals is 18(DAI)

If we read contract here
https://etherscan.io/token/0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643?a=0x2ec7947f3ac9aaaa44b53640506cdc9d848d9489#readContract

exchangeRateCurrent is 216064523443228187636427149 which has 27 digits so this is 0.021... on 28 decimal precision...

Comments in source code should be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@axic @mijovic and others