Skip to content

feat: add vp value to leaderboard #571

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

Open
wants to merge 5 commits into
base: feat-assign-fiat-value-to-vote
Choose a base branch
from

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Aug 6, 2025

Toward https://github.com/snapshot-labs/workflow/issues/625
Depends on #566

This PR will add a new vp_value column to the leaderboard, tracking the user's total voting power value across spaces and proposals

Value will be updated on:

  • vote creation
  • proposal deletion

Test

Add the new column in the database

 -- Add vp_value column to leaderboard table
  ALTER TABLE leaderboard ADD COLUMN vp_value DECIMAL(13,3) NOT NULL DEFAULT 0.000;

  -- Add index for the new vp_value column for efficient queries
  ALTER TABLE leaderboard ADD INDEX vp_value (vp_value);

With a copy of the database with almost 10M of rows, this query is pretty fast, less than 10s

  • vote on a proposal with value
  • in the leadearboard tables, in the row corresponding to your address and space, you should see the vote value
  • when voting on another proposal on the same space, this value should increment by the vote's value
  • when deleting a proposal, the value should decrement by the vote's value

Notes

  • This PR will only enable feature on future votes, a batch script to fill previous votes will come in a separate PR

@wa0x6e wa0x6e requested a review from Copilot August 6, 2025 20:33
Copilot

This comment was marked as outdated.

@wa0x6e wa0x6e changed the base branch from master to feat-assign-fiat-value-to-vote August 6, 2025 20:33
@wa0x6e wa0x6e requested a review from Copilot August 7, 2025 17:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds voting power value tracking to the leaderboard system by introducing a new vp_value column that accumulates the total voting power value for each user across spaces and proposals.

  • Adds vp_value column to the leaderboard table schema with appropriate indexing
  • Updates vote creation logic to increment the user's voting power value in the leaderboard
  • Implements voting power value decrementation when proposals are deleted

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/schema.sql Adds vp_value DECIMAL column and index to leaderboard table
src/writer/vote.ts Updates vote creation to track and increment voting power values in leaderboard
src/writer/delete-proposal.ts Implements batch processing to decrement voting power values when proposals are deleted
src/helpers/entityValue.ts Refactors vote value calculation using reduce for better readability

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.

1 participant