Department

Git Source

Inherits: Team, IDepartment

Author: Daniel Yamagata & Jerry Qi & Naveen Ailawadi

A multi-signature wallet whose signers are determined by its ancestors. A department can transfer funds recursively from the treasury to themselves, given there is sufficient approvals and balances. An ancestor is a department or the treasury, which is higher in the organizational hierarchy than 'this'. Unlike the traditional definition, an 'ancestor' does not include 'this', itself.

State Variables

DepartmentStorageLocation

bytes32 private constant DepartmentStorageLocation = 0xbcbd9931e6c2b25760bd06d79dd059ceba389ce5a1832f868178693a75fc3c00;

Functions

_getDepartmentStorage

function _getDepartmentStorage() internal pure returns (DepartmentStorage storage $);

constructor

constructor(address _mezzHub, address _mezzMigrator) Team(_mezzHub, _mezzMigrator);

onlyAncestor

modifier onlyAncestor();

onlyAncestorOrAuthorized

The msg.sender must be 'this' or an ancestor

modifier onlyAncestorOrAuthorized();

init

Standardized init function that all departments must inherit

function init(
    address initTreasury,
    address[] memory _owners,
    uint256 _threshhold,
    address initGuard,
    address initParent,
    bytes memory params
) external virtual;

Parameters

__Department_init

Sets the initial state for a department and validates inputs

function __Department_init(
    address initTreasury,
    address[] memory _owners,
    uint256 _threshold,
    address initGuard,
    address initParent,
    string memory initDepartmentName
) internal onlyInitializing;

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 functionSelector, bytes memory params)
    external
    virtual
    override(Team, ITeam)
    onlyAncestor
    freezable;

Parameters

swapGuard

A function to swap the guard of a team contract. Deploys and initializes the guard via the Mezz Deployer.

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)
    onlyAncestor
    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 departmentToInsert)
    external
    virtual
    override(Team, ITeam)
    freezable
    onlyAncestorOrAuthorized;

spend

Recursively transfers an 'amount' of 'asset' from the treasury to the caller, who must be a descendant of the treasury Will revert if the treasury has insufficient funds or the ancestors of 'this' have insufficient approvals

function spend(address asset, uint256 amount) external virtual freezable onlyChildOrThis;

getParent

function getParent() public view virtual override(Team, IChild) returns (address);

Returns

treasury

Returns the treasury as an ITreasury interface

function treasury() public view returns (ITreasury);

name

Returns the name of 'this', which is a string

function name() public view override(Team, ITeam) returns (string memory);

supportsInterface

ERC165 support

function supportsInterface(bytes4 interfaceId) public view virtual override(Team, IERC165) returns (bool);

_validateCallerIsAncestor

Reverts if the caller is not an ancestor

function _validateCallerIsAncestor() internal view virtual;

_validateCallerIsTeamOrAncestor

Reverts if the caller is not an ancestor or address(this)

function _validateCallerIsTeamOrAncestor() internal view virtual;

upgradeToNewerVersion

Upgrades 'this' to a newer version via the MezzMigrator

Only callable by 'this' or an ancestor

function upgradeToNewerVersion(uint256 newVersion, bytes memory data)
    public
    virtual
    onlyProxy
    onlyAncestorOrAuthorized;

_authorizePatch

Access control for 'resetToPatchedLatestVersion()'. Validation of 'data' is completd in Team.sol

function _authorizePatch(bytes memory data) internal view override;

Structs

DepartmentStorage

struct DepartmentStorage {
    ITreasury _treasury;
    address _parent;
    string _departmentName;
}

Last updated