Skip to content

Commit

Permalink
fix: Avoid moving funds if amount is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
bingen committed May 2, 2024
1 parent f1c59eb commit bfc773d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions contracts/src/TroveManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -867,9 +867,13 @@ contract TroveManager is ERC721, LiquityBase, Ownable, CheckContract, ITroveMana
uint256 _bold,
uint256 _ETH
) internal {
_defaultPool.decreaseBoldDebt(_bold);
_activePool.increaseRecordedDebtSum(_bold);
_defaultPool.sendETHToActivePool(_ETH);
if (_bold > 0) {
_defaultPool.decreaseBoldDebt(_bold);
_activePool.increaseRecordedDebtSum(_bold);
}
if (_ETH > 0) {
_defaultPool.sendETHToActivePool(_ETH);
}
}

// --- Redemption functions ---
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/test/redemptions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ contract Redemptions is DevTestSetup {
function testRedemptionIncludesAccruedTroveInterest() public {
(,, TroveIDs memory troveIDs) = _setupForRedemption();

(,, uint256 redistDebtGain_A,, uint256 accruedInterest_A) =
troveManager.getEntireDebtAndColl(troveIDs.A);
(,, uint256 redistDebtGain_A,, uint256 accruedInterest_A) = troveManager.getEntireDebtAndColl(troveIDs.A);
assertGt(accruedInterest_A, 0);
assertEq(redistDebtGain_A, 0);

Expand Down

0 comments on commit bfc773d

Please sign in to comment.