pub enum ThresholdResponse {
AbsoluteCount {
weight: u64,
total_weight: u64,
},
AbsolutePercentage {
percentage: Decimal,
total_weight: u64,
},
ThresholdQuorum {
threshold: Decimal,
quorum: Decimal,
total_weight: u64,
},
}
Expand description
This defines the different ways tallies can happen. Every contract should support a subset of these, ideally all.
The total_weight used for calculating success as well as the weights of each individual voter used in tallying should be snapshotted at the beginning of the block at which the proposal starts (this is likely the responsibility of a correct cw4 implementation).
Variants§
AbsoluteCount
Declares that a fixed weight of yes votes is needed to pass.
It does not matter how many no votes are cast, or how many do not vote,
as long as weight
yes votes are cast.
This is the simplest format and usually suitable for small multisigs of trusted parties, like 3 of 5. (weight: 3, total_weight: 5)
A proposal of this type can pass early as soon as the needed weight of yes votes has been cast.
AbsolutePercentage
Declares a percentage of the total weight that must cast Yes votes, in order for a proposal to pass. The passing weight is computed over the total weight minus the weight of the abstained votes.
This is useful for similar circumstances as AbsoluteCount
, where we have a relatively
small set of voters, and participation is required.
It is understood that if the voting set (group) changes between different proposals that
refer to the same group, each proposal will work with a different set of voter weights
(the ones snapshotted at proposal creation), and the passing weight for each proposal
will be computed based on the absolute percentage, times the total weights of the members
at the time of each proposal creation.
Example: we set percentage
to 51%. Proposal 1 starts when there is a total_weight
of 5.
This will require 3 weight of Yes votes in order to pass. Later, the Proposal 2 starts but the
total_weight
of the group has increased to 9. That proposal will then automatically
require 5 Yes of 9 to pass, rather than 3 yes of 9 as would be the case with AbsoluteCount
.
ThresholdQuorum
In addition to a threshold
, declares a quorum
of the total votes that must participate
in the election in order for the vote to be considered at all. Within the votes that
were cast, it requires threshold
votes in favor. That is calculated by ignoring
the Abstain votes (they count towards quorum
, but do not influence threshold
).
That is, we calculate Yes / (Yes + No + Veto)
and compare it with threshold
to consider
if the proposal was passed.
It is rather difficult for a proposal of this type to pass early. That can only happen if the required quorum has been already met, and there are already enough Yes votes for the proposal to pass.
30% Yes votes, 10% No votes, and 20% Abstain would pass early if quorum <= 60% (who has cast votes) and if the threshold is <= 37.5% (the remaining 40% voting no => 30% yes + 50% no). Once the voting period has passed with no additional votes, that same proposal would be considered successful if quorum <= 60% and threshold <= 75% (percent in favor if we ignore abstain votes).
This type is more common in general elections, where participation is often expected to
be low, and AbsolutePercentage
would either be too high to pass anything,
or allow low percentages to pass, independently of if there was high participation in the
election or not.
Trait Implementations§
Source§impl Clone for ThresholdResponse
impl Clone for ThresholdResponse
Source§fn clone(&self) -> ThresholdResponse
fn clone(&self) -> ThresholdResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ThresholdResponse
impl Debug for ThresholdResponse
Source§impl<'de> Deserialize<'de> for ThresholdResponse
impl<'de> Deserialize<'de> for ThresholdResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for ThresholdResponse
impl JsonSchema for ThresholdResponse
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl PartialEq for ThresholdResponse
impl PartialEq for ThresholdResponse
Source§impl Serialize for ThresholdResponse
impl Serialize for ThresholdResponse
impl StructuralPartialEq for ThresholdResponse
Auto Trait Implementations§
impl Freeze for ThresholdResponse
impl RefUnwindSafe for ThresholdResponse
impl Send for ThresholdResponse
impl Sync for ThresholdResponse
impl Unpin for ThresholdResponse
impl UnwindSafe for ThresholdResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more