Skip to content
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

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

ChaituVR
Copy link
Member

@ChaituVR ChaituVR commented Dec 10, 2024

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

  1. Go to http://127.0.0.1:8080/#/sep:0xa6380C7eC883CC0BcdAaf9f46d6F83Fa872BF700/profile/0x556B14CbdA79A36dC33FcD461a04A5BCb5dC2A70
  2. User has 8 AXMVP
  3. Impersonate as 0x556B14CbdA79A36dC33FcD461a04A5BCb5dC2A70
  4. Go to http://127.0.0.1:8080/#/sep:0xa6380C7eC883CC0BcdAaf9f46d6F83Fa872BF700/proposals
  5. You have following results (total VP is 8 AXMVP, you have 8 TEST and 1 WHITE):
image

Offchain

  1. Go to http://127.0.0.1:8080/#/s:black-flag.eth/profile/0x74fa01a5D0ef8039f1E14F4d4C8f90e8602e07B4
  2. User has 351.117 🏴
  3. Impersonate as 0x74fa01a5D0ef8039f1E14F4d4C8f90e8602e07B4
  4. Go to http://127.0.0.1:8080/#/s:black-flag.eth/proposals
  5. You have following resutls (total VP is 351.117 🏴):
image

@ChaituVR ChaituVR changed the title fix: use decimals of each strategy while calculating voting power fix: use decimals of each strategy to calculate voting power Dec 10, 2024

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.

Copy link
Contributor

@wa0x6e wa0x6e left a 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/helpers/utils.ts Outdated Show resolved Hide resolved
@Sekhmet Sekhmet dismissed their stale review December 12, 2024 14:31

I authored alternative implementation, won't review it as it's my code.

@Sekhmet Sekhmet requested a review from wa0x6e December 12, 2024 14:32
@Sekhmet
Copy link
Member

Sekhmet commented Dec 12, 2024

@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.
@Sekhmet Sekhmet force-pushed the fix-use-decimals-of-each-strategy branch from 7484aa0 to 576170f Compare December 12, 2024 14:39
Copy link
Contributor

@wa0x6e wa0x6e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tAck

@@ -310,7 +310,7 @@ watchEffect(() => {
<a
v-if="
votingPower?.status === 'success' &&
votingPower.totalVotingPower === BigInt(0)
votingPower.votingPowers.some(v => v.value > 0n)
Copy link
Contributor

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 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@Sekhmet Sekhmet merged commit 07a9236 into master Dec 16, 2024
2 checks passed
@Sekhmet Sekhmet deleted the fix-use-decimals-of-each-strategy branch December 16, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Wrong voting power everywhere
3 participants