diff --git a/src/contracts/misc/GhoBucketSteward.sol b/src/contracts/misc/GhoBucketSteward.sol index 4c764bc6..0d136ace 100644 --- a/src/contracts/misc/GhoBucketSteward.sol +++ b/src/contracts/misc/GhoBucketSteward.sol @@ -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 diff --git a/src/contracts/misc/interfaces/IGhoBucketSteward.sol b/src/contracts/misc/interfaces/IGhoBucketSteward.sol index 1dba429b..19dae0c7 100644 --- a/src/contracts/misc/interfaces/IGhoBucketSteward.sol +++ b/src/contracts/misc/interfaces/IGhoBucketSteward.sol @@ -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 diff --git a/src/test/TestGhoBucketSteward.t.sol b/src/test/TestGhoBucketSteward.t.sol index 89e3641e..28ceb0b9 100644 --- a/src/test/TestGhoBucketSteward.t.sol +++ b/src/test/TestGhoBucketSteward.t.sol @@ -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)); + } } diff --git a/src/test/TestGhoStewardsForkEthereum.t.sol b/src/test/TestGhoStewardsForkEthereum.t.sol index ea0b7726..62079fd7 100644 --- a/src/test/TestGhoStewardsForkEthereum.t.sol +++ b/src/test/TestGhoStewardsForkEthereum.t.sol @@ -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 { @@ -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; - } } diff --git a/src/test/TestGhoStewardsForkRemote.t.sol b/src/test/TestGhoStewardsForkRemote.t.sol index ccfae8df..c58f81c8 100644 --- a/src/test/TestGhoStewardsForkRemote.t.sol +++ b/src/test/TestGhoStewardsForkRemote.t.sol @@ -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 { @@ -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; - } }