VestingWalletLib
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
| Name | Type | Description |
|---|---|---|
| $ | 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
| Name | Type | Description |
|---|---|---|
| startTimestamp | uint64 | The Unix timestamp at which vesting begins. |
| durationSeconds | uint64 | The total duration of the vesting period in seconds. |
start
Returns the start timestamp of the vesting schedule.
function start() internal view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
duration
Returns the duration of the vesting schedule in seconds.
function duration() internal view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
end
Returns the end timestamp (start + duration).
function end() internal view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
released
Returns the total amount of ETH already released.
function released() internal view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
released
Returns the total amount of an ERC20 token already released.
function released(address token) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
releasable
Returns the ETH amount currently available to release.
function releasable() internal view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
releasable
Returns the ERC20 token amount currently available to release.
function releasable(address token) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
vestedAmount
Calculates the total vested ETH amount at a given timestamp.
function vestedAmount(uint64 timestamp) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| timestamp | uint64 | The Unix timestamp to evaluate. |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| token | address | The ERC20 token contract address. |
| timestamp | uint64 | The Unix timestamp to evaluate. |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| token | address | The 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
| Name | Type | Description |
|---|---|---|
| totalAllocation | uint256 | The total amount to be vested (balance + already released). |
| timestamp | uint64 | The timestamp at which to evaluate. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | The vested amount at the given timestamp. |