Solidity API

XAllocationVoting

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_

ROUND_STARTER_ROLE

bytes32 ROUND_STARTER_ROLE

Role identifier for the address that can start a new round

UPGRADER_ROLE

bytes32 UPGRADER_ROLE

Role identifier for the address that can upgrade the contract

GOVERNANCE_ROLE

bytes32 GOVERNANCE_ROLE

Role identifier for governance operations

CONTRACTS_ADDRESS_MANAGER_ROLE

bytes32 CONTRACTS_ADDRESS_MANAGER_ROLE

The role that can set the addresses of the contracts used by the VoterRewards contract.

InitializationData

Data for initializing the contract

Parameters

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

constructor() public

initialize

function initialize(struct XAllocationVoting.InitializationData data) public

Initialize the contract

Parameters

Name Type Description
data struct XAllocationVoting.InitializationData The initialization data

toggleAutoVoting

function toggleAutoVoting(address user) public

Toggle autovoting for the caller

setUserVotingPreferences

function setUserVotingPreferences(bytes32[] appIds) public

Set the voting preferences for the caller

setX2EarnAppsAddress

function setX2EarnAppsAddress(contract IX2EarnApps newX2EarnApps) external

Set the address of the X2EarnApps contract

setEmissionsAddress

function setEmissionsAddress(contract IEmissions newEmissions) external

Set the address of the Emissions contract

setVoterRewardsAddress

function setVoterRewardsAddress(contract IVoterRewards newVoterRewards) external

Set the address of the VoterRewards contract

setVeBetterPassport

function setVeBetterPassport(contract IVeBetterPassport newVeBetterPassport) external

Set the VeBetterPassport contract

setB3TRGovernor

function setB3TRGovernor(contract IB3TRGovernor newB3TRGovernor) external

Set the B3TRGovernor contract

setRelayerRewardsPoolAddress

function setRelayerRewardsPoolAddress(contract IRelayerRewardsPool newRelayerRewardsPool) external

Set the address of the RelayerRewardsPool contract

setVotingThreshold

function setVotingThreshold(uint256 newVotingThreshold) public virtual

_Update the voting threshold. This operation can only be performed through a governance proposal.

Emits a {VotingThresholdSet} event._

startNewRound

function startNewRound() public returns (uint256)

Start a new voting round for allocating funds to the x-apps

setAppSharesCap

function setAppSharesCap(uint256 appSharesCap_) external virtual

Set the max amount of shares an app can get in a round

setBaseAllocationPercentage

function setBaseAllocationPercentage(uint256 baseAllocationPercentage_) public virtual

Set the base allocation percentage for funds distribution in a round

setVotingPeriod

function setVotingPeriod(uint32 newVotingPeriod) public virtual

Set the voting period for a round

updateQuorumNumerator

function updateQuorumNumerator(uint256 newQuorumNumerator) public virtual

Update the quorum a round needs to reach to be successful

isUserAutoVotingEnabled

function isUserAutoVotingEnabled(address user) public view returns (bool)

Checks if auto-voting is enabled for an account

Parameters

Name Type Description
user address The address to check

Return Values

Name Type Description
[0] bool Whether auto-voting is enabled for the account

isUserAutoVotingEnabledInCurrentRound

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

isUserAutoVotingEnabledForRound

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

isUserAutoVotingEnabledAtTimepoint

function isUserAutoVotingEnabledAtTimepoint(address account, uint48 timepoint) public view returns (bool)

Check if auto-voting is enabled for an account at a specific

Parameters

Name Type Description
account address The address to check
timepoint uint48 block number

getUserVotingPreferences

function getUserVotingPreferences(address account) public view returns (bytes32[])

Get the voting preferences for an account

getTotalAutoVotingUsersAtRoundStart

function getTotalAutoVotingUsersAtRoundStart() public view returns (uint208)

Get the total number of users who enabled auto-voting at the last emission block

getTotalAutoVotingUsersAtTimepoint

function getTotalAutoVotingUsersAtTimepoint(uint48 timepoint) public view returns (uint208)

Get the total number of users who enabled autovoting at a specific timepoint

x2EarnApps

function x2EarnApps() public view returns (contract IX2EarnApps)

Returns the X2EarnApps contract

Return Values

Name Type Description
[0] contract IX2EarnApps IX2EarnApps The X2EarnApps contract interface

roundQuorum

function roundQuorum(uint256 roundId) external view returns (uint256)

Returns the quorum for a given round

votingPeriod

function votingPeriod() public view returns (uint256)

quorum

function quorum(uint256 blockNumber) public view returns (uint256)

supportsInterface

function supportsInterface(bytes4 interfaceId) public view returns (bool)

_authorizeUpgrade

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 {}_