Skip to content

Commit

Permalink
fix: requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CheyenneAtapour committed Aug 23, 2024
1 parent 747468c commit d3d9802
Showing 1 changed file with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {IDefaultInterestRateStrategyV2} from '../contracts/misc/dependencies/Aav
import {MockPool} from './mocks/MockPool.sol';
import {MockUpgradeableLockReleaseTokenPool} from './mocks/MockUpgradeableLockReleaseTokenPool.sol';

contract TestGhoStewards is Test {
contract TestGhoStewardsForkEthMainnet is Test {
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;

address public OWNER = makeAddr('OWNER');
Expand Down Expand Up @@ -103,7 +103,7 @@ contract TestGhoStewards is Test {
vm.stopPrank();
}

function testSetup() public {
function testStewardsPermissions() public {
assertEq(
IAccessControl(ACL_MANAGER).hasRole(
IACLManager(ACL_MANAGER).RISK_ADMIN_ROLE(),
Expand Down Expand Up @@ -161,12 +161,15 @@ contract TestGhoStewards is Test {
IDefaultInterestRateStrategyV2.InterestRateData memory currentRates = _getGhoBorrowRates();
vm.prank(RISK_COUNCIL);
GHO_AAVE_STEWARD.updateGhoBorrowRate(
currentRates.optimalUsageRatio,
currentRates.optimalUsageRatio - 1,
currentRates.baseVariableBorrowRate + 1,
currentRates.variableRateSlope1,
currentRates.variableRateSlope2
currentRates.variableRateSlope1 + 1,
currentRates.variableRateSlope2 + 1
);
assertEq(_getGhoBorrowRate(), currentRates.baseVariableBorrowRate + 1);
assertEq(_getOptimalUsageRatio(), currentRates.optimalUsageRatio - 1);
assertEq(_getBaseVariableBorrowRate(), currentRates.baseVariableBorrowRate + 1);
assertEq(_getVariableRateSlope1(), currentRates.variableRateSlope1 + 1);
assertEq(_getVariableRateSlope2(), currentRates.variableRateSlope2 + 1);
}

function testGhoBucketStewardUpdateFacilitatorBucketCapacity() public {
Expand All @@ -180,16 +183,16 @@ contract TestGhoStewards is Test {
assertEq(newBucketCapacity, capacity);
}

function testGhoBucketStewardSetControlledFacilitatorAdd() public {
address[] memory oldControlledFacilitators = GHO_BUCKET_STEWARD.getControlledFacilitators();
function testGhoBucketStewardSetControlledFacilitator() public {
address[] memory newGsmList = new address[](1);
address gho_gsm_4626 = makeAddr('gho_gsm_4626');
newGsmList[0] = gho_gsm_4626;
vm.prank(OWNER);
GHO_BUCKET_STEWARD.setControlledFacilitator(newGsmList, true);
address[] memory newControlledFacilitators = GHO_BUCKET_STEWARD.getControlledFacilitators();
assertEq(newControlledFacilitators.length, oldControlledFacilitators.length + 1);
assertTrue(_contains(newControlledFacilitators, gho_gsm_4626));
assertTrue(_isControlledFacilitator(gho_gsm_4626));
vm.prank(OWNER);
GHO_BUCKET_STEWARD.setControlledFacilitator(newGsmList, false);
assertFalse(_isControlledFacilitator(gho_gsm_4626));
}

function testGhoCcipStewardUpdateBridgeLimit() public {
Expand Down Expand Up @@ -269,11 +272,26 @@ contract TestGhoStewards is Test {
return configuration.getSupplyCap();
}

function _getGhoBorrowRate() internal view returns (uint32) {
function _getOptimalUsageRatio() internal view returns (uint16) {
IDefaultInterestRateStrategyV2.InterestRateData memory currentRates = _getGhoBorrowRates();
return currentRates.optimalUsageRatio;
}

function _getBaseVariableBorrowRate() internal view returns (uint32) {
IDefaultInterestRateStrategyV2.InterestRateData memory currentRates = _getGhoBorrowRates();
return currentRates.baseVariableBorrowRate;
}

function _getVariableRateSlope1() internal view returns (uint32) {
IDefaultInterestRateStrategyV2.InterestRateData memory currentRates = _getGhoBorrowRates();
return currentRates.variableRateSlope1;
}

function _getVariableRateSlope2() internal view returns (uint32) {
IDefaultInterestRateStrategyV2.InterestRateData memory currentRates = _getGhoBorrowRates();
return currentRates.variableRateSlope2;
}

function _getGhoBorrowRates()
internal
view
Expand All @@ -284,9 +302,10 @@ contract TestGhoStewards is Test {
return IDefaultInterestRateStrategyV2(rateStrategyAddress).getInterestRateDataBps(GHO_TOKEN);
}

function _contains(address[] memory list, address item) internal pure returns (bool) {
for (uint256 i = 0; i < list.length; i++) {
if (list[i] == item) {
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;
}
}
Expand Down

0 comments on commit d3d9802

Please sign in to comment.