In the LiquidationPool.distributeAssets
function, there is a potential for rewards loss caused by precision loss in the costInEuros
calculation.
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.
The sequence of division before multiplication can result in the loss of token rewards, impacting the accuracy and fairness of the distribution process.
Manual Review
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.