Claim Award Calculation Bug Fixed

This commit is contained in:
Luis Fernando Molina committed 2021-06-13 21:41:00 +02:00
1 parent 85bc313b89
commit f3a375fd40
5 files changed
+5678 -27

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -1 +1,60 @@
{"type":"Positions","name":"Superalgos","project":"Governance","positionClasss":[],"positions":[{"type":"Position","name":"Project Leader","config":"{\n \"description\": \"\", \"relativeWeight\": 0 \n}","project":"Governance","positions":[],"positionClasss":[],"id":"5f694173-4568-46b2-a52c-4244320919f7","savedPayload":{"position":{"x":30231,"y":38070},"targetPosition":{"x":30231,"y":37770},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"50c68665-5da2-48a8-b229-7a1563ae82d2","savedPayload":{"position":{"x":30231,"y":37770},"targetPosition":{"x":30231,"y":37770},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":true,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}
{
"type": "Positions",
"name": "Superalgos",
"project": "Governance",
"positionClasss": [],
"positions": [
{
"type": "Position",
"name": "Project Leader",
"config": "{\n \"description\": \"\", \"relativeWeight\": 0 \n}",
"project": "Governance",
"positions": [],
"positionClasss": [],
"id": "5f694173-4568-46b2-a52c-4244320919f7",
"savedPayload": {
"position": {
"x": 30231,
"y": 38070
},
"targetPosition": {
"x": 30231,
"y": 37770
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
],
"id": "50c68665-5da2-48a8-b229-7a1563ae82d2",
"savedPayload": {
"position": {
"x": 30231,
"y": 37770
},
"targetPosition": {
"x": 30231,
"y": 37770
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": true,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
@@ -1 +1,439 @@
{"type":"User Profile","name":"Julian-Molina","config":"{\n \"codeName\": \"\",\n \"tokens\": 500000\n}","project":"Governance","contributionClaims":{"type":"Contribution Claims","name":"New Contribution Claims","config":"{}","project":"Governance","assetContributionsFolder":[{"type":"Asset Contributions Folder","name":"Tutorials","config":"{}","project":"Governance","assetContributionsFolder":[{"type":"Asset Contributions Folder","name":"Tutorials Created","config":"{}","project":"Governance","assetContributionsFolder":[],"assetContributionClaims":[{"type":"Asset Contribution Claim","name":"","config":"{\n \"description\": \"\"\n}","project":"Governance","id":"b62215fd-405b-4b81-a446-d667de2fd23b","savedPayload":{"position":{"x":26082.78190893733,"y":22758.100619195047},"targetPosition":{"x":25822.974287801997,"y":22908.100619195047},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Getting Started Tutorial","id":"6c3f251e-cb80-42b7-935b-23bcbe218f97"}}}],"id":"30c01eef-80cf-4fb8-9231-af6694be0af9","savedPayload":{"position":{"x":25822.974287801997,"y":22908.100619195047},"targetPosition":{"x":25563.166666666664,"y":23058.100619195047},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Asset Contributions Folder","name":"Tutorials Mantainance","config":"{}","project":"Governance","assetContributionsFolder":[],"assetContributionClaims":[{"type":"Asset Contribution Claim","name":"","config":"{\n \"description\": \"\"\n}","project":"Governance","id":"4a841aaa-0730-4783-91be-87d718ee4e15","savedPayload":{"position":{"x":26082.78190893733,"y":23358.100619195047},"targetPosition":{"x":25822.974287801997,"y":23208.100619195047},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Asset","name":"Getting Started Tutorial","id":"6c3f251e-cb80-42b7-935b-23bcbe218f97"}}}],"id":"03cd14ee-432e-4c7c-b2b0-79dc24d07820","savedPayload":{"position":{"x":25822.974287801997,"y":23208.100619195047},"targetPosition":{"x":25563.166666666664,"y":23058.100619195047},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"assetContributionClaims":[],"id":"9318707a-afa0-4c84-8028-473eb448f96b","savedPayload":{"position":{"x":25563.166666666664,"y":23058.100619195047},"targetPosition":{"x":25263.166666666664,"y":23058.100619195047},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"featureContributionsFolder":[],"positionContributionsFolder":[],"id":"43a4118b-fc68-46a9-a7d8-fa4baafa5ad6","savedPayload":{"position":{"x":25263.166666666664,"y":23058.100619195047},"targetPosition":{"x":24963.166666666664,"y":23058.100619195047},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"votesDistribution":{"type":"Votes Distribution","name":"New Votes Distribution","config":"{\n\"codeName\": \"\"\n}","project":"Governance","votesSwitch":[{"type":"Votes Switch","name":"Test","config":"{\n \"description\": \"\"\n}","project":"Governance","votesSwitch":[],"claimVotesSwitch":[],"weightVotesSwitch":[],"userProfileVotesSwitch":[],"id":"f4127f8b-eb94-4e5e-aea9-71ea43ba5b5b","savedPayload":{"position":{"x":24663.166666666664,"y":23577.715861465713},"targetPosition":{"x":24813.166666666664,"y":23317.90824033038},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}}],"id":"84b2e7e0-577a-4edc-98fd-003905decb99","savedPayload":{"position":{"x":24813.166666666664,"y":23317.90824033038},"targetPosition":{"x":24963.166666666664,"y":23058.100619195047},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"userReferrer":{"type":"User Referrer","name":"","config":"{\n \"description\": \"\"\n}","project":"Governance","id":"edf7bcda-23f6-49bb-b9b2-9a34edcb4a40","savedPayload":{"position":{"x":24813.166666666664,"y":22798.292998059715},"targetPosition":{"x":24963.166666666664,"y":23058.100619195047},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"1fd95e41-4b22-48d5-be3a-904c37afcb11","savedPayload":{"position":{"x":24963.166666666664,"y":23058.100619195047},"targetPosition":{"x":24963.166666666664,"y":23058.10061919Line truncated
{
"type": "User Profile",
"name": "Julian-Molina",
"config": "{\n \"codeName\": \"\",\n \"tokens\": 500000\n}",
"project": "Governance",
"contributionClaims": {
"type": "Contribution Claims",
"name": "New Contribution Claims",
"config": "{}",
"project": "Governance",
"assetContributionsFolder": [
{
"type": "Asset Contributions Folder",
"name": "Tutorials",
"config": "{}",
"project": "Governance",
"assetContributionsFolder": [
{
"type": "Asset Contributions Folder",
"name": "Tutorials Created",
"config": "{}",
"project": "Governance",
"assetContributionsFolder": [],
"assetContributionClaims": [
{
"type": "Asset Contribution Claim",
"name": "",
"config": "{\n \"description\": \"\"\n}",
"project": "Governance",
"id": "b62215fd-405b-4b81-a446-d667de2fd23b",
"savedPayload": {
"position": {
"x": 26082.78190893733,
"y": 22758.100619195047
},
"targetPosition": {
"x": 25822.974287801997,
"y": 22908.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {},
"referenceParent": {
"type": "Asset",
"name": "Getting Started Tutorial",
"id": "6c3f251e-cb80-42b7-935b-23bcbe218f97"
}
}
}
],
"id": "30c01eef-80cf-4fb8-9231-af6694be0af9",
"savedPayload": {
"position": {
"x": 25822.974287801997,
"y": 22908.100619195047
},
"targetPosition": {
"x": 25563.166666666664,
"y": 23058.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
{
"type": "Asset Contributions Folder",
"name": "Tutorials Mantainance",
"config": "{}",
"project": "Governance",
"assetContributionsFolder": [],
"assetContributionClaims": [
{
"type": "Asset Contribution Claim",
"name": "",
"config": "{\n \"description\": \"\"\n}",
"project": "Governance",
"id": "4a841aaa-0730-4783-91be-87d718ee4e15",
"savedPayload": {
"position": {
"x": 26082.78190893733,
"y": 23358.100619195047
},
"targetPosition": {
"x": 25822.974287801997,
"y": 23208.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {},
"referenceParent": {
"type": "Asset",
"name": "Getting Started Tutorial",
"id": "6c3f251e-cb80-42b7-935b-23bcbe218f97"
}
}
}
],
"id": "03cd14ee-432e-4c7c-b2b0-79dc24d07820",
"savedPayload": {
"position": {
"x": 25822.974287801997,
"y": 23208.100619195047
},
"targetPosition": {
"x": 25563.166666666664,
"y": 23058.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
],
"assetContributionClaims": [],
"id": "9318707a-afa0-4c84-8028-473eb448f96b",
"savedPayload": {
"position": {
"x": 25563.166666666664,
"y": 23058.100619195047
},
"targetPosition": {
"x": 25263.166666666664,
"y": 23058.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
],
"featureContributionsFolder": [],
"positionContributionsFolder": [],
"id": "43a4118b-fc68-46a9-a7d8-fa4baafa5ad6",
"savedPayload": {
"position": {
"x": 25263.166666666664,
"y": 23058.100619195047
},
"targetPosition": {
"x": 24963.166666666664,
"y": 23058.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"votesDistribution": {
"type": "Votes Distribution",
"name": "New Votes Distribution",
"config": "{\n\"codeName\": \"\"\n}",
"project": "Governance",
"votesSwitch": [
{
"type": "Votes Switch",
"name": "Test",
"config": "{\n \"description\": \"\"\n}",
"project": "Governance",
"votesSwitch": [],
"claimVotesSwitch": [
{
"type": "Claim Votes Switch",
"name": "New Claim Votes Switch",
"config": "{}",
"project": "Governance",
"claimVotesSwitch": [],
"positionClaimVotes": [
{
"type": "Position Claim Vote",
"name": "Luis-Fernando-Molina Project Leader Superalgos",
"config": "{}",
"project": "Governance",
"id": "ab4d6901-a84c-44d3-a97a-7bc14de9ff31",
"savedPayload": {
"position": {
"x": 24963.166666666664,
"y": 24097.33110373638
},
"targetPosition": {
"x": 24813.166666666664,
"y": 23837.523482601046
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {},
"referenceParent": {
"type": "Position Contribution Claim",
"name": "Project Leader Superalgos",
"id": "a2bb4366-f480-4685-80b0-e40af9cddd8c"
}
}
}
],
"assetClaimVotes": [],
"featureClaimVotes": [],
"id": "6029fd9b-94b4-4b62-960a-14fb88107cdb",
"savedPayload": {
"position": {
"x": 24813.166666666664,
"y": 23837.523482601046
},
"targetPosition": {
"x": 24663.166666666664,
"y": 23577.715861465713
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
],
"weightVotesSwitch": [
{
"type": "Weight Votes Switch",
"name": "New Weight Votes Switch",
"config": "{}",
"project": "Governance",
"weightVotesSwitch": [],
"poolWeightVotes": [],
"assetWeightVotes": [],
"featureWeightVotes": [],
"positionWeightVotes": [
{
"type": "Position Weight Vote",
"name": "Superalgos Project Leader",
"config": "{}",
"project": "Governance",
"id": "11a8ac12-eba4-472d-b44b-8783720f8c6a",
"savedPayload": {
"position": {
"x": 24063.166666666664,
"y": 23577.715861465713
},
"targetPosition": {
"x": 24363.166666666664,
"y": 23577.715861465713
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {},
"referenceParent": {
"type": "Position",
"name": "Project Leader",
"id": "5f694173-4568-46b2-a52c-4244320919f7"
}
}
}
],
"id": "d98792e3-620f-4827-b17f-74096a2fe5c8",
"savedPayload": {
"position": {
"x": 24363.166666666664,
"y": 23577.715861465713
},
"targetPosition": {
"x": 24663.166666666664,
"y": 23577.715861465713
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
],
"userProfileVotesSwitch": [],
"id": "f4127f8b-eb94-4e5e-aea9-71ea43ba5b5b",
"savedPayload": {
"position": {
"x": 24663.166666666664,
"y": 23577.715861465713
},
"targetPosition": {
"x": 24813.166666666664,
"y": 23317.90824033038
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
],
"id": "84b2e7e0-577a-4edc-98fd-003905decb99",
"savedPayload": {
"position": {
"x": 24813.166666666664,
"y": 23317.90824033038
},
"targetPosition": {
"x": 24963.166666666664,
"y": 23058.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"userReferrer": {
"type": "User Referrer",
"name": "Luis-Fernando-Molina",
"config": "{\n \"description\": \"\"\n}",
"project": "Governance",
"id": "edf7bcda-23f6-49bb-b9b2-9a34edcb4a40",
"savedPayload": {
"position": {
"x": 24813.166666666664,
"y": 22798.292998059715
},
"targetPosition": {
"x": 24963.166666666664,
"y": 23058.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {},
"referenceParent": {
"type": "User Profile",
"name": "Luis-Fernando-Molina",
"id": "148911b3-b2f3-44fb-8cb4-017991789132"
}
}
},
"id": "1fd95e41-4b22-48d5-be3a-904c37afcb11",
"savedPayload": {
"position": {
"x": 24963.166666666664,
"y": 23058.100619195047
},
"targetPosition": {
"x": 24963.166666666664,
"y": 23058.100619195047
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": true,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
}
File diff suppressed because it is too large. Load diff
@@ -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)
}
}