This contract handles the voting for the most supported x2Earn applications through periodic allocation rounds. The user’s voting power is calculated on his VOT3 holdings at the start of each round, using a “Quadratic Funding” formula.
_Rounds are started by the Emissions contract. Interacts with the X2EarnApps contract to get the app data (eg: app IDs, app existence, eligible apps for each round). Interacts with the VotingRewards contract to save the user from casting a vote. The contract is using AccessControl to handle roles for admin, governance, and round-starting operations.
—– Version 2 —– - Integrated VeBetterPassport - Added check to ensure that the vote weight for an XApp cast by a user is greater than the voting threshold
—– Version 3 —– - Updated the X2EarnApps interface to support node endorsement feature
—– Version 4 —– - Updated the X2EarnApps interface to support node cooldown functionality
—– Version 6 —– - Align IVoterRewards and IEmissions interfaces with the new contracts
—– Version 7 —– - Proposal Execution: Count proposal deposits to x-allocation voting power
—– Version 8 —– - Added autovoting functionality allowing users to enable automatic voting with predefined app preferences_
bytes32 ROUND_STARTER_ROLE
Role identifier for the address that can start a new round
bytes32 UPGRADER_ROLE
Role identifier for the address that can upgrade the contract
bytes32 GOVERNANCE_ROLE
Role identifier for governance operations
bytes32 CONTRACTS_ADDRESS_MANAGER_ROLE
The role that can set the addresses of the contracts used by the VoterRewards contract.
Data for initializing the contract
| Name | Type | Description |
|---|
struct InitializationData {
contract IVotes vot3Token;
uint256 quorumPercentage;
uint32 initialVotingPeriod;
address timeLock;
contract IVoterRewards voterRewards;
contract IEmissions emissions;
address[] admins;
address upgrader;
address contractsAddressManager;
contract IX2EarnApps x2EarnAppsAddress;
uint256 baseAllocationPercentage;
uint256 appSharesCap;
uint256 votingThreshold;
}
constructor() public
function initialize(struct XAllocationVoting.InitializationData data) public
Initialize the contract
| Name | Type | Description |
|---|---|---|
| data | struct XAllocationVoting.InitializationData | The initialization data |
function toggleAutoVoting(address user) public
Toggle autovoting for the caller
function setUserVotingPreferences(bytes32[] appIds) public
Set the voting preferences for the caller
function setX2EarnAppsAddress(contract IX2EarnApps newX2EarnApps) external
Set the address of the X2EarnApps contract
function setEmissionsAddress(contract IEmissions newEmissions) external
Set the address of the Emissions contract
function setVoterRewardsAddress(contract IVoterRewards newVoterRewards) external
Set the address of the VoterRewards contract
function setVeBetterPassport(contract IVeBetterPassport newVeBetterPassport) external
Set the VeBetterPassport contract
function setB3TRGovernor(contract IB3TRGovernor newB3TRGovernor) external
Set the B3TRGovernor contract
function setRelayerRewardsPoolAddress(contract IRelayerRewardsPool newRelayerRewardsPool) external
Set the address of the RelayerRewardsPool contract
function setVotingThreshold(uint256 newVotingThreshold) public virtual
_Update the voting threshold. This operation can only be performed through a governance proposal.
Emits a {VotingThresholdSet} event._
function startNewRound() public returns (uint256)
Start a new voting round for allocating funds to the x-apps
function setAppSharesCap(uint256 appSharesCap_) external virtual
Set the max amount of shares an app can get in a round
function setBaseAllocationPercentage(uint256 baseAllocationPercentage_) public virtual
Set the base allocation percentage for funds distribution in a round
function setVotingPeriod(uint32 newVotingPeriod) public virtual
Set the voting period for a round
function updateQuorumNumerator(uint256 newQuorumNumerator) public virtual
Update the quorum a round needs to reach to be successful
function isUserAutoVotingEnabled(address user) public view returns (bool)
Checks if auto-voting is enabled for an account
| Name | Type | Description |
|---|---|---|
| user | address | The address to check |
| Name | Type | Description |
|---|---|---|
| [0] | bool | Whether auto-voting is enabled for the account |
function isUserAutoVotingEnabledInCurrentRound(address account) public view returns (bool)
Status changes mid-cycle will only take effect in the next cycle
Checks if auto-voting is enabled for an account at the start of the current cycle
function isUserAutoVotingEnabledForRound(address account, uint256 roundId) public view returns (bool)
Useful function for frontend to consume
Checks if auto-voting is enabled for an account at the start of a specific round
function isUserAutoVotingEnabledAtTimepoint(address account, uint48 timepoint) public view returns (bool)
Check if auto-voting is enabled for an account at a specific
| Name | Type | Description |
|---|---|---|
| account | address | The address to check |
| timepoint | uint48 | block number |
function getUserVotingPreferences(address account) public view returns (bytes32[])
Get the voting preferences for an account
function getTotalAutoVotingUsersAtRoundStart() public view returns (uint208)
Get the total number of users who enabled auto-voting at the last emission block
function getTotalAutoVotingUsersAtTimepoint(uint48 timepoint) public view returns (uint208)
Get the total number of users who enabled autovoting at a specific timepoint
function x2EarnApps() public view returns (contract IX2EarnApps)
Returns the X2EarnApps contract
| Name | Type | Description |
|---|---|---|
| [0] | contract IX2EarnApps | IX2EarnApps The X2EarnApps contract interface |
function roundQuorum(uint256 roundId) external view returns (uint256)
Returns the quorum for a given round
function votingPeriod() public view returns (uint256)
function quorum(uint256 blockNumber) public view returns (uint256)
function supportsInterface(bytes4 interfaceId) public view returns (bool)
function _authorizeUpgrade(address newImplementation) internal
_Function that should revert when msg.sender is not
authorized to upgrade the contract. Called by {upgradeToAndCall}.
Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
solidity function _authorizeUpgrade(address) internal onlyOwner {}_