-
Notifications
You must be signed in to change notification settings - Fork 24
Voting
Voting is the main purpose of the DAO. Here on Astro our smart contract supports two different Voting systems.
Token Weighted voting - based on the number of stacked voting tokens.
Role Weighted voting - where users of specific groups can hold a specific voting weight.
And all of that is highly customizable.
Available voting actions are:
- Approve - This action approves the proposal. When you choose this action you are directed to the near.wallet to verify your action. After which the action goes into effect
- Reject - Reject vote on a proposal in question. When you choose this action you are directed to the near.wallet to verify your action. After which the action goes into effect. If this option gets quorum, the proposal is rejected and the Bond is returned.
- Remove - Remove vote is for the proposals that you believe are invalid. After this action, you will no longer see this proposal in any feed. If this option gets quorum, the proposal is rejected and the Bond is NOT returned.
CLI examples:
Vote Approve:
near call near-cli-example.sputnikv2.testnet act_proposal '{"id":0,"action":"VoteApprove"}' --account-id test-account.testnet --gas 100000000000000
Vote Reject:
near call near-cli-example.sputnikv2.testnet act_proposal '{"id":0,"action":"VoteReject"}' --account-id test-account.testnet --gas 100000000000000
Vote Remove:
near call near-cli-example.sputnikv2.testnet act_proposal '{"id":0,"action":"VoteRemove"}' --account-id test-account.testnet --gas 100000000000000
Who can and who can't vote is defined by the Voting Policy that the DAO council have set up. You can specify Who can vote, How should they vote and what is the quorum required for the decision.
Here is the example of default Voting Policy from smart contracts:
// Some code/// Defines default policy:
/// - everyone can add proposals
/// - group consisting of the call can do all actions, consists of caller.
/// - non token weighted voting, requires 1/2 of the group to vote
/// - proposal & bounty bond is 1N
/// - proposal & bounty forgiveness period is 1 day
fn default_policy(council: Vec<AccountId>) -> Policy {
Policy {
roles: vec![
RolePermission {
name: "all".to_string(),
kind: RoleKind::Everyone,
permissions: vec!["*:AddProposal".to_string()].into_iter().collect(),
vote_policy: HashMap::default(),
},
RolePermission {
name: "council".to_string(),
kind: RoleKind::Group(council.into_iter().collect()),
// All actions except RemoveProposal are allowed by council.
permissions: vec![
"*:AddProposal".to_string(),
"*:VoteApprove".to_string(),
"*:VoteReject".to_string(),
"*:VoteRemove".to_string(),
"*:Finalize".to_string(),
]
.into_iter()
.collect(),
vote_policy: HashMap::default(),
},
],
default_vote_policy: VotePolicy::default(),
proposal_bond: U128(10u128.pow(24)),
proposal_period: WrappedDuration::from(1_000_000_000 * 60 * 60 * 24 * 7),
bounty_bond: U128(10u128.pow(24)),
bounty_forgiveness_period: WrappedDuration::from(1_000_000_000 * 60 * 60 * 24),
}
}
Next rules are used for voting:
- There is a policy that defines for Payout proposals at different amount how much "YES" votes are required. For non-Payout proposals - it's always 1/2 + 1 of council.
- If there is 0 "NO" votes and given "YES" votes - the expiration date updates to current time + cooldown time.
- If there is at least 1 "NO" then MAX_VOTE of "YES" votes is required.
- If there is MAX_VOTE "NO" votes - the proposal gets rejected and bond not returned.
- If there is no super majority and time to withdraw have passed - proposal fails and the bond gets returned.
For example, voting policy:
-
[(0, NumOrRation::Ration(1, 2))]
-- meaning that for any amount or vote MAX_VOTE = 1/2 + 1 is used. -
[(100, NumOrRation::Number(2)), (10000000, NumOrRation::Ration(2, 3))]
-- if amount is below 100 - 2 votes is enough within grace period. Otherwise MAX_VOTE = 2/3 + 1 to pass any larger proposal or add/remove council members.
Specific examples:
If there are 2 councils, with default policy of 50%: proposal needs both of them to vote YES to "Succeed" or both of them to vote NO to be "Rejected". If they vote differently, the vote will be considered "Fail" and bond
will be returned back to proposer.