-
Notifications
You must be signed in to change notification settings - Fork 5
Vesting Contracts
zToken vesting contracts are a simple smart contract built to vest ERC20 tokens to a set of users, linearly, over a period of time. The vesting contracts are built using Merkle Trees to lower the gas cost of deployment by shifting gas cost to the user.
Each instance of a deployed zToken vesting contract has it's own vesting structure. A vesting structure indicates how the tokens will vest, there are three parameters to this structure.
Parameter | Purpose |
---|---|
Start | What block does the vesting start on |
Duration | How many blocks does vesting occur over |
Cliff | How many blocks until the vesting cliff is reached |
If you are unfamiliar with linear vesting with a cliff, take a look at this diagram:
No shares are vested until the cliff is reached, then all the shares up until that point immediately vest. Vesting then continues at a linear rate.
Consult the README file of the repo on how to deploy a vesting contract.
The primary way to vest tokens to users is through the merkle tree file, more details on this can be found in the README.
If additional users need to be added to a vesting contract, you can call the awardTokens
method which is available in the MerkleTokenVestingV2
contract.
Note that you will need to send additional tokens to the vesting smart contract.
It is dangerous to call awardTokens
on a user that is in the merkle tree, as this will override the merkle tree if they have not already claimed their award of tokens.
You cannot call awardTokens
with a user that has already been awarded tokens.
If a user is allowed to claim tokens, as dictated by the merkle tree, they technically have not been awarded those tokens until they call the claimAward
method on the smart contract.
Only after they call claimAward
does the smart contract award them those tokens, and allows them to claim vested tokens.