Lendefi DAO
  • Home
  • ❱ audit
    • Ecosystem
    • GovernanceToken
    • InvestmentManager
    • InvestorVesting
    • LendefiGovernor
    • PartnerVesting
    • TeamManager
    • TeamVesting
    • Treasury
    • Deploy
  • ❱ ecosystem
    • Ecosystem
    • GovernanceToken
    • InvestmentManager
    • InvestorVesting
    • LendefiGovernor
    • PartnerVesting
    • TeamManager
    • TeamVesting
    • Treasury
  • ❱ interfaces
    • IECOSYSTEM
    • IINVMANAGER
    • ILENDEFI
    • IPARTNERVESTING
    • ITEAMMANAGER
    • ITEAMVESTING
    • ITREASURY
    • IVESTING
  • ❱ deploys
  • ❱ tokenomics
Powered by GitBook
On this page
  • State Variables
  • _start
  • _duration
  • _token
  • _timelock
  • _tokensReleased
  • Functions
  • onlyTimelock
  • constructor
  • cancelContract
  • release
  • start
  • duration
  • end
  • released
  • releasable
  • _checkTimelock
  • vestedAmount
  • _vestingSchedule
  1. ❱ ecosystem

TeamVesting

PreviousTeamManagerNextTreasury

Last updated 2 months ago

Inherits:, Context, Ownable2Step, ReentrancyGuard

Cancellable Vesting contract

Offers flexible withdrawal schedule (gas efficient)

Implements secure linear vesting for the DAO team

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

address private immutable _token;

_timelock

Address of the timelock controller that can cancel vesting

address public immutable _timelock;

_tokensReleased

Running total of tokens that have been released

uint256 private _tokensReleased;

Functions

onlyTimelock

Restricts function access to the timelock controller only

Used for cancellation functionality

modifier onlyTimelock();

constructor

Creates a new vesting contract for a team member

Sets the beneficiary as the owner, initializes immutable vesting parameters

constructor(address token, address timelock, address beneficiary, uint64 startTimestamp, uint64 durationSeconds)
    Ownable(beneficiary);

Parameters

Name
Type
Description

token

address

Address of the ERC20 token to be vested

timelock

address

Address of the timelock controller

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 timelock

function cancelContract() external nonReentrant onlyTimelock returns (uint256 remainder);

Returns

Name
Type
Description

remainder

uint256

The amount of unvested tokens returned to the timelock

release

Releases vested tokens to the beneficiary

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

function release() public virtual nonReentrant onlyOwner;

start

Returns the timestamp when vesting starts

This value is immutable and set during contract creation

function start() public view virtual returns (uint256);

Returns

Name
Type
Description

<none>

uint256

The start timestamp of the vesting period

duration

Returns the duration of the vesting period

This value is immutable and set during contract creation

function duration() public view virtual returns (uint256);

Returns

Name
Type
Description

<none>

uint256

The duration in seconds of the vesting period

end

Returns the timestamp when vesting ends

Calculated as start() + duration()

function end() public view virtual returns (uint256);

Returns

Name
Type
Description

<none>

uint256

The end timestamp of the vesting period

released

Returns the amount of tokens already released

Used in vesting calculations to determine how many more tokens can be released

function released() public view virtual returns (uint256);

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

Subtracts already released tokens from the total vested amount

function releasable() public view virtual returns (uint256);

Returns

Name
Type
Description

<none>

uint256

The amount of tokens currently available to be released

_checkTimelock

Verifies the caller is the timelock controller

Throws Unauthorized error if caller is not the timelock

function _checkTimelock() internal view virtual;

vestedAmount

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

Internal function used by releasable()

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

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

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

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

Git Source
ITEAMVESTING