ERC20VestableVotesUpgradeableV1

Alluvial

ERC20VestableVotesUpgradeableV1

This is an ERC20 extension that- can be used as source of vote power (inherited from OpenZeppelin ERC20VotesUpgradeable)- can delegate vote power from an account to another account (inherited from OpenZeppelin ERC20VotesUpgradeable)- can manage token vestings: ownership is progressively transferred to a beneficiary according to a vesting schedule- keeps a history (checkpoints) of each account's vote power@notice Notes from OpenZeppelin ERC20VotesUpgradeable- vote power can be delegated either by calling the {delegate} function, or by providing a signature to be used with {delegateBySig}- keeps a history (checkpoints) of each account's vote power- power can be queried through the public accessors {getVotes} and {getPastVotes}.- by default, token balance does not account for voting power. This makes transfers cheaper. The downside is that itrequires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.@notice Notes about token vesting- any token holder can call the method {createVestingSchedule} in order to transfer tokens to a beneficiary according to a vesting schedule. Whencreating a vesting schedule, tokens are transferred to an escrow that holds the token while the vesting progresses. Voting power of the escrowed token is delegated to thebeneficiary or a delegatee account set by the vesting schedule creator- the schedule beneficiary call {releaseVestingSchedule} to get vested tokens transferred from escrow- the schedule creator can revoke a revocable schedule by calling {revokeVestingSchedule} in which case the non-vested tokens are transfered from the escrow back to the creator- the schedule beneficiary can delegate escrow voting power to any account by calling {delegateVestingEscrow}@notice Vesting schedule attributes are- start : start time of the vesting period- cliff duration: duration before which first tokens gets ownable- total duration: duration of the entire vesting (sum of all vesting period durations)- period duration: duration of a single period of vesting- lock duration: duration before tokens gets unlocked. can exceed the duration of the vesting chedule- amount: amount of tokens granted by the vesting schedule- beneficiary: beneficiary of tokens after they are releaseVestingScheduled- revocable: whether the schedule can be revoked@notice Vesting schedule- if currentTime < cliff: vestedToken = 0- if cliff <= currentTime < end: vestedToken = (vestedPeriodCount(currentTime) * periodDuration * amount) / totalDuration- if end < currentTime: vestedToken = amount@notice Remark: After cliff new tokens get vested at the end of each period@notice Vested token & lock period- a vested token is a token that will be eventually releasable from the escrow to the beneficiary once the lock period is over- lock period prevents beneficiary from releasing vested tokens before the lock period ends. Vested tokenswill eventually be releasable once the lock period is over@notice Example: Joe gets a vesting starting on Jan 1st 2022 with duration of 1 year and a lock period of 2 years.On Jan 1st 2023, Joe will have all tokens vested but can not yet release it due to the lock period.On Jan 1st 2024, lock period is over and Joe can release all tokens.

Methods

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() external view returns (bytes32)

See {IERC20Permit-DOMAIN_SEPARATOR}.

Returns

NameTypeDescription

_0

bytes32

undefined

allowance

function allowance(address owner, address spender) external view returns (uint256)

See {IERC20-allowance}.

Parameters

NameTypeDescription

owner

address

undefined

spender

address

undefined

Returns

NameTypeDescription

_0

uint256

undefined

approve

function approve(address spender, uint256 amount) external nonpayable returns (bool)

See {IERC20-approve}. NOTE: If amount is the maximum uint256, the allowance is not updated on transferFrom. This is semantically equivalent to an infinite approval. Requirements: - spender cannot be the zero address.

Parameters

NameTypeDescription

spender

address

undefined

amount

uint256

undefined

Returns

NameTypeDescription

_0

bool

undefined

balanceOf

function balanceOf(address account) external view returns (uint256)

See {IERC20-balanceOf}.

Parameters

NameTypeDescription

account

address

undefined

Returns

NameTypeDescription

_0

uint256

undefined

checkpoints

function checkpoints(address account, uint32 pos) external view returns (struct ERC20VotesUpgradeable.Checkpoint)

Get the pos-th checkpoint for account.

Parameters

NameTypeDescription

account

address

undefined

pos

uint32

undefined

Returns

NameTypeDescription

_0

ERC20VotesUpgradeable.Checkpoint

undefined

computeVestingReleasableAmount

function computeVestingReleasableAmount(uint256 _index) external view returns (uint256)

