Treasury
Last updated
Last updated
Inherits:, Initializable, UUPSUpgradeable, PausableUpgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable
Treasury contract with 3-year linear vesting and external multisig support
Implements a secure and upgradeable treasury with vesting for ETH and ERC20 tokens
Notes:
security-contact: security@nebula-labs.xyz
copyright: Copyright (c) 2025 Nebula Holding Inc. All rights reserved.
oz-upgrades:
Role identifier for accounts that can release funds
Role identifier for accounts that can pause/unpause the contract
Role identifier for accounts that can upgrade the contract
Upgrade timelock duration in seconds (3 days)
Current version of the contract implementation Incremented during upgrades
Start timestamp of the vesting schedule
Duration of the vesting period in seconds
Total amount of ETH already released
Timelock controller address
Mapping of token address to amount released for each token
Pending upgrade information
Reserved storage space for future upgrades This allows adding new state variables in future versions while maintaining the storage layout (30 - 7 = 23)
Modifier to check for non-zero address
Parameters
addr
address
The address to check
Modifier to check for non-zero amount
Parameters
amount
uint256
The amount to check
Prevents initialization of the implementation contract
Note: oz-upgrades-unsafe-allow: constructor
Allows the contract to receive ETH
Emits a {Received} event
Initializes the treasury contract
Sets up the initial state of the contract
Parameters
timelock
address
The address that will have the DEFAULT_ADMIN_ROLE and MANAGER_ROLE
multisig
address
The address of the Gnosis Safe multisig that will be granted the UPGRADER_ROLE
startOffset
uint256
The number of seconds the start time is before the current block timestamp
vestingDuration
uint256
The duration of vesting in seconds (must be at least 730 days)
Pauses all token transfers and releases
Can only be called by accounts with the PAUSER_ROLE
Unpauses token transfers and releases
Can only be called by accounts with the PAUSER_ROLE
Releases a specific amount of vested ETH
Can only be called by accounts with the MANAGER_ROLE
Reverts if the requested amount exceeds vested amount
Parameters
to
address
The address that will receive the ETH
amount
uint256
The amount of ETH to release
Releases a specific amount of vested tokens
Can only be called by accounts with the MANAGER_ROLE
Reverts if the requested amount exceeds vested amount
Parameters
token
address
The ERC20 token to release
to
address
The address that will receive the tokens
amount
uint256
The amount of tokens to release
Updates the vesting schedule parameters
Can only be called by accounts with the DEFAULT_ADMIN_ROLE
Parameters
newStart
uint256
The new start timestamp
newDuration
uint256
The new duration in seconds
Only callable by addresses with MANAGER_ROLE
Emergency function to withdraw all tokens to the timelock
Notes:
throws: ZeroAddress if token address is zero
throws: ZeroBalanceError if contract has no token balance
Parameters
token
address
The ERC20 token to withdraw
Only callable by addresses with MANAGER_ROLE
Emergency function to withdraw all ETH to the timelock
Note: throws: ZeroBalanceError if contract has no ETH balance
Schedules an upgrade to a new implementation
Parameters
newImplementation
address
Address of the new implementation
Cancels a previously scheduled upgrade
Only callable by addresses with UPGRADER_ROLE
Returns the remaining time before a scheduled upgrade can be executed
Returns
<none>
uint256
timeRemaining The time remaining in seconds, or 0 if no upgrade is scheduled or timelock has passed
Get the timelock controller address
Returns
<none>
address
The timelock controller address
Returns the amount of ETH that can be released now
Returns
<none>
uint256
Amount of releasable ETH
Returns the amount of a specific token that can be released now
Parameters
token
address
The ERC20 token to check
Returns
<none>
uint256
Amount of releasable tokens
Calculates the amount of ETH vested at a specific timestamp
Parameters
timestamp
uint256
The timestamp to check
Returns
<none>
uint256
The vested amount of ETH
Calculates the amount of tokens vested at a specific timestamp
Parameters
token
address
The ERC20 token to check
timestamp
uint256
The timestamp to check
Returns
<none>
uint256
The vested amount of tokens
Returns the current contract version
Returns
<none>
uint32
Current version number
Returns the start timestamp of the vesting period
Returns
<none>
uint256
Start timestamp
Returns the duration of the vesting period
Returns
<none>
uint256
Duration in seconds
Returns the end timestamp of the vesting period
Returns
<none>
uint256
End timestamp (start + duration)
Returns the amount of ETH already released
Returns
<none>
uint256
Amount of ETH released so far
Returns the amount of a specific token already released
Parameters
token
address
The ERC20 token to check
Returns
<none>
uint256
Amount of tokens released so far
Authorizes and processes contract upgrades with timelock enforcement
Internal override for UUPS upgrade authorization
Parameters
newImplementation
address
Address of the new implementation contract
Internal function to calculate vested amounts for a given allocation and timestamp
Uses linear vesting between start and end time
Parameters
totalAllocation
uint256
The total amount to vest
timestamp
uint256
The timestamp to check
Returns
<none>
uint256
The amount vested at the specified timestamp