# MezzShares

[Git Source](https://github.com/EntreDevelopers-Lab-Inc/Mezz-Companies/blob/f7a3e84e3dd5bb33c4bd7f77283983f9e8ba20b2/src/core/shares/MezzShares.sol)

**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

```solidity
bytes32 private constant MezzSharesStorageLocation = 0x6829dd64f0945a99a0d73ec15476b4eceeec289ab2b16126da6305eb5684a600;
```

## Functions

### \_getMezzSharesStorage

```solidity
function _getMezzSharesStorage() internal pure returns (MezzSharesStorage storage $);
```

### constructor

```solidity
constructor(address _mezzHub) StateAware(_mezzHub);
```

### \_\_MezzShares\_init

```solidity
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

```solidity
function treasury() public view override(BoardControlled, VotesDelegator, IBoardControlled) returns (ITreasury);
```

### authorizedShares

Returns the number of authorized shares

```solidity
function authorizedShares() public view virtual override returns (uint256);
```

**Returns**

| Name     | Type      | Description                     |
| -------- | --------- | ------------------------------- |
| `<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*

```solidity
function votingWeight() external view virtual returns (uint256);
```

**Returns**

| Name     | Type      | Description       |
| -------- | --------- | ----------------- |
| `<none>` | `uint256` | The voting weight |

### authorizeShares

Authorizes the specified number of shares

*Increments 'authorizedShares' by 'amount'. Only callable by the Mezz Governor*

```solidity
function authorizeShares(uint256 amount) external virtual onlyMezzGovernance;
```

**Parameters**

| Name     | Type      | Description                       |
| -------- | --------- | --------------------------------- |
| `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*

```solidity
function issueShares(
    address recipient,
    uint256 amount,
    uint32 duration,
    uint32 cliff,
    uint256 initialUnlock,
    uint48 startDate,
    bool obligatory
) external virtual onlyBoard returns (uint256);
```

**Parameters**

| Name            | Type      | Description                                                             |
| --------------- | --------- | ----------------------------------------------------------------------- |
| `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**

| Name     | Type      | Description                                                           |
| -------- | --------- | --------------------------------------------------------------------- |
| `<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*

```solidity
function burn(uint256 amount) external virtual;
```

**Parameters**

| Name     | Type      | Description                  |
| -------- | --------- | ---------------------------- |
| `amount` | `uint256` | The number of shares to burn |

### updateDelegate

Updates the delegate of 'delegator' from 'fromDelegate' to 'toDelegate'. Only callable by the Delegate Registry

```solidity
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.

```solidity
function outstandingSupply() public view returns (uint256);
```

### fullyDilutedSupply

Returns the fully diluted supply of shares, which include the number of authorized shares

```solidity
function fullyDilutedSupply() public view returns (uint256);
```

### delegates

Returns the delegate for 'account' that is set in the delegate registry

```solidity
function delegates(address account) public view virtual override(IVotes, ModifiedVotesUpgradeable) returns (address);
```

### delegateBySig

*Overridden 'delegateBySig()' such that it always revert*

```solidity
function delegateBySig(address, uint256, uint256, uint8, bytes32, bytes32)
    public
    virtual
    override(IVotes, ModifiedVotesUpgradeable);
```

### delegate

*Overridden 'delegate()' such that it always reverts*

```solidity
function delegate(address) public virtual override(IVotes, ModifiedVotesUpgradeable);
```

### \_delegate

```solidity
function _delegate(address, address) internal virtual override;
```

### name

Returns the name of the asset as a string

```solidity
function name() public view virtual override(Asset, IAsset, ERC20Upgradeable) returns (string memory);
```

### symbol

Returns the symbol of the asset as a string

```solidity
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"))*

```solidity
function coreId() public pure virtual override(Credentialed, ICredentialed) returns (bytes32);
```

### version

Returns the version of the implementation as a uint256

```solidity
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*

```solidity
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*

```solidity
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*

```solidity
function CLOCK_MODE()
    public
    view
    virtual
    override(ModifiedVotesUpgradeable, VotesDelegator, IERC6372)
    returns (string memory);
```

### \_getVotingUnits

```solidity
function _getVotingUnits(address account) internal view virtual override returns (uint256);
```

### \_maxSupply

```solidity
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*

```solidity
function _update(address from, address to, uint256 value) internal virtual override;
```

**Parameters**

| Name    | Type      | Description                                             |
| ------- | --------- | ------------------------------------------------------- |
| `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*

```solidity
function _transferVotingUnits(address from, address to, uint256 amount) internal virtual override;
```

### supportsInterface

*ERC165 support*

```solidity
function supportsInterface(bytes4 interfaceId) public view virtual override(Asset, IERC165) returns (bool);
```

## Structs

### MezzSharesStorage

```solidity
struct MezzSharesStorage {
    uint256 _authorizedShares;
    uint256 _votingWeight;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mezzanine.xyz/smart-contracts/source-code/core/mezzshares.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
