Closed sherlock-admin3 closed 2 months ago
Invalid, computations are correct, the full amountDue is added to totalPrincipalTokensRepaid
since the whole loan is closed when liquidateDefaultedLoanWithIncentive
is called and so there is no outstanding loans.
MaslarovK.eth
high
Wrong accounting in the
LenderCommitmentGroup_Smart::liquidateDefaultedLoanWithIncentive
Summary
Wrong accounting in the
LenderCommitmentGroup_Smart::liquidateDefaultedLoanWithIncentive
when totalPrincipalTokensRepaid is increased.Vulnerability Detail
There is a problem in the
LenderCommitmentGroup_Smart::liquidateDefaultedLoanWithIncentive
when _tokenAmountDifference <= 0 (or with other words - in the else statement).The amount being transfered is
amountDue - tokensToGiveToSender
but when the
totalPrincipalTokensRepaid
is increased, it is increased with the wholeamountDue
:Impact
This will lead to wrong accounting and mess up the calculations based on this variable:
Code Snippet
https://github.com/sherlock-audit/2024-04-teller-finance/blob/main/teller-protocol-v2-audit-2024/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol#L422-L472
Tool used
Manual Review
Recommendation
Implement the following change: