RoleManager.sol
Inherits: Governance2Step
State Variables
name
bytes32 internal constant _name_ = bytes32(abi.encodePacked("Yearn V3 Vault Role Manager"));
DADDY
Position ID for "daddy".
bytes32 public constant DADDY = keccak256("Daddy");
BRAIN
Position ID for "brain".
bytes32 public constant BRAIN = keccak256("Brain");
KEEPER
Position ID for "keeper".
bytes32 public constant KEEPER = keccak256("Keeper");
SECURITY
Position ID for "security".
bytes32 public constant SECURITY = keccak256("Security");
REGISTRY
Position ID for the Registry.
bytes32 public constant REGISTRY = keccak256("Registry");
ACCOUNTANT
Position ID for the Accountant.
bytes32 public constant ACCOUNTANT = keccak256("Accountant");
DEBT_ALLOCATOR
Position ID for Debt Allocator
bytes32 public constant DEBT_ALLOCATOR = keccak256("Debt Allocator");
STRATEGY_MANAGER
Position ID for Strategy manager.
bytes32 public constant STRATEGY_MANAGER = keccak256("Strategy Manager");
ALLOCATOR_FACTORY
Position ID for the Allocator Factory.
bytes32 public constant ALLOCATOR_FACTORY = keccak256("Allocator Factory");
chad
Immutable address that the RoleManager position
address public immutable chad;
vaults
Array storing addresses of all managed vaults.
address[] public vaults;
defaultProfitMaxUnlock
Default time until profits are fully unlocked for new vaults.
uint256 public defaultProfitMaxUnlock = 10 days;
_positions
Mapping of position ID to position information.
mapping(bytes32 => Position) internal _positions;
vaultConfig
Mapping of vault addresses to its config.
mapping(address => VaultConfig) public vaultConfig;
_assetToVault
Mapping of underlying asset, api version and category to vault.
mapping(address => mapping(string => mapping(uint256 => address))) internal _assetToVault;
Functions
onlyPositionHolder
Only allow either governance or the position holder to call.
modifier onlyPositionHolder(bytes32 _positionId);
_isPositionHolder
Check if the msg sender is governance or the specified position holder.
function _isPositionHolder(bytes32 _positionId) internal view virtual;
constructor
constructor(
address _governance,
address _daddy,
address _brain,
address _security,
address _keeper,
address _strategyManager,
address _registry
) Governance2Step(_governance);
newVault
Creates a new endorsed vault with default profit max unlock time and doesn't set the deposit limit.
function newVault(address _asset, uint256 _category) external virtual onlyPositionHolder(DADDY) returns (address);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | Address of the underlying asset. |
_category | uint256 | Category of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | _vault Address of the newly created vault. |
newVault
Creates a new endorsed vault with default profit max unlock time.
function newVault(address _asset, uint256 _category, uint256 _depositLimit)
external
virtual
onlyPositionHolder(DADDY)
returns (address);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | Address of the underlying asset. |
_category | uint256 | Category of the vault. |
_depositLimit | uint256 | The deposit limit to start the vault with. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | _vault Address of the newly created vault. |
newVault
Creates a new endorsed vault.
function newVault(address _asset, uint256 _category, uint256 _depositLimit, uint256 _profitMaxUnlockTime)
external
virtual
onlyPositionHolder(DADDY)
returns (address);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | Address of the underlying asset. |
_category | uint256 | Category of the vault. |
_depositLimit | uint256 | The deposit limit to start the vault with. |
_profitMaxUnlockTime | uint256 | Time until profits are fully unlocked. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | _vault Address of the newly created vault. |
_newVault
Creates a new endorsed vault.
function _newVault(address _asset, uint256 _category, uint256 _depositLimit, uint256 _profitMaxUnlockTime)
internal
virtual
returns (address _vault);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | Address of the underlying asset. |
_category | uint256 | Category of the vault. |
_depositLimit | uint256 | The deposit limit to start the vault with. |
_profitMaxUnlockTime | uint256 | Time until profits are fully unlocked. |
Returns
Name | Type | Description |
---|---|---|
_vault | address | Address of the newly created vault. |
_deployAllocator
Deploys a debt allocator for the specified vault.
function _deployAllocator(address _vault) internal virtual returns (address _debtAllocator);
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault. |
Returns
Name | Type | Description |
---|---|---|
_debtAllocator | address | Address of the deployed debt allocator. |
_sanctify
Assigns roles to the newly added vault. This will override any previously set roles for the holders. But not effect the roles held by other addresses.
function _sanctify(address _vault, address _debtAllocator) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault to sanctify. |
_debtAllocator | address | Address of the debt allocator for the vault. |
_setRole
Used internally to set the roles on a vault for a given position. Will not set the roles if the position holder is address(0). This does not check that the roles are !=0 because it is expected that the holder will be set to 0 if the position is not being used.
function _setRole(address _vault, Position memory _position) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault. |
_position | Position | Holder address and roles to set. |
_setAccountant
Sets the accountant on the vault and adds the vault to the accountant.
This temporarily gives the ACCOUNTANT_MANAGER
role to this contract.
function _setAccountant(address _vault) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault to set up the accountant for. |
_setDepositLimit
Used to set an initial deposit limit when a new vault is deployed.
Any further updates to the limit will need to be done by an address that
holds the DEPOSIT_LIMIT_MANAGER
role.
function _setDepositLimit(address _vault, uint256 _depositLimit) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the newly deployed vault. |
_depositLimit | uint256 | The deposit limit to set. |
addNewVault
Adds a new vault to the RoleManager with the specified category.
If not already endorsed this function will endorse the vault. A new debt allocator will be deployed and configured.
function addNewVault(address _vault, uint256 _category) external virtual;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault to be added. |
_category | uint256 | Category associated with the vault. |
addNewVault
Adds a new vault to the RoleManager with the specified category and debt allocator.
If not already endorsed this function will endorse the vault.
function addNewVault(address _vault, uint256 _category, address _debtAllocator)
public
virtual
onlyPositionHolder(DADDY);
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault to be added. |
_category | uint256 | Category associated with the vault. |
_debtAllocator | address | Address of the debt allocator for the vault. |
updateDebtAllocator
Update a _vault
s debt allocator.
This will deploy a new allocator using the current allocator factory set.
function updateDebtAllocator(address _vault) external virtual returns (address _newDebtAllocator);
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault to update the allocator for. |
updateDebtAllocator
Update a _vault
s debt allocator to a specified _debtAllocator
.
function updateDebtAllocator(address _vault, address _debtAllocator) public virtual onlyPositionHolder(BRAIN);
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault to update the allocator for. |
_debtAllocator | address | Address of the new debt allocator. |
updateKeeper
Update a _vault
s keeper to a specified _keeper
.
function updateKeeper(address _vault, address _keeper) external virtual onlyPositionHolder(BRAIN);
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault to update the keeper for. |
_keeper | address | Address of the new keeper. |
removeVault
Removes a vault from the RoleManager.
This will NOT un-endorse the vault from the registry.
function removeVault(address _vault) external virtual onlyPositionHolder(BRAIN);
Parameters
Name | Type | Description |
---|---|---|
_vault | address | Address of the vault to be removed. |
removeRoles
Removes a specific role(s) for a _holder
from the _vaults
.
Can be used to remove one specific role or multiple.
function removeRoles(address[] calldata _vaults, address _holder, uint256 _role) external virtual onlyGovernance;
Parameters
Name | Type | Description |
---|---|---|
_vaults | address[] | Array of vaults to adjust. |
_holder | address | Address who's having a role removed. |
_role | uint256 | The role or roles to remove from the _holder . |