GovernanceToken
Inherits: ERC20Upgradeable, ERC20BurnableUpgradeable, ERC20PausableUpgradeable, AccessControlUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, UUPSUpgradeable
Burnable contract that votes and has BnM-Bridge functionality
Implements a secure and upgradeable DAO governance token
Notes:
security-contact: security@nebula-labs.xyz
oz-upgrades:
State Variables
INITIAL_SUPPLY
Token supply and distribution constants
uint256 private constant INITIAL_SUPPLY = 50_000_000 ether;DEFAULT_MAX_BRIDGE_AMOUNT
uint256 private constant DEFAULT_MAX_BRIDGE_AMOUNT = 5_000 ether;TREASURY_SHARE
uint256 private constant TREASURY_SHARE = 27_400_000 ether;ECOSYSTEM_SHARE
DEPLOYER_SHARE
UPGRADE_TIMELOCK_DURATION
Upgrade timelock duration (in seconds)
TGE_ROLE
AccessControl Role Constants
PAUSER_ROLE
BRIDGE_ROLE
UPGRADER_ROLE
MANAGER_ROLE
initialSupply
Initial token supply
maxBridge
max bridge passthrough amount
version
number of UUPS upgrades
tge
tge initialized variable
pendingUpgrade
__gap
Storage gap for future upgrades
Functions
nonZeroAmount
Modifier to check for non-zero amounts
Parameters
amount
uint256
The amount to validate
nonZeroAddress
Modifier to check for non-zero addresses
Parameters
addr
address
The address to validate
constructor
Note: oz-upgrades-unsafe-allow: constructor
receive
initializeUUPS
Sets up the initial state of the contract, including roles and token supplies.
Initializes the UUPS contract.
Notes:
requires: The addresses must not be zero.
events-emits: Initialized event.
throws: ZeroAddress if any address is zero.
Parameters
guardian
address
The address of the guardian (admin).
timelock
address
The address of the timelock controller.
setBridgeAddress
Sets the bridge address with BRIDGE_ROLE
Notes:
requires-role: MANAGER_ROLE
throws: ZeroAddress if bridgeAddress is zero
Parameters
bridgeAddress
address
The address of the bridge contract
initializeTGE
Sets up the initial token distribution between the ecosystem and treasury contracts.
Initializes the Token Generation Event (TGE).
Notes:
requires: The ecosystem and treasury addresses must not be zero.
requires: TGE must not be already initialized.
events-emits: TGE event.
throws: ZeroAddress if any address is zero.
throws: TGEAlreadyInitialized if TGE was already initialized.
Parameters
ecosystem
address
The address of the ecosystem contract.
treasury
address
The address of the treasury contract.
pause
This function can be called by an account with the PAUSER_ROLE to pause the contract.
Pauses all token transfers and operations.
Notes:
requires-role: PAUSER_ROLE
events-emits: {Paused} event from PausableUpgradeable
unpause
This function can be called by an account with the PAUSER_ROLE to unpause the contract.
Unpauses all token transfers and operations.
Notes:
requires-role: PAUSER_ROLE
events-emits: {Unpaused} event from PausableUpgradeable
bridgeMint
Can only be called by the official Bridge contract
Mints tokens for cross-chain bridge transfers
Notes:
requires-role: BRIDGE_ROLE
requires: Total supply must not exceed initialSupply
requires: to address must not be zero
requires: amount must not be zero or exceed maxBridge limit
events-emits: BridgeMint event
throws: ZeroAddress if recipient address is zero
throws: ZeroAmount if amount is zero
throws: BridgeAmountExceeded if amount exceeds maxBridge
throws: MaxSupplyExceeded if the mint would exceed initialSupply
Parameters
to
address
Address receiving the tokens
amount
uint256
Amount to mint
updateMaxBridgeAmount
Only callable by manager role
Updates the maximum allowed bridge amount per transaction
Notes:
requires-role: MANAGER_ROLE
requires: New amount must be greater than zero and less than 1% of total supply
events-emits: MaxBridgeUpdated event
throws: ZeroAmount if newMaxBridge is zero
throws: ValidationFailed if bridge amount is too high
Parameters
newMaxBridge
uint256
New maximum bridge amount
scheduleUpgrade
Only callable by an address with UPGRADER_ROLE
Schedules an upgrade to a new implementation
Notes:
requires-role: UPGRADER_ROLE
events-emits: UpgradeScheduled event
throws: ZeroAddress if newImplementation is zero
Parameters
newImplementation
address
Address of the new implementation
cancelUpgrade
Cancels a previously scheduled upgrade
Only callable by addresses with UPGRADER_ROLE
upgradeTimelockRemaining
Returns the remaining time before a scheduled upgrade can be executed
Returns
<none>
uint256
The time remaining in seconds, or 0 if no upgrade is scheduled or timelock has passed
nonces
_update
_authorizeUpgrade
Internal authorization for contract upgrades with timelock enforcement
Notes:
requires-role: UPGRADER_ROLE (enforced by the function modifier)
requires: Upgrade must be scheduled and timelock must be expired
throws: UpgradeNotScheduled if no upgrade was scheduled
throws: UpgradeTimelockActive if timelock period hasn't passed
Parameters
newImplementation
address
Address of the new implementation contract
Events
Initialized
Initialized Event.
Parameters
src
address
sender address
TGE
event emitted at TGE
Parameters
amount
uint256
token amount
BridgeMint
event emitted when bridge triggers a mint
Parameters
src
address
sender
to
address
beneficiary address
amount
uint256
token amount
MaxBridgeUpdated
Emitted when the maximum bridge amount is updated
Parameters
admin
address
The address that updated the value
oldMaxBridge
uint256
Previous maximum bridge amount
newMaxBridge
uint256
New maximum bridge amount
BridgeRoleAssigned
Emitted when a bridge role is assigned
Parameters
admin
address
The admin who set the role
bridgeAddress
address
The bridge address receiving the role
UpgradeScheduled
Emitted when an upgrade is scheduled
Parameters
sender
address
The address that scheduled the upgrade
implementation
address
The new implementation address
scheduledTime
uint64
The time when the upgrade was scheduled
effectiveTime
uint64
The time when the upgrade can be executed
UpgradeCancelled
Emitted when a scheduled upgrade is cancelled
Parameters
canceller
address
The address that cancelled the upgrade
implementation
address
The implementation address that was cancelled
Upgrade
Upgrade Event.
Parameters
src
address
sender address
implementation
address
address
Errors
ZeroAddress
Error thrown when an address parameter is zero
ZeroAmount
Error thrown when an amount parameter is zero
MaxSupplyExceeded
Error thrown when a mint would exceed the max supply
BridgeAmountExceeded
Error thrown when bridge amount exceeds allowed limit
TGEAlreadyInitialized
Error thrown when TGE is already initialized
InvalidAddress
Error thrown when addresses don't match expected values
UpgradeTimelockActive
Error thrown when trying to execute an upgrade too soon
UpgradeNotScheduled
Error thrown when trying to execute an upgrade that wasn't scheduled
ImplementationMismatch
Error thrown when trying to execute an upgrade with wrong implementation
ValidationFailed
Error thrown for general validation failures
Structs
UpgradeRequest
Upgrade timelock storage
Last updated