The Standard

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

LiquidationPool::distributeAssets() division before multiplication can lead to precision loss

Summary and Vulnerability Details

The distributeAssets() function in the LiquidationPool contract performs a division before multiplication.

Solidity's integer division truncates. Thus, performing division before multiplication can lead to precision loss and should be avoided

Impact

Solidity's integer division truncates and can lead to false calculations due to precision loss

Tools Used

Manual Review

Recommendations

Perform multiplications before any divisions and use the following formula:

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

instead of:

uint256 costInEuros = _portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd) / uint256(priceEurUsd) * _hundredPC / _collateralRate;
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.