Treasury
Inherits: ITreasury, Team
Author: Daniel Yamagata & Naveen Ailawadi
A Safe-like contract whose signers are a company's board of directors. A Mezzanine company resembles a tree data structure. The 'Treasury' is the root node of the tree, while 'departments' and 'modules' are internal and leaf nodes. A treasury should hold nearly all assets of a company. Funds can be spent recursively by departments and modules given there are sufficcient approvals and balances. The entirety of a company can be queried either directly from the treasury or via a tree traversal algorithm
State Variables
TreasuryStorageLocation
bytes32 private constant TreasuryStorageLocation = 0xa29865ab22e3c13f4e3fda97514b6fba0b0844305463cbe6cf02bc044b877500;
Functions
_getTreasuryStorage
function _getTreasuryStorage() internal pure returns (TreasuryStorage storage $);
constructor
constructor(address _mezzHub, address _mezzMigrator) Team(_mezzHub, _mezzMigrator);
onlyMezzGovernance
modifier onlyMezzGovernance();
onlyPayrollManager
modifier onlyPayrollManager();
init
function init(DataTypes.TreasuryInitArgs memory initArgs) external virtual initializer;
__Treasury_init
function __Treasury_init(DataTypes.TreasuryInitArgs memory initArgs) internal virtual onlyInitializing;
capitalStack
Returns the address of the company's capital stack
function capitalStack() public view returns (address);
delegateRegistry
Returns the address of the company's delegate registry
function delegateRegistry() public view returns (address);
denominationAsset
Returns the address of the denomination asset
All debt by the company will be recorded in terms of the denomination asset This value is immutable
function denominationAsset() public view returns (address);
getCommonShares
Returns the address of the company's common shares
A treasury will only have a single set of common shares
function getCommonShares() public view returns (address);
getGovernor
Returns the address of the Governor
The Governor is able to manage the signers of the Treasury
function getGovernor() public view returns (address);
getTokenTimelock
Returns the address of the Token Timelock
Used by Mezz Shares to issue and vest shares atomically
function getTokenTimelock() public view returns (address);
getPayrollManager
Returns the address of the Payroll Manager
The Payroll Manager is a shortbound ERC721 contract that manages the payroll of employees. It is able to arbitrarily spend money and common shares from the treasury without approvals. It is controlled by the board of directors (i.e. the Treasury) and a set of admins, who are set by the board
function getPayrollManager() public view returns (address);
isAddingAsset
Returns true if the treasury is adding an asset, false otherwise. A callback used by the capital stack to prevent the treasury from arbitrarily adding an asset to the capital stack
function isAddingAsset() public view returns (bool);
isRemovingAsset
Returns true if the treasury is removing an asset, false otherwise. A callback used by the capital stack to prevent the treasury from arbitrarily removing an asset from the capital stack
function isRemovingAsset() public view returns (bool);
manageOwners
A function to manage the signers of a Gnosis Safe.
Makes external, authorized calls on address(this) that are normally blocked by Mezz Guards. This function is overridden and access-controlled such that the caller must be a Treasury's governor or a department's ancestor. Refer to Constants.sol for the given function selectors that can be used as an 'action'
function manageOwners(bytes4 action, bytes memory params)
external
virtual
override(Team, ITeam)
onlyMezzGovernance
freezable;
Parameters
action
bytes4
The function selector of the function to call
params
bytes
The abi-encoded parameters to pass to the function
swapGuard
A function to swap the guard of a team contract.
Makes external, authorized calls on address(this) that are normally blocked by Mezz Guards. This function is overridden and access-controlled such that the caller must be a Treasury's governor or a department's ancestor
function swapGuard(bytes32 guardCoreId, bytes memory params)
external
virtual
override(Team, ITeam)
onlyMezzGovernance
freezable
returns (address);
insertChild
Inserts 'childToInsert' to the '_children' set. 'childToInsert' must support the module or department interface. Will revert if 'childToInsert' is already in the '_children' set
function insertChild(address childToInsert) external virtual override(Team, ITeam) authorized pausable;
removeChild
Removes 'childToRemove' from the '_children' set. Will revert if 'childToRemove' is not in the '_children' set
function removeChild(address childToRemove) external virtual override(Team, ITeam) authorized freezable;
changeGovernor
Deploys and initializes a new governor. Sets the new governor accordingly
Changes the current governor to a new one associated with 'governorCoreId' A treasury cannot change its governor to one with the same core ID
function changeGovernor(bytes32 governorCoreId, bytes memory params)
external
virtual
onlyMezzGovernance
pausable
returns (address);
Parameters
governorCoreId
bytes32
The core ID of the governor to switch to
params
bytes
Bespoke abi.encoded parameters to pass to the governor's init() function
Returns
<none>
address
The address of the new governor
addAssetToCapitalStack
Deploys an asset with 'assetCoreId' via the Mezz Deployer and adds it to the seniority level with 'seniorityLevelIndex' in the capital stack. If the asset supports the Mezz Shares interface, adds it to the company's shares. Adds a document to the Document Registry with 'assetDocumentName' and 'assetDocumentUri'. The 'owner' of the document will be the capital stack. The name and URI can be updated retroactively at any time.
function addAssetToCapitalStack(
bytes32 assetCoreId,
uint256 seniorityLevelIndex,
bytes memory params,
string memory assetDocumentName,
string memory assetDocumentUri
) external virtual authorized pausable returns (address);
Parameters
assetCoreId
bytes32
seniorityLevelIndex
uint256
params
bytes
The bespoke abi.encoded parameters to pass to the asset's init() function
assetDocumentName
string
assetDocumentUri
string
removeAssetFromCapitalStack
Removes an asset from the capital stack. The 'removable()' function of 'assetToRemove()' must return true for this function to succeed. The conditions for removal are bespoke to each asset. For example, the total supply of a share class must be zero for it to be removed. If 'assetToRemove' supports the Mezz Shares interface, it will be removed from the company's shares. The document associated with the asset will be updated to null
function removeAssetFromCapitalStack(address assetToRemove) external virtual authorized freezable;
spendPayroll
Transfers an 'amount' of an 'asset' to the payroll module. Only callable by the payroll module. The asset must either be a whitelisted denomination asset or the company's common shares. Returns the amount of the asset paid to the recipient, inclusive of ERC20 transfer fees.
This function bypasses all of the treasury's ERC20 allowances. This was designed in a manner to prevent the board from needing to manually setting approvals for payroll
function spendPayroll(address recipient, address asset, uint256 amount)
external
virtual
onlyPayrollManager
pausable
returns (uint256);
Parameters
recipient
address
The recipient of the funds
asset
address
The asset to pay the recipient in
amount
uint256
The amount of the asset to pay the recipient
Returns
<none>
uint256
The amount paid, which takes into account any native ERC20 transfer fees built into 'asset'
spend
Transfers 'amount' of asset to the caller, who must be a child. Sends any set fees for the treasury implementation to the fee controller
function spend(address asset, uint256 amount) external virtual onlyChild pausable;
coreId
Returns the coreId of the implementation as a bytes32
The core ID is the keccak256 hash of the contract name followed by a version under the following syntax: "mezzanine.coreId.ContractName.vX" For example, the core ID of the 2nd version of the Treasury would be the following: keccak256(abi.encodePacked("mezzanine.coreId.Treasury.v2"))
function coreId() public pure virtual override(Credentialed, ICredentialed) returns (bytes32);
version
Returns the version of the implementation as a uint256
function version() public pure virtual override(Credentialed, ICredentialed) returns (uint256);
name
Returns the name of 'this', which is a string
function name() public view override(Team, ITeam) returns (string memory);
symbol
Returns the symbol for the company
function symbol() public view returns (string memory);
getParent
Returns the parent of 'this'. If 'this' is a department or module, returns the team that directly controls 'this'. If 'this' is the Treasury, returns the sentinel parent, which is address(0x1)
function getParent() public pure override(Team, IChild) returns (address);
Returns
<none>
address
The parent, which is either the treasury, a department, a module, or the sentinel parent
getShares
Returns the addresses for the company's share classes as an address array
function getShares() public view returns (address[] memory);
isValidShares
Returns true if 'sharesToCheck' is a valid share class for the company, false otherwise
function isValidShares(address sharesToCheck) public view returns (bool);
Parameters
sharesToCheck
address
The shares to check
outstandingSupply
Returns the summation of the outstanding supply for all share classes. This does not include any vesting or treasury shares
function outstandingSupply() external view returns (uint256);
fullyDilutedSupply
Returns the summation of the fully diluted supply for all share classes. This includes authorized, vesting, and treasury shares
function fullyDilutedSupply() external view returns (uint256);
_validateCallerIsPayrollManager
function _validateCallerIsPayrollManager() internal view;
_validateCallerIsGovernance
function _validateCallerIsGovernance() internal view;
_authorizePatch
Access control for 'resetToPatchedLatestVersion()'. Validation of 'data' is completd in Team.sol
function _authorizePatch(bytes memory data) internal view virtual override;
supportsInterface
ERC165 support
function supportsInterface(bytes4 interfaceId) public view virtual override(Team, IERC165) returns (bool);
Structs
TreasuryStorage
struct TreasuryStorage {
bool _addingAssetHook;
bool _removingAssetHook;
address _commonShares;
address _denominationAsset;
address _capitalStack;
address _delegateRegistry;
address _tokenTimelock;
address _payrollManager;
address _governor;
string _name;
string _symbol;
EnumerableSet.AddressSet _shares;
}
Last updated