Skip to content

Commit

Permalink
Merge pull request #395 from liquity/dedaub_l7
Browse files Browse the repository at this point in the history
Make claimAllCollGains revert for 0 gains
  • Loading branch information
RickGriff authored Aug 30, 2024
2 parents 73ac893 + 425ade1 commit 7d9c8e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/src/StabilityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ contract StabilityPool is LiquityBase, IStabilityPool, IStabilityPoolEvents {
activePool.mintAggInterest();

uint256 collToSend = stashedColl[msg.sender];
_requireNonZeroAmount(collToSend);
stashedColl[msg.sender] = 0;

emit DepositOperation(msg.sender, Operation.claimAllCollGains, 0, 0, 0, 0, 0, collToSend);
Expand Down
23 changes: 23 additions & 0 deletions contracts/src/test/stabilityPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,29 @@ contract SPTest is DevTestSetup {
vm.stopPrank();
}

function testClaimAllCollGainsRevertsWhenUserHasNoCollGains() public {
// A has stashed & current gains, B has only current
_setupStashedAndCurrentCollGains();

// B
uint256 compoundedDeposit_B = stabilityPool.getCompoundedBoldDeposit(B);
assertGt(compoundedDeposit_B, 0);

// B withdraws deposit and tries to withdraw stashed coll gains
vm.startPrank(B);
stabilityPool.withdrawFromSP(compoundedDeposit_B, true);
assertEq(stabilityPool.getCompoundedBoldDeposit(B), 0);
vm.expectRevert("StabilityPool: Amount must be non-zero");
stabilityPool.claimAllCollGains();
vm.stopPrank();

//As does C, who never had a deposit
vm.startPrank(C);
vm.expectRevert("StabilityPool: Amount must be non-zero");
stabilityPool.claimAllCollGains();
vm.stopPrank();
}

function testClaimAllCollGainsDoesNotChangeCompoundedDeposit() public {
// A has stashed & current gains, B has only current
_setupStashedAndCurrentCollGains();
Expand Down

0 comments on commit 7d9c8e6

Please sign in to comment.