Description
This contract defines risk classes and their caps, and maps each strategy to a risk level. Referenced by the AlchemistAllocator during allocation calls to enforce DAO-defined boundaries around risk management.
Risk Class
A struct that defines a risk class
globalCap
- Description - Max combined allocation across all strategies of this risk class, expressed as a WAD percentage of the vault's
totalAssets(1e18 = 100%). - Type -
uint256 - Used By
getGlobalCap()
localCap
- Description - Max allocation for a single strategy in the risk class, expressed as a WAD percentage of the vault's
totalAssets(1e18 = 100%). - Type -
uint256 - Used By
getIndividualCap()
Variables
admin
- Description - The current admin. Only this address can modify caps and assignments.
- Type -
address - Updated By
- Read By
admin()
pendingAdmin
- Description - The first step in a two-step process of setting a new administrator. The pendingAdmin is set by the current admin, then the pendingAdmin must accept the responsibility to lock in the change of admin.
- Type -
address - Updated By
- Read By
pendingAdmin()
riskClasses
- Description - Mapping from riskLevel ID to a Risk Class. The constructor seeds three default risk levels, each as a WAD percentage of vault
totalAssets(1e18 = 100%): 0 = Low withglobalCap1e18 andlocalCap1e18 (100% / 100%), 1 = Medium withglobalCap4e17 andlocalCap25e16 (40% global / 25% local), and 2 = High withglobalCap1e17 andlocalCap1e17 (10% / 10%). The admin can change any of these withsetRiskClass. - Type -
mapping(uint8 => RiskClass) - Updated By
- Read By
riskClasses(uint8)- public getter, returns(uint256 globalCap, uint256 localCap)getGlobalCap(uint8 riskLevel)getIndividualCap(uint256 strategyId)
strategyRiskLevel
- Description - Mapping of strategyID to riskLevel, used to look up caps for a strategy.
- Type -
mapping(uint256 => uint8) - Updated By
- Read By
strategyRiskLevel(uint256)- public getter, returnsuint8getStrategyRiskLevel(uint256 strategyId)getIndividualCap(uint256 strategyId)
Functions
Admin Actions
Functions that can only be called by the current admin. Attempts to call using other addresses will revert with a message of
PD.
transferOwnership(address _newAdmin)
- Description - Sets the pending admin. First part of a two-step process to change the admin. The second step is the pendingAdmin accepting the role by calling acceptOwnership.
@param _newAdmin- Address of the new pendingAdmin.
- Visibility Specifier - external
- State Mutability Specifier - nonpayable
- Reverts
- With
"PD"ifmsg.senderis not the current admin.
- With
- Emits - none
acceptOwnership()
- Description - Can only be called by the current
pendingAdmin. Used to accept the admin role. - Visibility Specifier - external
- State Mutability Specifier - nonpayable
- Reverts
- With
"PD"ifmsg.senderis not the currentpendingAdmin.
- With
- Emits
setRiskClass(uint8 classId, uint256 globalCap, uint256 localCap)
- Description - Sets caps for a given risk class.
@param classId- The risk class ID.@param globalCap- Max combined allocation for all strategies in this class, as a WAD percentage of vaulttotalAssets(1e18 = 100%).@param localCap- Max allocation for a single strategy in this class, as a WAD percentage of vaulttotalAssets(1e18 = 100%).
- Visibility Specifier - external
- State Mutability Specifier - nonpayable
- Reverts
- With
"PD"ifmsg.senderis not the current admin.
- With
- Emits
assignStrategyRiskLevel(uint256 strategyId, uint8 riskLevel)
- Description - Assigns a risk level to a strategy.
@param strategyId- The strategy ID.@param riskLevel- Risk level to assign.
- Visibility Specifier - external
- State Mutability Specifier - nonpayable
- Reverts
- With
"PD"ifmsg.senderis not the current admin.
- With
- Emits - none
Reading State
Reads derived, calculated, or internal state.
getIndividualCap(uint256 strategyId)
- Description - Returns the local cap for the strategy's assigned risk class. The local cap is the max allocation for a single strategy in the risk class, as a WAD percentage of the vault's
totalAssets(1e18 = 100%).@param strategyId- The strategy identifier.
- Visibility Specifier - external
- State Mutability Specifier - view
- Returns -
uint256- the local cap, WAD-scaled (1e18 = 100%)
getGlobalCap(uint8 riskLevel)
- Description - Returns the global cap for the specified risk class. The global cap is the max combined allocation for strategies in a risk class, as a WAD percentage of the vault's
totalAssets(1e18 = 100%).@param riskLevel- Risk class ID.
- Visibility Specifier - external
- State Mutability Specifier - view
- Returns -
uint256- the global cap, WAD-scaled (1e18 = 100%)
getStrategyRiskLevel(uint256 strategyId)
- Description - Returns the risk level currently assigned to a strategy.
@param strategyId- The strategy identifier.
- Visibility Specifier - external
- State Mutability Specifier - view
- Returns -
uint8- the assigned risk level (0 = Low, 1 = Medium, 2 = High by default; unassigned strategies return 0)
Events
-
AdminChanged(address indexed admin)- emitted whenadminis updated viaacceptOwnership. -
RiskClassModified(uint256 indexed class, uint256 indexed globalCap, uint256 indexed localCap)- emitted when a risk class's caps are updated.