Unvest Docs
Search
K

VestingToken

This contract stores the core logic for locking tokens and releasing them, while also allowing transfers and maintaining an accurate count of the locked and unlocked tokens being transferred.

Implements and Inherits

  • ERC20Upgradeable: ERC20 token with the constructor logic in the __ERC20_init function.
  • IVestingToken: to store Milestones and provide a function to initialize them.

Public Functions and Variables

underlyingToken

The ERC20 token that this contract will be locking and vesting.

manager

The manager that deployed this contract which controls the values for fee and feeCollector.

milestones

An array of Milestones describing the times and behaviour of the rules to release the vested tokens.

initialize

  • name (string): This ERC20 token name.
  • symbol (string): This ERC20 token symbol.
  • underlyingTokenAddress (address): The ERC20 token that will be held by this contract.
  • milestonesArray (Milestone[]): Array of all Milestones for this contract's lifetime.
Initializes the contract by setting up the ERC20 variables, the underlyingToken, and the milestonesArrayinformation.
The Ramp of the first Milestone in the milestonesArray will always act as a Cliff since it doesn't have a previous milestone.

addRecipient

  • recipient (address): The address that will receive the newly minted vestingToken.
  • amount (uint256): The amount of underlyingToken to be vested.
Vests an amount of underlyingToken and mints vestingTokens for a recipient.

addRecipients

  • recipients (address[]): Array of addresses that will receive the newly minted vestingTokens.
  • amounts (uint256[]): Array of amounts of underlyingToken to be vested.
Vests multiple amounts of underlyingToken and mints vestingTokens for multiple recipients.

importRecipient

  • recipient (address): The address that will receive the newly minted vestingToken.
  • amount (uint256): The amount of underlyingToken to be vested.
  • claimableAmountOfImport (uint256): The amount of underlyingToken from this transaction that should be considered claimable.
  • unlocked (uint256): The unlocked percentage value at the time of the export of this transaction.
Behaves as addRecipient but provides the ability to set the initial state of the recipient's metadata. This functionality is included in order to allow users to restart an allocation on a different chain and keeping the inner state as close as possible to the original.
The claimedAmountAfterTransfer value for the recipient is inferred from the parameters.
The claimedBalance value for the recipient is lost in the transfer and will start from 0 in this new contract.
In the rare case where the contract and it's users are migrated after the last milestone has been reached, theclaimedSupply value for the whole contract is lost in the transfer.

importRecipients

  • recipients (address[]):
  • amounts (uint256[]):
  • claimableAmountsOfImport (uint256[]):
  • unlocked (uint256):
Behaves as addRecipient but provides the ability to set the initial state of the recipient's metadata. This functionality is included in order to allow users to restart an allocation on a different chain and keeping the inner state as close as possible to the original.
The claimedAmountAfterTransfer value for each recipient is inferred from the parameters.
The claimedBalance value for each recipient is lost in the transfer and will start from 0 in this new contract.
In the rare case where the contract and it's users are migrated after the last milestone has been reached, theclaimedAmountAfterTransfer can't be inferred and the claimedSupply value for the whole contract is lost in the transfer.

exportRecipient

  • recipient (address): The address that will be exported.
Returns the arguments to use in a call importRecipient on a different contract to migrate the recipient's metadata.

exportRecipients

  • recipients (address[]): Array of addresses that will be exported.
The arguments to use in a call importRecipients on a different contract to migrate the recipients' metadata.

unlockedPercentage

The percentage of underlyingToken that users could claim.

claimedSupply

The amount of underlyingToken that were held in this contract and have been claimed.

claimableSupply

The amount of underlyingToken being held in this contract and that can be claimed.

lockedSupply'

The amount of underlyingToken being held in this contract that can't be claimed yet.

claimedBalanceOf

  • account (address): The address whose tokens are being queried.
The amount of underlyingToken that were held in this contract and this account already claimed.

claimableBalanceOf

  • account (address): The address whose tokens are being queried.
The amount of underlyingToken that this account owns and can claim.

lockedBalanceOf

  • account (address): The address whose tokens are being queried.
The amount of underlyingToken that this account owns but can't claim yet.

claim

This function transfers the claimable amount of underlyingToken and transfers it to msg.sender.
emits a Claim event with the msg.sender as the claimer and the claimableAmount as the amount.

transfer

  • to (address): Address of recipient.
  • amount (uint256): Amount of tokens.
Calculates and transfers the fee before executing a normal ERC20 transfer.
With each transfer not only the amount of tokens is transferred but also the amounts of locked and claimable balances are updated.

transferFrom

  • from (address): Address of sender.
  • to (address): Address of recipient.
  • amount (uint256): Amount of tokens.
Calculates and transfers the fee before executing a normal ERC20 transferFrom.
With each transfer not only the amount of tokens is transferred but also the amounts of locked and claimable balances are updated.