fix(governance): fix willpassbylpvotecalculation (#5824)
This commit is contained in:
parent
b8725a7fa8
commit
a92fe92778
@ -333,7 +333,6 @@ const VoteBreakDownUI = ({
|
||||
noPercentage,
|
||||
noLPPercentage,
|
||||
yesPercentage,
|
||||
yesLPPercentage,
|
||||
yesTokens,
|
||||
noTokens,
|
||||
totalEquityLikeShareWeight,
|
||||
@ -346,6 +345,7 @@ const VoteBreakDownUI = ({
|
||||
majorityLPMet,
|
||||
willPassByTokenVote,
|
||||
willPassByLPVote,
|
||||
lpVoteWeight,
|
||||
} = voteInfo;
|
||||
|
||||
const participationThresholdProgress = BigNumber.min(
|
||||
@ -425,7 +425,7 @@ const VoteBreakDownUI = ({
|
||||
data-testid="lp-majority-breakdown"
|
||||
>
|
||||
<VoteProgress
|
||||
percentageFor={yesLPPercentage}
|
||||
percentageFor={lpVoteWeight}
|
||||
colourfulBg={true}
|
||||
testId="lp-majority-progress"
|
||||
>
|
||||
@ -444,10 +444,10 @@ const VoteBreakDownUI = ({
|
||||
<span>{t('liquidityProviderVotesFor')}:</span>
|
||||
<Tooltip
|
||||
description={
|
||||
<span>{yesLPPercentage.toFixed(defaultDP)}%</span>
|
||||
<span>{lpVoteWeight.toFixed(defaultDP)}%</span>
|
||||
}
|
||||
>
|
||||
<button>{yesLPPercentage.toFixed(1)}%</button>
|
||||
<button>{lpVoteWeight.toFixed(1)}%</button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
|
@ -273,4 +273,74 @@ describe('use-vote-information', () => {
|
||||
expect(current?.willPassByTokenVote).toEqual(false);
|
||||
expect(current?.willPassByLPVote).toEqual(true);
|
||||
});
|
||||
|
||||
it('mainnet recreation: only yes LP votes equal passing', () => {
|
||||
const yesVotes = 0;
|
||||
const noVotes = 70;
|
||||
const yesEquityLikeShareWeight = '0.21';
|
||||
const noEquityLikeShareWeight = '0';
|
||||
const fixedTokenValue = 1000000000000000000;
|
||||
|
||||
const proposal = generateProposal({
|
||||
terms: {
|
||||
change: {
|
||||
__typename: 'UpdateMarket',
|
||||
marketId: '12345',
|
||||
},
|
||||
},
|
||||
votes: {
|
||||
__typename: 'ProposalVotes',
|
||||
yes: generateYesVotes(
|
||||
yesVotes,
|
||||
fixedTokenValue,
|
||||
yesEquityLikeShareWeight
|
||||
),
|
||||
no: generateNoVotes(noVotes, fixedTokenValue, noEquityLikeShareWeight),
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
result: { current },
|
||||
} = renderHook(() =>
|
||||
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||
);
|
||||
|
||||
expect(current?.willPassByTokenVote).toEqual(false);
|
||||
expect(current?.willPassByLPVote).toEqual(true);
|
||||
});
|
||||
|
||||
it('mainnet recreation: mixed yes and no LP votes equal failing', () => {
|
||||
const yesVotes = 0;
|
||||
const noVotes = 70;
|
||||
const yesEquityLikeShareWeight = '0.21';
|
||||
const noEquityLikeShareWeight = '0.22';
|
||||
const fixedTokenValue = 1000000000000000000;
|
||||
|
||||
const proposal = generateProposal({
|
||||
terms: {
|
||||
change: {
|
||||
__typename: 'UpdateMarket',
|
||||
marketId: '12345',
|
||||
},
|
||||
},
|
||||
votes: {
|
||||
__typename: 'ProposalVotes',
|
||||
yes: generateYesVotes(
|
||||
yesVotes,
|
||||
fixedTokenValue,
|
||||
yesEquityLikeShareWeight
|
||||
),
|
||||
no: generateNoVotes(noVotes, fixedTokenValue, noEquityLikeShareWeight),
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
result: { current },
|
||||
} = renderHook(() =>
|
||||
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||
);
|
||||
|
||||
expect(current?.willPassByTokenVote).toEqual(false);
|
||||
expect(current?.willPassByLPVote).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
@ -123,15 +123,19 @@ const getVoteData = (
|
||||
totalSupply.multipliedBy(params.requiredParticipation)
|
||||
);
|
||||
|
||||
const lpVoteWeight = yesEquityLikeShareWeight
|
||||
.dividedBy(totalEquityLikeShareWeight)
|
||||
.multipliedBy(100);
|
||||
|
||||
const participationLPMet = params.requiredParticipationLP
|
||||
? totalEquityLikeShareWeight.isGreaterThan(params.requiredParticipationLP)
|
||||
? lpVoteWeight.isGreaterThan(params.requiredParticipationLP)
|
||||
: false;
|
||||
|
||||
const majorityMet = yesPercentage.isGreaterThanOrEqualTo(
|
||||
requiredMajorityPercentage
|
||||
);
|
||||
|
||||
const majorityLPMet = yesLPPercentage.isGreaterThanOrEqualTo(
|
||||
const majorityLPMet = lpVoteWeight.isGreaterThanOrEqualTo(
|
||||
requiredMajorityLPPercentage
|
||||
);
|
||||
|
||||
@ -149,14 +153,12 @@ const getVoteData = (
|
||||
|
||||
const willPassByLPVote =
|
||||
participationLPMet &&
|
||||
new BigNumber(yesLPPercentage).isGreaterThanOrEqualTo(
|
||||
requiredMajorityLPPercentage
|
||||
);
|
||||
lpVoteWeight.isGreaterThanOrEqualTo(requiredMajorityLPPercentage);
|
||||
|
||||
let willPass = false;
|
||||
|
||||
if (changeType === 'UpdateMarket' || changeType === 'UpdateMarketState') {
|
||||
willPass = willPassByTokenVote && willPassByLPVote;
|
||||
willPass = willPassByTokenVote || willPassByLPVote;
|
||||
} else {
|
||||
willPass = willPassByTokenVote;
|
||||
}
|
||||
@ -182,6 +184,7 @@ const getVoteData = (
|
||||
totalLPTokensPercentage,
|
||||
willPassByTokenVote,
|
||||
willPassByLPVote,
|
||||
lpVoteWeight: lpVoteWeight.isNaN() ? new BigNumber(0) : lpVoteWeight,
|
||||
yesVotes: new BigNumber(votes.yes.totalNumber ?? 0),
|
||||
noVotes: new BigNumber(votes.no.totalNumber ?? 0),
|
||||
totalVotes: new BigNumber(votes.yes.totalNumber ?? 0).plus(
|
||||
|
Loading…
Reference in New Issue
Block a user