Open code423n4 opened 2 years ago
@LilYeti: This is intended behavior, and acts the same in Liquity. https://github.com/liquity/dev/blob/main/packages/contracts/contracts/StabilityPool.sol#L661-L678
The sponsor acknowledged the issue, since it is not stated how the loss of precision is better than the alternative.
Handle
certora
Vulnerability details
Impact
In
StabilityPool
line 747 you multiply a sum of two parameters but since the second parameter is calculated through division it can cause lack of precision since the order of the operations is div()->mul() instead of mul()->div()Tools Used
Manual code review
Recommended Mitigation Steps
dont divide
secondPortion
bySCALE_FACTOR
, instead multiply thefirstPortion
bySCALE_FACTOR
and after you multiply their sum byinitialDeposit
, divide the result bySCALE_FACTOR
. like this:original:
changed: