The Standard

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

Precision loss in LiquidationPool.sol::distributeAssets

Summary

Precision loss in LiquidationPool.sol::distributeAssets. Users will lose significant rewards when assets are distributed.

Vulnerability Details

Due to solidity's floating point issue ie. truncation of extra decimal points. The calculation ordering would lead to significant loses for uses.
uint256 costInEuros = _portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd) / uint256(priceEurUsd) * _hundredPC / _collateralRate;
There is division before multiplication which would lead to precision errors for the users and am imbalance in liquidity.

Impact

the contract's economic model could be affected due to compounded rounding errors, which might lead to undesirable financial outcomes for the users and the contract's balance.

Tools Used

Manual Review

Recommendations

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

uint256 totalValueInUsd = scaledPortion * uint256(assetPriceUsd);
uint256 totalValueInEuros = totalValueInUsd * _hundredPC / uint256(priceEurUsd);
uint256 costInEuros = totalValueInEuros / _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.