Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isControlledFacilitator to GhoBucketSteward #429

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading