GovernanceToken
Last updated
Last updated
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:
Token supply and distribution constants
Upgrade timelock duration (in seconds)
AccessControl Role Constants
Initial token supply
max bridge passthrough amount
number of UUPS upgrades
tge initialized variable
Storage gap for future upgrades
Modifier to check for non-zero amounts
Parameters
amount
uint256
The amount to validate
Modifier to check for non-zero addresses
Parameters
addr
address
The address to validate
Note: oz-upgrades-unsafe-allow: constructor
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.
throws: ZeroAddress if any address is zero.
Parameters
guardian
address
The address of the guardian (admin).
timelock
address
The address of the timelock controller.
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
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.
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.
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
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
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
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
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
throws: ZeroAmount if newMaxBridge is zero
throws: ValidationFailed if bridge amount is too high
Parameters
newMaxBridge
uint256
New maximum bridge amount
Only callable by an address with UPGRADER_ROLE
Schedules an upgrade to a new implementation
Notes:
requires-role: UPGRADER_ROLE
throws: ZeroAddress if newImplementation is zero
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
The time remaining in seconds, or 0 if no upgrade is scheduled or timelock has passed
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
Initialized Event.
Parameters
src
address
sender address
event emitted at TGE
Parameters
amount
uint256
token amount
event emitted when bridge triggers a mint
Parameters
src
address
sender
to
address
beneficiary address
amount
uint256
token amount
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
Emitted when a bridge role is assigned
Parameters
admin
address
The admin who set the role
bridgeAddress
address
The bridge address receiving the role
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
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 Event.
Parameters
src
address
sender address
implementation
address
address
Error thrown when an address parameter is zero
Error thrown when an amount parameter is zero
Error thrown when a mint would exceed the max supply
Error thrown when bridge amount exceeds allowed limit
Error thrown when TGE is already initialized
Error thrown when addresses don't match expected values
Error thrown when trying to execute an upgrade too soon
Error thrown when trying to execute an upgrade that wasn't scheduled
Error thrown when trying to execute an upgrade with wrong implementation
Error thrown for general validation failures
Upgrade timelock storage
events-emits: event.
events-emits: event.
events-emits: event
events-emits: event
events-emits: event