The base vesting contract that implements core vesting functionality and virtual token features.
-
Vesting Schedule Management:
- Configurable start time, cliff period, and duration
- Customizable slice periods for gradual token release
- Optional revocability per schedule
- Admin controls for schedule management
-
Virtual Token Implementation:
- ERC20-compatible interface
- Non-transferable by design
- Balance represents vested tokens
- Automatic balance updates on vesting events
-
Access Control:
DEFAULT_ADMIN_ROLE
: Can manage vesting schedules and contract settingsVESTING_CREATOR_ROLE
: Can create new vesting schedules
- OpenZeppelin's AccessControlDefaultAdminRules
- OpenZeppelin's ReentrancyGuard
- OpenZeppelin's Pausable
- IERC20Metadata
createVestingSchedule()
: Creates new vesting schedulesrelease()
: Releases vested tokens to beneficiariesrevoke()
: Allows admin to revoke revocable scheduleswithdraw()
: Enables admin to withdraw unused tokens
- Reentrancy protection on critical functions
- Pausable functionality for emergency stops
- Role-based access control
- Comprehensive input validation
Extends TokenVesting with Merkle tree functionality for efficient schedule distribution.
- Merkle Tree Integration:
- Efficient proof verification
- Prevention of double-claiming
- Batch schedule distribution support
- TokenVesting
claimSchedule()
: Claims vesting schedule using Merkle proofupdateMerkleRoot()
: Updates the Merkle rootscheduleClaimed()
: Checks if a schedule has been claimed
Extends TokenVestingMerkle with purchasing capabilities.
- Purchase Mechanism:
- ETH payments for vesting schedules
- Configurable cost per vToken
- Customizable payment receiver
- TokenVestingMerkle
claimSchedule()
: Claims schedule with paymentsetVTokenCost()
: Updates the cost per vTokensetPaymentReceiver()
: Sets payment receiver address
Located in src/deprecated/
:
- Enables querying vesting balances across multiple contracts
- Supports external vesting contract integration
- Combines MultiTokenVesting and TokenVestingMerklePurchasable
- Supports cross-contract schedule verification
- Flexible Vesting Schedules: Configure start time, cliff period, duration, and release intervals
- Access Control: Role-based permissions for administrative functions
- Safety Features: Includes reentrancy protection and pausable functionality
- Virtual Token: ERC20-compatible representation of vested tokens (non-transferable)
- Merkle Tree Support: Efficient distribution of vesting schedules
- Purchase Options: Optional ETH payment for vesting schedule creation
The smart contracts have been thoroughly tested with comprehensive coverage across all active contracts:
-
TokenVesting.sol:
- Lines: 97.96% (96/98)
- Statements: 98.48% (130/132)
- Branches: 95.45% (21/22)
- Functions: 95.45% (21/22)
-
TokenVestingMerkle.sol:
- Lines: 100% (16/16)
- Statements: 100% (13/13)
- Branches: 100% (2/2)
- Functions: 100% (4/4)
-
TokenVestingMerklePurchasable.sol:
- Lines: 100% (29/29)
- Statements: 93.55% (29/31)
- Branches: 66.67% (4/6)
- Functions: 100% (6/6)
- Total Tests: 54
- Passing Tests: 54
- Failed Tests: 0
- Skipped Tests: 0
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
Foundry consists of:
- Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
- Chisel: Fast, utilitarian, and verbose solidity REPL.
$ forge build
$ forge test
$ forge fmt
$ forge snapshot
$ anvil
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
$ cast <subcommand>
$ forge --help
$ anvil --help
$ cast --help