TokenTimelock
Inherits: Patchable, StateAware, VotesDelegator, AdminControlled, MezzERC721Upgradeable, ITokenTimelock
Author: Daniel Yamagata & Naveen Ailawadi
This contract is used to vest a company's shares for a period of time. It is used by a company's Common Shares and Preferred Shares. The voting power of vesting shares can be delegated and used in governance
*Invariants:
_erc20Vesting[token] is always greater than or equal to _erc20Released[token]
_vestingScheduleByTokenId[tokenId].amount is always greater than or equal to _erc20ReleasedByTokenId[tokenId][shares]. This is inclusive of when the token's data is deleted upon vesting completion or when the vesting is canceled*
State Variables
TokenTimelockStorageLocation
Functions
_getTokenTimelockStorage
constructor
receive
The Token Timelock should not receive the native token used to pay for gas All native tokens transferred to this contract will be locked forever and effectively burned
init
Initializes the token timelock contract
Parameters
__TokenTimelock_Init
treasury
Returns the address of the treasury, whose signers are the company's board of directors
vestShares
Vest shares for a recipient according to a vesting schedule. Vesting is cancellable by the board or a set of admins determined by the board depending on if it is obligatory
'data.shares' must be tracked by the treasury, otherwise the function call will revert. This function uses an ERC721 safe transfer, which is susceptible to reentrancy. It follows the CEI pattern accordingly. There is no validation of 'data.startDate' being in the past. It is the responsibility of the caller to ensure its validity. If the start date is in the past farther than 'data.duration', the shares will be instantly vested. The max start date is two years into the future, at which point the shares will begin to vest
Parameters
Returns
release
Releases vested tokens to the owner of an ERC721. Can be called by anyone
This function is not access controlled. Any account can release vested shares for any token ID Vested shares are transferred to the owner of the token
Parameters
Returns
cancelVestingAtTimepoint
Cache and Validate
This function is primarily used by the Payroll Manager when an employee resigns at a timepoint
Returns
cancelVesting
Cancels the vesting for a given token. Releases any vested shares and burns the remaining amount allocated to the token.
This function will revert if the caller is not the token owner nor an admin. If the caller is an admin, this function will revert if the token is obligatory
Parameters
Returns
_cancelVesting
_handleCanceledShares
If the owner is the payroll manager, transfer the vesting shares back to the treasury Otherwise, burn the shares. This is done to prevent the treasury from having to re-authorize and re-issue shares that were allocated to employees but subsequently canceled
extendVestingDuration
Extends the vesting duration for the given 'tokenId'. Only callable by the token owner
This function will revert if the token does not exist
Parameters
Returns
extendVestingAmount
Increases the vesting amount for 'tokenId' by 'equityExtension'
This function is not access controlled. It is callable by anyone This function will revert if the token does not exist
Parameters
Returns
updateDelegate
Updates the delegate of 'delegator' from 'fromDelegate' to 'toDelegate'. Only callable by the Delegate Registry
isObligatory
Returns whether or not a given token is obligatory
Parameters
Returns
wasCanceled
Returns true if the token was canceled, false otherwise
hasCompleted
Returns true if the token has completed its vesting, false otherwise
exists
Returns true if the token exists, false otherwise
getVestingSchedule
Returns the vesting schedule for the given token
Parameters
Returns
getRemainingVestingAmount
Returns the remaining vesting amount for the given token
The remaining vesting amount refers to the difference between the shares attributed to the vesting schedule and how much has been released
getVestingEndDate
Returns the Unix-timestamp in seconds at which the vesting schedule will complete
released
Returns the amount of shares that have been released for a given token
Parameters
Returns
releasable
Returns the amount of shares that are releasable for a given token. 'Releasable' refers to the amount of shares that have vested and have not yet been released
Parameters
Returns
getVotesByShareClass
Returns the current number of voting units for 'account' based on 'shares'
The return value does not adjust for the voting weight of 'shares'
getPastVotesByShareClass
Returns the voting units for 'account' based on 'shares' at the given 'timepoint'
The return value does not adjust for the voting weight of 'shares'. This function will revert if 'timepoint' is in the present or the future
getERC20VestingByAccount
Returns the current amount of 'shares' that are vesting for 'account'
getCumulativeERC20Vesting
Returns the cumlative amount of shares that are vesting or have been vested in the token timelock
Parameters
Returns
getCumulativeERC20Released
Returns the cumlative amount of shares that have been released from the token timelock
Parameters
Returns
name
Returns the name of the token timelock
symbol
Returns the symbol of the token timelock
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"))
version
Returns the version of the implementation as a uint256
_release
Releases the '_releasableAmount' of vested shares to the owner of the token 'Releasable' refers to the amount vested minus the amount already released
Parameters
_releasable
Returns the amount of tokens that are 'releasable' for a given token 'Releasable' refers to the amount vested minus the amount already released
Parameters
Returns
_vestedAmount
Calculates the vested amount of shares for a given vesting schedule. Does not check the released amount of shares Precision loss is possible, but extremely unlikely since shares will always have 18 decimals
Parameters
Returns
_burnTokenAndDeleteData
Burn a token with 'tokenId' and deletes it corresponding data in storage
Parameters
_validateCallerIsOwnerOrAdminAndNonObligatory
*Reverts if:
The caller is not the token owner or an admin
If the caller is an admin and the token is obligatory*
_checkInvariants
Asserts that the invariants hold true. Panics otherwise
Parameters
_update
Overridden updated from '_ERC721Upgradeable' such that the voting units of a delegate is updated on token transfer, including burning
Returns
_transferVotingUnits
Transfers the voting units of 'shares' from the delegatee of 'from' to the delegatee of 'to'
_moveDelegateVotes
Moves delegated votes of 'shares' from one delegate to another
_push
_add
_subtract
supportsInterface
ERC165 support
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'
Parameters
_authorizePatch
Access control for 'resetToPatchedLatestVersion()'
Structs
TokenTimelockStorage
Last updated