PQV
Search
⌃K
👩💻

Developer Guides

Governor C allows the deployment on-chain voting system using PQV, with respect to Compound's Governor Alpha & Bravo interface.

Hardcoded Parameters

Proposal Threshold

/// @notice The minimum setable proposal threshold
uint public constant MIN_PROPOSAL_THRESHOLD = 50000e18; // 50,000 Comp
​
/// @notice The maximum setable proposal threshold
uint public constant MAX_PROPOSAL_THRESHOLD = 100000e18; //100,000 Comp
Addresses with more than 50,000 COMP (or any ERC20 token registered by function initialize) can invoke proposal. This threshold can be changed by admin within the range of [50000, 100000].

Voting Period

/// @notice The minimum setable voting period
uint public constant MIN_VOTING_PERIOD = 5760; // About 24 hours
​
/// @notice The max setable voting period
uint public constant MAX_VOTING_PERIOD = 80640; // About 2 weeks
After starting of the proposal, COMP holders can submit their votes during a voting period. The voting period can be changed by admin within the range of [5760, 80640] Ethereum blocks.
Each blockchain has a different block interval. Even at the same protocol, it can be changed after a hardfork.

Voting Delay

/// @notice The min setable voting delay
uint public constant MIN_VOTING_DELAY = 1;
​
/// @notice The max setable voting delay
uint public constant MAX_VOTING_DELAY = 40320; // About 1 week
Users allow to vote for the proposal after a certain delay. The voting delay can be changed by admin within the range of [1, 40320] Ethereum blocks.

Quorum

/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
uint public constant quorumVotes = 400000e18; // 400,000 = 4% of Comp
According to majority, at least 400,000 votes are cast for the proposal to execute.

Max Operations per Proposal

/// @notice The maximum number of actions that can be included in a proposal
uint public constant proposalMaxOperations = 10; // 10 actions
The maximum number of actions that can be included in one proposal. Each action is same as booked function-call belongs to the proposal.

Storage

New Proposal State: Unfinalized

/// @notice Possible states that a proposal may be in
/// @dev Add `Unfinalized` state - represent that the proposal is ready to get a `baseRandom` number
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed,
Unfinalized // for PQV's random aggregation round
}
Enumerated type ProposalState. The types are Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed, and Unfinalized.
Unfinalized state refers to a status in which casting has been completed but votes aggregation has not yet begun. It is changed into Defeated or Succeeded after executing the finalized function.
Governor C uses Chainlink VRF v1.

Fee

function feeUpdate(uint newFee) public
Fee is required to fulfill a VRF request. Therefore, the contract should own enough LINK to pay the specified fee.
Fee varies by network. To prepare for changes in fee, Governor C provides a fee update function. The admin can change the VRF request fee.

Request Randomness

function requestFlagedRandomness() public returns (bytes32 requestId)
function requestBaseFlagedRandom(uint proposalId) external
Those functions invoke Chainlink's requestRandomness, which makes the initial request for randomness.

PQV

Probabilistic Element
ee
​

// e = 1.05
uint32 public expN = 105;
uint32 public expD = 100;
Probabilistic element
ee
is calculated by
expNexpD\frac{exp_N}{exp_D}
. The default value is
1.051.05
. The higher
ee
, the more similar to the result of QV. Details are here: PQV EVALUATION - Change of similarity according to change of PQV probabilistic element.
function eUpdate(uint32 newExpN, uint32 newExpD) public
The admin can change
ee
by assigning new expN and expD.

Expectation Value

function pqvExpect(uint proposalId) public view returns (
bool isSucceeded,
uint aggregatedForVotes,
uint aggregatedAgainstVotes,
uint aggregatedAbstainVotes
)
pqvExpect gets expectation value of for, against, and abstain votes before finalizing proposal. It also returns bool of a proposal's success or failure.

Finalize

function finalize(uint proposalId) external
Finalizes an active proposal. After the proposal is finalized, votes aggregation is triggered and its state is changed into either Defeated or Succeeded.

Implementation