IVesting

Git Source

Provides a standard interface for token vesting contracts

Functions

claim

Claims all tokens currently available for the caller according to their vesting schedule

function claim() external;

startVesting

Creates a new vesting schedule for a beneficiary

function startVesting(VestingParams calldata params) external;

Parameters

NameTypeDescription
paramsVestingParamsStruct containing the parameters for the new vesting schedule

vestedAmount

Returns the total amount of tokens vested for a beneficiary at the current time

function vestedAmount(address _claimer) external view returns (uint256);

Parameters

NameTypeDescription
_claimeraddressAddress of the beneficiary

Returns

NameTypeDescription
<none>uint256Amount of tokens vested

claimableAmount

Returns the amount of tokens that can currently be claimed by a beneficiary

function claimableAmount(address _claimer) external view returns (uint256);

Parameters

NameTypeDescription
_claimeraddressAddress of the beneficiary

Returns

NameTypeDescription
<none>uint256Amount of tokens claimable

withdrawUnallocated

Withdraws all unallocated tokens from the contract to the specified address

function withdrawUnallocated(address _to) external;

Parameters

NameTypeDescription
_toaddressAddress to receive the withdrawn tokens

getVestingInfo

Returns the information about a vesting schedule for a beneficiary

function getVestingInfo(address _claimer) external view returns (VestingInfo memory);

Parameters

NameTypeDescription
_claimeraddressAddress of the beneficiary

Returns

NameTypeDescription
<none>VestingInfoVestingInfo struct containing the vesting information

getInitData

Returns the ABI-encoded initialization data for the contract

function getInitData(address _deployManager, address _token, address _owner) external view returns (bytes memory);

Parameters

NameTypeDescription
_deployManageraddressAddress of the deploy manager
_tokenaddressAddress of the ERC20 token
_owneraddressAddress of the contract owner

Returns

NameTypeDescription
<none>bytesABI-encoded initialization data

Events

VestingCreated

Emitted when a new vesting schedule is created

event VestingCreated(address indexed beneficiary, uint256 amount, uint256 creationTime);

Parameters

NameTypeDescription
beneficiaryaddressAddress of the beneficiary
amountuint256Total number of tokens to be vested
creationTimeuint256Timestamp when the vesting schedule was created

TokensWithdrawn

Emitted when tokens are withdrawn from the contract

event TokensWithdrawn(address indexed to, uint256 amount);

Parameters

NameTypeDescription
toaddressAddress receiving the withdrawn tokens
amountuint256Number of tokens withdrawn

Claim

Emitted when a beneficiary claims vested tokens

event Claim(address indexed beneficiary, uint256 amount, uint256 timestamp);

Parameters

NameTypeDescription
beneficiaryaddressAddress of the beneficiary
amountuint256Number of tokens claimed
timestampuint256Timestamp when the claim was made

Errors

VestingNotFound

Reverts if the vesting schedule does not exist for the beneficiary

error VestingNotFound();

ClaimNotAvailable

Reverts if the claim is not yet available

error ClaimNotAvailable(uint256 blockTimestamp, uint256 availableFrom);

Parameters

NameTypeDescription
blockTimestampuint256Current block timestamp
availableFromuint256Timestamp when the claim becomes available

NothingToClaim

Reverts if there are no tokens available to claim

error NothingToClaim();

InfsufficientBalance

Reverts if the contract does not have enough tokens to allocate

error InfsufficientBalance(uint256 availableBalance, uint256 totalAmount);

Parameters

NameTypeDescription
availableBalanceuint256Number of tokens currently available in the contract
totalAmountuint256Number of tokens required for vesting

VestingAlreadyExist

Reverts if a vesting schedule already exists for the beneficiary

error VestingAlreadyExist();

AmountCantBeZero

Reverts if the specified amount is zero

error AmountCantBeZero();

StartTimeShouldBeFuture

Reverts if the vesting start time is not in the future

error StartTimeShouldBeFuture(uint256 startTime, uint256 blockTimestamp);

Parameters

NameTypeDescription
startTimeuint256The specified start time
blockTimestampuint256The current block timestamp

DurationCantBeZero

Reverts if the vesting duration is zero

error DurationCantBeZero();

CooldownCantBeLongerThanDuration

Reverts if the claim cooldown period is longer than the vesting duration

error CooldownCantBeLongerThanDuration();

InvalidBeneficiary

Reverts if the beneficiary address is invalid

error InvalidBeneficiary();

BelowMinimalClaimAmount

Reverts if the claimable amount is less than the minimum claim amount

error BelowMinimalClaimAmount(uint256 minClaimAmount, uint256 claimable);

Parameters

NameTypeDescription
minClaimAmountuint256The minimum claimable amount
claimableuint256The actual claimable amount

CooldownNotPassed

Reverts if the required cooldown period between claims has not passed

error CooldownNotPassed(uint256 blockTimestamp, uint256 lastClaimTime);

Parameters

NameTypeDescription
blockTimestampuint256The current block timestamp
lastClaimTimeuint256The timestamp of the last claim

NothingToWithdraw

Reverts if there are no tokens available to withdraw

error NothingToWithdraw();

Structs

VestingInfo

Information about a beneficiary's vesting schedule

struct VestingInfo {
    uint256 totalAmount;
    uint256 startTime;
    uint256 cliff;
    uint256 duration;
    uint256 claimed;
    uint256 lastClaimTime;
    uint256 claimCooldown;
    uint256 minClaimAmount;
    bool created;
}

Properties

NameTypeDescription
totalAmountuint256Total number of tokens to be vested
startTimeuint256Timestamp when vesting begins
cliffuint256Duration of the cliff period in seconds
durationuint256Total duration of the vesting period in seconds
claimeduint256Amount of tokens already claimed
lastClaimTimeuint256Timestamp of the last claim
claimCooldownuint256Minimum time interval between claims in seconds
minClaimAmountuint256Minimum amount that can be claimed in a single transaction
createdboolIndicates whether the vesting schedule has been created

VestingParams

Parameters for creating a new vesting schedule in startVesting function

struct VestingParams {
    address beneficiary;
    uint256 totalAmount;
    uint256 startTime;
    uint256 cliff;
    uint256 duration;
    uint256 claimCooldown;
    uint256 minClaimAmount;
}

Properties

NameTypeDescription
beneficiaryaddressAddress that will receive vested tokens
totalAmountuint256Total number of tokens to be vested
startTimeuint256Timestamp when vesting begins
cliffuint256Duration of the cliff period in seconds
durationuint256Total duration of the vesting period in seconds
claimCooldownuint256Minimum time interval between claims in seconds
minClaimAmountuint256Minimum amount that can be claimed in a single transaction