SIGN IN SIGN UP
unionlabs / union UNCLAIMED

The trust-minimized, zero-knowledge bridging protocol, designed for censorship resistance, extremely high security, and usage in decentralized finance.

0 0 174 Rust

feat(evm): introduce vesting contracts (#4667)

## Overview
A token vesting system that manages time-locked token releases for
beneficiaries through individual vesting accounts, with integrated
staking capabilities for governance participation.
## Core Components
### VestingManager
- **Purpose**: Central controller for all vesting schedules and staking
operations
- **Key Functions**:
- `update()` - Create/modify vesting schedules with beneficiary, start
time, cliff, and duration
- `release()` - Release vested tokens to beneficiaries (callable by
anyone)
- `stake()` - Stake tokens from vesting account for governance
(beneficiary only)
- `unstake()` - Unstake tokens back to vesting account (beneficiary
only)
- `withdrawStake()` - Withdraw unstaked tokens to vesting account
(beneficiary only)
- `upgradeVestingAccountBeacon()` - Upgrade all vesting account
implementations
### VestingAccount
- **Purpose**: Individual proxy contracts that hold tokens for each
vesting schedule
- **Key Functions**:
- `transfer()` - Transfer tokens to beneficiary (only callable by
VestingManager)
- `execute()` - Execute arbitrary calls (restricted to authority)
- `stake()` - Execute staking operations through ZKGM protocol (only
callable by VestingManager)
- `unstake()` - Execute unstaking operations through ZKGM protocol (only
callable by VestingManager)
- `withdrawStake()` - Execute stake withdrawal through ZKGM protocol
(only callable by VestingManager)
- **Deployment**: Created deterministically using CREATE3 when vesting
schedule is updated
## Vesting Schedule Parameters
- **Beneficiary**: Address that receives vested tokens
- **Start**: Timestamp when vesting begins
- **Cliff**: Duration before any tokens can be released
- **Duration**: Total vesting period
- **Key**: Unique identifier for each vesting schedule
## Vesting Logic
- **Before cliff**: 0% of tokens releasable
- **After cliff**: Linear vesting based on time elapsed
- **After duration**: 100% of tokens releasable
- **Formula**: `(totalAllocation * (timestamp - start)) / duration`
## Staking Integration
- **Governance Participation**: Beneficiaries can stake their vested
tokens for governance voting
- **Beneficiary Control**: Only the designated beneficiary can initiate
staking operations
- **Account Validation**: All staking operations enforce that sender and
beneficiary must be the vesting account itself (force vesting on staking
yield etc...)
## Access Control
- **Authority-based**: Uses OpenZeppelin's AccessManaged for restricted
functions
- **Public release**: Anyone can trigger token releases for any vesting
schedule
- **Beneficiary-only staking**: Only beneficiaries can control staking
operations for their vesting schedules
- **Upgradeable**: Both contracts support UUPS upgrades
## Events
- `Updated`: Emitted when vesting schedule is created/modified
- `Released`: Emitted when tokens are released to beneficiary
- `Staked`: Emitted when tokens are staked for governance
- `Unstaked`: Emitted when tokens are unstaked
- `StakeWithdrawn`: Emitted when unstaked tokens are withdrawn
H
hussein committed
e52234e0b26bd3a26c8c78d3f2bd073bc0ebde9a
Committed by GitHub <noreply@github.com> on 6/26/2025, 9:47:17 AM