NativeTokenVestingManagerFactory
Factory for deploying native token (ETH) vesting managers with gas-based fee structures and simplified deployment.
Contract Information
File Location: contracts/factories/NativeTokenVestingManagerFactory.sol
Inheritance:
contract NativeTokenVestingManagerFactory is INativeTokenVestingManagerFactory, FactoryFeeManager
Overview
The NativeTokenVestingManagerFactory
provides standardized deployment of NativeTokenVestingManager
instances specifically designed for native blockchain tokens (ETH). Unlike ERC20 token managers, native token managers have simplified fee structures and don't require token address parameters.
Key Features
- Native token support - Deploys managers for ETH/native tokens only
- Gas-based fees only - Simplified fee structure using only gas fees
- Direct ETH handling - No token approvals or transfers required
- Consistent deployment patterns - Same deployment flow as other factories
- Admin privilege management - Deployer becomes admin automatically
Key Differences from ERC20 Factory
- No token address parameter - Native tokens don't require contract addresses
- Gas fees only - Does not support token-based fees
- Simplified fee logic - Only considers gas fees from custom configurations
- Direct ETH transfers - Uses
msg.value
for funding operations
Note: Still takes the token fee for compatibility.
Constructor
constructor(
address feeCollector_,
uint256 defaultGasFee_,
uint256 defaultTokenFee_
) FactoryFeeManager(feeCollector_, defaultGasFee_, defaultTokenFee_)
Parameters:
feeCollector_
: Address that will receive feesdefaultGasFee_
: Default gas fee amount (in wei) for deployments without custom feesdefaultTokenFee_
: Inherited fromFactoryFeeManager
but unused for native token managers
Note: While defaultTokenFee_
is inherited from FactoryFeeManager
, it's not used for native token manager deployments.
Example:
// Deploy factory with ETH gas fees
NativeTokenVestingManagerFactory factory = new NativeTokenVestingManagerFactory(
0x123...789, // Fee collector address
0.001 ether, // 0.001 ETH gas fee
0 // Token fee unused for native tokens
);
Core Functions
newNativeTokenVestingManager
function newNativeTokenVestingManager(
ITypes.FundingType fundingType
) external returns (NativeTokenVestingManager)
Deploys a new NativeTokenVestingManager
instance with caller-specific gas fee configuration.
Parameters:
fundingType
: Funding model (ITypes.FundingType.Full
orITypes.FundingType.Partial
)
Returns: Address of the newly deployed NativeTokenVestingManager
Process:
- Gas fee determination - Checks for custom gas fees for
msg.sender
, otherwise uses default - Manager deployment - Creates new
NativeTokenVestingManager
with determined parameters - Admin transfer - Sets deployer as admin and removes factory admin privileges
- Event emission - Emits
NativeTokenVestingManagerCreated
event
Example:
// Deploy manager with full funding for ETH
NativeTokenVestingManager manager = factory.newNativeTokenVestingManager(
ITypes.FundingType.Full
);
// The Manager is deployed with:
// - Token: Native ETH
// - Fee type: Gas (only option for native tokens)
// - Fee amount: Determined by deployer's custom config or factory default
// - Fee collector: Factory's fee collector
// - Funding type: Full
// - Admin: msg.sender (deployer)
Events
NativeTokenVestingManagerCreated
event NativeTokenVestingManagerCreated(
NativeTokenVestingManager indexed nativeTokenVestingManager,
uint256 fee,
address indexed feeCollector,
address creator,
ITypes.FundingType fundingType
)
Emitted when a new NativeTokenVestingManager
is deployed.
Parameters:
nativeTokenVestingManager
: Address of the deployed manager contractfee
: Gas fee amount (in wei)feeCollector
: Address that will collect feescreator
: Address that deployed the managerfundingType
: Funding model used
Note: Unlike ERC20 factories, there's no token
or feeType
parameter since native token managers only work with ETH and gas fees.
Fee Structure Logic
The factory determines gas fees based on deployer identity:
// Pseudocode for gas fee determination
if (hasCustomGasFee[msg.sender]) {
// Use custom gas fee set by factory admin
fee = customGasFees[msg.sender];
} else {
// Use factory default gas fee
fee = defaultGasFee;
}
// Fee type is always Gas for native token managers
feeType = ITypes.FeeType.Gas;
Security Considerations
ETH Handling
- Direct ETH transfers - Uses
msg.value
and low-level calls for ETH handling - Reentrancy protection - Manager contracts implement reentrancy guards with check-effect-interaction pattern
- Failed transfer handling - Proper error handling for ETH transfers
Access Control
- Factory admin controls - Only factory admin can set custom gas fees
- Manager admin transfer - Deployer becomes manager admin immediately
- Fee collector security - Fee collector address is immutable per deployment
Gas Optimization
- Simplified fee logic - Only gas fees reduce complexity
- Direct ETH handling - No token approval/transfer overhead
- Efficient deployment - Minimal factory logic for gas savings
Common Use Cases
1. Employee ETH Compensation
// Deploy manager for employee ETH vesting
NativeTokenVestingManager employeeManager = factory.newNativeTokenVestingManager(
ITypes.FundingType.Partial
);
// Fund and vest ETH based on employment terms
2. Project-Based ETH Distribution
// Deploy manager for project payments
NativeTokenVestingManager projectManager = factory.newNativeTokenVestingManager(
ITypes.FundingType.Full
);
// Create milestone-based ETH vesting for contractors
3. Investor ETH Returns
// Deploy manager for investor returns
NativeTokenVestingManager investorManager = factory.newNativeTokenVestingManager(
ITypes.FundingType.Full
);
// Set up ETH distribution schedules for investors
Best Practices
- ETH amount validation - Always verify
msg.value
matches expected amounts - Gas estimation - Account for gas fees when planning ETH distributions
- Funding strategy - Choose appropriate funding type based on use case
- Admin setup - Configure manager admin controls after deployment
- Security review - Audit ETH handling and admin controls
Comparison with ERC20 Factory
Feature | NativeTokenVestingManagerFactory | TokenVestingManagerFactory |
---|---|---|
Token Type | ETH/Native only | ERC20 tokens |
Token Parameter | Not required | Required |
Fee Types | Gas only | Gas or Token-based |
Funding Method | msg.value | Token transfers |
Complexity | Simplified | More complex |
Gas Cost | Lower | Higher (token operations) |
The NativeTokenVestingManagerFactory
provides a streamlined solution for ETH-based vesting with simplified deployment and management compared to ERC20 token alternatives.