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

Loss of precision #95

Open
code423n4 opened this issue Jul 7, 2021 · 2 comments
Open

Loss of precision #95

code423n4 opened this issue Jul 7, 2021 · 2 comments
Labels

Comments

@code423n4
Copy link
Contributor

Handle

cmichel

Vulnerability details

Vulnerability Details

In ._totalAssetsEmergency there's a loss of precision in the assets computation due to first truncating by the chainlink decimal factor and then multiplying by DEFAULT_DECIMALS_FACTOR afterwards.

assets = assets.mul(price).div(CHAINLINK_PRICE_DECIMAL_FACTOR);
assets = assets.mul(DEFAULT_DECIMALS_FACTOR).div(decimals);

Impact

There can be a loss of precision in the computations.

Recommended Mitigation Steps

Multiply by DEFAULT_DECIMALS_FACTOR first before dividing by CHAINLINK_PRICE_DECIMAL_FACTOR

@code423n4 code423n4 added 1 (Low Risk) bug Something isn't working labels Jul 7, 2021
code423n4 added a commit that referenced this issue Jul 7, 2021
@kitty-the-kat
Copy link
Collaborator

No any precision loss. The 1st line is the token amount, the 2nd line is the dollar amount.

@ghoul-sol
Copy link
Collaborator

Technically warden is right but I doubt there will be any precision loss in practice. I'll keep it as non-critical.

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

No branches or pull requests

3 participants