Skip to content
Lattice

VestingWalletLib

Git Source

Title: VestingWallet Library

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/finance/VestingWallet.sol)

Library implementing linear vesting of ETH and ERC20 tokens to a beneficiary.

The beneficiary is the Ownable owner of the contract. To change the beneficiary, transfer ownership via OwnableLib.

Functions

vestingWalletStorage

function vestingWalletStorage() internal pure returns (VestingWalletStorage storage $);

Returns

NameTypeDescription
$VestingWalletStorage

registerInterface

Registers support for the IVestingWallet interface via ERC-165.

function registerInterface() internal;

__VestingWallet_init

Initializes the VestingWallet module.

Must be called inside an initializer-guarded function (see Initializable).

function __VestingWallet_init(uint64 startTimestamp, uint64 durationSeconds) internal;

Parameters

NameTypeDescription
startTimestampuint64The Unix timestamp at which vesting begins.
durationSecondsuint64The total duration of the vesting period in seconds.

start

Returns the start timestamp of the vesting schedule.

function start() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256

duration

Returns the duration of the vesting schedule in seconds.

function duration() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256

end

Returns the end timestamp (start + duration).

function end() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256

released

Returns the total amount of ETH already released.

function released() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256

released

Returns the total amount of an ERC20 token already released.

function released(address token) internal view returns (uint256);

Parameters

NameTypeDescription
tokenaddress

Returns

NameTypeDescription
<none>uint256

releasable

Returns the ETH amount currently available to release.

function releasable() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256

releasable

Returns the ERC20 token amount currently available to release.

function releasable(address token) internal view returns (uint256);

Parameters

NameTypeDescription
tokenaddress

Returns

NameTypeDescription
<none>uint256

vestedAmount

Calculates the total vested ETH amount at a given timestamp.

function vestedAmount(uint64 timestamp) internal view returns (uint256);

Parameters

NameTypeDescription
timestampuint64The Unix timestamp to evaluate.

Returns

NameTypeDescription
<none>uint256

vestedAmount

Calculates the total vested ERC20 token amount at a given timestamp.

function vestedAmount(address token, uint64 timestamp) internal view returns (uint256);

Parameters

NameTypeDescription
tokenaddressThe ERC20 token contract address.
timestampuint64The Unix timestamp to evaluate.

Returns

NameTypeDescription
<none>uint256

release

Releases all currently releasable ETH to the beneficiary (owner).

Anyone may call; funds always go to the owner.

function release() internal;

release

Releases all currently releasable tokens of an ERC20 to the beneficiary (owner).

Anyone may call; funds always go to the owner. Uses a low-level call to support non-returning ERC20 tokens (e.g. USDT, BNB, OMG) that omit the bool return value from transfer().

function release(address token) internal;

Parameters

NameTypeDescription
tokenaddressThe ERC20 token contract address.

_vestingSchedule

Applies the linear vesting formula to a total allocation.

function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view returns (uint256);

Parameters

NameTypeDescription
totalAllocationuint256The total amount to be vested (balance + already released).
timestampuint64The timestamp at which to evaluate.

Returns

NameTypeDescription
<none>uint256The vested amount at the given timestamp.