Skip to content

Commit

Permalink
Merge pull request #147 from liquity/return_early_movePendingTroveRew…
Browse files Browse the repository at this point in the history
…ardsToActivePool

fix: Avoid moving funds if amount is zero
  • Loading branch information
bingen committed May 3, 2024
2 parents a42bb35 + bfc773d commit c9d0011
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 @@ -729,9 +729,13 @@ contract TroveManager is ERC721, LiquityBase, Ownable, ITroveManager {
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 @@ -110,8 +110,7 @@ contract Redemptions is DevTestSetup {
// Fast-forward to generate interest
vm.warp(block.timestamp + 1 days);

(,, 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 c9d0011

Please sign in to comment.