Team

Git Source

Inherits: Initializable, ContextUpgradeable, StateAware, Patchable, Safe, ITeam

Author: Daniel Yamagata & Jerry Qi & Naveen Ailawadi

A base contract that coordinates a group of people making decisions, such as a Treasury or Department. Teams directly inherit from Safe, making them capable of executing arbitrary transactions given the proper authorization by its signers.

Safe does not implement upgrade-friendly storage. Therefore, it is of utter importance that all upgradeable contracts that inherit from 'Team' use ERC7201 namespaced storage to prevent potential storage collisions. Some may be curious why we are not creating a '$' var when accessing ERC7201 storage. This is because Safe and the other dependencies used take up an enormous amount of contract size. Therefore, we are heavily optimizing for contract size rather than readability or gas efficiency

State Variables

TeamStorageLocation

bytes32 private constant TeamStorageLocation = 0xc7b1874f9540775a2ee3dd2e2c7ee421a4027040e4b76eb32ebb1dabf89ce400;

Functions

_getTeamStorage

function _getTeamStorage() internal pure returns (TeamStorage storage $);

constructor

constructor(address _mezzHub, address _mezzMigrator) StateAware(_mezzHub) Patchable(_mezzMigrator);

onlyChild

Reverts if the caller is not a child

modifier onlyChild();

onlyChildOrThis

Reverts if the caller is not a child or 'this'

modifier onlyChildOrThis();

__Team_init

Initializes the Safe's state and sets the guard

function __Team_init(address[] memory _owners, uint256 _threshhold, address initGuard) internal onlyInitializing;

Parameters

Name
Type
Description

_owners

address[]

The initial signers/owners

_threshhold

uint256

The initial threshold

initGuard

address

The guard to set

execMultipleTransactions

A function to execute multiple tranctions atomically via the Team's Safe fuctionality.

The 'target' of the call is 'this' but the function selector of each 'transaction' must be 'execTransaction' The function, itself, is not pausable or freezable. However, 'execTransaction' is freezable, meaning this function will revert if the protocol state is frozen or if the implementation is frozen.

function execMultipleTransactions(bytes[] memory transactions) public payable virtual returns (bool[] memory);

Parameters

Name
Type
Description

transactions

bytes[]

Returns

Name
Type
Description

<none>

bool[]

An array of booleans that indicate whether or not each transaction was successful Each element of the array should be 'true', since any call to this function will revert if any of the transactions fail

execTransaction

Same as safe's execTransaction, except uses the 'freezable' modifier

Reference.

function execTransaction(
    address to,
    uint256 value,
    bytes calldata data,
    Enum.Operation operation,
    uint256 safeTxGas,
    uint256 baseGas,
    uint256 gasPrice,
    address gasToken,
    address payable refundReceiver,
    bytes memory signatures
) public payable virtual override freezable returns (bool);

execTransactionFromModule

Safe modules have been disabled, since they could arbitrarily change the signers of a team

function execTransactionFromModule(address, uint256, bytes memory, Enum.Operation)
    public
    virtual
    override
    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 owners, bytes memory params) external virtual;

Parameters

Name
Type
Description

owners

bytes4

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 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 authorized freezable;

removeChild

Removes 'childToRemove' from the '_children' set. Will revert if 'childToRemove' is not in the '_children' set

function removeChild(address departmentToRemove) external virtual authorized freezable;

getChildren

Returns all children as an address array

function getChildren() public view returns (address[] memory);

getSolvency

Returns the 'solvency' of this as defined by the DataTypes.Solvency enum

function getSolvency() public view returns (DataTypes.Solvency);

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 view virtual returns (address);

Returns

Name
Type
Description

<none>

address

The parent, which is either the treasury, a department, a module, or the sentinel parent

name

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

function name() public view virtual returns (string memory);

_validateSolvent

Reverts if the company state is not solvent

function _validateSolvent() internal view virtual;

_isCallerChild

Returns true if the caller is a 'child'

function _isCallerChild() internal view virtual returns (bool);

_validateCallerIsChild

Reverts if the caller is not a 'child' of 'this'

function _validateCallerIsChild() internal view virtual;

_validateCallerIsChildOrThis

Reverts if the caller is not 'this' or a 'child' of 'this'

function _validateCallerIsChildOrThis() internal view virtual;

_validateLiquidating

Reverts if the company state is not liquidating

function _validateLiquidating() internal view virtual;

supportsInterface

ERC165 support

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

upgradeToAndCall

Overridden 'upgradeToAndCall' from UUPSUpgradeable Validates that the 'data' is not to manage the owners and threshold, set the guard, or enable modules '_authorizeUpgrade()' has been overridden in MezzUUPSUpgradeable such that this can only be called by the Mezz Migrator

function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual override onlyProxy;

_authorizePatch

Overridden '_authorizePatch' from Patchable. Validates 'data' is not used to manage the owners, threshold,

Overridden '_authorizePatch' from Patchable. Validates 'data' is not used to manage the owners, threshold, set the guard, or enable modules

function _authorizePatch(bytes memory data) internal view virtual override;

Structs

TeamStorage

struct TeamStorage {
    DataTypes.Solvency _solvency;
    EnumerableSet.AddressSet _children;
}

Last updated