Skip to content

Commit

Permalink
return 0 target assets when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
hexonaut committed Mar 15, 2024
1 parent 0b6de36 commit a888da1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/plans/D3MOperatorPlan.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ contract D3MOperatorPlan is ID3MPlan {
}

function getTargetAssets(uint256) external override view returns (uint256) {
if (enabled == 0) return 0;

return targetAssets;
}

Expand Down
6 changes: 5 additions & 1 deletion src/tests/plans/D3MOperatorPlan.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ contract D3MOperatorPlanTest is D3MPlanBaseTest {
function test_implements_getTargetAssets() public {
_setupOperatorAndTargetAssets();

uint256 result = plan.getTargetAssets(123e18);
uint256 result = plan.getTargetAssets(123e18); // argument doesn't matter

assertEq(result, 100e18);
}
Expand All @@ -94,11 +94,15 @@ contract D3MOperatorPlanTest is D3MPlanBaseTest {

assertEq(plan.enabled(), 1);
assertTrue(plan.active());
assertEq(plan.getTargetAssets(0), 100e18);

vm.expectEmit(true, true, true, true);
emit Disable();
plan.disable();

assertTrue(!plan.active());
assertEq(plan.enabled(), 0);
assertEq(plan.getTargetAssets(0), 0); // returns 0 when disabled
}

}

0 comments on commit a888da1

Please sign in to comment.