Claim Award Calculation Bug Fixed
This commit is contained in:
1 parent
85bc313b89
commit
f3a375fd40
5 files changed
+5678
-27
No files matched your search
@@ -53,8 +53,10 @@ function newGovernanceFunctionLibraryClaims() {
|
||||
node.type !== 'Position Class'
|
||||
) {
|
||||
if (node.payload.votes !== undefined) {
|
||||
node.payload.claimsCount = 0
|
||||
node.payload.claimsVotes = 0
|
||||
node.payload.claims = {
|
||||
count: 0,
|
||||
votes: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +97,19 @@ function newGovernanceFunctionLibraryClaims() {
|
||||
node.type !== 'Position Contributions Folder' &&
|
||||
node.type !== 'Contribution Claims'
|
||||
) {
|
||||
if (node.payload.claims === undefined) {
|
||||
node.payload.claims = {
|
||||
awarded: {
|
||||
tokens: 0,
|
||||
percentage: 0
|
||||
},
|
||||
share: {
|
||||
count: 0,
|
||||
percentage: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
node.payload.votes !== undefined &&
|
||||
node.payload.votes > 0 &&
|
||||
@@ -104,11 +119,11 @@ function newGovernanceFunctionLibraryClaims() {
|
||||
node.payload.referenceParent.payload.votes > 0 &&
|
||||
node.payload.referenceParent.payload.weight !== undefined &&
|
||||
node.payload.referenceParent.payload.weight > 0 &&
|
||||
node.payload.referenceParent.payload.claimsCount !== undefined &&
|
||||
node.payload.referenceParent.payload.claimsVotes !== undefined
|
||||
node.payload.referenceParent.payload.claims.count !== undefined &&
|
||||
node.payload.referenceParent.payload.claims.votes !== undefined
|
||||
) {
|
||||
node.payload.referenceParent.payload.claimsCount++
|
||||
node.payload.referenceParent.payload.claimsVotes = node.payload.referenceParent.payload.claimsVotes + node.payload.votes
|
||||
node.payload.referenceParent.payload.claims.count++
|
||||
node.payload.referenceParent.payload.claims.votes = node.payload.referenceParent.payload.claims.votes + node.payload.votes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +165,7 @@ function newGovernanceFunctionLibraryClaims() {
|
||||
node.type !== 'Contribution Claims'
|
||||
) {
|
||||
if (
|
||||
node.payload.claims !== undefined &&
|
||||
node.payload.votes !== undefined &&
|
||||
node.payload.votes > 0 &&
|
||||
node.payload.referenceParent !== undefined &&
|
||||
@@ -158,25 +174,30 @@ function newGovernanceFunctionLibraryClaims() {
|
||||
node.payload.referenceParent.payload.votes > 0 &&
|
||||
node.payload.referenceParent.payload.weight !== undefined &&
|
||||
node.payload.referenceParent.payload.weight > 0 &&
|
||||
node.payload.referenceParent.payload.claimsCount !== undefined &&
|
||||
node.payload.referenceParent.payload.claimsVotes !== undefined
|
||||
node.payload.referenceParent.payload.claims.count !== undefined &&
|
||||
node.payload.referenceParent.payload.claims.votes !== undefined
|
||||
) {
|
||||
/*
|
||||
We will use the concept of Vote Ratio for the situation in which the total votes in claims exeeds the
|
||||
amount of votes for wigthing. When this happen the Votes Ratio will be used to redude the amount of
|
||||
tokens awarded proportionally to how much was exeeded.
|
||||
We will use the concept of Vote Reward Claims Ratio for the situation in which the
|
||||
total votes in claims exeeds the amount of votes of the reward. When this happens
|
||||
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.claimsVotes
|
||||
let votesRatio = node.payload.referenceParent.payload.votes / node.payload.referenceParent.payload.claims.votes
|
||||
if (votesRatio > 1) { votesRatio = 1 }
|
||||
/*
|
||||
Share Count means the amount to claims pointing to the same potential tokens reward.
|
||||
Share Count means the amount to claims pointing to the same potential tokens reward.
|
||||
*/
|
||||
let shareCount = node.payload.referenceParent.payload.claimsCount
|
||||
let sharePercentage = node.payload.votes * 100 / node.payload.referenceParent.payload.claimsVotes
|
||||
let awarded = node.payload.votes / node.payload.referenceParent.payload.votes * node.payload.referenceParent.payload.tokens * votesRatio
|
||||
let awardedPercentage = node.payload.votes / node.payload.referenceParent.payload.votes * 100 * votesRatio
|
||||
node.payload.claims.share.count = node.payload.referenceParent.payload.claims.count
|
||||
node.payload.claims.share.percentage = node.payload.votes * 100 / node.payload.referenceParent.payload.claims.votes
|
||||
node.payload.claims.awarded.tokens =
|
||||
Math.min(
|
||||
node.payload.votes / node.payload.referenceParent.payload.votes * node.payload.referenceParent.payload.tokens * votesRatio,
|
||||
node.payload.votes
|
||||
)
|
||||
node.payload.claims.awarded.percentage = node.payload.claims.awarded.tokens / node.payload.referenceParent.payload.tokens * 100
|
||||
|
||||
drawClaims(node, shareCount, sharePercentage, awarded, awardedPercentage)
|
||||
drawClaims(node)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,13 +228,13 @@ function newGovernanceFunctionLibraryClaims() {
|
||||
}
|
||||
}
|
||||
|
||||
function drawClaims(node, shareCount, sharePercentage, awarded, awardedPercentage) {
|
||||
function drawClaims(node) {
|
||||
let satatus =
|
||||
new Intl.NumberFormat().format(awarded) +
|
||||
new Intl.NumberFormat().format(node.payload.claims.awarded.tokens) +
|
||||
' ' + 'SA Tokens Awarded' + ' - ' +
|
||||
'From Reward: ' + awardedPercentage.toFixed(2) + '%' + ' - ' +
|
||||
'Shared Between: ' + shareCount + ' claims' + ' - ' +
|
||||
'Share of Claims: ' + sharePercentage.toFixed(2) + '%'
|
||||
'From Reward: ' + node.payload.claims.awarded.percentage.toFixed(2) + '%' + ' - ' +
|
||||
'Shared Between: ' + node.payload.claims.share.count + ' claims' + ' - ' +
|
||||
'Share of Claims: ' + node.payload.claims.share.percentage.toFixed(2) + '%'
|
||||
node.payload.uiObject.setStatus(satatus)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user