diff --git a/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts b/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts index ac79bd084d..b57fce3cd3 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,8 @@ export const useERC20LinearStrategy = () => { formatted: getTimeDuration(votingPeriodValue), }, quorumPercentage: { - value: quorumNumerator, - formatted: quorumNumerator.toString() + '%', + value: quorumPercentage, + formatted: quorumPercentage.toString() + '%', }, timeLockPeriod: { value: BigNumber.from(timeLockPeriodValue), diff --git a/src/models/AzoriusTxBuilder.ts b/src/models/AzoriusTxBuilder.ts index 59dd244c4e..331007d059 100644 --- a/src/models/AzoriusTxBuilder.ts +++ b/src/models/AzoriusTxBuilder.ts @@ -90,17 +90,22 @@ export class AzoriusTxBuilder extends BaseTxBuilder { } } } + } - this.setPredictedStrategyAddress(); + public async init() { + await this.setPredictedStrategyAddress(); this.setPredictedAzoriusAddress(); this.setContracts(); - if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) { - daoData = daoData as AzoriusERC20DAO; + if ( + (this.daoData as AzoriusERC20DAO | AzoriusERC721DAO).votingStrategyType === + VotingStrategyType.LINEAR_ERC20 + ) { + const azoriusDAOData = this.daoData as AzoriusERC20DAO; if ( - parentTokenAddress && - daoData.parentAllocationAmount && - !daoData.parentAllocationAmount.isZero() + this.parentTokenAddress && + azoriusDAOData.parentAllocationAmount && + !azoriusDAOData.parentAllocationAmount.isZero() ) { this.setEncodedSetupTokenClaimData(); this.setPredictedTokenClaimAddress(); @@ -373,9 +378,11 @@ export class AzoriusTxBuilder extends BaseTxBuilder { ); } - private setPredictedStrategyAddress() { + private async setPredictedStrategyAddress() { const azoriusGovernanceDaoData = this.daoData as AzoriusGovernanceDAO; if (azoriusGovernanceDaoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) { + const quorumDenominator = + await this.azoriusContracts!.linearVotingMasterCopyContract.QUORUM_DENOMINATOR(); const encodedStrategyInitParams = defaultAbiCoder.encode( ['address', 'address', 'address', 'uint32', 'uint256', 'uint256', 'uint256'], [ @@ -384,7 +391,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(quorumDenominator.div(100)), // 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/models/DaoTxBuilder.ts b/src/models/DaoTxBuilder.ts index 7d67ff2b83..90663b03db 100644 --- a/src/models/DaoTxBuilder.ts +++ b/src/models/DaoTxBuilder.ts @@ -75,7 +75,7 @@ export class DaoTxBuilder extends BaseTxBuilder { shouldSetSnapshot: boolean = true, existingSafe?: { owners: string[] } ): Promise { - const azoriusTxBuilder = this.txBuilderFactory.createAzoriusTxBuilder(); + const azoriusTxBuilder = await this.txBuilderFactory.createAzoriusTxBuilder(); // transactions that must be called by safe this.internalTxs = []; diff --git a/src/models/TxBuilderFactory.ts b/src/models/TxBuilderFactory.ts index 20208239a1..49787f15b2 100644 --- a/src/models/TxBuilderFactory.ts +++ b/src/models/TxBuilderFactory.ts @@ -118,8 +118,8 @@ export class TxBuilderFactory extends BaseTxBuilder { ); } - public createAzoriusTxBuilder(): AzoriusTxBuilder { - return new AzoriusTxBuilder( + public async createAzoriusTxBuilder(): Promise { + const azoriusTxBuilder = new AzoriusTxBuilder( this.signerOrProvider, this.baseContracts, this.azoriusContracts!, @@ -129,5 +129,8 @@ export class TxBuilderFactory extends BaseTxBuilder { this.parentAddress, this.parentTokenAddress ); + + await azoriusTxBuilder.init(); + return azoriusTxBuilder; } }