The Standard

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

Loss of precision in `distributeAssets` function while calculating `costInEuros`

Summary

In function distributeAssets of LiquidationPool.sol contract, while calculating the costInEuros , division is done before multiplication. So this leads to precision loss.

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

Though the amount of precision loss is not high, but still it will get accumulated to form a high loss.

Vulnerability Details

The vulnerability is present in https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L220-L221

Impact

This leads to precision loss, which can affect the amount of EUROs each position gets and also might affect the reward.

Tools Used

Manual review

Recommendations

Always do multiplication before division to prevent precision losses.

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.