Computes the releasable amount of tokens for a vesting schedule.

Parameters

NameTypeDescription

_index

uint256

index of the vesting schedule

Returns

NameTypeDescription

_0

uint256

amount of releasable tokens

computeVestingVestedAmount

function computeVestingVestedAmount(uint256 _index) external view returns (uint256)

Computes the vested amount of tokens for a vesting schedule.

Parameters

NameTypeDescription

_index

uint256

index of the vesting schedule

Returns

NameTypeDescription

_0

uint256

amount of vested tokens

createVestingSchedule

function createVestingSchedule(uint64 _start, uint32 _cliffDuration, uint32 _duration, uint32 _periodDuration, uint32 _lockDuration, bool _revocable, uint256 _amount, address _beneficiary, address _delegatee, bool _ignoreGlobalUnlockSchedule) external nonpayable returns (uint256)

Creates a new vesting scheduleThere may delay between the time a user should start vesting tokens and the time the vesting schedule is actually created on the contract.Typically a user joins the Liquid Collective but some weeks pass before the user gets all legal agreements in place and signed for thetoken grant emission to happen. In this case, the vesting schedule created for the token grant would start on the join date which is in the past.

As vesting schedules can be created in the past, this means that you should be careful when creating a vesting schedule and what duration parametersyou use as this contract would allow creating a vesting schedule in the past and even a vesting schedule that has already ended.

Parameters

NameTypeDescription

_start

uint64

start time of the vesting

_cliffDuration

uint32

duration to vesting cliff (in seconds)

_duration

uint32

total vesting schedule duration after which all tokens are vested (in seconds)

_periodDuration

uint32

duration of a period after which new tokens unlock (in seconds)

_lockDuration

uint32

duration during which tokens are locked (in seconds)

_revocable

bool

whether the vesting schedule is revocable or not

_amount

uint256

amount of token attributed by the vesting schedule

_beneficiary

address

address of the beneficiary of the tokens

_delegatee

address

address to delegate escrow voting power to

_ignoreGlobalUnlockSchedule

bool

whether the vesting schedule should ignore the global lock

Returns

NameTypeDescription

_0

uint256

index of the created vesting schedule

decimals

function decimals() external view returns (uint8)

Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5.05 (505 / 10 ** 2). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.

Returns

NameTypeDescription

_0

uint8

undefined

decreaseAllowance

function decreaseAllowance(address spender, uint256 subtractedValue) external nonpayable returns (bool)

Atomically decreases the allowance granted to spender by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - spender cannot be the zero address. - spender must have allowance for the caller of at least subtractedValue.

Parameters

NameTypeDescription

spender

address

undefined

subtractedValue

uint256

undefined

Returns

NameTypeDescription

_0

bool

undefined

delegate

function delegate(address delegatee) external nonpayable

Delegate votes from the sender to delegatee.

Parameters

NameTypeDescription

delegatee

address

undefined

delegateBySig

function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external nonpayable

Delegates votes from signer to delegatee

Parameters

NameTypeDescription

delegatee

address

undefined

nonce

uint256

undefined

expiry

uint256

undefined

v

uint8

undefined

r

bytes32

undefined

s

bytes32

undefined

delegateVestingEscrow

function delegateVestingEscrow(uint256 _index, address _delegatee) external nonpayable returns (bool)

Delegate vesting escrowed tokens

Parameters

NameTypeDescription

_index

uint256

index of the vesting schedule

_delegatee

address

address to delegate the token to

Returns

NameTypeDescription

_0

bool

True on success

delegates

function delegates(address account) external view returns (address)

Get the address account is currently delegating to.

Parameters

NameTypeDescription

account

address

undefined

Returns

NameTypeDescription

_0

address

undefined

getPastTotalSupply

function getPastTotalSupply(uint256 blockNumber) external view returns (uint256)

Retrieve the totalSupply at the end of blockNumber. Note, this value is the sum of all balances. It is but NOT the sum of all the delegated votes! Requirements: - blockNumber must have been already mined

Parameters

NameTypeDescription

blockNumber

uint256

undefined

Returns

NameTypeDescription

_0

uint256

undefined

getPastVotes

function getPastVotes(address account, uint256 blockNumber) external view returns (uint256)

Retrieve the number of votes for account at the end of blockNumber. Requirements: - blockNumber must have been already mined

