There is a division before multiplication bug in _accrueInterest() method of Lendgine.sol which may result in loss of interest being accrued due to huge precision loss. There is same error in invariant method of Pair.sol as well which can cause larger Precision Loss.
As in the above 2 cases, Division is taking place before multiplication. In Lendgine, timeElapsed is multiplied on the result of a division while in Pair, token0Scale and token1Scale are multiplied on the result of a division. This causes Incorrect calculation which can lead to the protocol functioning incorrectly.
Tools Used
Manual Review
Recommended Mitigation Steps
Consider multiplying all the numerators first before dividing.
Lines of code
https://github.com/code-423n4/2023-01-numoen/blob/main/src/core/Lendgine.sol#L252 https://github.com/code-423n4/2023-01-numoen/blob/main/src/core/Pair.sol#L56-L57
Vulnerability details
Impact
There is a division before multiplication bug in
_accrueInterest()
method ofLendgine.sol
which may result in loss of interest being accrued due to huge precision loss. There is same error ininvariant
method ofPair.sol
as well which can cause larger Precision Loss.Proof of Concept
Link to Code
Link to Code
As in the above 2 cases, Division is taking place before multiplication. In
Lendgine
,timeElapsed
is multiplied on the result of a division while inPair
,token0Scale
andtoken1Scale
are multiplied on the result of a division. This causes Incorrect calculation which can lead to the protocol functioning incorrectly.Tools Used
Manual Review
Recommended Mitigation Steps
Consider multiplying all the numerators first before dividing.
Mitigated code:
Link to Code
Link to Code