Precision loss in calculation due to division before multiplication
In the function distibuteAssets() while calculating value of costInEuros,
uint256 costInEuros = _portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd) / uint256(priceEurUsd)
* _hundredPC / _collateralRate;
first value obtained from (_portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd)) is divided by priceEurUsd and then multiplied by hundredPC which can cause rounding error.
Suppose value obtained from (_portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd)) < priceEurUsd in that case costInEuros will be 0.
Manually
In calculation of costInEuros first perform all multiplications and then division
uint256 costInEuros = (_portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd) * _hundredPC)/ uint256(priceEurUsd) / _collateralRate;
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.