Skip to content

Commit

Permalink
fix: Add isControlledFacilitator to GhoBucketSteward (#429)
Browse files Browse the repository at this point in the history
* feat: Add isControlledFacilitator function

* fix: Remove isControlledFacilitator helper function
  • Loading branch information
CheyenneAtapour authored Oct 14, 2024
1 parent a8f654a commit 0a6fbd4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
5 changes: 5 additions & 0 deletions src/contracts/misc/GhoBucketSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ contract GhoBucketSteward is Ownable, RiskCouncilControlled, IGhoBucketSteward {
return _controlledFacilitators.values();
}

/// @inheritdoc IGhoBucketSteward
function isControlledFacilitator(address facilitator) external view returns (bool) {
return _controlledFacilitatorsByAddress[facilitator];
}

/// @inheritdoc IGhoBucketSteward
function getFacilitatorBucketCapacityTimelock(
address facilitator
Expand Down
7 changes: 7 additions & 0 deletions src/contracts/misc/interfaces/IGhoBucketSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ interface IGhoBucketSteward {
*/
function getControlledFacilitators() external view returns (address[] memory);

/**
* @notice Checks if a facilitator is controlled by this steward
* @param facilitator The facilitator address to check
* @return True if the facilitator is controlled by this steward
*/
function isControlledFacilitator(address facilitator) external view returns (bool);

/**
* @notice Returns timestamp of the facilitators last bucket capacity update
* @param facilitator The facilitator address
Expand Down
11 changes: 11 additions & 0 deletions src/test/TestGhoBucketSteward.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,15 @@ contract TestGhoBucketSteward is TestGhoBase {
newGsmList[0] = address(GHO_GSM_4626);
GHO_BUCKET_STEWARD.setControlledFacilitator(newGsmList, true);
}

function testIsControlledFacilitator() public {
address facilitator = makeAddr('FACILITATOR');
address[] memory controlledFacilitators = new address[](1);
controlledFacilitators[0] = facilitator;
vm.prank(SHORT_EXECUTOR);
GHO_BUCKET_STEWARD.setControlledFacilitator(controlledFacilitators, true);
assertTrue(GHO_BUCKET_STEWARD.isControlledFacilitator(facilitator));
address nonFacilitator = makeAddr('NON_FACILITATOR');
assertFalse(GHO_BUCKET_STEWARD.isControlledFacilitator(nonFacilitator));
}
}
14 changes: 2 additions & 12 deletions src/test/TestGhoStewardsForkEthereum.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ contract TestGhoStewardsForkEthereum is Test {
newGsmList[0] = gho_gsm_4626;
vm.prank(OWNER);
GHO_BUCKET_STEWARD.setControlledFacilitator(newGsmList, true);
assertTrue(_isControlledFacilitator(gho_gsm_4626));
assertTrue(GHO_BUCKET_STEWARD.isControlledFacilitator(gho_gsm_4626));
vm.prank(OWNER);
GHO_BUCKET_STEWARD.setControlledFacilitator(newGsmList, false);
assertFalse(_isControlledFacilitator(gho_gsm_4626));
assertFalse(GHO_BUCKET_STEWARD.isControlledFacilitator(gho_gsm_4626));
}

function testGhoCcipStewardUpdateBridgeLimit() public {
Expand Down Expand Up @@ -298,14 +298,4 @@ contract TestGhoStewardsForkEthereum is Test {
address rateStrategyAddress = POOL_DATA_PROVIDER.getInterestRateStrategyAddress(GHO_TOKEN);
return IDefaultInterestRateStrategyV2(rateStrategyAddress).getInterestRateDataBps(GHO_TOKEN);
}

function _isControlledFacilitator(address target) internal view returns (bool) {
address[] memory controlledFacilitators = GHO_BUCKET_STEWARD.getControlledFacilitators();
for (uint256 i = 0; i < controlledFacilitators.length; i++) {
if (controlledFacilitators[i] == target) {
return true;
}
}
return false;
}
}
14 changes: 2 additions & 12 deletions src/test/TestGhoStewardsForkRemote.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ contract TestGhoStewardsForkRemote is Test {
newGsmList[0] = gho_gsm_4626;
vm.prank(OWNER);
GHO_BUCKET_STEWARD.setControlledFacilitator(newGsmList, true);
assertTrue(_isControlledFacilitator(gho_gsm_4626));
assertTrue(GHO_BUCKET_STEWARD.isControlledFacilitator(gho_gsm_4626));
vm.prank(OWNER);
GHO_BUCKET_STEWARD.setControlledFacilitator(newGsmList, false);
assertFalse(_isControlledFacilitator(gho_gsm_4626));
assertFalse(GHO_BUCKET_STEWARD.isControlledFacilitator(gho_gsm_4626));
}

function testGhoCcipStewardUpdateRateLimit() public {
Expand Down Expand Up @@ -348,14 +348,4 @@ contract TestGhoStewardsForkRemote is Test {
address rateStrategyAddress = POOL_DATA_PROVIDER.getInterestRateStrategyAddress(GHO_TOKEN);
return IDefaultInterestRateStrategyV2(rateStrategyAddress).getInterestRateDataBps(GHO_TOKEN);
}

function _isControlledFacilitator(address target) internal view returns (bool) {
address[] memory controlledFacilitators = GHO_BUCKET_STEWARD.getControlledFacilitators();
for (uint256 i = 0; i < controlledFacilitators.length; i++) {
if (controlledFacilitators[i] == target) {
return true;
}
}
return false;
}
}

0 comments on commit 0a6fbd4

Please sign in to comment.