PartnerVesting

Git Source

Inherits:IPARTNERVESTING, Context, Ownable2Step, ReentrancyGuard

Author: alexei@nebula-labs(dot)xyz

Manages linear token vesting for Lendefi partners

Implements a time-based linear vesting schedule with partner control and DAO cancellation capability

Note: security-contact: security@nebula-labs.xyz

State Variables

_start

Start timestamp of the vesting period

uint64 private immutable _start;

_duration

Duration of the vesting period in seconds

uint64 private immutable _duration;

_token

Address of the token being vested

_creator

Address that created this contract (Ecosystem contract)

_tokensReleased

Running total of tokens that have been released

Functions

onlyAuthorized

Restricts function access to the contract creator only

Used for cancellation functionality

constructor

Creates a new vesting contract for a partner

Sets the beneficiary as the owner, initializes immutable vesting parameters

Parameters

Name
Type
Description

token

address

Address of the ERC20 token to be vested

beneficiary

address

Address that will receive the vested tokens

startTimestamp

uint64

UNIX timestamp when vesting begins

durationSeconds

uint64

Duration of vesting period in seconds

cancelContract

Cancels the vesting contract, releasing vested tokens and returning unvested tokens

First releases any vested tokens to the beneficiary, then returns remaining tokens to creator

Returns

Name
Type
Description

remainder

uint256

The amount of tokens returned to the creator

release

Releases vested tokens to the beneficiary

Can be called by anyone but tokens are always sent to the owner (beneficiary)

start

Returns the timestamp when vesting starts

Returns

Name
Type
Description

<none>

uint256

The start timestamp of the vesting period

duration

Returns the duration of the vesting period

Returns

Name
Type
Description

<none>

uint256

The duration in seconds of the vesting period

end

Returns the timestamp when vesting ends

Returns

Name
Type
Description

<none>

uint256

The end timestamp of the vesting period

released

Returns the amount of tokens already released

Returns

Name
Type
Description

<none>

uint256

The amount of tokens that have been released so far

releasable

Calculates the amount of tokens that can be released now

Returns

Name
Type
Description

<none>

uint256

The amount of tokens currently available to be released

vestedAmount

Calculates the amount of tokens that have vested by a given timestamp

Internal function used by releasable()

Parameters

Name
Type
Description

timestamp

uint64

The timestamp to calculate vested amount for

Returns

Name
Type
Description

<none>

uint256

The total amount of tokens vested at the specified timestamp

_vestingSchedule

Calculates vested tokens according to the linear vesting schedule

Implements the core vesting calculation logic

Parameters

Name
Type
Description

totalAllocation

uint256

Total token allocation (current balance + already released)

timestamp

uint64

The timestamp to calculate vested amount for

Returns

Name
Type
Description

<none>

uint256

The amount of tokens vested at the specified timestamp

_checkAuthorized

Verifies the caller is authorized to perform creator-only actions

Throws Unauthorized error if caller is not the creator

Last updated