Governance: standarizing Voting program

This commit is contained in:
Luis Fernando Molina committed 2021-06-23 12:15:12 +02:00
1 parent c0cd4e18dc
commit 4638b624b0
4 files changed
+37 -32

No files matched your search

@@ -54,7 +54,7 @@
},
{
"style": "Javascript",
"text": "/*\nWe will use the concept of Vote Ratio for the situation in which the total votes in claims exeeds the\namount of votes for wigthing. When this happen the Votes Ratio will be used to redude the amount of \ntokens awarded proportionally to how much was exeeded.\n*/\nlet votesRatio = node.payload.referenceParent.payload.votes / node.payload.referenceParent.payload.claimsVotes\nif (votesRatio > 1) { votesRatio = 1 }\n/*\n Share Count means the amount to claims pointing to the same potential tokens reward.\n*/\nlet shareCount = node.payload.referenceParent.payload.claimsCount\nlet sharePercentage = node.payload.votes * 100 / node.payload.referenceParent.payload.claimsVotes\nlet awarded = node.payload.votes / node.payload.referenceParent.payload.votes * node.payload.referenceParent.payload.tokens * votesRatio\nlet awardedPercentage = node.payload.votes / node.payload.referenceParent.payload.votes * 100 * votesRatio",
"text": "/*\nWe will use the concept of Vote Ratio for the situation in which the total votes in claims exeeds the\namount of votes for wigthing. When this happen the Votes Ratio will be used to redude the amount of \ntokens awarded proportionally to how much was exeeded.\n*/\nlet votesRatio = node.payload.referenceParent.payload.votingProgram.votes / node.payload.referenceParent.payload.claimsVotes\nif (votesRatio > 1) { votesRatio = 1 }\n/*\n Share Count means the amount to claims pointing to the same potential tokens reward.\n*/\nlet shareCount = node.payload.referenceParent.payload.claimsCount\nlet sharePercentage = node.payload.votingProgram.votes * 100 / node.payload.referenceParent.payload.claimsVotes\nlet awarded = node.payload.votingProgram.votes / node.payload.referenceParent.payload.votingProgram.votes * node.payload.referenceParent.payload.tokens * votesRatio\nlet awardedPercentage = node.payload.votingProgram.votes / node.payload.referenceParent.payload.votingProgram.votes * 100 * votesRatio",
"updated": 1623007674072
},
{
@@ -84,7 +84,7 @@ function newGovernanceFunctionLibraryClaimsProgram() {
node.type !== 'Feature Class' &&
node.type !== 'Position Class'
) {
if (node.payload.votes !== undefined) {
if (node.payload.votingProgram.votes !== undefined) {
node.payload.claimsProgram = {
count: 0,
votes: 0
@@ -173,19 +173,20 @@ function newGovernanceFunctionLibraryClaimsProgram() {
node.type !== 'Claims Program'
) {
if (
node.payload.votes !== undefined &&
node.payload.votes > 0 &&
node.payload.votingProgram !== undefined &&
node.payload.votingProgram.votes !== undefined &&
node.payload.votingProgram.votes > 0 &&
node.payload.referenceParent !== undefined &&
node.payload.referenceParent.payload !== undefined &&
node.payload.referenceParent.payload.votes !== undefined &&
node.payload.referenceParent.payload.votes > 0 &&
node.payload.referenceParent.payload.votingProgram.votes !== undefined &&
node.payload.referenceParent.payload.votingProgram.votes > 0 &&
node.payload.referenceParent.payload.weight !== undefined &&
node.payload.referenceParent.payload.weight > 0 &&
node.payload.referenceParent.payload.claimsProgram.count !== undefined &&
node.payload.referenceParent.payload.claimsProgram.votes !== undefined
) {
node.payload.referenceParent.payload.claimsProgram.count++
node.payload.referenceParent.payload.claimsProgram.votes = node.payload.referenceParent.payload.claimsProgram.votes + node.payload.votes
node.payload.referenceParent.payload.claimsProgram.votes = node.payload.referenceParent.payload.claimsProgram.votes + node.payload.votingProgram.votes
}
}
@@ -247,12 +248,12 @@ function newGovernanceFunctionLibraryClaimsProgram() {
) {
if (
node.payload.claimsProgram !== undefined &&
node.payload.votes !== undefined &&
node.payload.votes > 0 &&
node.payload.votingProgram.votes !== undefined &&
node.payload.votingProgram.votes > 0 &&
node.payload.referenceParent !== undefined &&
node.payload.referenceParent.payload !== undefined &&
node.payload.referenceParent.payload.votes !== undefined &&
node.payload.referenceParent.payload.votes > 0 &&
node.payload.referenceParent.payload.votingProgram.votes !== undefined &&
node.payload.referenceParent.payload.votingProgram.votes > 0 &&
node.payload.referenceParent.payload.weight !== undefined &&
node.payload.referenceParent.payload.weight > 0 &&
node.payload.referenceParent.payload.claimsProgram.count !== undefined &&
@@ -264,17 +265,17 @@ function newGovernanceFunctionLibraryClaimsProgram() {
the Votes Rewards Claims Ratio will be used to redude the amount of tokens awarded
proportionally to how much was exeeded.
*/
let votesRatio = node.payload.referenceParent.payload.votes / node.payload.referenceParent.payload.claimsProgram.votes
let votesRatio = node.payload.referenceParent.payload.votingProgram.votes / node.payload.referenceParent.payload.claimsProgram.votes
if (votesRatio > 1) { votesRatio = 1 }
/*
Share Count means the amount to claims pointing to the same potential tokens reward.
*/
node.payload.claimsProgram.share.count = node.payload.referenceParent.payload.claimsProgram.count
node.payload.claimsProgram.share.percentage = node.payload.votes * 100 / node.payload.referenceParent.payload.claimsProgram.votes
node.payload.claimsProgram.share.percentage = node.payload.votingProgram.votes * 100 / node.payload.referenceParent.payload.claimsProgram.votes
node.payload.claimsProgram.awarded.tokens =
Math.min(
node.payload.votes / node.payload.referenceParent.payload.votes * node.payload.referenceParent.payload.tokens * votesRatio,
node.payload.votes,
node.payload.votingProgram.votes / node.payload.referenceParent.payload.votingProgram.votes * node.payload.referenceParent.payload.tokens * votesRatio,
node.payload.votingProgram.votes,
programPower
)
node.payload.claimsProgram.awarded.percentage = node.payload.claimsProgram.awarded.tokens / node.payload.referenceParent.payload.tokens * 100
@@ -55,15 +55,17 @@ function newGovernanceFunctionLibraryVotingProgram() {
if (userProfile.tokenPowerSwitch.votingProgram === undefined) { continue }
if (userProfile.tokenPowerSwitch.votingProgram.payload === undefined) { continue }
userProfile.tokenPowerSwitch.votingProgram.payload.votes = userProfile.tokenPowerSwitch.votingProgram.payload.tokenPower
userProfile.tokenPowerSwitch.votingProgram.payload.votingProgram.votes = userProfile.tokenPowerSwitch.votingProgram.payload.tokenPower
distributeVotingProgram(userProfile.tokenPowerSwitch.votingProgram)
distributeProgram(userProfile.tokenPowerSwitch.votingProgram)
}
function resetVotes(node) {
if (node === undefined) { return }
if (node.payload === undefined) { return }
node.payload.votes = 0
node.payload.votingProgram = {
votes: 0
}
/*
When we reach certain node types, we will halt the distribution, because these are targets for
voting power.
@@ -126,17 +128,19 @@ function newGovernanceFunctionLibraryVotingProgram() {
}
}
function distributeVotingProgram(votingProgram) {
if (votingProgram.payload === undefined) { return }
let votes = votingProgram.payload.votes
distributeProgramPower(votingProgram, votes)
function distributeProgram(programNode) {
if (programNode.payload === undefined) { return }
let votes = programNode.payload.votingProgram.votes
programNode.payload.votingProgram.ownPower = votes
distributeProgramPower(programNode, votes)
}
function distributeProgramPower(node, votes, percentage) {
if (node === undefined) { return }
if (node.payload === undefined) { return }
node.payload.votes = node.payload.votes + votes
drawVotes(node, node.payload.votes, percentage)
node.payload.votingProgram.votes = node.payload.votingProgram.votes + votes
drawVotes(node, node.payload.votingProgram.votes, percentage)
/*
When we reach certain node types, we will halt the distribution, because these are targets for
voting power.
@@ -310,12 +314,12 @@ function newGovernanceFunctionLibraryVotingProgram() {
function drawProgram(node) {
if (node.payload !== undefined) {
const ownPowerText = parseFloat(node.payload.votingProgram.ownPower.toFixed(2)).toLocaleString('en')
node.payload.uiObject.statusAngleOffset = 0
node.payload.uiObject.statusAtAngle = false
node.payload.uiObject.setStatus(ownPowerText + ' Voting Power')
}
}
@@ -60,8 +60,8 @@ function newGovernanceFunctionLibraryWeights() {
node.payload.referenceParent !== undefined
)
) {
if (node.payload.votes !== undefined) {
totalVotes = totalVotes + node.payload.votes
if (node.payload.votingProgram.votes !== undefined) {
totalVotes = totalVotes + node.payload.votingProgram.votes
}
}
@@ -114,9 +114,9 @@ function newGovernanceFunctionLibraryWeights() {
node.payload.referenceParent !== undefined
)
) {
if (node.payload.votes !== undefined) {
if (node.payload.votes !== undefined) {
node.payload.weight = node.payload.votes / totalVotes
if (node.payload.votingProgram.votes !== undefined) {
if (node.payload.votingProgram.votes !== undefined) {
node.payload.weight = node.payload.votingProgram.votes / totalVotes
}
}
}