Parameters

NameTypeDescription

account

address

undefined

blockNumber

uint256

undefined

Returns

NameTypeDescription

_0

uint256

undefined

getVestingSchedule

function getVestingSchedule(uint256 _index) external view returns (struct VestingSchedulesV2.VestingSchedule)

Get vesting schedule

The vesting schedule structure represents a static configuration used to compute the desiredvesting details of a beneficiary at all times. The values won't change even after tokens are released.The only dynamic field of the structure is end, and is updated whenever a vesting schedule is revoked

Parameters

NameTypeDescription

_index

uint256

Index of the vesting schedule

Returns

NameTypeDescription

_0

VestingSchedulesV2.VestingSchedule

undefined

getVestingScheduleCount

function getVestingScheduleCount() external view returns (uint256)

Get count of vesting schedules

Returns

NameTypeDescription

_0

uint256

count of vesting schedules

getVotes

function getVotes(address account) external view returns (uint256)

Gets the current votes balance for account

Parameters

NameTypeDescription

account

address

undefined

Returns

NameTypeDescription

_0

uint256

undefined

increaseAllowance

function increaseAllowance(address spender, uint256 addedValue) external nonpayable returns (bool)

Atomically increases the allowance granted to spender by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - spender cannot be the zero address.

Parameters

NameTypeDescription

spender

address

undefined

addedValue

uint256

undefined

Returns

NameTypeDescription

_0

bool

undefined

isGlobalUnlockedScheduleIgnored

function isGlobalUnlockedScheduleIgnored(uint256 _index) external view returns (bool)

Get vesting global unlock schedule activation status for a vesting schedule

Parameters

NameTypeDescription

_index

uint256

Index of the vesting schedule

Returns

NameTypeDescription

_0

bool

true if the vesting schedule should ignore the global unlock schedule

name

function name() external view returns (string)

Returns the name of the token.

Returns

NameTypeDescription

_0

string

undefined

nonces

function nonces(address owner) external view returns (uint256)

See {IERC20Permit-nonces}.

Parameters

NameTypeDescription

owner

address

undefined

Returns

NameTypeDescription

_0

uint256

undefined

numCheckpoints

function numCheckpoints(address account) external view returns (uint32)

Get number of checkpoints for account.

Parameters

NameTypeDescription

account

address

undefined

Returns

NameTypeDescription

_0

uint32

undefined

permit

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable

See {IERC20Permit-permit}.

Parameters

NameTypeDescription

owner

address

undefined

spender

address

undefined

value

uint256

undefined

deadline

uint256

undefined

v

uint8

undefined

r

bytes32

undefined

s

bytes32

undefined

releaseVestingSchedule

function releaseVestingSchedule(uint256 _index) external nonpayable returns (uint256)

Release vesting scheduleWhen tokens are released from the escrow, the delegated address of the escrow will see its voting power decrease.The beneficiary has to make sure its delegation parameters are set properly to be able to use/delegate the voting power of its balance.

Parameters

NameTypeDescription

_index

uint256

Index of the vesting schedule to release

Returns

NameTypeDescription

_0

uint256

released amount

revokeVestingSchedule

function revokeVestingSchedule(uint256 _index, uint64 _end) external nonpayable returns (uint256)

Revoke vesting schedule

Parameters

NameTypeDescription

_index

uint256

Index of the vesting schedule to revoke

_end

uint64

End date for the schedule

Returns

NameTypeDescription

_0

uint256

amount returned to the vesting schedule creator

symbol

function symbol() external view returns (string)

Returns the symbol of the token, usually a shorter version of the name.

Returns

NameTypeDescription

_0

string

undefined

totalSupply

function totalSupply() external view returns (uint256)

See {IERC20-totalSupply}.

Returns

NameTypeDescription

_0

uint256

undefined

transfer

function transfer(address to, uint256 amount) external nonpayable returns (bool)

See {IERC20-transfer}. Requirements: - to cannot be the zero address. - the caller must have a balance of at least amount.

Parameters

NameTypeDescription

to

address

undefined

amount

uint256

undefined

Returns

NameTypeDescription

_0

bool

undefined

transferFrom

function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool)

See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum uint256. Requirements: - from and to cannot be the zero address. - from must have a balance of at least amount. - the caller must have allowance for from's tokens of at least amount.

Parameters

NameTypeDescription

