From 871bc54d818fe0806e6da1238e0e1f876c76ca34 Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Fri, 9 Feb 2024 17:22:16 +0100 Subject: [PATCH 1/6] Multiply quorum percentage by 10000 to get it into proper format during Safe deployment, adjust quorum displaying accordingly --- src/components/Proposals/ProposalSummary.tsx | 5 ++++- .../governance/useERC20LinearStrategy.ts | 20 ++++++++++++------- src/models/AzoriusTxBuilder.ts | 2 +- src/types/fractal.ts | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/Proposals/ProposalSummary.tsx b/src/components/Proposals/ProposalSummary.tsx index 3357332046..854805b0cf 100644 --- a/src/components/Proposals/ProposalSummary.tsx +++ b/src/components/Proposals/ProposalSummary.tsx @@ -87,7 +87,10 @@ export default function ProposalSummary({ const strategyQuorum = votesToken && isERC20 - ? votingStrategy.quorumPercentage!.value.toNumber() + ? votingStrategy + .quorumPercentage!.value.mul(100) + .div(votingStrategy.quorumDenominator?.value || 1000000) + .toNumber() : isERC721 ? votingStrategy.quorumThreshold!.value.toNumber() : 1; diff --git a/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts b/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts index ac79bd084d..2941fe72d7 100644 --- a/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts +++ b/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts @@ -28,12 +28,15 @@ export const useERC20LinearStrategy = () => { if (!ozLinearVotingContract || !azoriusContract) { return {}; } - const [votingPeriodBlocks, quorumNumerator, timeLockPeriod] = await Promise.all([ - ozLinearVotingContract.asSigner.votingPeriod(), - ozLinearVotingContract.asSigner.quorumNumerator(), - azoriusContract.asSigner.timelockPeriod(), - ]); + const [votingPeriodBlocks, quorumNumerator, quorumDenominator, timeLockPeriod] = + await Promise.all([ + ozLinearVotingContract.asSigner.votingPeriod(), + ozLinearVotingContract.asSigner.quorumNumerator(), + ozLinearVotingContract.asSigner.QUORUM_DENOMINATOR(), + azoriusContract.asSigner.timelockPeriod(), + ]); + const quorumPercentage = quorumNumerator.mul(100).div(quorumDenominator); const votingPeriodValue = await blocksToSeconds(votingPeriodBlocks, provider); const timeLockPeriodValue = await blocksToSeconds(timeLockPeriod, provider); const votingData = { @@ -42,8 +45,11 @@ export const useERC20LinearStrategy = () => { formatted: getTimeDuration(votingPeriodValue), }, quorumPercentage: { - value: quorumNumerator, - formatted: quorumNumerator.toString() + '%', + value: quorumPercentage, + formatted: quorumPercentage.toString() + '%', + }, + quorumDenominator: { + value: quorumDenominator, }, timeLockPeriod: { value: BigNumber.from(timeLockPeriodValue), diff --git a/src/models/AzoriusTxBuilder.ts b/src/models/AzoriusTxBuilder.ts index 59dd244c4e..82c19eb08a 100644 --- a/src/models/AzoriusTxBuilder.ts +++ b/src/models/AzoriusTxBuilder.ts @@ -384,7 +384,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { '0x0000000000000000000000000000000000000001', // Azorius module azoriusGovernanceDaoData.votingPeriod, BigNumber.from(1), // proposer weight, how much is needed to create a proposal. - azoriusGovernanceDaoData.quorumPercentage, // quorom numerator, denominator is 1,000,000, so quorum percentage is 50% + azoriusGovernanceDaoData.quorumPercentage.mul(10000), // quorom numerator, denominator is 1,000,000, so quorum percentage is quorumNumerator * 100 / quorumDenominator BigNumber.from(500000), // basis numerator, denominator is 1,000,000, so basis percentage is 50% (simple majority) ] ); diff --git a/src/types/fractal.ts b/src/types/fractal.ts index 63a996aebd..8bb8cf946b 100644 --- a/src/types/fractal.ts +++ b/src/types/fractal.ts @@ -308,6 +308,7 @@ export interface VotingStrategyAzorius extends VotingStrategy { export interface VotingStrategy { votingPeriod?: Type; quorumPercentage?: Type; + quorumDenominator?: Type; quorumThreshold?: Type; timeLockPeriod?: Type; } From d19d8dff781f7673432c67bcfbe82bd2c7bdadc9 Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Fri, 9 Feb 2024 17:28:26 +0100 Subject: [PATCH 2/6] Do not divide by quorum denominator --- src/components/Proposals/ProposalSummary.tsx | 7 +++---- src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts | 3 --- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/Proposals/ProposalSummary.tsx b/src/components/Proposals/ProposalSummary.tsx index 854805b0cf..f9256b1b4b 100644 --- a/src/components/Proposals/ProposalSummary.tsx +++ b/src/components/Proposals/ProposalSummary.tsx @@ -87,10 +87,7 @@ export default function ProposalSummary({ const strategyQuorum = votesToken && isERC20 - ? votingStrategy - .quorumPercentage!.value.mul(100) - .div(votingStrategy.quorumDenominator?.value || 1000000) - .toNumber() + ? votingStrategy.quorumPercentage!.value.toNumber() : isERC721 ? votingStrategy.quorumThreshold!.value.toNumber() : 1; @@ -107,6 +104,8 @@ export default function ProposalSummary({ .mul(strategyQuorum) .toString(); + console.log(strategyQuorum, reachedQuorum, totalQuorum); + const ShowVotingPowerButton = (