-
Notifications
You must be signed in to change notification settings - Fork 219
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
* The formula is n_staked_tokens = scaling_factor * n_voter_weight | ||
*/ | ||
public async getScalingFactor(): Promise<number> { | ||
const targetAccount = await this.getTargetAccount(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this 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
No description provided.