from

address

undefined

to

address

undefined

amount

uint256

undefined

Returns

NameTypeDescription

_0

bool

undefined

vestingEscrow

function vestingEscrow(uint256 _index) external view returns (address)

Get the address of the escrow for a vesting schedule

Parameters

NameTypeDescription

_index

uint256

Index of the vesting schedule

Returns

NameTypeDescription

_0

address

address of the escrow

Events

Approval

event Approval(address indexed owner, address indexed spender, uint256 value)

Emitted when the allowance of a spender for an owner is set by a call to {approve}. value is the new allowance.

Parameters

NameTypeDescription

owner indexed

address

undefined

spender indexed

address

undefined

value

uint256

undefined

CreatedVestingSchedule

event CreatedVestingSchedule(uint256 index, address indexed creator, address indexed beneficiary, uint256 amount)

A new vesting schedule has been created

Parameters

NameTypeDescription

index

uint256

Vesting schedule index

creator indexed

address

Creator of the vesting schedule

beneficiary indexed

address

Vesting beneficiary address

amount

uint256

Vesting schedule amount

DelegateChanged

event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate)

Emitted when an account changes their delegate.

Parameters

NameTypeDescription

delegator indexed

address

undefined

fromDelegate indexed

address

undefined

toDelegate indexed

address

undefined

DelegateVotesChanged

event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance)

Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.

Parameters

NameTypeDescription

delegate indexed

address

undefined

previousBalance

uint256

undefined

newBalance

uint256

undefined

DelegatedVestingEscrow

event DelegatedVestingEscrow(uint256 index, address indexed oldDelegatee, address indexed newDelegatee, address indexed beneficiary)

Vesting escrow has been delegated

Parameters

NameTypeDescription

index

uint256

Vesting schedule index

oldDelegatee indexed

address

old delegatee

newDelegatee indexed

address

new delegatee

beneficiary indexed

address

vesting schedule beneficiary

Initialized

event Initialized(uint8 version)

Triggered when the contract has been initialized or reinitialized.

Parameters

NameTypeDescription

version

uint8

undefined

ReleasedVestingSchedule

event ReleasedVestingSchedule(uint256 index, uint256 releasedAmount)

Vesting schedule has been released

Parameters

NameTypeDescription

index

uint256

Vesting schedule index

releasedAmount

uint256

Amount of tokens released to the beneficiary

RevokedVestingSchedule

event RevokedVestingSchedule(uint256 index, uint256 returnedAmount, uint256 newEnd)

Vesting schedule has been revoked

Parameters

NameTypeDescription

index

uint256

Vesting schedule index

returnedAmount

uint256

Amount of tokens returned to the creator

newEnd

uint256

New end timestamp after revoke action

Transfer

event Transfer(address indexed from, address indexed to, uint256 value)

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

Parameters

NameTypeDescription

from indexed

address

undefined

to indexed

address

undefined

value

uint256

undefined

Errors

GlobalUnlockUnderlfow

error GlobalUnlockUnderlfow()

Underflow in global unlock logic (should never happen)

InvalidRevokedVestingScheduleEnd

error InvalidRevokedVestingScheduleEnd()

Attempt to revoke a vesting schedule with an invalid end parameter

InvalidVestingScheduleParameter

error InvalidVestingScheduleParameter(string msg)

Invalid parameter for a vesting schedule

Parameters

NameTypeDescription

msg

string

undefined

Unauthorized

error Unauthorized(address caller)

The operator is unauthorized for the caller

Parameters

NameTypeDescription

caller

address

Address performing the call

UnsufficientVestingScheduleCreatorBalance

error UnsufficientVestingScheduleCreatorBalance()

Vesting schedule creator has unsufficient balance to create vesting schedule

VestingScheduleIsLocked

error VestingScheduleIsLocked()

The vesting schedule is locked

VestingScheduleNotFound

error VestingScheduleNotFound(uint256 index)

The VestingSchedule was not found

Parameters

NameTypeDescription

index

uint256

vesting schedule index

VestingScheduleNotRevocable

error VestingScheduleNotRevocable()

The vesting schedule is not revocable

VestingScheduleNotRevocableInPast

error VestingScheduleNotRevocableInPast()

Attempt to revoke a schedule in the past

ZeroReleasableAmount

error ZeroReleasableAmount()

No token to release

Last updated