InvestorVesting
Overview
The InvestorVesting contract implements a linear token vesting schedule for investors participating in the Lendefi DAO ecosystem. Derived from OpenZeppelin's VestingWallet, this contract provides a clean, gas-efficient mechanism for token distribution with time-based release controls.
Architecture Analysis
Contract Structure
Inheritance Model: Implements IVESTING interface and inherits from Context and Ownable2Step
Storage Design: Uses immutable variables for core parameters (token, start, duration)
Release Mechanism: On-demand release pattern rather than automatic distribution
Ownership Model: Two-step ownership transfer for improved security
Vesting Design
Schedule Type: Pure linear vesting with no cliff period
Calculation Method: Uses time proportion formula:
totalAllocation * (currentTime - startTime) / duration
Flexibility: Relies on manual release calls rather than automatic distribution
Technical Assessment
Strengths
Gas Efficiency:
Immutable variables reduce storage operations
On-demand release pattern conserves gas
Efficient vesting calculation with minimal operations
Security Features:
Two-step ownership transfers prevent accidental transfers
SafeERC20 usage protects against non-standard token implementations
Input validation for zero addresses
Precise timestamp handling with SafeCast
Clean Design:
Single-responsibility principle followed throughout
Clear separation between calculation and execution
Minimal storage footprint
Auditability:
Simple, straightforward implementation
Well-documented functions with comments
Clear naming conventions
Potential Concerns
Limited Flexibility:
No cliff period option for investors
No partial release functionality
No way to adjust vesting parameters after deployment
Transfer Restrictions:
Beneficiary (owner) cannot transfer partial rights to another address
No streaming of tokens (only discrete releases)
Technical Considerations:
Mapping for
_erc20Released
seems unnecessary since only one token is usedNo recovery mechanism for accidentally sent tokens
No events for constructor initialization
Edge Cases:
No handling for token rebasing or fee-on-transfer tokens
Function may fail if token implements hooks that consume excessive gas
Code Quality Assessment
Documentation: Good NatSpec documentation for functions
Input Validation: Basic zero address check in constructor
Event Emissions: Appropriate event for token release
Variable Naming: Clear and descriptive
Code Organization: Logical grouping of functions
Inheritance: Appropriate use of OpenZeppelin contracts
Inherits: IVESTING, Context, Ownable2Step
Investor Vesting contract
Offers flexible withdrawal schedule (gas efficient)
Implements linear vesting schedule for investors
Note: security-contact: security@nebula-labs.xyz
State Variables
_start
start timestamp
_duration
duration seconds
_token
token address
_erc20Released
amount of tokens released
Functions
constructor
Sets the owner to beneficiary address, the start timestamp and the vesting duration of the vesting contract.
release
Release the tokens that have already vested. Emits a {ERC20Released} event.
start
Getter for the start timestamp.
Returns
<none>
uint256
start timestamp
duration
Getter for the vesting duration.
Returns
<none>
uint256
duration seconds
end
Getter for the end timestamp.
Returns
<none>
uint256
end timnestamp
released
Getter for the amount of token already released
Returns
<none>
uint256
amount of tokens released so far
releasable
Getter for the amount of vested ERC20
tokens.
Returns
<none>
uint256
amount of vested tokens
vestedAmount
Calculates the amount of tokens that has already vested. Default implementation is a linear vesting curve.
Parameters
timestamp
uint64
current timestamp
Returns
<none>
uint256
amount vested
_vestingSchedule
Virtual implementation of the vesting formula. This returns the amount vested, as a function of time, for an asset given its total historical allocation.
Parameters
totalAllocation
uint256
initial amount
timestamp
uint64
current timestamp
Returns
<none>
uint256
amount vested
Last updated