UniversalFundCoreFacet
Author: CMX Protocol Team
Core fund facet handling initialization, status management, and basic operations
*This facet provides the fundamental fund functionality including:
Fund initialization with configuration and component contracts
Fund status management and lifecycle transitions
Basic fund information and view functions
Diamond-based access control (replacing AccessManaged)
Emergency pause/unpause functionality Key Features:
Diamond storage pattern for state management
Role-based access control without external dependencies
Comprehensive fund configuration validation
Automatic fund activation when target is reached
Fund term management for closed-end funds Access Control Roles:
ENTITY_ROLE: Fund manager/GP with full operational control
EMERGENCY_ADMIN_ROLE: Can pause/unpause fund operations*
State Variables
ENTITY_ROLE
Role identifier for fund entity/GP
bytes32 public constant ENTITY_ROLE = keccak256("ENTITY_ROLE");
EMERGENCY_ADMIN_ROLE
Role identifier for emergency admin
bytes32 public constant EMERGENCY_ADMIN_ROLE = keccak256("EMERGENCY_ADMIN_ROLE");
Functions
onlyRole
modifier onlyRole(bytes32 role);
whenNotPaused
modifier whenNotPaused();
onlyStatus
modifier onlyStatus(IUniversalFund.FundStatus requiredStatus);
initialize
Initialize the fund with configuration and component contracts
Only callable once - checks that name is not already set
function initialize(
string memory _name,
string memory _symbol,
IUniversalFund.FundConfig memory _config,
address _capitalAccountRegistry,
address _distributionEngine,
address _unitToken
) external;
Parameters
_name
string
Human-readable name of the fund
_symbol
string
Symbol/ticker of the fund
_config
IUniversalFund.FundConfig
Fund configuration parameters
_capitalAccountRegistry
address
Address of capital account registry
_distributionEngine
address
Address of distribution engine
_unitToken
address
Address of fund unit token
setFundStatus
Update fund status with validation
Only callable by entity role
function setFundStatus(IUniversalFund.FundStatus newStatus) external onlyRole(ENTITY_ROLE);
Parameters
newStatus
IUniversalFund.FundStatus
The new status to transition to
extendFundTerm
Extend fund term for closed-end funds
Only callable by entity role, subject to extension limits
function extendFundTerm(uint256 additionalMonths) external onlyRole(ENTITY_ROLE);
Parameters
additionalMonths
uint256
Number of months to extend the fund term
pause
Pause fund operations
Only callable by emergency admin role
function pause() external onlyRole(EMERGENCY_ADMIN_ROLE);
unpause
Unpause fund operations
Only callable by emergency admin role
function unpause() external onlyRole(EMERGENCY_ADMIN_ROLE);
grantRole
Grant a role to an account
Only callable by entity role
function grantRole(bytes32 role, address account) external onlyRole(ENTITY_ROLE);
Parameters
role
bytes32
The role to grant
account
address
The account to grant the role to
revokeRole
Revoke a role from an account
Only callable by entity role
function revokeRole(bytes32 role, address account) external onlyRole(ENTITY_ROLE);
Parameters
role
bytes32
The role to revoke
account
address
The account to revoke the role from
getFundConfig
Get fund configuration
function getFundConfig() external view returns (IUniversalFund.FundConfig memory config);
Returns
config
IUniversalFund.FundConfig
The fund configuration struct
getFundStatus
Get current fund status
function getFundStatus() external view returns (IUniversalFund.FundStatus status);
Returns
status
IUniversalFund.FundStatus
The current fund status
name
Get fund name
function name() external view returns (string memory);
Returns
<none>
string
name The fund name
symbol
Get fund symbol
function symbol() external view returns (string memory);
Returns
<none>
string
symbol The fund symbol
getTotalCommitments
Get total committed capital
function getTotalCommitments() external view returns (uint256 totalCommitments);
Returns
totalCommitments
uint256
Total commitments from all investors
getTotalContributions
Get total contributed capital
function getTotalContributions() external view returns (uint256 totalContributions);
Returns
totalContributions
uint256
Total contributions from all investors
getUnfundedCommitments
Get unfunded commitments
function getUnfundedCommitments() external view returns (uint256 unfunded);
Returns
unfunded
uint256
Amount of committed but not yet contributed capital
getPortfolioValue
Get current portfolio value
function getPortfolioValue() external view returns (uint256 portfolioValue);
Returns
portfolioValue
uint256
Current value of portfolio investments
canExtendTerm
Check if fund term can be extended
function canExtendTerm() public view returns (bool canExtend);
Returns
canExtend
bool
True if the fund term can be extended
hasRole
Check if an account has a specific role
function hasRole(bytes32 role, address account) external view returns (bool);
Parameters
role
bytes32
The role to check
account
address
The account to check
Returns
<none>
bool
hasRole True if the account has the role
paused
Check if fund is paused
function paused() external view returns (bool isPaused);
Returns
isPaused
bool
True if the fund is paused
getAvailableBalance
Get available balance for investments
function getAvailableBalance() external view returns (uint256 balance);
Returns
balance
uint256
Available balance in the fund
_setFundStatus
Internal function to update fund status with validation
function _setFundStatus(IUniversalFund.FundStatus newStatus) internal;
Parameters
newStatus
IUniversalFund.FundStatus
The new status to transition to
_checkRole
Internal function to check if an account has a role
function _checkRole(bytes32 role, address account) internal view;
Parameters
role
bytes32
The role to check
account
address
The account to check
receive
Receive function to accept ETH
Only accepts ETH if denomination asset is ETH (address(0))
receive() external payable;
Events
FundInitialized
Emitted when fund is initialized
event FundInitialized(string name, string symbol, IUniversalFund.FundConfig config);
FundStatusChanged
Emitted when fund status changes
event FundStatusChanged(IUniversalFund.FundStatus oldStatus, IUniversalFund.FundStatus newStatus);
FundTermExtended
Emitted when fund term is extended
event FundTermExtended(uint256 newTermEndDate);
Paused
Emitted when fund is paused
event Paused(address account);
Unpaused
Emitted when fund is unpaused
event Unpaused(address account);
Errors
UnauthorizedAccess
Thrown when caller lacks required role
error UnauthorizedAccess(address caller, bytes32 role);
AlreadyInitialized
Thrown when fund is already initialized
error AlreadyInitialized();
InvalidConfiguration
Thrown when invalid configuration is provided
error InvalidConfiguration(string reason);
InvalidStatusTransition
Thrown when invalid status transition is attempted
error InvalidStatusTransition(IUniversalFund.FundStatus from, IUniversalFund.FundStatus to);
FundPaused
Thrown when operations are attempted while paused
error FundPaused();
InvalidFundStatus
Thrown when fund is not in required status
error InvalidFundStatus(IUniversalFund.FundStatus required, IUniversalFund.FundStatus actual);
Last updated
Was this helpful?