Governor_v1.sol
Inherits: ERC165Upgradeable, IGovernor_v1, AccessControlUpgradeable
Author: Inverter Network
This contract manages various administrative functions that can be executed only by specified multisig addresses. It supports upgrades to {IInverterBeacon_v1} contracts through role-based permissions, enabling a timelocked upgrade process and emergency procedures.
Inherits from {ERC165Upgradeable} for interface detection, {AccessControlUpgradeable} for role-based access control, and implements the {IGovernor_v1} interface for governance functionalities, i.e. setting the fee manager, setting the timelock, upgrading the beacons and exposing the emergency shutdown.
State Variables
COMMUNITY_MULTISIG_ROLE
Role of the community multisig.
TEAM_MULTISIG_ROLE
Role of the team multisig.
feeManager
{FeeManager_v1} contract.
moduleFactory
{ModuleFactory_v1} contract.
linkedBeacons
Array of {IInverterBeacon_v1}s that are linked to this {Governor_v1}, populated via moduleFactoryInitCallback
.
timelockPeriod
Length of each timelock.
beaconTimelock
Struct to store timelock information for each {IInverterBeacon_v1}.
__gap
Storage gap for future upgrades.
Functions
supportsInterface
See {IERC165-supportsInterface}.
onlyLinkedModuleFactory
Modifier to guarantee function is only callable by the linked {ModuleFactory_v1}.
linkedBeaconsEmpty
Modifier to guarantee linked {IInverterBeacon_v1}s are not empty.
validAddress
Modifier to guarantee the given address is valid.
validTimelockPeriod
Modifier to guarantee the given timelock period is valid.
accessibleBeacon
Modifier to guarantee the given {IInverterBeacon_v1} is accessible.
onlyCommunityOrTeamMultisig
Modifier to guarantee only the community or team multisig can call the function.
upgradeProcessAlreadyStarted
Modifier to check if the upgrade process for the given {IInverterBeacon_v1} is already started.
timelockPeriodExceeded
Modifier to check if the timelock period for the given {IInverterBeacon_v1} is exceeded.
constructor
init
The module's initializer function.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the community multisig. |
|
| The address of the team multisig. |
|
| The timelock period needed to upgrade a {IInverterBeacon_v1}. |
|
| The address of the initial {FeeManager_v1}. |
|
| The address of the initial {ModuleFactory_v1}. |
moduleFactoryInitCallback
Callback function that is called by {ModuleFactory_v1} during initialization.
Parameters
Name | Type | Description |
---|---|---|
|
| The array of {IInverterBeacon_v1}s that will be registered. |
getBeaconTimelock
Returns the current timelock of a {IInverterBeacon_v1} address.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the {IInverterBeacon_v1}. |
Returns
Name | Type | Description |
---|---|---|
|
| The timelock of the {IInverterBeacon_v1} address. |
getLinkedBeacons
Returns the list of currently linked {IInverterBeacon_v1}s.
Returns
Name | Type | Description |
---|---|---|
|
| LinkedBeacons The array of {IInverterBeacon_v1}s that are currently linked to the {Governor_v1}. |
getFeeManager
Returns the {FeeManager_v1} address.
Returns
Name | Type | Description |
---|---|---|
|
| Address of the {FeeManager_v1}. |
setFeeManager
Sets the address of the {FeeManager_v1}.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the new {FeeManager_v1}. |
getModuleFactory
Returns the {ModuleFactory_v1} address.
Returns
Name | Type | Description |
---|---|---|
|
| Address of the {ModuleFactory_v1}. |
setModuleFactory
Sets the address of the {ModuleFactory_v1}.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the new {ModuleFactory_v1}. |
setFeeManagerMaxFee
Sets the maximum fee percentage that can be assigned in the linked {FeeManager_v1}.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The max Fee in relation to the BPS. |
setFeeManagerDefaultProtocolTreasury
Sets the default protocol treasury address in the linked {FeeManager_v1}.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the default protocol treasury. |
setFeeManagerWorkflowTreasuries
Sets the protocol treasury address for a specific workflow in the linked {FeeManager_v1}.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the workflow. |
|
| The address of the protocol treasury for that specific workflow. |
setFeeManagerDefaultCollateralFee
Sets the default collateral fee of the protocol in the linked {FeeManager_v1}.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The default collateral fee of the protocol in relation to the BPS. |
setFeeManagerDefaultIssuanceFee
Sets the default issuance fee of the protocol in the linked {FeeManager_v1}.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The default issuance fee of the protocol in relation to the BPS. |
setFeeManagerCollateralWorkflowFee
Sets the collateral fee for a specific workflow module function in the linked {FeeManager_v1}.
Can only be accessed by either the COMMUNITY_MULTISIG_ROLE
or the TEAM_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the workflow that contains the module function. |
|
| The address of the module that contains the function. |
|
| The function selector of the target function. |
|
| Boolean that determines if the fee is actually used or not. |
|
| The collateral fee in relation to the BPS. |
setFeeManagerIssuanceWorkflowFee
Sets the issuance fee for a specific workflow module function in the linked {FeeManager_v1}.
Can only be accessed by either the COMMUNITY_MULTISIG_ROLE
or the TEAM_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the workflow that contains the module function. |
|
| The address of the module that contains the function. |
|
| The function selector of the target function. |
|
| Boolean that determines if the fee is actually used or not. |
|
| The issuance fee in relation to the BPS. |
registerMetadataInModuleFactory
Registers a {IInverterBeacon_v1} with the provided metadata
in the target {ModuleFactory_v1}.
Can only be accessed by either the COMMUNITY_MULTISIG_ROLE
or the TEAM_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The metadata that will be registered. |
|
| The {IInverterBeacon_v1} that will be registered. |
upgradeBeaconWithTimelock
Starts the upgrade process of a {IInverterBeacon_v1} by creating a timelock period after which the {IInverterBeacon_v1} can be upgraded via triggerUpgradeBeaconWithTimelock()
.
This function will override previous timelocks even if they are active.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the {IInverterBeacon_v1} that is intended to be upgraded. |
|
| The address of the intended new Implementation of the {IInverterBeacon_v1}. |
|
| The intended new minor version of the {IInverterBeacon_v1}. |
|
| The intended new patch version of the {IInverterBeacon_v1}. |
triggerUpgradeBeaconWithTimelock
Upgrades a {IInverterBeacon_v1} with the data provided by the active timelock.
Can only be accessed by either the COMMUNITY_MULTISIG_ROLE
or the TEAM_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the {IInverterBeacon_v1} that is intended to be upgraded. |
cancelUpgrade
Cancels an upgrade of {IInverterBeacon_v1} by setting the active timelock to inactive.
Can only be accessed by either the COMMUNITY_MULTISIG_ROLE
or the TEAM_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the {IInverterBeacon_v1} for which the timelock should be canceled. |
setTimelockPeriod
Sets the timelock period of a {IInverterBeacon_v1} upgrade process.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
|
initiateBeaconShutdown
Initiates the shutdown of a {IInverterBeacon_v1}.
Can only be accessed by either the COMMUNITY_MULTISIG_ROLE
or the TEAM_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the {IInverterBeacon_v1} that should be shut down. |
initiateBeaconShutdownForAllLinkedBeacons
Initiates the shutdown of all linked {IInverterBeacon_v1}s.
Can only be accessed by either the COMMUNITY_MULTISIG_ROLE
or the TEAM_MULTISIG_ROLE
.
forceUpgradeBeaconAndRestartImplementation
This function forces the upgrade of a beacon and restarts the implementation afterwards.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the {IInverterBeacon_v1} that is intended to be upgraded and restarted. |
|
| The address of the intended new Implementation of the {IInverterBeacon_v1}. |
|
| The intended new minor version of the {IInverterBeacon_v1}. |
|
| The intended new patch version of the {IInverterBeacon_v1}. |
restartBeaconImplementation
Restarts the {IInverterBeacon_v1} implementation.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the {IInverterBeacon_v1} that should restarted. |
acceptOwnership
Accepts the ownership over the target address.
Can only be accessed by the COMMUNITY_MULTISIG_ROLE
or TEAM_MULTISIG_ROLE
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of target that wants to hand over the ownership. |
_setFeeManager
sets the internal {FeeManager_v1} address.
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the new {FeeManager_v1}. |
_setTimelockPeriod
sets the internal timelock period.
Parameters
Name | Type | Description |
---|---|---|
|
| the new timelock period. |
_setModuleFactory
sets the internal {ModuleFactory_v1} address.
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the new {ModuleFactory_v1}. |
_isBeaconAccessible
Internal function that checks if target address is a {IInverterBeacon_v1} and this contract has the ownership of it.
Last updated