BGT
The Berachain Governance Token ($BGT) is a soulbound ERC20 token, which cannot be transferred, only earned through Reward Vaults, used for governance proposals and voting, and can be redeemed for $BERA.
Inherits: IBGT, ERC20VotesUpgradeable, OwnableUpgradeable, Multicallable
Structs
QueuedBoost
The queued boost struct for validator boosting.
struct QueuedBoost {
uint32 blockNumberLast;
uint128 balance;
}
Properties
Name | Type | Description |
---|---|---|
blockNumberLast | uint32 | The last block number boost balance was queued |
balance | uint128 | The queued BGT balance to boost with |
QueuedDropBoost
The queued drop boost struct for validator boosting.
struct QueuedDropBoost {
uint32 blockNumberLast;
uint128 balance;
}
Properties
Name | Type | Description |
---|---|---|
blockNumberLast | uint32 | The last block number boost balance was queued for dropping |
balance | uint128 | The boosted BGT balance to drop boost with |
UserBoost
The user boost struct for tracking validator boosts.
struct UserBoost {
uint128 boost;
uint128 queuedBoost;
}
Properties
Name | Type | Description |
---|---|---|
boost | uint128 | The boost balance being used by the user |
queuedBoost | uint128 | The queued boost balance to be used by the user |
State Variables
activateBoostDelay
The block delay for activating boosts.
uint32 public activateBoostDelay;
bgtTermsAndConditions
The BGT terms and conditions.
string public bgtTermsAndConditions;
boosted
The mapping of balances used to boost validator rewards by an account
mapping(address account => mapping(bytes pubkey => uint128)) public boosted;
boostedQueue
The mapping of queued boosts on a validator by an account
mapping(address account => mapping(bytes pubkey => QueuedBoost)) public boostedQueue;
boostees
The mapping of boost balances for a validator
mapping(bytes pubkey => uint128) public boostees;
dropBoostDelay
The block delay for dropping boosts.
uint32 public dropBoostDelay;
dropBoostQueue
The mapping of queued drop boosts on a validator by an account
mapping(address account => mapping(bytes pubkey => QueuedDropBoost)) public dropBoostQueue;
isWhitelistedSender
The mapping of approved senders.
mapping(address sender => bool) public isWhitelistedSender;
staker
The BGTStaker contract address that we are using to stake and withdraw BGT.
This contract is used to distribute dapp fees to BGT delegators.
address public staker;
totalBoosts
Total amount of BGT used for validator boosts
uint128 public totalBoosts;
userBoosts
The mapping of user boosts
mapping(address account => UserBoost) public userBoosts;
View Functions
minter
function minter() external view returns (address);
Functions
activateBoost
Activates a queued boost on a validator.
Emits:
function activateBoost(address account, bytes calldata pubkey) external;
Parameters
Name | Type | Description |
---|---|---|
account | address | The account to activate boost for |
pubkey | bytes | The validator public key |
burn
Burns BGT tokens from the caller.
function burn(uint256 amount) external;
cancelQueuedBoost
Cancels a queued boost on a validator.
Emits:
function cancelQueuedBoost(bytes calldata pubkey) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The validator public key |
cancelQueuedDropBoost
Cancels a queued drop boost on a validator.
Emits:
function cancelQueuedDropBoost(bytes calldata pubkey) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The validator public key |
dropBoost
Drops a boost on a validator.
Emits:
function dropBoost(bytes calldata pubkey, uint128 amount) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The validator public key |
amount | uint128 | The amount to drop boost |
initialize
Initializes the BGT contract.
function initialize(address _governance, address _staker) external initializer;
mint
Mints BGT tokens to the specified address.
Only the minter can call this function.
function mint(address to, uint256 amount) external;
queueBoost
Queues a boost on a validator.
Emits:
function queueBoost(bytes calldata pubkey, uint128 amount) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The validator public key |
amount | uint128 | The amount to queue for boost |
queueDropBoost
Queues a drop boost on a validator.
Emits:
function queueDropBoost(bytes calldata pubkey, uint128 amount) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The validator public key |
amount | uint128 | The amount to queue for drop boost |
redeem
Redeems native tokens for BGT.
Emits:
function redeem(address receiver, uint256 amount) external payable;
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address to receive native tokens |
amount | uint256 | The amount of BGT to redeem |
setActivateBoostDelay
Sets the delay for activating boosts.
Emits:
function setActivateBoostDelay(uint32 _activateBoostDelay) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_activateBoostDelay | uint32 | The new activate boost delay |
setBgtTermsAndConditions
Sets the BGT terms and conditions.
Emits:
function setBgtTermsAndConditions(string calldata _bgtTermsAndConditions) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_bgtTermsAndConditions | string | The new terms and conditions |
setDropBoostDelay
Sets the delay for dropping boosts.
Emits:
function setDropBoostDelay(uint32 _dropBoostDelay) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_dropBoostDelay | uint32 | The new drop boost delay |
setMinter
Sets the minter address.
Emits:
function setMinter(address _minter) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_minter | address | The new minter address |
setStaker
Sets the staker contract address.
Emits:
function setStaker(address _staker) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_staker | address | The new staker contract address |
whitelistSender
Whitelists or removes a sender.
Emits:
function whitelistSender(address sender, bool approved) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
sender | address | The sender address |
approved | bool | Whether to whitelist or remove |
Events
ActivateBoost
Emitted when a boost is activated.
event ActivateBoost(address indexed account, bytes pubkey, uint128 amount);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account that activated the boost |
pubkey | bytes | The validator public key |
amount | uint128 | The amount of boost activated |
Approval
Emitted when an approval is made.
event Approval(address indexed owner, address indexed spender, uint256 value);
Parameters
Name | Type | Description |
---|---|---|
owner | address | The token owner |
spender | address | The approved spender |
value | uint256 | The approved amount |
CancelQueuedBoost
Emitted when a queued boost is cancelled.
event CancelQueuedBoost(address indexed account, bytes pubkey, uint128 amount);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account that cancelled the boost |
pubkey | bytes | The validator public key |
amount | uint128 | The amount of boost cancelled |
CancelQueuedDropBoost
Emitted when a queued drop boost is cancelled.
event CancelQueuedDropBoost(address indexed account, bytes pubkey, uint128 amount);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account that cancelled the drop boost |
pubkey | bytes | The validator public key |
amount | uint128 | The amount of drop boost cancelled |
DelegateChanged
Emitted when a delegate is changed.
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
Parameters
Name | Type | Description |
---|---|---|
delegator | address | The delegator address |
fromDelegate | address | The previous delegate |
toDelegate | address | The new delegate |
DelegateVotesChanged
Emitted when delegate votes change.
event DelegateVotesChanged(address indexed delegate, uint256 previousVotes, uint256 newVotes);
Parameters
Name | Type | Description |
---|---|---|
delegate | address | The delegate address |
previousVotes | uint256 | The previous vote count |
newVotes | uint256 | The new vote count |
DropBoost
Emitted when a boost is dropped.
event DropBoost(address indexed account, bytes pubkey, uint128 amount);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account that dropped the boost |
pubkey | bytes | The validator public key |
amount | uint128 | The amount of boost dropped |
EIP712DomainChanged
Emitted when the EIP712 domain changes.
event EIP712DomainChanged();
Initialized
Emitted when the contract is initialized.
event Initialized(uint64 version);
Parameters
Name | Type | Description |
---|---|---|
version | uint64 | The initialization version |
OwnershipTransferred
Emitted when ownership is transferred.
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
Parameters
Name | Type | Description |
---|---|---|
previousOwner | address | The previous owner |
newOwner | address | The new owner |
QueueBoost
Emitted when a boost is queued.
event QueueBoost(address indexed account, bytes pubkey, uint128 amount);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account that queued the boost |
pubkey | bytes | The validator public key |
amount | uint128 | The amount of boost queued |
QueueDropBoost
Emitted when a drop boost is queued.
event QueueDropBoost(address indexed account, bytes pubkey, uint128 amount);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account that queued the drop boost |
pubkey | bytes | The validator public key |
amount | uint128 | The amount of drop boost queued |
Redeem
Emitted when BGT is redeemed for native tokens.
event Redeem(address indexed account, address indexed receiver, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account that redeemed |
receiver | address | The receiver of native tokens |
amount | uint256 | The amount redeemed |
SetActivateBoostDelay
Emitted when the activate boost delay is set.
event SetActivateBoostDelay(uint32 activateBoostDelay);
Parameters
Name | Type | Description |
---|---|---|
activateBoostDelay | uint32 | The new activate boost delay |
SetBgtTermsAndConditions
Emitted when BGT terms and conditions are set.
event SetBgtTermsAndConditions(string bgtTermsAndConditions);
Parameters
Name | Type | Description |
---|---|---|
bgtTermsAndConditions | string | The new terms and conditions |
SetDropBoostDelay
Emitted when the drop boost delay is set.
event SetDropBoostDelay(uint32 dropBoostDelay);
Parameters
Name | Type | Description |
---|---|---|
dropBoostDelay | uint32 | The new drop boost delay |
SetMinter
Emitted when the minter is set.
event SetMinter(address indexed minter);
Parameters
Name | Type | Description |
---|---|---|
minter | address | The new minter address |
SetStaker
Emitted when the staker is set.
event SetStaker(address indexed staker);
Parameters
Name | Type | Description |
---|---|---|
staker | address | The new staker address |
Transfer
Emitted when tokens are transferred.
event Transfer(address indexed from, address indexed to, uint256 value);
Parameters
Name | Type | Description |
---|---|---|
from | address | The sender address |
to | address | The recipient address |
value | uint256 | The amount transferred |
WhitelistSender
Emitted when a sender is whitelisted or removed.
event WhitelistSender(address indexed sender, bool approved);
Parameters
Name | Type | Description |
---|---|---|
sender | address | The sender address |
approved | bool | Whether whitelisted or removed |
Errors
ZeroAddress
error ZeroAddress();
Thrown when attempting to initialize with a zero address.
UnauthorizedETHTransfer
error UnauthorizedETHTransfer();
Thrown when attempting an unauthorized ETH transfer.
VotesExpiredSignature
error VotesExpiredSignature(uint256 expiry);
Thrown when attempting to use an expired signature for voting.
Parameters
Name | Type | Description |
---|---|---|
expiry | uint256 | The expiry timestamp of the signature |