Skip to content

feat: update proposal's value #570

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 6 commits into
base: master
Choose a base branch
from

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Aug 6, 2025

Enhanced Proposal Value Calculation System

This PR refines the proposal value tracking system by implementing standardized precision and centralized
calculation logic for proposal USD values.

Key Features

🎯 Core Enhancement

  • Update scores_total_value column precision from DECIMAL(64,30) to DECIMAL(13,3) for optimized storage and performance (feat: set vote fiat value #566)
  • Implement centralized proposal value calculation logic in dedicated helper functions for improved maintainability

🔧 Technical Implementation

  • Centralized Logic: Consolidated value calculation in src/helpers/entityValue.ts creating a single source of truth for all value operations
  • Helper Functions: New dedicated functions for proposal value computation improving code organization and reusability (will be useful later, when introducing batch refresh of all proposals)

Database Changes

  • Modified scores_total_value column from DECIMAL(64,30) to DECIMAL(13,3) optimizing storage while maintaining appropriate precision for USD values

Testing

Update the db with

  ALTER TABLE proposals MODIFY COLUMN scores_total_value DECIMAL(13,3) NOT NULL DEFAULT 0.000;
  • create a proposal with erc-20 strategies
  • vote
  • when proposal close, it should update the scores_total_value column, with the voter's total voting power x strategy value

@wa0x6e wa0x6e force-pushed the feat-update-proposal-scores-value branch from af4325d to 0e77cd4 Compare August 6, 2025 14:52
@wa0x6e wa0x6e requested a review from Copilot August 6, 2025 17:44
Copilot

This comment was marked as outdated.

@wa0x6e wa0x6e force-pushed the feat-update-proposal-scores-value branch from 1f8ae4e to 0706ce6 Compare August 7, 2025 13:55
@wa0x6e wa0x6e requested a review from Copilot August 7, 2025 16:44
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 updates proposal value calculation functionality by implementing a new system to calculate and store the USD value of a proposal's total voting power. The change reduces database precision from 30 to 3 decimal places for better USD representation and adds comprehensive value calculation logic.

Key changes:

  • Implements getProposalValue function to calculate proposal USD values based on voting power and strategy values
  • Updates database schema to use DECIMAL(13,3) precision for scores_total_value column
  • Integrates value calculation into the proposal scoring workflow

Reviewed Changes

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

File Description
src/helpers/entityValue.ts New helper function to calculate proposal values with validation and error handling
src/scores.ts Integration of value calculation into proposal update workflow
test/schema.sql Database schema update to reduce decimal precision from (64,30) to (13,3)
test/unit/helpers/entityValue.test.ts Comprehensive test coverage for the new value calculation function

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