Skip to content

Conversation

@keyvankhademi
Copy link
Contributor

No description provided.

@vercel
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

@keyvankhademi keyvankhademi merged commit c987d49 into main Sep 24, 2024
6 checks passed
@keyvankhademi keyvankhademi deleted the scaling branch September 24, 2024 23:49
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