The Standard

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

`distributeAssets` function revert if asset has more than 18 decimals.

Vulnerability Details

When costInEuros calculates in distributeAssets function it used asset decimals. If asset has more than 18 decimals function revert.

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

https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/LiquidationPool.sol#L220

Impact

Assets can't be distributed.

Tools Used

Manual review.

Recommendations

Consider to normalize decimals.

...
++ uint8 decimals;
++ if (asset.token.dec > 18) {
++ decimals = asset.token.dec - 18;
++ } else {
++ decimals = 18 - asset.token.dec;
++ }
-- uint256 costInEuros = _portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd) / uint256(priceEurUsd) * _hundredPC / _collateralRate;
++ uint256 costInEuros = _portion * 10 ** (decimals) * uint256(assetPriceUsd) / uint256(priceEurUsd) * _hundredPC / _collateralRate;
...
Updates

Lead Judging Commences

hrishibhat Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

informational/invalid

Support

FAQs

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

Give us feedback!