The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Valid

Precision loss when calculating the costInEuros.

Summary

The calculation of the costInEuros in the distributeAssets() suffers from a rounding down issue, resulting in a small precision loss that can be improved.

Vulnerability Details

Division before multiplication can lead to rounding down issue since Solidity has no fixed-point numbers. During the calculation of the variable costInEuros in the distributeAssets() function, division is done before multiplication. Hence, the computed result can suffer from the rounding down issue, resulting in a small precision loss.

Impact

The computed result by costInEuros variable can suffer from the rounding down issue.

Tools Used

Manual Testing

Recommendations

Do multiplication before division

-uint256 costInEuros = _portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd) / uint256(priceEurUsd)
- * _hundredPC / _collateralRate;
+uint256 costInEuros = _portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd)
+ * _hundredPC / (_collateralRate * uint256(priceEurUsd));
Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

precision

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.