-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix: use decimals of each strategy to calculate voting power #1037
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tAck
I authored alternative implementation, won't review it as it's my code.
@ChaituVR I update this implementation, now it should work for both offchain and onchain spaces - as I dug deeper it turned out it needed different approach than what I suggested initially. Updated PR description with current implementation details. Would be great to have you review this change, and test it, from my side it can get merged after you and @wa0x6e approve it. |
In case of onchain strategies decimals are only there to specify how strategy value should be formatted, but it doesn't have effect on how this value is interpreted (strategy with VP value of 1 and 18 decimals and strategy with VP value of 1 and 0 decimals are actually the same and give sum of 2 VP). We need to separate cumulativeDecimals (used to calculate cumulative VP) and displayDecimals (used to display specific strategy's value). Depending on the context one or another needs to be used.
7484aa0
to
576170f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tAck
apps/ui/src/views/Proposal.vue
Outdated
@@ -310,7 +310,7 @@ watchEffect(() => { | |||
<a | |||
v-if=" | |||
votingPower?.status === 'success' && | |||
votingPower.totalVotingPower === BigInt(0) | |||
votingPower.votingPowers.some(v => v.value > 0n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that show when only one strategies among n strategies have 0 VP, but user still have enough VP to vote ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Summary
In case of onchain strategies decimals are only there to specify how
strategy value should be formatted, but it doesn't have effect on how
this value is interpreted (strategy with VP value of 1 and 18 decimals and
strategy with VP value of 1 and 0 decimals are actually the same and give sum
of 2 VP).
We need to separate cumulativeDecimals (used to calculate cumulative VP) and
displayDecimals (used to display specific strategy's value).
Depending on the context one or another needs to be used.
Closes: #1036
How to test
Onchain
0x556B14CbdA79A36dC33FcD461a04A5BCb5dC2A70
Offchain
0x74fa01a5D0ef8039f1E14F4d4C8f90e8602e07B4