g8keepVester

g8keepVester

Inherits: IG8keepDeployerVesting

A vesting contract for tokens deployed on the g8keep platform.

State Variables

nextVestingId

The next ID to assign to a token vesting.

uint256 public nextVestingId;

deploymentVestings

Mapping of vesting IDs to their vesting parameters.

mapping(uint256 => DeploymentVesting) public deploymentVestings;

Functions

deploymentVest

Creates a vesting at the time of token deployment for the deployer to be able to claim their tokens linearly over a period of time.

The caller of this function must be the token contract.

function deploymentVest(address _deployer, uint256 _tokensToDeployer, uint256 _vestTime)
    external
    returns (uint256 vestingId);

Parameters

NameTypeDescription

_deployer

address

Address that owns the vesting and will receive tokens when claiming.

_tokensToDeployer

uint256

Amount of tokens that are being vested.

_vestTime

uint256

Amount of times in seconds for the tokens to vest over.

claim

Calculates the claimable tokens for a vesting ID and transfers them to the recipient.

Must be called by the owner of the vesting ID.

function claim(uint256 _id) external;

Parameters

NameTypeDescription

_id

uint256

ID of the vesting to be claimed.

vested

Calculates the amount of tokens available to claim for a vesting ID.

function vested(uint256 _id) external view returns (uint256 vestedAmount);

Parameters

NameTypeDescription

_id

uint256

ID of the vesting to check.

Returns

NameTypeDescription

vestedAmount

uint256

Amount of tokens available to claim.

getVesting

Returns all of the vesting parameters for a vesting ID.

function getVesting(uint256 _id) external view returns (DeploymentVesting memory);

Parameters

NameTypeDescription

_id

uint256

ID of the vesting to return parameters of.

_vested

Internal function to calculate the amount of tokens that are available to claim for the vesting ID and returns a storage pointer for the vesting to update in storage in the claim function.

function _vested(uint256 _id) internal view returns (DeploymentVesting storage vesting, uint256 vestedAmount);

Parameters

NameTypeDescription

_id

uint256

ID of the vesting to be claimed.

Returns

NameTypeDescription

vesting

DeploymentVesting

Storage pointer to the vesting parameters for updates.

vestedAmount

uint256

Amount of tokens available to claim.

Events

DeploymentVestCreated

Emitted when a deployment vest is created.

event DeploymentVestCreated(
    uint256 indexed id,
    address indexed recipient,
    address indexed token,
    uint128 amount,
    uint40 vestingStart,
    uint40 vestingEnd
);

DeploymentVestClaimed

Emitted when a claim is made for vested tokens.

event DeploymentVestClaimed(
    uint256 indexed id, address indexed recipient, address indexed token, uint256 amountClaimed
);

Errors

InvalidAddress

Thrown when a deployment vest is being created and the deployer address is zero.

error InvalidAddress();

InvalidAmount

Thrown when a deployment vest is being created and the amount of tokens is zero.

error InvalidAmount();

InvalidCaller

Thrown when claiming vested tokens and the caller is not the vesting recipient.

error InvalidCaller();

InvalidDuration

Thrown when a deployment vest is being created and the vesting time is zero or

the end time would overflow a uint40.

error InvalidDuration();

InvalidVestingId

Thrown when claiming vested tokens and the vesting ID is greater than or equal to the next ID.

error InvalidVestingId();

NoTokensVested

Thrown when claiming vested tokens and there are no tokens available to claim.

error NoTokensVested();

Structs

DeploymentVesting

Struct of the vesting parameters for an ID.

struct DeploymentVesting {
    address recipient;
    uint40 vestingStart;
    uint40 vestingEnd;
    address token;
    uint40 lastClaim;
    uint128 amount;
    uint128 claimed;
}

Last updated