GovernanceToken
Overview
The GovernanceToken contract implements the core token functionality for the Lendefi DAO ecosystem, serving as both a governance instrument and a bridgeable asset. It leverages OpenZeppelin's upgradeable contract framework and incorporates multiple token standards and security features.
Architecture Analysis
Contract Structure
Extensive inheritance: Combines seven OpenZeppelin upgradeable contracts to provide comprehensive functionality
UUPS upgradeability pattern: Implements the Universal Upgradeable Proxy Standard for future upgrades
Role-based access control: Uses AccessControl for permission management
Governance features: Incorporates ERC20Votes for on-chain governance
Token Economics
Fixed supply model: 50M tokens total supply
Predetermined distribution:
56% allocated to treasury
44% allocated to ecosystem
Bridge mechanism: Supports cross-chain functionality with safety limits (20K tokens max per bridge transaction)
Two-phase initialization: Separates contract setup from token generation event
Technical Assessment
Strengths
Security features:
Role-based permission system with specialized roles
Pausability for emergency situations
Bridge transaction size limits
One-time TGE initialization protection
Proper supply cap enforcement in bridge minting
Governance capabilities:
Full ERC20Votes implementation for governance participation
Permit functionality for gasless approvals
Checkpoints for vote delegation
Upgrade safety:
Version tracking via the version variable
Storage gap for future extension
Restricted upgrade authorization
Event emissions for upgrade transparency
Cross-chain design:
Bridge functionality with safety limits
Supply preservation across chains
Potential Concerns
Centralization risks:
Admin role has significant control (DEFAULT_ADMIN_ROLE)
No time-locks or multi-signature requirements for sensitive operations
Bridge functionality:
No mechanism to pause only bridge operations in emergency
No clear recovery path for failed bridge transactions
Fixed bridge limit with no adjustment mechanism
Initial distribution:
No vesting for initial token distribution
All tokens are immediately liquid at TGE
Code Quality Assessment
Documentation: Good NatSpec documentation for most functions and parameters
Error handling: Proper use of custom errors with descriptive messages
Event emissions: Comprehensive event logging for important state changes
Variable naming: Clear and descriptive naming conventions
Gas optimization: Standard OpenZeppelin patterns with reasonable efficiency
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
MAX_BRIDGE_AMOUNT
TREASURY_SHARE
ECOSYSTEM_SHARE
PAUSER_ROLE
AccessControl Pauser Role
BRIDGE_ROLE
AccessControl Bridge Role
UPGRADER_ROLE
AccessControl Upgrader Role
initialSupply
Initial token supply
maxBridge
max bridge passthrough amount
version
number of UUPS upgrades
tge
tge initialized variable
__gap
Functions
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 guardian address must not be zero.
events-emits: Initialized event.
throws: ZeroAddress if the guardian address is zero.
Parameters
guardian
address
The address of the guardian (admin).
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
requires: amount must not 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 admin role
Updates the maximum allowed bridge amount per transaction
Notes:
requires-role: DEFAULT_ADMIN_ROLE
requires: New amount must be greater than zero
events-emits: MaxBridgeUpdated event
throws: ZeroAmount if newMaxBridge is zero
Parameters
newMaxBridge
uint256
New maximum bridge amount
nonces
_update
_authorizeUpgrade
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
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
ValidationFailed
Error thrown for general validation failures
Last updated