MezzShares
Inherits: StateAware, VotesDelegator, Asset, ModifiedERC20VotesUpgradeable, IMezzShares
Author: Daniel Yamagata & Naveen Ailawadi
A base contract for share classes in the Mezzanine Protocol. Each share class has a voting weight, which is used to calculate voting power in governance. The 'governor' of a company must authorize shares before they can be issued. Shares can only be issued by the company's treasury, whose signers are the board of directors.
This contract is intended to be inherited and extended by specific share types. The clock() and CLOCK_MODE() differ from ERC20VotesUpgradeable. Mezz Shares uses block.timestamp in place of block.number This is due to the fact that block production times vary by chain, making block.number an unreliable measure of time for this implementation. _transferVotingUnits() has been overridden such that _totalCheckpoints is decremented when shares are transferred to the treasury and incremented when shares are transferred from the treasury
State Variables
MezzSharesStorageLocation
bytes32 private constant MezzSharesStorageLocation = 0x6829dd64f0945a99a0d73ec15476b4eceeec289ab2b16126da6305eb5684a600;
Functions
_getMezzSharesStorage
function _getMezzSharesStorage() internal pure returns (MezzSharesStorage storage $);
constructor
constructor(address _mezzHub) StateAware(_mezzHub);
__MezzShares_init
function __MezzShares_init(address initTreasury, uint256 initVotingWeight) internal onlyInitializing;
treasury
Returns the address of the treasury, whose signers are the company's board of directors
function treasury() public view override(BoardControlled, VotesDelegator, IBoardControlled) returns (ITreasury);
authorizedShares
Returns the number of authorized shares
function authorizedShares() public view virtual override returns (uint256);
Returns
<none>
uint256
The number of authorized shares
votingWeight
Returns the voting weight of the shares
'votingWeight' is how much voting power each share has in governance
function votingWeight() external view virtual returns (uint256);
Returns
<none>
uint256
The voting weight
authorizeShares
Authorizes the specified number of shares
Increments 'authorizedShares' by 'amount'. Only callable by the Mezz Governor
function authorizeShares(uint256 amount) external virtual onlyMezzGovernance;
Parameters
amount
uint256
The number of shares to authorize
issueShares
Issues a number of shares to an account or vests shares to the account via the Token Timelock
Decrements 'authorizedShares' by 'value'. Only callable by the Treasury. This function will revert if 'duration' is zero and 'cliff', 'initialUnlock', 'startDate, and 'obligatory' are not null
function issueShares(
address recipient,
uint256 amount,
uint32 duration,
uint32 cliff,
uint256 initialUnlock,
uint48 startDate,
bool obligatory
) external virtual onlyBoard returns (uint256);
Parameters
recipient
address
The account to issue or vest shares to
amount
uint256
The number of shares to issue
duration
uint32
The duration of the vesting period in seconds
cliff
uint32
The time in seconds after the start date that the initial unlock occurs
initialUnlock
uint256
The number of shares that unlock at the cliff
startDate
uint48
The start date of the vesting period as a Unix-timestamp in seconds
obligatory
bool
Whether the shares' vesting is obligatory or not
Returns
<none>
uint256
The token timelock's address if the shares are vested, otherwise zero
burn
Burns the sender's shares by 'amount'
Called by the Token Timelock when vesting is canceled
function burn(uint256 amount) external virtual;
Parameters
amount
uint256
The number of shares to burn
updateDelegate
Updates the delegate of 'delegator' from 'fromDelegate' to 'toDelegate'. Only callable by the Delegate Registry
function updateDelegate(address account, address oldDelegatee, address newDelegatee)
external
virtual
override(VotesDelegator, IVotesDelegator)
onlyDelegateRegistry;
outstandingSupply
Returns the number of shares outstanding. The outstanding shares are the total supply minus the treasury shares and shares that are vesting in the Token Timelock.
function outstandingSupply() public view returns (uint256);
fullyDilutedSupply
Returns the fully diluted supply of shares, which include the number of authorized shares
function fullyDilutedSupply() public view returns (uint256);
delegates
Returns the delegate for 'account' that is set in the delegate registry
function delegates(address account) public view virtual override(IVotes, ModifiedVotesUpgradeable) returns (address);
delegateBySig
Overridden 'delegateBySig()' such that it always revert
function delegateBySig(address, uint256, uint256, uint8, bytes32, bytes32)
public
virtual
override(IVotes, ModifiedVotesUpgradeable);
delegate
Overridden 'delegate()' such that it always reverts
function delegate(address) public virtual override(IVotes, ModifiedVotesUpgradeable);
_delegate
function _delegate(address, address) internal virtual override;
name
Returns the name of the asset as a string
function name() public view virtual override(Asset, IAsset, ERC20Upgradeable) returns (string memory);
symbol
Returns the symbol of the asset as a string
function symbol() public view virtual override(Asset, IAsset, ERC20Upgradeable) returns (string memory);
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);
removable
Returns true if the total supply of shares is zero, false otherwise
This function is queried by the treasury and capital stack to see if shares can be removed. To get a total supply of zero, all outstanding shares should be burned
function removable() public view virtual override(Asset, IAsset) returns (bool);
clock
Returns the block.timestamp as a uint48
EIP-6372 implementation. block.timestamp is used over block.number
function clock() public view virtual override(ModifiedVotesUpgradeable, VotesDelegator, IERC6372) returns (uint48);
CLOCK_MODE
Returns a URL-query-like string as specified in EIP-6372
Timestamp is used over block.number
function CLOCK_MODE()
public
view
virtual
override(ModifiedVotesUpgradeable, VotesDelegator, IERC6372)
returns (string memory);
_getVotingUnits
function _getVotingUnits(address account) internal view virtual override returns (uint256);
_maxSupply
function _maxSupply() internal view virtual override returns (uint256);
_update
Override _update(...), which is used on transfers in OZ's ERC20Votes implementation, such that delegatation is automatically completed for the receiver, if not already set
function _update(address from, address to, uint256 value) internal virtual override;
Parameters
from
address
The address from which the tokens are being transferred
to
address
The address to which the tokens are being transferred
value
uint256
The amount of tokens being transferred
_transferVotingUnits
Overridden _transferVotingUnits() from OpenZeppelin's VotesUpgradeable.sol Decrements _totalCheckpoints when shares are transferred to the treasury Increments _totalCheckpoints when shares are transferred from the treasury
function _transferVotingUnits(address from, address to, uint256 amount) internal virtual override;
supportsInterface
ERC165 support
function supportsInterface(bytes4 interfaceId) public view virtual override(Asset, IERC165) returns (bool);
Structs
MezzSharesStorage
struct MezzSharesStorage {
uint256 _authorizedShares;
uint256 _votingWeight;
}
Last updated