DelegateRegistry

Git Source

Inherits: NoncesUpgradeable, StateAware, BoardControlled, Patchable, MezzEIP712, IDelegateRegistry

Author: Daniel Yamagata

A contract used to delegate voting power of a company's non-vesting and vesting shares. Delegates will receive the voting power of the delegator which can subsequently be used in governance

Invariant: the delegate of address(0) will always be address(0)

State Variables

DELEGATION_TYPEHASH

bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");

DelegateRegistryStorageLocation

bytes32 private constant DelegateRegistryStorageLocation =
    0xa90ac951d12c63c63be62b72ff9c8457724b4d380ebdd06ffdd610ee98f70300;

Functions

constructor

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

_getDelegateRegistryStorage

function _getDelegateRegistryStorage() internal pure returns (DelegateRegistryStorage storage $);

init

Initializes the delegate registry's state. Called atomically by the Mezz Deployer

function init(address initTreasury) external virtual initializer;

__DelegateRegisitry_init

function __DelegateRegisitry_init(address initTreasury) internal virtual onlyInitializing;

selfDelegate

Self-delegates 'account' under the following conditions:

  • account is not address(0)

  • The delegatee of 'account' is not set

  • The caller is a valid share class or the token timelock

  • 'account' is an EOA or properly supports the 'IMezzSelfDelegator' interface

If any of these conditions are false, the function will make no changes to state and return

function selfDelegate(address account) external virtual;

delegate

Updates the delegatee of the caller to 'newDelegatee' and updates the state of all share classes and the token timelock

function delegate(address newDelegate) external virtual freezable;

delegateBySig

Updates the delegatee of 'account' to 'newDelegatee' and updates the state of all share classes and the token timelock. A valid 'signature' for 'account' is required, otherwise this function will revert

function delegateBySig(address account, address newDelegate, bytes memory signature) external virtual freezable;

_delegate

Validate

Updates the voting power of 'newDelegate' for all shares and the Token Timelock. Runs in O(n) The number of shares that a company can have is limited to 15. This is reasonable, preventing the reversion of this function due to the block gas limit

function _delegate(address account, address newDelegate) internal virtual;

delegates

Returns the delegatee for 'account' if it is set. Otherwise, returns address(0)

function delegates(address account) public view virtual returns (address);

version

Returns the version of the implementation as a uint256

function version() public pure virtual override(Credentialed, ICredentialed) returns (uint256);

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);

getDelegationTransactionHash

Returns the transaction hash for

function getDelegationTransactionHash(address account, address newDelegate, uint256 accountNonce)
    public
    view
    returns (bytes32);

_getDelegationStructHash

function _getDelegationStructHash(address account, address newDelegate, uint256 accountNonce)
    internal
    pure
    returns (bytes32);

supportsInterface

ERC165 support

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

upgradeToNewerVersion

Upgrades 'this' to a newer version via the Mezz Migrator. Only callable by the Treasury, whose signers are the board of directors

Will revert if the protocol state is 'Paused' or 'Frozen'

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

Parameters

Name
Type
Description

newVersion

uint256

The new version to upgrade to

data

bytes

The data to be passed to the new implementation, which likely should be a reinitializer function if used

_authorizePatch

Access control for 'resetToPatchedLatestVersion()'

function _authorizePatch(bytes memory) internal view virtual override;

Structs

DelegateRegistryStorage

struct DelegateRegistryStorage {
    mapping(address => address) _delegateeByAccount;
}

Last updated