From 5f92f09058763e1769e1e61c03bc64f27d6f1cdb Mon Sep 17 00:00:00 2001 From: CheyenneAtapour Date: Mon, 14 Oct 2024 19:56:54 +0100 Subject: [PATCH] feat: Add isControlledFacilitator function --- src/contracts/misc/GhoBucketSteward.sol | 5 +++++ src/contracts/misc/interfaces/IGhoBucketSteward.sol | 7 +++++++ src/test/TestGhoBucketSteward.t.sol | 11 +++++++++++ 3 files changed, 23 insertions(+) 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)); + } }