-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add state needed for calculating voting power to subgraph #664
Conversation
We can do this now that Governance is a submodule of the repo.
// Create initial stats | ||
let stats = new GovernanceStats("stats"); | ||
stats.totalLQTYStaked = BigInt.fromI32(0); | ||
stats.totalOffset = BigInt.fromI32(0); | ||
stats.totalInitiatives = 0; |
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.
Just noticed totalInitiatives
is never increased. Is the idea to track the number of GovernanceInitiative entities (i.e. only increased, never decreased, not even on unregistration)?
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.
No the idea was to track the number of active initiatives, this is something that was missing.
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.
Thanks @danielattilasimon, that’s great!
I deployed this version, and I built on top of it for this PR: #672
Do you think we could add the total voting power somewhere in the graph? Or is it something I could calculate easily with what we have already? So that the app could show a % rather than a unitless number.
Both the total voting power and your individual voting power are linear functions of time, but their y-intercepts (called "offset" in the backend and subgraph) are different, hence your % share will change over time even if nobody changes their stake. As such, I would leave it to the frontend to calculate the user's most up-to-date share like this:
where |
@danielattilasimon added in #677, thank you 🙏 |
We add the necessary state needed for calculating both total and per-user voting power. This could be useful if one wants to know e.g. their share of the total votes. Voting power is internally represented by a pair of
(lqty, offset)
values, from which the voting power at timet
can be calculated as:votingPower(t) = lqty * t - offset
.Also get Governance ABI from forge, just like for other contracts. We can do this now that Governance is a submodule of the repo.
Also fixes an issue where people's LQTY stake could be wrong in the subgraph if someone sent LQTY directly to their UserProxy.
Also, now we have events when the initial initiatives are being registered, so we no longer need the block handler.