Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improved majority voting docs formatting #16

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions contracts/src/governance/majority-voting/MajorityVotingBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,26 @@ import {IMajorityVoting} from "./IMajorityVoting.sol";
/// ### Parameterization
///
/// We define two parameters
///
/// $$\texttt{support} = \frac{N_\text{yes}}{N_\text{yes} + N_\text{no}} \in [0,1]$$
///
/// and
///
/// $$\texttt{participation} = \frac{N_\text{yes} + N_\text{no} + N_\text{abstain}}{N_\text{total}} \in [0,1],$$
///
/// where $N_\text{yes}$, $N_\text{no}$, and $N_\text{abstain}$ are the yes, no, and abstain votes that have been cast and $N_\text{total}$ is the total voting power available at proposal creation time.
///
/// #### Limit Values: Support Threshold & Minimum Participation
///
/// Two limit values are associated with these parameters and decide if a proposal execution should be possible: $\texttt{supportThreshold} \in [0,1]$ and $\texttt{minParticipation} \in [0,1]$.
/// Two limit values are associated with these parameters and decide if proposal execution is possible: $\texttt{supportThreshold} \in [0,1]$ and $\texttt{minParticipation} \in [0,1]$.
///
/// For threshold values, $>$ comparison is used. This **does not** include the threshold value. E.g., for $\texttt{supportThreshold} = 50\%$, the criterion is fulfilled if there is at least one more yes than no votes ($N_\text{yes} = N_\text{no} + 1$).
/// For minimum values, $\ge{}$ comparison is used. This **does** include the minimum participation value. E.g., for $\texttt{minParticipation} = 40\%$ and $N_\text{total} = 10$, the criterion is fulfilled if 4 out of 10 votes were casted.
///
/// Majority voting implies that the support threshold is set with
///
/// $$\texttt{supportThreshold} \ge 50\% .$$
///
/// However, this is not enforced by the contract code and developers can make unsafe parameters and only the frontend will warn about bad parameter settings.
///
/// ### Execution Criteria
Expand All @@ -43,18 +49,22 @@ import {IMajorityVoting} from "./IMajorityVoting.sol";
/// #### The Support Criterion
///
/// For a proposal to pass, the required ratio of yes and no votes must be met:
///
/// $$(1- \texttt{supportThreshold}) \cdot N_\text{yes} > \texttt{supportThreshold} \cdot N_\text{no}.$$
///
/// Note, that the inequality yields the simple majority voting condition for $\texttt{supportThreshold}=\frac{1}{2}$.
///
/// #### The Participation Criterion
///
/// For a proposal to pass, the minimum voting power must have been cast:
///
/// $$N_\text{yes} + N_\text{no} + N_\text{abstain} \ge \texttt{minVotingPower},$$
///
/// where $\texttt{minVotingPower} = \texttt{minParticipation} \cdot N_\text{total}$.
///
/// ### Vote Replacement Execution
///
/// The contract allows votes to be replaced. Voters can vote multiple times and only the latest voteOption is tallied.
/// The contract allows votes to be replaced. Voters can vote multiple times and only the latest vote option is tallied.
///
/// ### Early Execution
///
Expand All @@ -69,27 +79,23 @@ import {IMajorityVoting} from "./IMajorityVoting.sol";
///
/// We can use this quantity to calculate the worst-case support that would be obtained if all remaining votes are casted with no:
///
/// $$
/// \begin{align*}
/// $$\begin{align*}
/// \texttt{worstCaseSupport}
/// &= \frac{N_\text{yes}}{N_\text{yes} + (N_\text{no, worst-case})} \\[3mm]
/// &= \frac{N_\text{yes}}{N_\text{yes} + (N_\text{no} + \texttt{remainingVotes})} \\[3mm]
/// &= \frac{N_\text{yes}}{N_\text{yes} + N_\text{no} + N_\text{total} - (N_\text{yes} + N_\text{no} + N_\text{abstain})} \\[3mm]
/// &= \frac{N_\text{yes}}{N_\text{total} - N_\text{abstain}}
/// \end{align*}
/// $$
/// \end{align*}$$
///
/// In analogy, we can modify [the support criterion](#the-support-criterion) from above to allow for early execution:
///
/// $$
/// \begin{align*}
/// $$\begin{align*}
/// (1 - \texttt{supportThreshold}) \cdot N_\text{yes}
/// &> \texttt{supportThreshold} \cdot N_\text{no, worst-case} \\[3mm]
/// &> \texttt{supportThreshold} \cdot (N_\text{no} + \texttt{remainingVotes}) \\[3mm]
/// &> \texttt{supportThreshold} \cdot (N_\text{no} + N_\text{total}-(N_\text{yes}+N_\text{no}+N_\text{abstain})) \\[3mm]
/// &> \texttt{supportThreshold} \cdot (N_\text{total} - N_\text{yes} - N_\text{abstain})
/// \end{align*}
/// $$
/// \end{align*} $$
///
/// Accordingly, early execution is possible when the vote is open, the modified support criterion, and the particicpation criterion are met.
/// @dev This contract implements the `IMajorityVoting` interface.
Expand Down