fix(governance): fix lp vote counts (#5521)
This commit is contained in:
parent
145792f216
commit
bd70b0c233
@ -281,8 +281,8 @@ describe('VoteBreakdown', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Progress bar displays status - LP majority', () => {
|
it('Progress bar displays status - LP majority', () => {
|
||||||
const yesVotesLP = 800;
|
const yesVotesLP = 0.8;
|
||||||
const noVotesLP = 200;
|
const noVotesLP = 0.2;
|
||||||
const expectedProgress = (yesVotesLP / (yesVotesLP + noVotesLP)) * 100; // 80%
|
const expectedProgress = (yesVotesLP / (yesVotesLP + noVotesLP)) * 100; // 80%
|
||||||
|
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
@ -105,8 +105,6 @@ export const VoteBreakdown = ({ proposal }: VoteBreakdownProps) => {
|
|||||||
yesLPPercentage,
|
yesLPPercentage,
|
||||||
yesTokens,
|
yesTokens,
|
||||||
noTokens,
|
noTokens,
|
||||||
yesEquityLikeShareWeight,
|
|
||||||
noEquityLikeShareWeight,
|
|
||||||
totalEquityLikeShareWeight,
|
totalEquityLikeShareWeight,
|
||||||
requiredMajorityPercentage,
|
requiredMajorityPercentage,
|
||||||
requiredMajorityLPPercentage,
|
requiredMajorityLPPercentage,
|
||||||
@ -135,6 +133,7 @@ export const VoteBreakdown = ({ proposal }: VoteBreakdownProps) => {
|
|||||||
.multipliedBy(100),
|
.multipliedBy(100),
|
||||||
new BigNumber(100)
|
new BigNumber(100)
|
||||||
);
|
);
|
||||||
|
|
||||||
const willPass = willPassByTokenVote || willPassByLPVote;
|
const willPass = willPassByTokenVote || willPassByLPVote;
|
||||||
const updateMarketVotePassMethod = willPassByTokenVote
|
const updateMarketVotePassMethod = willPassByTokenVote
|
||||||
? t('byTokenVote')
|
? t('byTokenVote')
|
||||||
@ -202,50 +201,24 @@ export const VoteBreakdown = ({ proposal }: VoteBreakdownProps) => {
|
|||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<span>{t('liquidityProviderVotesFor')}:</span>
|
<span>{t('liquidityProviderVotesFor')}:</span>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
description={formatNumber(
|
description={
|
||||||
yesEquityLikeShareWeight,
|
<span>{yesLPPercentage.toFixed(defaultDP)}%</span>
|
||||||
defaultDP
|
}
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
<button>
|
<button>{yesLPPercentage.toFixed(1)}%</button>
|
||||||
<CompactVotes number={yesEquityLikeShareWeight} />
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<span>
|
|
||||||
(
|
|
||||||
<Tooltip
|
|
||||||
description={
|
|
||||||
<span>{yesLPPercentage.toFixed(defaultDP)}%</span>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<button>{yesLPPercentage.toFixed(0)}%</button>
|
|
||||||
</Tooltip>
|
|
||||||
)
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<span>{t('liquidityProviderVotesAgainst')}:</span>
|
<span>{t('liquidityProviderVotesAgainst')}:</span>
|
||||||
<Tooltip
|
|
||||||
description={formatNumber(
|
|
||||||
noEquityLikeShareWeight,
|
|
||||||
defaultDP
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<button>
|
|
||||||
<CompactVotes number={noEquityLikeShareWeight} />
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<span>
|
<span>
|
||||||
(
|
|
||||||
<Tooltip
|
<Tooltip
|
||||||
description={
|
description={
|
||||||
<span>{noLPPercentage.toFixed(defaultDP)}%</span>
|
<span>{noLPPercentage.toFixed(defaultDP)}%</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<button>{noLPPercentage.toFixed(0)}%</button>
|
<button>{noLPPercentage.toFixed(1)}%</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -282,13 +255,8 @@ export const VoteBreakdown = ({ proposal }: VoteBreakdownProps) => {
|
|||||||
defaultDP
|
defaultDP
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<button>
|
<span>{totalEquityLikeShareWeight.toFixed(1)}%</span>
|
||||||
<CompactVotes number={totalEquityLikeShareWeight} />
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<span>
|
|
||||||
({totalEquityLikeShareWeight.toFixed(defaultDP)}%)
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -54,8 +54,8 @@ describe('use-vote-information', () => {
|
|||||||
it('returns all required vote information', () => {
|
it('returns all required vote information', () => {
|
||||||
const yesVotes = 40;
|
const yesVotes = 40;
|
||||||
const noVotes = 60;
|
const noVotes = 60;
|
||||||
const yesEquityLikeShareWeight = '30';
|
const yesEquityLikeShareWeight = '0.30';
|
||||||
const noEquityLikeShareWeight = '70';
|
const noEquityLikeShareWeight = '0.70';
|
||||||
// Note - giving a fixedTokenValue of 1 means a ratio of 1:1 votes to tokens, making sums easier :)
|
// Note - giving a fixedTokenValue of 1 means a ratio of 1:1 votes to tokens, making sums easier :)
|
||||||
const fixedTokenValue = 1000000000000000000;
|
const fixedTokenValue = 1000000000000000000;
|
||||||
|
|
||||||
@ -195,10 +195,10 @@ describe('use-vote-information', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('correctly shows whether an update market proposal will pass by token or LP vote - both failing', () => {
|
it('correctly shows whether an update market proposal will pass by token or LP vote - both failing', () => {
|
||||||
const yesVotes = 20;
|
const yesVotes = 0.2;
|
||||||
const noVotes = 70;
|
const noVotes = 0.7;
|
||||||
const yesEquityLikeShareWeight = '30';
|
const yesEquityLikeShareWeight = '0.30';
|
||||||
const noEquityLikeShareWeight = '60';
|
const noEquityLikeShareWeight = '0.60';
|
||||||
const fixedTokenValue = 1000000000000000000;
|
const fixedTokenValue = 1000000000000000000;
|
||||||
|
|
||||||
const proposal = generateProposal({
|
const proposal = generateProposal({
|
||||||
|
@ -61,7 +61,7 @@ export const useVoteInformation = ({
|
|||||||
const noEquityLikeShareWeight = !proposal?.votes.no
|
const noEquityLikeShareWeight = !proposal?.votes.no
|
||||||
.totalEquityLikeShareWeight
|
.totalEquityLikeShareWeight
|
||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
: new BigNumber(proposal.votes.no.totalEquityLikeShareWeight);
|
: new BigNumber(proposal.votes.no.totalEquityLikeShareWeight).times(100);
|
||||||
|
|
||||||
const yesTokens = new BigNumber(
|
const yesTokens = new BigNumber(
|
||||||
addDecimal(proposal?.votes.yes.totalTokens ?? 0, decimals)
|
addDecimal(proposal?.votes.yes.totalTokens ?? 0, decimals)
|
||||||
@ -70,7 +70,7 @@ export const useVoteInformation = ({
|
|||||||
const yesEquityLikeShareWeight = !proposal?.votes.yes
|
const yesEquityLikeShareWeight = !proposal?.votes.yes
|
||||||
.totalEquityLikeShareWeight
|
.totalEquityLikeShareWeight
|
||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
: new BigNumber(proposal.votes.yes.totalEquityLikeShareWeight);
|
: new BigNumber(proposal.votes.yes.totalEquityLikeShareWeight).times(100);
|
||||||
|
|
||||||
const totalTokensVoted = yesTokens.plus(noTokens);
|
const totalTokensVoted = yesTokens.plus(noTokens);
|
||||||
|
|
||||||
@ -81,12 +81,7 @@ export const useVoteInformation = ({
|
|||||||
const yesPercentage = totalTokensVoted.isZero()
|
const yesPercentage = totalTokensVoted.isZero()
|
||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
: yesTokens.multipliedBy(100).dividedBy(totalTokensVoted);
|
: yesTokens.multipliedBy(100).dividedBy(totalTokensVoted);
|
||||||
|
const yesLPPercentage = yesEquityLikeShareWeight;
|
||||||
const yesLPPercentage = totalEquityLikeShareWeight.isZero()
|
|
||||||
? new BigNumber(0)
|
|
||||||
: yesEquityLikeShareWeight
|
|
||||||
.multipliedBy(100)
|
|
||||||
.dividedBy(totalEquityLikeShareWeight);
|
|
||||||
|
|
||||||
const noPercentage = totalTokensVoted.isZero()
|
const noPercentage = totalTokensVoted.isZero()
|
||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
@ -103,9 +98,7 @@ export const useVoteInformation = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const participationLPMet = requiredParticipationLP
|
const participationLPMet = requiredParticipationLP
|
||||||
? totalEquityLikeShareWeight.isGreaterThan(
|
? totalEquityLikeShareWeight.isGreaterThan(requiredParticipationLP)
|
||||||
totalSupply.multipliedBy(requiredParticipationLP)
|
|
||||||
)
|
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
const majorityMet = yesPercentage.isGreaterThanOrEqualTo(
|
const majorityMet = yesPercentage.isGreaterThanOrEqualTo(
|
||||||
@ -120,9 +113,7 @@ export const useVoteInformation = ({
|
|||||||
.multipliedBy(100)
|
.multipliedBy(100)
|
||||||
.dividedBy(totalSupply);
|
.dividedBy(totalSupply);
|
||||||
|
|
||||||
const totalLPTokensPercentage = totalEquityLikeShareWeight
|
const totalLPTokensPercentage = totalEquityLikeShareWeight;
|
||||||
.multipliedBy(100)
|
|
||||||
.dividedBy(totalSupply);
|
|
||||||
|
|
||||||
const willPassByTokenVote =
|
const willPassByTokenVote =
|
||||||
participationMet &&
|
participationMet &&
|
||||||
|
@ -116,7 +116,8 @@ export const generateYesVotes = (
|
|||||||
fixedTokenValue?: number,
|
fixedTokenValue?: number,
|
||||||
totalEquityLikeShareWeight?: string
|
totalEquityLikeShareWeight?: string
|
||||||
): Votes => {
|
): Votes => {
|
||||||
const votes = Array.from(Array(numberOfVotes)).map(() => {
|
const votes = [];
|
||||||
|
for (let i = 0; i < numberOfVotes; i++) {
|
||||||
const vote: Vote = {
|
const vote: Vote = {
|
||||||
__typename: 'Vote',
|
__typename: 'Vote',
|
||||||
value: Schema.VoteValue.VALUE_YES,
|
value: Schema.VoteValue.VALUE_YES,
|
||||||
@ -152,8 +153,9 @@ export const generateYesVotes = (
|
|||||||
datetime: faker.date.past().toISOString(),
|
datetime: faker.date.past().toISOString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
return vote;
|
votes.push(vote);
|
||||||
});
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
__typename: 'ProposalVoteSide',
|
__typename: 'ProposalVoteSide',
|
||||||
totalNumber: votes.length.toString(),
|
totalNumber: votes.length.toString(),
|
||||||
@ -172,7 +174,8 @@ export const generateNoVotes = (
|
|||||||
fixedTokenValue?: number,
|
fixedTokenValue?: number,
|
||||||
totalEquityLikeShareWeight?: string
|
totalEquityLikeShareWeight?: string
|
||||||
): Votes => {
|
): Votes => {
|
||||||
const votes = Array.from(Array(numberOfVotes)).map(() => {
|
const votes = [];
|
||||||
|
for (let i = 0; i < numberOfVotes; i++) {
|
||||||
const vote: Vote = {
|
const vote: Vote = {
|
||||||
__typename: 'Vote',
|
__typename: 'Vote',
|
||||||
value: Schema.VoteValue.VALUE_NO,
|
value: Schema.VoteValue.VALUE_NO,
|
||||||
@ -207,8 +210,9 @@ export const generateNoVotes = (
|
|||||||
},
|
},
|
||||||
datetime: faker.date.past().toISOString(),
|
datetime: faker.date.past().toISOString(),
|
||||||
};
|
};
|
||||||
return vote;
|
votes.push(vote);
|
||||||
});
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
__typename: 'ProposalVoteSide',
|
__typename: 'ProposalVoteSide',
|
||||||
totalNumber: votes.length.toString(),
|
totalNumber: votes.length.toString(),
|
||||||
|
@ -298,8 +298,8 @@
|
|||||||
"liquidityOnsenIntro": "Earn rewards for providing liquidity on the",
|
"liquidityOnsenIntro": "Earn rewards for providing liquidity on the",
|
||||||
"liquidityOnsenLinkText": "SushiSwap Onsen Menu",
|
"liquidityOnsenLinkText": "SushiSwap Onsen Menu",
|
||||||
"liquidityProviderVote": "Liquidity provider vote",
|
"liquidityProviderVote": "Liquidity provider vote",
|
||||||
"liquidityProviderVotesAgainst": "LP votes against",
|
"liquidityProviderVotesAgainst": "LP share against",
|
||||||
"liquidityProviderVotesFor": "LP votes for",
|
"liquidityProviderVotesFor": "LP share for",
|
||||||
"liquidityRewardsTitle": "Active liquidity rewards",
|
"liquidityRewardsTitle": "Active liquidity rewards",
|
||||||
"liquidityRewardsTitlePrevious": "Previous liquidity rewards",
|
"liquidityRewardsTitlePrevious": "Previous liquidity rewards",
|
||||||
"liquidityStakedBalance": "SLP token balance",
|
"liquidityStakedBalance": "SLP token balance",
|
||||||
@ -759,7 +759,7 @@
|
|||||||
"Total stake": "Total stake",
|
"Total stake": "Total stake",
|
||||||
"Total supply": "Total supply",
|
"Total supply": "Total supply",
|
||||||
"totalDistributed": "Total distributed",
|
"totalDistributed": "Total distributed",
|
||||||
"totalLiquidityProviderTokensVoted": "Total LP tokens voted",
|
"totalLiquidityProviderTokensVoted": "Total LP share voted",
|
||||||
"totalPenalties": "Total penalties",
|
"totalPenalties": "Total penalties",
|
||||||
"TotalPenaltiesDescription": "Total of penalties taking into account performance (considering proportion of blocks proposed against the number of blocks the validator was expected to propose) and any overstaking.",
|
"TotalPenaltiesDescription": "Total of penalties taking into account performance (considering proportion of blocks proposed against the number of blocks the validator was expected to propose) and any overstaking.",
|
||||||
"totalStake": "Total stake",
|
"totalStake": "Total stake",
|
||||||
|
Loading…
Reference in New Issue
Block a user