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 the deployerCoordinatorManager role to the HyperdriveFactory #1022

Merged
merged 2 commits into from
May 13, 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
38 changes: 34 additions & 4 deletions contracts/src/factory/HyperdriveFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ contract HyperdriveFactory is IHyperdriveFactory {
/// received. Defaults to `RECEIVE_LOCKED`
uint256 private receiveLockState = RECEIVE_LOCKED;

/// @notice The governance address that updates the factory's configuration.
/// @notice The governance address that updates the factory's configuration
/// and can add or remove deployer coordinators.
address public governance;

/// @notice The deployer coordinator manager that can add or remove deployer
/// coordinators.
address public deployerCoordinatorManager;

/// @notice The governance address used when new instances are deployed.
address public hyperdriveGovernance;

Expand Down Expand Up @@ -105,6 +110,8 @@ contract HyperdriveFactory is IHyperdriveFactory {
struct FactoryConfig {
/// @dev The address which can update a factory.
address governance;
/// @dev The address which can add and remove deployer coordinators.
address deployerCoordinatorManager;
/// @dev The address which is set as the governor of hyperdrive.
address hyperdriveGovernance;
/// @dev The default addresses which will be set to have the pauser role.
Expand Down Expand Up @@ -304,6 +311,7 @@ contract HyperdriveFactory is IHyperdriveFactory {

// Initialize the other parameters.
governance = _factoryConfig.governance;
deployerCoordinatorManager = _factoryConfig.deployerCoordinatorManager;
hyperdriveGovernance = _factoryConfig.hyperdriveGovernance;
feeCollector = _factoryConfig.feeCollector;
sweepCollector = _factoryConfig.sweepCollector;
Expand All @@ -322,6 +330,17 @@ contract HyperdriveFactory is IHyperdriveFactory {
_;
}

/// @dev Ensure that the sender is either the governance address or the
/// deployer coordinator manager.
modifier onlyDeployerCoordinatorManager() {
if (
msg.sender != governance && msg.sender != deployerCoordinatorManager
) {
revert IHyperdriveFactory.Unauthorized();
}
_;
}

/// @notice Allows ether to be sent to the contract. This is gated by a lock
/// to prevent ether from becoming stuck in the contract.
receive() external payable {
Expand All @@ -337,7 +356,18 @@ contract HyperdriveFactory is IHyperdriveFactory {
emit GovernanceUpdated(_governance);
}

/// @notice Allows governance to change the hyperdrive governance address
/// @notice Allows governance to change the deployer coordinator manager
/// address.
/// @param _deployerCoordinatorManager The new deployer coordinator manager
/// address.
function updateDeployerCoordinatorManager(
address _deployerCoordinatorManager
) external onlyGovernance {
deployerCoordinatorManager = _deployerCoordinatorManager;
emit DeployerCoordinatorManagerUpdated(_deployerCoordinatorManager);
}

/// @notice Allows governance to change the hyperdrive governance address.
/// @param _hyperdriveGovernance The new hyperdrive governance address.
function updateHyperdriveGovernance(
address _hyperdriveGovernance
Expand Down Expand Up @@ -648,7 +678,7 @@ contract HyperdriveFactory is IHyperdriveFactory {
/// @param _deployerCoordinator The new deployer coordinator.
function addDeployerCoordinator(
address _deployerCoordinator
) external onlyGovernance {
) external onlyDeployerCoordinatorManager {
if (isDeployerCoordinator[_deployerCoordinator]) {
revert IHyperdriveFactory.DeployerCoordinatorAlreadyAdded();
}
Expand All @@ -663,7 +693,7 @@ contract HyperdriveFactory is IHyperdriveFactory {
function removeDeployerCoordinator(
address _deployerCoordinator,
uint256 _index
) external onlyGovernance {
) external onlyDeployerCoordinatorManager {
if (!isDeployerCoordinator[_deployerCoordinator]) {
revert IHyperdriveFactory.DeployerCoordinatorNotAdded();
}
Expand Down
5 changes: 5 additions & 0 deletions contracts/src/interfaces/IHyperdriveFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ interface IHyperdriveFactory {
/// @notice Emitted when the factory's governance is updated.
event GovernanceUpdated(address indexed governance);

/// @notice Emitted when the deployer coordinator manager is updated.
event DeployerCoordinatorManagerUpdated(
address indexed deployerCoordinatorManager
);

/// @notice Emitted when the governance address used in new deployments is
/// updated.
event HyperdriveGovernanceUpdated(address indexed hyperdriveGovernance);
Expand Down
1 change: 1 addition & 0 deletions test/instances/erc4626/ERC4626Hyperdrive.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ contract ERC4626HyperdriveTest is HyperdriveTest {
factory = new HyperdriveFactory(
HyperdriveFactory.FactoryConfig({
governance: alice,
deployerCoordinatorManager: celine,
hyperdriveGovernance: bob,
feeCollector: feeCollector,
sweepCollector: sweepCollector,
Expand Down
1 change: 1 addition & 0 deletions test/instances/erc4626/ERC4626Validation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abstract contract ERC4626ValidationTest is HyperdriveTest {
factory = new HyperdriveFactory(
HyperdriveFactory.FactoryConfig({
governance: alice,
deployerCoordinatorManager: celine,
hyperdriveGovernance: bob,
feeCollector: feeCollector,
sweepCollector: sweepCollector,
Expand Down
1 change: 1 addition & 0 deletions test/instances/erc4626/UsdcERC4626.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ contract UsdcERC4626 is ERC4626ValidationTest {
factory = new HyperdriveFactory(
HyperdriveFactory.FactoryConfig({
governance: alice,
deployerCoordinatorManager: celine,
hyperdriveGovernance: bob,
feeCollector: feeCollector,
sweepCollector: sweepCollector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ contract ERC4626DeployerCoordinatorTest is DeployerCoordinatorTest {
new HyperdriveFactory(
HyperdriveFactory.FactoryConfig({
governance: alice,
deployerCoordinatorManager: celine,
hyperdriveGovernance: bob,
feeCollector: feeCollector,
sweepCollector: sweepCollector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ contract RethDeployerCoordinatorTest is DeployerCoordinatorTest {
new HyperdriveFactory(
HyperdriveFactory.FactoryConfig({
governance: alice,
deployerCoordinatorManager: celine,
hyperdriveGovernance: bob,
feeCollector: feeCollector,
sweepCollector: sweepCollector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ contract StethDeployerCoordinatorTest is DeployerCoordinatorTest {
new HyperdriveFactory(
HyperdriveFactory.FactoryConfig({
governance: alice,
deployerCoordinatorManager: celine,
hyperdriveGovernance: bob,
feeCollector: feeCollector,
sweepCollector: sweepCollector,
Expand Down
Loading
Loading