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

feat(staking): add governance ui methods #1937

Merged
merged 12 commits into from
Sep 24, 2024
Merged

feat(staking): add governance ui methods #1937

merged 12 commits into from
Sep 24, 2024

Conversation

keyvankhademi
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Sep 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2024 11:44pm
pyth-staking-v2-mainnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2024 11:44pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2024 11:44pm
staking-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 24, 2024 11:44pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
proposals ⬜️ Ignored (Inspect) Visit Preview Sep 24, 2024 11:44pm
xc-admin-frontend ⬜️ Ignored (Inspect) Visit Preview Sep 24, 2024 11:44pm

* The formula is n_staked_tokens = scaling_factor * n_voter_weight
*/
public async getScalingFactor(): Promise<number> {
const targetAccount = await this.getTargetAccount();
Copy link
Contributor

@guibescos guibescos Sep 19, 2024

Choose a reason for hiding this comment

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

Note: this is only valid if someone has cranked the target account (happens whenever someone stakes to unstakes, or whenever someome slashes). I generally think this approach seems fine

}

const scalingFactor = await this.getScalingFactor();
return Number(mainAccount.balance) / scalingFactor;
Copy link
Contributor

Choose a reason for hiding this comment

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

It needs to be the voter weight, that is the sum of all positions that have governance target and are active

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right!

const currentAccount = stakeAccountBalances[i];
if (
currentAccount !== undefined &&
currentAccount.balance > mainAccount.balance
Copy link
Contributor

Choose a reason for hiding this comment

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

Sort by voterWeight not by balance

Copy link
Contributor

@guibescos guibescos left a comment

Choose a reason for hiding this comment

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

I think you also need a method to return the user's voter weight account and the total voter weight account

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.

2 participants