Skip to content

Commit

Permalink
fix: no receivables update in extension
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrusowsky committed Sep 16, 2023
1 parent d8d08e7 commit e95d313
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/Clearinghouse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,8 @@ contract Clearinghouse is Policy, RolesConsumer, CoolerCallback {
// Ensure Clearinghouse is the lender.
if (loan.lender != address(this)) revert NotLender();

// Calculate extension interest based on remaining principal.
uint256 interestBase = interestForLoan(loan.principal, loan.request.duration);
if (loan.interestDue != interestBase) {
// If interest has manually been repaid, receivables need to be updated
interestReceivables += interestBase - loan.interestDue;
}

// Transfer in extension interest from the caller.
dai.transferFrom(msg.sender, loan.recipient, interestBase * times_);

Expand Down
2 changes: 1 addition & 1 deletion src/test/Clearinghouse.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ contract ClearinghouseTest is Test {
assertEq(extendedLoan.collateral, repaidLoan.collateral, "collateral");
assertEq(extendedLoan.expiry, repaidLoan.expiry + repaidLoan.request.duration * times_, "expiry");
// Check: clearinghouse storage
assertEq(clearinghouse.interestReceivables(), initInterest + initLoan.interestDue - repaidLoan.interestDue);
assertEq(clearinghouse.interestReceivables(), initInterest);
assertEq(clearinghouse.principalReceivables(), initPrincipal);
}

Expand Down

0 comments on commit e95d313

Please sign in to comment.