From b0d60a9d8cd99239c9d443a8b289ff7239401913 Mon Sep 17 00:00:00 2001 From: CheyenneAtapour Date: Tue, 30 Jul 2024 11:11:38 -0700 Subject: [PATCH] fix: rename bucket capacity manager --- ...nager.sol => GhoBucketCapacitySteward.sol} | 20 +- src/contracts/misc/GhoGsmSteward.sol | 2 +- ...ager.sol => IGhoBucketCapacitySteward.sol} | 6 +- src/test/TestBucketCapacityManager.t.sol | 181 ------------------ src/test/TestGhoBase.t.sol | 30 +-- ...sol => TestGhoBucketCapacitySteward.t.sol} | 66 +++---- src/test/TestGhoCcipStewardArbitrum.t.sol | 104 ---------- src/test/helpers/Constants.sol | 2 +- 8 files changed, 54 insertions(+), 357 deletions(-) rename src/contracts/misc/{BucketCapacityManager.sol => GhoBucketCapacitySteward.sol} (87%) rename src/contracts/misc/interfaces/{IBucketCapacityManager.sol => IGhoBucketCapacitySteward.sol} (93%) delete mode 100644 src/test/TestBucketCapacityManager.t.sol rename src/test/{TestBucketCapacityManagerArbitrum.t.sol => TestGhoBucketCapacitySteward.t.sol} (72%) delete mode 100644 src/test/TestGhoCcipStewardArbitrum.t.sol diff --git a/src/contracts/misc/BucketCapacityManager.sol b/src/contracts/misc/GhoBucketCapacitySteward.sol similarity index 87% rename from src/contracts/misc/BucketCapacityManager.sol rename to src/contracts/misc/GhoBucketCapacitySteward.sol index 030cfd0c..758b8877 100644 --- a/src/contracts/misc/BucketCapacityManager.sol +++ b/src/contracts/misc/GhoBucketCapacitySteward.sol @@ -5,25 +5,25 @@ import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; import {IGhoToken} from '../gho/interfaces/IGhoToken.sol'; import {RiskCouncilControlled} from './RiskCouncilControlled.sol'; -import {IBucketCapacityManager} from './interfaces/IBucketCapacityManager.sol'; +import {IGhoBucketCapacitySteward} from './interfaces/IGhoBucketCapacitySteward.sol'; /** - * @title BucketCapacityManager + * @title GhoBucketCapacitySteward * @author Aave Labs * @notice Helper contract for managing bucket capacities of controlled facilitators * @dev Only the Risk Council is able to action contract's functions, based on specific conditions that have been agreed upon with the community. * @dev Requires GHO_TOKEN_BUCKET_MANAGER_ROLE on GhoToken */ -contract BucketCapacityManager is Ownable, RiskCouncilControlled, IBucketCapacityManager { +contract GhoBucketCapacitySteward is Ownable, RiskCouncilControlled, IGhoBucketCapacitySteward { using EnumerableSet for EnumerableSet.AddressSet; - /// @inheritdoc IBucketCapacityManager + /// @inheritdoc IGhoBucketCapacitySteward uint256 public constant MINIMUM_DELAY = 2 days; - /// @inheritdoc IBucketCapacityManager + /// @inheritdoc IGhoBucketCapacitySteward address public immutable GHO_TOKEN; - /// @inheritdoc IBucketCapacityManager + /// @inheritdoc IGhoBucketCapacitySteward function RISK_COUNCIL() public view override returns (address) { return COUNCIL; } @@ -60,7 +60,7 @@ contract BucketCapacityManager is Ownable, RiskCouncilControlled, IBucketCapacit _transferOwnership(owner); } - /// @inheritdoc IBucketCapacityManager + /// @inheritdoc IGhoBucketCapacitySteward function updateFacilitatorBucketCapacity( address facilitator, uint128 newBucketCapacity @@ -77,7 +77,7 @@ contract BucketCapacityManager is Ownable, RiskCouncilControlled, IBucketCapacit IGhoToken(GHO_TOKEN).setFacilitatorBucketCapacity(facilitator, newBucketCapacity); } - /// @inheritdoc IBucketCapacityManager + /// @inheritdoc IGhoBucketCapacitySteward function setControlledFacilitator( address[] memory facilitatorList, bool approve @@ -92,12 +92,12 @@ contract BucketCapacityManager is Ownable, RiskCouncilControlled, IBucketCapacit } } - /// @inheritdoc IBucketCapacityManager + /// @inheritdoc IGhoBucketCapacitySteward function getControlledFacilitators() external view returns (address[] memory) { return _controlledFacilitators.values(); } - /// @inheritdoc IBucketCapacityManager + /// @inheritdoc IGhoBucketCapacitySteward function getFacilitatorBucketCapacityTimelock( address facilitator ) external view returns (uint40) { diff --git a/src/contracts/misc/GhoGsmSteward.sol b/src/contracts/misc/GhoGsmSteward.sol index 8bb48489..4d150d98 100644 --- a/src/contracts/misc/GhoGsmSteward.sol +++ b/src/contracts/misc/GhoGsmSteward.sol @@ -14,7 +14,7 @@ import {RiskCouncilControlled} from './RiskCouncilControlled.sol'; * @author Aave Labs * @notice Helper contract for managing parameters of the GSM * @dev Only the Risk Council is able to action contract's functions, based on specific conditions that have been agreed upon with the community. - * @dev Requires role GSM_CONFIGURATOR_ROLE on the GhoGsm contract and CONFIGURATOR on every GSM asset to be managed + * @dev Requires role GSM_CONFIGURATOR_ROLE on every GSM contract to be managed */ contract GhoGsmSteward is Ownable, RiskCouncilControlled, IGhoGsmSteward { using EnumerableSet for EnumerableSet.AddressSet; diff --git a/src/contracts/misc/interfaces/IBucketCapacityManager.sol b/src/contracts/misc/interfaces/IGhoBucketCapacitySteward.sol similarity index 93% rename from src/contracts/misc/interfaces/IBucketCapacityManager.sol rename to src/contracts/misc/interfaces/IGhoBucketCapacitySteward.sol index 3b572583..b6d3af69 100644 --- a/src/contracts/misc/interfaces/IBucketCapacityManager.sol +++ b/src/contracts/misc/interfaces/IGhoBucketCapacitySteward.sol @@ -2,11 +2,11 @@ pragma solidity ^0.8.10; /** - * @title IBucketCapacityManager + * @title IGhoBucketCapacitySteward * @author Aave Labs - * @notice Defines the basic interface of the BucketCapacityManager + * @notice Defines the basic interface of the GhoBucketCapacitySteward */ -interface IBucketCapacityManager { +interface IGhoBucketCapacitySteward { /** * @notice Adds/Removes controlled facilitators * @dev Only callable by owner diff --git a/src/test/TestBucketCapacityManager.t.sol b/src/test/TestBucketCapacityManager.t.sol deleted file mode 100644 index 92ccc391..00000000 --- a/src/test/TestBucketCapacityManager.t.sol +++ /dev/null @@ -1,181 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import './TestGhoBase.t.sol'; - -contract TestBucketCapacityManager is TestGhoBase { - function setUp() public { - /// @dev Since block.timestamp starts at 0 this is a necessary condition (block.timestamp > `MINIMUM_DELAY`) for the timelocked contract methods to work. - vm.warp(BUCKET_CAPACITY_MANAGER.MINIMUM_DELAY() + 1); - - // Grant roles - GHO_TOKEN.grantRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(BUCKET_CAPACITY_MANAGER)); - } - - function testConstructor() public { - assertEq(BUCKET_CAPACITY_MANAGER.owner(), SHORT_EXECUTOR); - assertEq(BUCKET_CAPACITY_MANAGER.GHO_TOKEN(), address(GHO_TOKEN)); - assertEq(BUCKET_CAPACITY_MANAGER.RISK_COUNCIL(), RISK_COUNCIL); - - address[] memory controlledFacilitators = BUCKET_CAPACITY_MANAGER.getControlledFacilitators(); - assertEq(controlledFacilitators.length, 2); - - uint40 facilitatorTimelock = BUCKET_CAPACITY_MANAGER.getFacilitatorBucketCapacityTimelock( - controlledFacilitators[0] - ); - assertEq(facilitatorTimelock, 0); - } - - function testRevertConstructorInvalidExecutor() public { - vm.expectRevert('INVALID_OWNER'); - new BucketCapacityManager(address(0), address(0x002), address(0x003)); - } - - function testRevertConstructorInvalidGhoToken() public { - vm.expectRevert('INVALID_GHO_TOKEN'); - new BucketCapacityManager(address(0x001), address(0), address(0x003)); - } - - function testRevertConstructorInvalidRiskCouncil() public { - vm.expectRevert('INVALID_RISK_COUNCIL'); - new BucketCapacityManager(address(0x001), address(0x002), address(0)); - } - - function testUpdateFacilitatorBucketCapacity() public { - (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - vm.prank(RISK_COUNCIL); - uint128 newBucketCapacity = uint128(currentBucketCapacity) + 1; - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity(address(GHO_ATOKEN), newBucketCapacity); - (uint256 capacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - assertEq(newBucketCapacity, capacity); - } - - function testUpdateFacilitatorBucketCapacityMaxValue() public { - (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - uint128 newBucketCapacity = uint128(currentBucketCapacity * 2); - vm.prank(RISK_COUNCIL); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity(address(GHO_ATOKEN), newBucketCapacity); - (uint256 capacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - assertEq(capacity, newBucketCapacity); - } - - function testUpdateFacilitatorBucketCapacityTimelock() public { - (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - vm.prank(RISK_COUNCIL); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( - address(GHO_ATOKEN), - uint128(currentBucketCapacity) + 1 - ); - uint40 timelock = BUCKET_CAPACITY_MANAGER.getFacilitatorBucketCapacityTimelock( - address(GHO_ATOKEN) - ); - assertEq(timelock, block.timestamp); - } - - function testUpdateFacilitatorBucketCapacityAfterTimelock() public { - (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - vm.prank(RISK_COUNCIL); - uint128 newBucketCapacity = uint128(currentBucketCapacity) + 1; - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity(address(GHO_ATOKEN), newBucketCapacity); - skip(BUCKET_CAPACITY_MANAGER.MINIMUM_DELAY() + 1); - uint128 newBucketCapacityAfterTimelock = newBucketCapacity + 1; - vm.prank(RISK_COUNCIL); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( - address(GHO_ATOKEN), - newBucketCapacityAfterTimelock - ); - (uint256 capacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - assertEq(capacity, newBucketCapacityAfterTimelock); - } - - function testRevertUpdateFacilitatorBucketCapacityIfUnauthorized() public { - vm.expectRevert('INVALID_CALLER'); - vm.prank(ALICE); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity(address(GHO_ATOKEN), 123); - } - - function testRevertUpdateFaciltatorBucketCapacityIfUpdatedTooSoon() public { - (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - vm.prank(RISK_COUNCIL); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( - address(GHO_ATOKEN), - uint128(currentBucketCapacity) + 1 - ); - vm.prank(RISK_COUNCIL); - vm.expectRevert('DEBOUNCE_NOT_RESPECTED'); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( - address(GHO_ATOKEN), - uint128(currentBucketCapacity) + 2 - ); - } - - function testRevertUpdateFacilitatorBucketCapacityIfFacilitatorNotInControl() public { - (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_GSM_4626)); - vm.prank(RISK_COUNCIL); - vm.expectRevert('FACILITATOR_NOT_CONTROLLED'); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( - address(GHO_GSM_4626), - uint128(currentBucketCapacity) + 1 - ); - } - - function testRevertUpdateFacilitatorBucketCapacityIfStewardLostBucketManagerRole() public { - (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - GHO_TOKEN.revokeRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(BUCKET_CAPACITY_MANAGER)); - vm.expectRevert( - AccessControlErrorsLib.MISSING_ROLE( - GHO_TOKEN_BUCKET_MANAGER_ROLE, - address(BUCKET_CAPACITY_MANAGER) - ) - ); - vm.prank(RISK_COUNCIL); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( - address(GHO_ATOKEN), - uint128(currentBucketCapacity) + 1 - ); - } - - function testRevertUpdateFacilitatorBucketCapacityIfMoreThanDouble() public { - (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - vm.prank(RISK_COUNCIL); - vm.expectRevert('INVALID_BUCKET_CAPACITY_UPDATE'); - BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( - address(GHO_ATOKEN), - uint128(currentBucketCapacity * 2) + 1 - ); - } - - function testSetControlledFacilitatorAdd() public { - address[] memory oldControlledFacilitators = BUCKET_CAPACITY_MANAGER - .getControlledFacilitators(); - address[] memory newGsmList = new address[](1); - newGsmList[0] = address(GHO_GSM_4626); - vm.prank(SHORT_EXECUTOR); - BUCKET_CAPACITY_MANAGER.setControlledFacilitator(newGsmList, true); - address[] memory newControlledFacilitators = BUCKET_CAPACITY_MANAGER - .getControlledFacilitators(); - assertEq(newControlledFacilitators.length, oldControlledFacilitators.length + 1); - assertTrue(_contains(newControlledFacilitators, address(GHO_GSM_4626))); - } - - function testSetControlledFacilitatorsRemove() public { - address[] memory oldControlledFacilitators = BUCKET_CAPACITY_MANAGER - .getControlledFacilitators(); - address[] memory disableGsmList = new address[](1); - disableGsmList[0] = address(GHO_GSM); - vm.prank(SHORT_EXECUTOR); - BUCKET_CAPACITY_MANAGER.setControlledFacilitator(disableGsmList, false); - address[] memory newControlledFacilitators = BUCKET_CAPACITY_MANAGER - .getControlledFacilitators(); - assertEq(newControlledFacilitators.length, oldControlledFacilitators.length - 1); - assertFalse(_contains(newControlledFacilitators, address(GHO_GSM))); - } - - function testRevertSetControlledFacilitatorIfUnauthorized() public { - vm.expectRevert(OwnableErrorsLib.CALLER_NOT_OWNER()); - vm.prank(RISK_COUNCIL); - address[] memory newGsmList = new address[](1); - newGsmList[0] = address(GHO_GSM_4626); - BUCKET_CAPACITY_MANAGER.setControlledFacilitator(newGsmList, true); - } -} diff --git a/src/test/TestGhoBase.t.sol b/src/test/TestGhoBase.t.sol index 9805d109..f047bee3 100644 --- a/src/test/TestGhoBase.t.sol +++ b/src/test/TestGhoBase.t.sol @@ -88,7 +88,7 @@ import {UpgradeableBurnMintTokenPool} from '../contracts/misc/deps/Dependencies. import {RateLimiter} from '../contracts/misc/deps/Dependencies.sol'; import {IGhoCcipSteward} from '../contracts/misc/interfaces/IGhoCcipSteward.sol'; import {GhoCcipSteward} from '../contracts/misc/GhoCcipSteward.sol'; -import {BucketCapacityManager} from '../contracts/misc/BucketCapacityManager.sol'; +import {GhoBucketCapacitySteward} from '../contracts/misc/GhoBucketCapacitySteward.sol'; contract TestGhoBase is Test, Constants, Events { using WadRayMath for uint256; @@ -140,8 +140,8 @@ contract TestGhoBase is Test, Constants, Events { GhoCcipSteward GHO_CCIP_STEWARD; GhoGsmSteward GHO_GSM_STEWARD; GhoCcipSteward ARB_GHO_CCIP_STEWARD; - BucketCapacityManager BUCKET_CAPACITY_MANAGER; - BucketCapacityManager ARB_BUCKET_CAPACITY_MANAGER; + GhoBucketCapacitySteward GHO_BUCKET_CAPACITY_STEWARD; + GhoBucketCapacitySteward ARB_GHO_BUCKET_CAPACITY_STEWARD; FixedRateStrategyFactory FIXED_RATE_STRATEGY_FACTORY; UpgradeableLockReleaseTokenPool GHO_TOKEN_POOL; @@ -365,8 +365,8 @@ contract TestGhoBase is Test, Constants, Events { // Deploy Gho GSM Steward GHO_GSM_STEWARD = new GhoGsmSteward(SHORT_EXECUTOR, RISK_COUNCIL); - // Deploy Bucket Capacity Manager - BUCKET_CAPACITY_MANAGER = new BucketCapacityManager( + // Deploy Gho Bucket Capacity Steward + GHO_BUCKET_CAPACITY_STEWARD = new GhoBucketCapacitySteward( SHORT_EXECUTOR, address(GHO_TOKEN), RISK_COUNCIL @@ -375,7 +375,7 @@ contract TestGhoBase is Test, Constants, Events { controlledFacilitators[0] = address(GHO_ATOKEN); controlledFacilitators[1] = address(GHO_GSM); vm.prank(SHORT_EXECUTOR); - BUCKET_CAPACITY_MANAGER.setControlledFacilitator(controlledFacilitators, true); + GHO_BUCKET_CAPACITY_STEWARD.setControlledFacilitator(controlledFacilitators, true); // Setup GHO Token Pool uint64 SOURCE_CHAIN_SELECTOR = 1; @@ -418,24 +418,6 @@ contract TestGhoBase is Test, Constants, Events { // Setup Arb GHO Token Pool vm.prank(OWNER); ARB_GHO_TOKEN_POOL.applyChainUpdates(chainUpdate); - - // Deploy Arb Gho CCIP Steward - ARB_GHO_CCIP_STEWARD = new GhoCcipSteward( - SHORT_EXECUTOR, - address(GHO_TOKEN), - address(ARB_GHO_TOKEN_POOL), - RISK_COUNCIL, - true - ); - - // Deploy Arb Bucket Capacity Manager - ARB_BUCKET_CAPACITY_MANAGER = new BucketCapacityManager( - SHORT_EXECUTOR, - address(GHO_TOKEN), - RISK_COUNCIL - ); - vm.prank(SHORT_EXECUTOR); - ARB_BUCKET_CAPACITY_MANAGER.setControlledFacilitator(controlledFacilitators, true); } function getOutboundRateLimiterConfig() public pure returns (RateLimiter.Config memory) { diff --git a/src/test/TestBucketCapacityManagerArbitrum.t.sol b/src/test/TestGhoBucketCapacitySteward.t.sol similarity index 72% rename from src/test/TestBucketCapacityManagerArbitrum.t.sol rename to src/test/TestGhoBucketCapacitySteward.t.sol index f28f46b8..9e6b68af 100644 --- a/src/test/TestBucketCapacityManagerArbitrum.t.sol +++ b/src/test/TestGhoBucketCapacitySteward.t.sol @@ -3,25 +3,25 @@ pragma solidity ^0.8.0; import './TestGhoBase.t.sol'; -contract TestBucketCapacityManagerArbitrum is TestGhoBase { +contract TestGhoBucketCapacitySteward is TestGhoBase { function setUp() public { /// @dev Since block.timestamp starts at 0 this is a necessary condition (block.timestamp > `MINIMUM_DELAY`) for the timelocked contract methods to work. - vm.warp(ARB_BUCKET_CAPACITY_MANAGER.MINIMUM_DELAY() + 1); + vm.warp(GHO_BUCKET_CAPACITY_STEWARD.MINIMUM_DELAY() + 1); // Grant roles - GHO_TOKEN.grantRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(ARB_BUCKET_CAPACITY_MANAGER)); + GHO_TOKEN.grantRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(GHO_BUCKET_CAPACITY_STEWARD)); } function testConstructor() public { - assertEq(ARB_BUCKET_CAPACITY_MANAGER.owner(), SHORT_EXECUTOR); - assertEq(ARB_BUCKET_CAPACITY_MANAGER.GHO_TOKEN(), address(GHO_TOKEN)); - assertEq(ARB_BUCKET_CAPACITY_MANAGER.RISK_COUNCIL(), RISK_COUNCIL); + assertEq(GHO_BUCKET_CAPACITY_STEWARD.owner(), SHORT_EXECUTOR); + assertEq(GHO_BUCKET_CAPACITY_STEWARD.GHO_TOKEN(), address(GHO_TOKEN)); + assertEq(GHO_BUCKET_CAPACITY_STEWARD.RISK_COUNCIL(), RISK_COUNCIL); - address[] memory controlledFacilitators = ARB_BUCKET_CAPACITY_MANAGER + address[] memory controlledFacilitators = GHO_BUCKET_CAPACITY_STEWARD .getControlledFacilitators(); assertEq(controlledFacilitators.length, 2); - uint40 facilitatorTimelock = ARB_BUCKET_CAPACITY_MANAGER.getFacilitatorBucketCapacityTimelock( + uint40 facilitatorTimelock = GHO_BUCKET_CAPACITY_STEWARD.getFacilitatorBucketCapacityTimelock( controlledFacilitators[0] ); assertEq(facilitatorTimelock, 0); @@ -29,24 +29,24 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { function testRevertConstructorInvalidExecutor() public { vm.expectRevert('INVALID_OWNER'); - new BucketCapacityManager(address(0), address(0x002), address(0x003)); + new GhoBucketCapacitySteward(address(0), address(0x002), address(0x003)); } function testRevertConstructorInvalidGhoToken() public { vm.expectRevert('INVALID_GHO_TOKEN'); - new BucketCapacityManager(address(0x001), address(0), address(0x003)); + new GhoBucketCapacitySteward(address(0x001), address(0), address(0x003)); } function testRevertConstructorInvalidRiskCouncil() public { vm.expectRevert('INVALID_RISK_COUNCIL'); - new BucketCapacityManager(address(0x001), address(0x002), address(0)); + new GhoBucketCapacitySteward(address(0x001), address(0x002), address(0)); } function testUpdateFacilitatorBucketCapacity() public { (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); vm.prank(RISK_COUNCIL); uint128 newBucketCapacity = uint128(currentBucketCapacity) + 1; - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), newBucketCapacity ); @@ -58,7 +58,7 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); uint128 newBucketCapacity = uint128(currentBucketCapacity * 2); vm.prank(RISK_COUNCIL); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), newBucketCapacity ); @@ -69,11 +69,11 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { function testUpdateFacilitatorBucketCapacityTimelock() public { (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); vm.prank(RISK_COUNCIL); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), uint128(currentBucketCapacity) + 1 ); - uint40 timelock = ARB_BUCKET_CAPACITY_MANAGER.getFacilitatorBucketCapacityTimelock( + uint40 timelock = GHO_BUCKET_CAPACITY_STEWARD.getFacilitatorBucketCapacityTimelock( address(GHO_ATOKEN) ); assertEq(timelock, block.timestamp); @@ -83,14 +83,14 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); vm.prank(RISK_COUNCIL); uint128 newBucketCapacity = uint128(currentBucketCapacity) + 1; - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), newBucketCapacity ); - skip(ARB_BUCKET_CAPACITY_MANAGER.MINIMUM_DELAY() + 1); + skip(GHO_BUCKET_CAPACITY_STEWARD.MINIMUM_DELAY() + 1); uint128 newBucketCapacityAfterTimelock = newBucketCapacity + 1; vm.prank(RISK_COUNCIL); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), newBucketCapacityAfterTimelock ); @@ -101,19 +101,19 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { function testRevertUpdateFacilitatorBucketCapacityIfUnauthorized() public { vm.expectRevert('INVALID_CALLER'); vm.prank(ALICE); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity(address(GHO_ATOKEN), 123); + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity(address(GHO_ATOKEN), 123); } function testRevertUpdateFaciltatorBucketCapacityIfUpdatedTooSoon() public { (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); vm.prank(RISK_COUNCIL); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), uint128(currentBucketCapacity) + 1 ); vm.prank(RISK_COUNCIL); vm.expectRevert('DEBOUNCE_NOT_RESPECTED'); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), uint128(currentBucketCapacity) + 2 ); @@ -123,7 +123,7 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_GSM_4626)); vm.prank(RISK_COUNCIL); vm.expectRevert('FACILITATOR_NOT_CONTROLLED'); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_GSM_4626), uint128(currentBucketCapacity) + 1 ); @@ -131,15 +131,15 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { function testRevertUpdateFacilitatorBucketCapacityIfStewardLostBucketManagerRole() public { (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); - GHO_TOKEN.revokeRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(ARB_BUCKET_CAPACITY_MANAGER)); + GHO_TOKEN.revokeRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(GHO_BUCKET_CAPACITY_STEWARD)); vm.expectRevert( AccessControlErrorsLib.MISSING_ROLE( GHO_TOKEN_BUCKET_MANAGER_ROLE, - address(ARB_BUCKET_CAPACITY_MANAGER) + address(GHO_BUCKET_CAPACITY_STEWARD) ) ); vm.prank(RISK_COUNCIL); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), uint128(currentBucketCapacity) + 1 ); @@ -149,33 +149,33 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { (uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN)); vm.prank(RISK_COUNCIL); vm.expectRevert('INVALID_BUCKET_CAPACITY_UPDATE'); - ARB_BUCKET_CAPACITY_MANAGER.updateFacilitatorBucketCapacity( + GHO_BUCKET_CAPACITY_STEWARD.updateFacilitatorBucketCapacity( address(GHO_ATOKEN), uint128(currentBucketCapacity * 2) + 1 ); } function testSetControlledFacilitatorAdd() public { - address[] memory oldControlledFacilitators = ARB_BUCKET_CAPACITY_MANAGER + address[] memory oldControlledFacilitators = GHO_BUCKET_CAPACITY_STEWARD .getControlledFacilitators(); address[] memory newGsmList = new address[](1); newGsmList[0] = address(GHO_GSM_4626); vm.prank(SHORT_EXECUTOR); - ARB_BUCKET_CAPACITY_MANAGER.setControlledFacilitator(newGsmList, true); - address[] memory newControlledFacilitators = ARB_BUCKET_CAPACITY_MANAGER + GHO_BUCKET_CAPACITY_STEWARD.setControlledFacilitator(newGsmList, true); + address[] memory newControlledFacilitators = GHO_BUCKET_CAPACITY_STEWARD .getControlledFacilitators(); assertEq(newControlledFacilitators.length, oldControlledFacilitators.length + 1); assertTrue(_contains(newControlledFacilitators, address(GHO_GSM_4626))); } function testSetControlledFacilitatorsRemove() public { - address[] memory oldControlledFacilitators = ARB_BUCKET_CAPACITY_MANAGER + address[] memory oldControlledFacilitators = GHO_BUCKET_CAPACITY_STEWARD .getControlledFacilitators(); address[] memory disableGsmList = new address[](1); disableGsmList[0] = address(GHO_GSM); vm.prank(SHORT_EXECUTOR); - ARB_BUCKET_CAPACITY_MANAGER.setControlledFacilitator(disableGsmList, false); - address[] memory newControlledFacilitators = ARB_BUCKET_CAPACITY_MANAGER + GHO_BUCKET_CAPACITY_STEWARD.setControlledFacilitator(disableGsmList, false); + address[] memory newControlledFacilitators = GHO_BUCKET_CAPACITY_STEWARD .getControlledFacilitators(); assertEq(newControlledFacilitators.length, oldControlledFacilitators.length - 1); assertFalse(_contains(newControlledFacilitators, address(GHO_GSM))); @@ -186,6 +186,6 @@ contract TestBucketCapacityManagerArbitrum is TestGhoBase { vm.prank(RISK_COUNCIL); address[] memory newGsmList = new address[](1); newGsmList[0] = address(GHO_GSM_4626); - ARB_BUCKET_CAPACITY_MANAGER.setControlledFacilitator(newGsmList, true); + GHO_BUCKET_CAPACITY_STEWARD.setControlledFacilitator(newGsmList, true); } } diff --git a/src/test/TestGhoCcipStewardArbitrum.t.sol b/src/test/TestGhoCcipStewardArbitrum.t.sol deleted file mode 100644 index 59fd39ab..00000000 --- a/src/test/TestGhoCcipStewardArbitrum.t.sol +++ /dev/null @@ -1,104 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import './TestGhoBase.t.sol'; -import {IGhoCcipSteward} from '../contracts/misc/interfaces/IGhoCcipSteward.sol'; -import {RateLimiter} from 'src/contracts/misc/deps/Dependencies.sol'; - -contract TestGhoCcipStewardArbitrum is TestGhoBase { - RateLimiter.Config rateLimitConfig = - RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15}); - - event ChainConfigured( - uint64 remoteChainSelector, - RateLimiter.Config outboundRateLimiterConfig, - RateLimiter.Config inboundRateLimiterConfig - ); - function setUp() public { - /// @dev Since block.timestamp starts at 0 this is a necessary condition (block.timestamp > `MINIMUM_DELAY`) for the timelocked contract methods to work. - vm.warp(ARB_GHO_CCIP_STEWARD.MINIMUM_DELAY() + 1); - - // Grant required roles - vm.prank(ARB_GHO_TOKEN_POOL.owner()); - ARB_GHO_TOKEN_POOL.setRateLimitAdmin(address(ARB_GHO_CCIP_STEWARD)); - } - - function testConstructor() public { - assertEq(ARB_GHO_CCIP_STEWARD.MINIMUM_DELAY(), MINIMUM_DELAY_V2); - - assertEq(ARB_GHO_CCIP_STEWARD.owner(), SHORT_EXECUTOR); - assertEq(ARB_GHO_CCIP_STEWARD.GHO_TOKEN(), address(GHO_TOKEN)); - assertEq(ARB_GHO_CCIP_STEWARD.GHO_TOKEN_POOL(), address(ARB_GHO_TOKEN_POOL)); - assertEq(ARB_GHO_CCIP_STEWARD.RISK_COUNCIL(), RISK_COUNCIL); - } - function testUpdateRateLimit() public { - vm.expectEmit(false, false, false, true); - emit ChainConfigured( - 2, - RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15}), - RateLimiter.Config({isEnabled: true, capacity: type(uint128).max, rate: 1e15}) - ); - vm.prank(RISK_COUNCIL); - ARB_GHO_CCIP_STEWARD.updateRateLimit( - 2, - rateLimitConfig.isEnabled, - rateLimitConfig.capacity, - rateLimitConfig.rate, - rateLimitConfig.isEnabled, - rateLimitConfig.capacity, - rateLimitConfig.rate - ); - } - - function testRevertUpdateRateLimitIfUnauthorized() public { - vm.prank(ALICE); - vm.expectRevert('INVALID_CALLER'); - ARB_GHO_CCIP_STEWARD.updateRateLimit( - 2, - rateLimitConfig.isEnabled, - rateLimitConfig.capacity, - rateLimitConfig.rate, - rateLimitConfig.isEnabled, - rateLimitConfig.capacity, - rateLimitConfig.rate - ); - } - - function testRevertUpdateRateLimitToZero() public { - RateLimiter.Config memory invalidConfig = RateLimiter.Config({ - isEnabled: true, - capacity: 0, - rate: 0 - }); - vm.prank(RISK_COUNCIL); - vm.expectRevert(); - ARB_GHO_CCIP_STEWARD.updateRateLimit( - 2, - invalidConfig.isEnabled, - invalidConfig.capacity, - invalidConfig.rate, - rateLimitConfig.isEnabled, - rateLimitConfig.capacity, - rateLimitConfig.rate - ); - } - - function testRevertUpdateRateLimitRateGreaterThanCapacity() public { - RateLimiter.Config memory invalidConfig = RateLimiter.Config({ - isEnabled: true, - capacity: 10, - rate: 100 - }); - vm.prank(RISK_COUNCIL); - vm.expectRevert(); - ARB_GHO_CCIP_STEWARD.updateRateLimit( - 2, - invalidConfig.isEnabled, - invalidConfig.capacity, - invalidConfig.rate, - rateLimitConfig.isEnabled, - rateLimitConfig.capacity, - rateLimitConfig.rate - ); - } -} diff --git a/src/test/helpers/Constants.sol b/src/test/helpers/Constants.sol index 30201f5e..79ff304d 100644 --- a/src/test/helpers/Constants.sol +++ b/src/test/helpers/Constants.sol @@ -54,7 +54,7 @@ contract Constants { uint256 constant BORROW_RATE_CHANGE_MAX = 0.01e4; uint40 constant STEWARD_LIFESPAN = 90 days; - // Stewards + // Gho Stewards uint256 constant GHO_BORROW_RATE_CHANGE_MAX = 0.0500e27; uint256 constant GSM_FEE_RATE_CHANGE_MAX = 0.0050e4; uint256 constant GHO_BORROW_RATE_MAX = 0.2500e27;