Skip to content

Commit 4157544

Browse files
committed
feat: ejectImplant to support disallowing self-eject with threshold reduction
1 parent 34d9a19 commit 4157544

File tree

10 files changed

+20
-9
lines changed

10 files changed

+20
-9
lines changed

scripts/yearnBorg.s.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ contract YearnBorgDeployScript is Script {
119119
address(ychadSafe),
120120
address(new PlaceholderFailSafeImplant()), // Placeholder because Yearn BORG does not use failSafe
121121
true, // _allowManagement
122-
true // _allowEjection
122+
true, // _allowEjection
123+
false // _allowSelfEjectReduce
123124
);
124125
sudo = new sudoImplant(
125126
implantAuth,

src/implants/ejectImplant.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ contract ejectImplant is BaseImplant {
2222
address public immutable FAIL_SAFE;
2323
bool public immutable ALLOW_AUTH_MANAGEMENT;
2424
bool public immutable ALLOW_AUTH_EJECT;
25+
bool public immutable ALLOW_AUTH_SELF_EJECT_REDUCE;
2526
uint256 public failSafeSignerThreshold;
2627

2728
// Errors and Events
@@ -40,12 +41,13 @@ contract ejectImplant is BaseImplant {
4041

4142
/// @param _auth initialize authorization parameters for this contract, including applicable conditions
4243
/// @param _borgSafe address of the applicable BORG's Gnosis Safe which is adding this ejectImplant
43-
constructor(BorgAuth _auth, address _borgSafe, address _failSafe, bool _allowManagement, bool _allowEjection) BaseImplant(_auth, _borgSafe) {
44+
constructor(BorgAuth _auth, address _borgSafe, address _failSafe, bool _allowManagement, bool _allowEjection, bool _allowSelfEjectReduce) BaseImplant(_auth, _borgSafe) {
4445
if (IBaseImplant(_failSafe).IMPLANT_ID() != 0)
4546
revert ejectImplant_InvalidFailSafeImplant();
4647
FAIL_SAFE = _failSafe;
4748
ALLOW_AUTH_MANAGEMENT = _allowManagement;
4849
ALLOW_AUTH_EJECT = _allowEjection;
50+
ALLOW_AUTH_SELF_EJECT_REDUCE = _allowSelfEjectReduce;
4951
}
5052

5153
/// @notice setFailSafeSignerThreshold for the DAO or oversight BORG to set the maximum threshold for the fail safe to be triggered
@@ -193,6 +195,7 @@ contract ejectImplant is BaseImplant {
193195
/// @param _reduce boolean to reduce the threshold if the owner is the last to self-eject
194196
function selfEject(bool _reduce) public conditionCheck {
195197
if (!ISafe(BORG_SAFE).isOwner(msg.sender)) revert ejectImplant_NotOwner();
198+
if(_reduce && !ALLOW_AUTH_SELF_EJECT_REDUCE) revert ejectImplant_ActionNotEnabled();
196199

197200
address[] memory owners = ISafe(BORG_SAFE).getOwners();
198201
address prevOwner = address(0x1);

test/PBVBorg.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ contract PBVBorgTest is Test {
6060
safe = IGnosisSafe(MULTISIG);
6161
core = new borgCore(auth, 0x1, borgCore.borgModes.whitelist, 'pbv-borg-testing', address(safe));
6262
failSafe = new failSafeImplant(auth, address(safe), dao);
63-
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true);
63+
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true, true);
6464

6565

6666
//for test: give out some tokens

test/blackList.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ contract BlackListTest is Test {
5050
mockPerm = new MockPerm();
5151

5252
failSafe = new failSafeImplant(auth, address(safe), dao);
53-
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true);
53+
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true, true);
5454

5555
deal(owner, 2 ether);
5656
deal(MULTISIG, 2 ether);

test/borgCore.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ contract BorgCoreTest is Test {
4848
core = new borgCore(auth, 0x1, borgCore.borgModes.whitelist, 'borg-core-testing', address(safe));
4949

5050
failSafe = new failSafeImplant(auth, address(safe), dao);
51-
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true);
51+
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true, true);
5252

5353
deal(owner, 2 ether);
5454
deal(MULTISIG, 2 ether);

test/ejectImplant.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ contract EjectTest is Test {
4949
core = new borgCore(auth, 0x1, borgCore.borgModes.whitelist, "eject-testing", address(safe));
5050

5151
failSafe = new failSafeImplant(auth, address(safe), dao);
52-
eject = new ejectImplant(auth, MULTISIG, address(failSafe), true, true);
52+
eject = new ejectImplant(auth, MULTISIG, address(failSafe), true, true, true);
5353
vm.prank(dao);
5454
auth.updateRole(address(eject), 99);
5555

test/grantBorg.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ contract GrantBorgTest is Test {
9797
safe = IGnosisSafe(MULTISIG);
9898
core = new borgCore(auth, 0x1, borgCore.borgModes.whitelist, 'grant-bool-testing', address(safe));
9999
failSafe = new failSafeImplant(auth, address(safe), dao);
100-
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true);
100+
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true, true);
101101
opGrant = new optimisticGrantImplant(auth, MULTISIG, address(metaVesTController));
102102
//constructor(Auth _auth, address _borgSafe, uint256 _duration, uint _quorum, uint256 _threshold, uint _cooldown, address _governanceAdapter, address _governanceExecutor, address _metaVesT, address _metaVesTController)
103103
vetoGrant = new daoVetoGrantImplant(auth, MULTISIG, 600, 5, 10, 600, address(governanceAdapter), address(mockDao), address(metaVesTController));

test/signatureCondition.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ contract SigConditionTest is Test {
6969
safe = IGnosisSafe(MULTISIG);
7070
core = new borgCore(auth, 0x1, borgCore.borgModes.whitelist, 'sig-condition-testing', address(safe));
7171
failSafe = new failSafeImplant(auth, address(safe), dao);
72-
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true);
72+
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true, true);
7373

7474
//create SignatureCondition.Logic for and
7575
SignatureCondition.Logic logic = SignatureCondition.Logic.AND;

test/voteBorg.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ contract VoteBorgTest is Test {
101101
safe = IGnosisSafe(MULTISIG);
102102
core = new borgCore(auth, 0x1, borgCore.borgModes.whitelist, 'grant-bool-testing', address(safe));
103103
failSafe = new failSafeImplant(auth, address(safe), dao);
104-
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true);
104+
eject = new ejectImplant(auth, MULTISIG, address(failSafe), false, true, true);
105105
opGrant = new optimisticGrantImplant(auth, MULTISIG, address(metaVesTController));
106106
//constructor(Auth _auth, address _borgSafe, uint256 _duration, uint _quorum, uint256 _threshold, uint _cooldown, address _governanceAdapter, address _governanceExecutor, address _metaVesT, address _metaVesTController)
107107
vetoGrant = new daoVetoGrantImplant(auth, MULTISIG, 600, 5, 10, 600, address(governanceAdapter), address(mockDao), address(metaVesTController));

test/yearnBorgAcceptance.t.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ contract YearnBorgAcceptanceTest is Test {
164164
assertEq(eject.failSafeSignerThreshold(), 0, "Unexpected failSafeSignerThreshold");
165165
assertTrue(eject.ALLOW_AUTH_MANAGEMENT(), "Auth management should be allowed");
166166
assertTrue(eject.ALLOW_AUTH_EJECT(), "Auth ejection should be allowed");
167+
assertFalse(eject.ALLOW_AUTH_SELF_EJECT_REDUCE(), "Auth self-eject with reduce should not be allowed");
167168
}
168169

169170
/// @dev Safe normal operations should be unrestricted
@@ -190,6 +191,12 @@ contract YearnBorgAcceptanceTest is Test {
190191
// Self-resign without changing threshold
191192
uint256 thresholdBefore = ychadSafe.getThreshold();
192193

194+
// Self-resign with threshold reduce should not be allowed
195+
vm.expectRevert(abi.encodeWithSelector(ejectImplant.ejectImplant_ActionNotEnabled.selector));
196+
vm.prank(testSigner);
197+
eject.selfEject(true);
198+
199+
// Otherwise, it should pass
193200
vm.prank(testSigner);
194201
eject.selfEject(false);
195202

0 commit comments

Comments
 (0)