The Standard

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

Calculating asset distribution is susceptible to precision loss due to division before multiplication

Summary

In the LiquidationPool.distributeAssets function, there is a potential for rewards loss caused by precision loss in the costInEuros calculation.

Vulnerability Details

The LiquidationPool.distributeAssets function calculates _portion by using a combination of multiplication and division operations. The initial computation of _portion is based on the formula: assetAmount * positionStaked / stakeTotal. This value is subsequently utilized in the costInEuros equation, which expands to:
assetAmount * positionStaked / stakeTotal * decimals * assetPriceUsd / priceEurUsd * _hundredPC / _collateralRate.

The issue arises due to several divisions occurring before multiplications in this formula, potentially leading to significant precision loss, and in some cases, resulting in a calculation that equals 0.

Impact

The sequence of division before multiplication can result in the loss of token rewards, impacting the accuracy and fairness of the distribution process.

Tools Used

Manual Review

Recommendations

It is advisable to restructure the calculation process by performing all multiplications first, followed by the divisions. This approach can minimize precision loss, ensuring more accurate and equitable asset distribution.

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.