Vesting

Vesting contract is an ERC20 based vesting protocol. It allows owners to create multiple vesting schedules and deposit tokens to allow users to receive those funds in a way described by the plan.

Methods

initialize(address, uint256)

This function is used to initialize the necessary things of the Astra DAO contract, set the owner of the contract, and store it in the state variable.

  • Parameters

  • address token_: Astra DAO token address.

  • uint256 _keeperInterval: Interval for token airdrop.

addUserDetails(address[],uint256[],uint256,uint256,uint256, uint256,bool)

Creates a new vesting schedule with multiple addresses. To create vesting, admin needs these details, arrays of address and amount of the beneficiary to whom vested tokens are transferred, start time, cliff time, duration of the vesting period, details if vesting is revocable or not.

  • Parameters

  • address[] _to: Arrays of address of the beneficiary to whom vested tokens are transferred.

  • uint256 _start: Start time of the vesting period.

  • uint256 _cliff: Duration in seconds of the cliff in which tokens will begin to vest.

  • uint256 _duration: Duration in seconds of the period in which the tokens will vest.

  • uint256 _slicePeriodSeconds: Duration of a slice period for the vesting in seconds.

  • bool _revocable: Whether the vesting is revocable or not.

  • uint256[] _amount: Array of total amount of tokens to be released at the end of the vesting.

checkUpkeep(bytes)

Chainlink call this function to verify before calling automation function.

computeReleasableAmount(bytes32)

Computes the vested amount of tokens for the given vesting schedule identifier.

  • Parameter

  • byte32 vestingScheduleId: Vesting Id to get the relesable amount.

computeNextVestingScheduleIdForHolder(address)

Computes the next vesting schedule identifier for a given holder address.

  • Parameter

  • address holder: User address to calculate next vesting ID.

computeVestingScheduleIdForAddressAndIndex(address,uint256)

Computes the vesting schedule identifier for an address and an index.

  • Parameter

  • address holder: User address to get vesting ID.

  • uint256 index: Index to get vesting ID.

createVestingSchedule(address,uint256,uint256,uint256, uint256,bool,uint256)

Creates a new vesting schedule for a single beneficiary. To create vesting, admin needs these details, address and amount of the beneficiary to whom vested tokens are transferred, start time, cliff time, duration of the vesting period, details if vesting is revocable or not.

  • Parameters

  • address _to: Address of the beneficiary to whom vested tokens are transferred.

  • uint256 _start: Start time of the vesting period.

  • uint256 _cliff: Duration in seconds of the cliff in which tokens will begin to vest.

  • uint256 _duration: Duration in seconds of the period in which the tokens will vest.

  • uint256 _slicePeriodSeconds: Duration of a slice period for the vesting in seconds.

  • bool _revocable: Whether the vesting is revocable or not.

  • uint256 _amount: Total amount of tokens to be released at the end of the vesting.

getVestingSchedulesCountByBeneficiary(address)

Returns the number of vesting schedules associated with a beneficiary.

  • Parameter

  • address _beneficiary: Beneficiary address to calculate total vestings for user.

getVestingIdAtIndex(uint256)

Returns the vesting schedule id at the given index.

  • Parameter

  • uint256 index: Index to get vesting ID at that index.

getVestingScheduleByAddressAndIndex(address,uint256)

Returns the vesting schedule information for a given holder and index.

  • Parameter

  • address holder: User address to get vesting ID.

  • uint256 index: Index to get vesting ID for user at that index.

getVestingSchedulesTotalAmount()

Returns the total amount of vesting schedules.

getToken()

Returns the address of the ERC20 token managed by the vesting contract.

getVestingSchedulesCount()

Returns the number of vesting schedules managed by this contract.

getVestingSchedule(bytes32)

Returns the vesting schedule information for a given identifier.

  • Parameter

  • bytes32 vestingScheduleId: Get vesting schedue details for vesting ID.

getWithdrawableAmount()

Returns the amount of tokens that can be withdrawn by the owner.

getLastVestingScheduleForHolder(address)

Returns the last vesting schedule for a given holder address.

  • Parameter

  • address holder: User address to get the vesting details.

getCurrentTime()

Get latest time.

multisendToken(address[],uint256[])

Send tokens to multiple accounts. This function will be used for airdrop.

  • Parameter

  • address[] recipients: Array of user addresses.

  • uint256[] values: Array for amount of token users will get.

performUpkeep(bytes)

Chainlink automation function that will release tokens to all users. This function is public, and anyone can call it.

  • Parameter

  • bytes performData: Data came from chainlink at the time of performing upkeep.

revoke(bytes32)

Revokes the vesting schedule for a given identifier.

  • Parameter

  • bytes32 vestingScheduleId: Vesting schedule ID to revoke.

release(bytes32,uint256)

Release vested amount of tokens. Transaction will be reverted if user tries to claim more than the elligible amount.

  • Parameter

  • bytes32 vestingScheduleId: Vesting ID to claim the tokens.

  • uint256 amount: Amount of token to claim.

setNewUpKeepTime(uint256)

Set a new start time, after which chainlink keeper will start automation.

  • Parameter

  • uint256 _newUpKeepTime: Chainlink upkeep time. You need to pass in epoch time.

setNewKeeperInterval(uint256)

Set a new time interval after which the keeper will call the contract.

  • Parameter

  • uint256 _newKeeperInterval: New interval after token will be airdropped.

Last updated