Skip to content

Commit

Permalink
test: deploy new stewards
Browse files Browse the repository at this point in the history
  • Loading branch information
CheyenneAtapour committed Jul 25, 2024
1 parent c5298a1 commit ab18643
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/contracts/misc/GhoGsmSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.10;

import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';
import {FixedFeeStrategy} from '../facilitators/gsm/feeStrategy/FixedFeeStrategy.sol';
import {IGsm} from '../facilitators/gsm/interfaces/IGsm.sol';
import {IGsmFeeStrategy} from '../facilitators/gsm/feeStrategy/interfaces/IGsmFeeStrategy.sol';
import {IGhoGsmSteward} from './interfaces/IGhoGsmSteward.sol';
Expand All @@ -28,6 +29,7 @@ contract GhoGsmSteward is Ownable, IGhoGsmSteward, RiskCouncilControlled {

mapping(address => GsmDebounce) internal _gsmTimelocksByAddress;

mapping(uint256 => mapping(uint256 => address)) internal _gsmFeeStrategiesByRates;
EnumerableSet.AddressSet internal _gsmFeeStrategies;

/**
Expand Down Expand Up @@ -90,6 +92,18 @@ contract GhoGsmSteward is Ownable, IGhoGsmSteward, RiskCouncilControlled {
_isDifferenceLowerThanMax(currentSellFee, sellFee, GSM_FEE_RATE_CHANGE_MAX),
'INVALID_SELL_FEE_UPDATE'
);

address cachedStrategyAddress = _gsmFeeStrategiesByRates[buyFee][sellFee];
if (cachedStrategyAddress == address(0)) {
FixedFeeStrategy newRateStrategy = new FixedFeeStrategy(buyFee, sellFee);
cachedStrategyAddress = address(newRateStrategy);
_gsmFeeStrategiesByRates[buyFee][sellFee] = cachedStrategyAddress;
_gsmFeeStrategies.add(cachedStrategyAddress);
}

_gsmTimelocksByAddress[gsm].gsmFeeStrategyLastUpdated = uint40(block.timestamp);

IGsm(gsm).updateFeeStrategy(cachedStrategyAddress);
}

/**
Expand Down
37 changes: 37 additions & 0 deletions src/test/TestGhoBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ import {IGhoSteward} from '../contracts/misc/interfaces/IGhoSteward.sol';
import {IGhoStewardV2} from '../contracts/misc/interfaces/IGhoStewardV2.sol';
import {IArbGhoSteward} from '../contracts/misc/interfaces/IArbGhoSteward.sol';
import {ArbGhoSteward} from '../contracts/misc/ArbGhoSteward.sol';
import {IGhoAaveSteward} from '../contracts/misc/interfaces/IGhoAaveSteward.sol';
import {GhoAaveSteward} from '../contracts/misc/GhoAaveSteward.sol';
import {IGhoCcipSteward} from '../contracts/misc/interfaces/IGhoCcipSteward.sol';
import {GhoCcipSteward} from '../contracts/misc/GhoCcipSteward.sol';
import {IGhoGsmSteward} from '../contracts/misc/interfaces/IGhoGsmSteward.sol';
import {GhoGsmSteward} from '../contracts/misc/GhoGsmSteward.sol';
import {GhoOracle} from '../contracts/facilitators/aave/oracle/GhoOracle.sol';
import {GhoStableDebtToken} from '../contracts/facilitators/aave/tokens/GhoStableDebtToken.sol';
import {GhoToken} from '../contracts/gho/GhoToken.sol';
Expand Down Expand Up @@ -135,6 +141,9 @@ contract TestGhoBase is Test, Constants, Events {
GhoSteward GHO_STEWARD;
GhoStewardV2 GHO_STEWARD_V2;
ArbGhoSteward ARB_GHO_STEWARD;
GhoAaveSteward GHO_AAVE_STEWARD;
GhoCcipSteward GHO_CCIP_STEWARD;
GhoGsmSteward GHO_GSM_STEWARD;

FixedRateStrategyFactory FIXED_RATE_STRATEGY_FACTORY;
UpgradeableLockReleaseTokenPool GHO_TOKEN_POOL;
Expand Down Expand Up @@ -337,6 +346,34 @@ contract TestGhoBase is Test, Constants, Events {
UpgradeableLockReleaseTokenPool(address(tokenPoolProxy)).acceptOwnership();
GHO_TOKEN_POOL = UpgradeableLockReleaseTokenPool(address(tokenPoolProxy));

// New stewards:
// Deploy Gho Aave Steward
GHO_AAVE_STEWARD = new GhoAaveSteward(
SHORT_EXECUTOR,
address(PROVIDER),
address(GHO_TOKEN),
address(FIXED_RATE_STRATEGY_FACTORY),
RISK_COUNCIL
);
// TODO: Confirm required roles
GHO_TOKEN.grantRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(GHO_AAVE_STEWARD));

// Deploy Gho CCIP Steward
GHO_CCIP_STEWARD = new GhoCcipSteward(
SHORT_EXECUTOR,
address(GHO_TOKEN),
address(GHO_TOKEN_POOL),
RISK_COUNCIL
);
vm.prank(OWNER);
GHO_TOKEN_POOL.setRateLimitAdmin(address(GHO_CCIP_STEWARD));
GHO_TOKEN.grantRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(GHO_CCIP_STEWARD));

// Deploy Gho GSM Steward
GHO_GSM_STEWARD = new GhoGsmSteward(SHORT_EXECUTOR, RISK_COUNCIL);
GHO_GSM.grantRole(GSM_CONFIGURATOR_ROLE, address(GHO_GSM_STEWARD));

// TODO: Remove the old stewards after finalizing tests
// Deploy Steward V2
GHO_STEWARD_V2 = new GhoStewardV2(
SHORT_EXECUTOR,
Expand Down

0 comments on commit ab18643

Please sign in to comment.