Merge pull request #1093 from Luis-Fernando-Molina/next-version

Contribution: token distribution and weight implemented
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-06-05 22:25:39 -04:00
commit b710b0925f
4 files changed
+43 -10

No files matched your search

@@ -14,9 +14,17 @@ function newGovernanceFunctionLibraryWeights() {
if (node === undefined) { return }
if (node.payload === undefined) { return }
if (node.payload.votes !== undefined) {
totalVotes = totalVotes + node.payload.votes
if (
node.type !== 'Pool Class' &&
node.type !== 'Asset Class' &&
node.type !== 'Feature Class' &&
node.type !== 'Position Class'
) {
if (node.payload.votes !== undefined) {
totalVotes = totalVotes + node.payload.votes
}
}
node.payload.weight = 0
/*
Now we will count the voting power of this node's children.
@@ -52,9 +60,19 @@ function newGovernanceFunctionLibraryWeights() {
if (node === undefined) { return }
if (node.payload === undefined) { return }
if (node.payload.votes !== undefined) {
node.payload.weight = node.payload.votes / totalVotes
if (
node.type !== 'Pool Class' &&
node.type !== 'Asset Class' &&
node.type !== 'Feature Class' &&
node.type !== 'Position Class'
) {
if (node.payload.votes !== undefined) {
if (node.payload.votes !== undefined) {
node.payload.weight = node.payload.votes / totalVotes
}
}
}
/*
Now we will count the voting power of this node's children.
*/
@@ -25,7 +25,15 @@ function newGobernanceAssetsSpace() {
}
function physics() {
if (UI.projects.superalgos.spaces.designSpace.workspace === undefined) { return }
let assets = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('Assets')
/* Weight Calculation Follows */
for (let i = 0; i < assets.length; i++) {
let asset = assets[i]
UI.projects.governance.functionLibraries.weights.calculateWeights(asset)
}
}
function getContainer(point) {
@@ -63,7 +63,7 @@ function newGovernancePoolsSpace() {
function poolsDistribute(pools) {
let tokenFlow = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(pools.payload, 'tokens')
distributeTokenFlow(pools, tokenFlow)
distributeTokens(pools, tokenFlow)
}
function resetTokenFlow(node) {
@@ -119,7 +119,7 @@ function newGovernancePoolsSpace() {
}
}
function distributeTokenFlow(node, tokenFlow) {
function distributeTokens(node, tokenFlow) {
if (node === undefined) { return }
if (node.payload === undefined) { return }
/*
@@ -151,7 +151,7 @@ function newGovernancePoolsSpace() {
transfered to it and not distributed among children.
*/
if (node.payload.referenceParent !== undefined) {
distributeTokenFlow(node.payload.referenceParent, tokenFlow)
distributeTokens(node.payload.referenceParent, node.payload.tokenFlow)
return
}
/*
@@ -163,7 +163,6 @@ function newGovernancePoolsSpace() {
node.type === 'Feature'
) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
for (let i = 0; i < schemaDocument.childrenNodesProperties.length; i++) {
let property = schemaDocument.childrenNodesProperties[i]
@@ -172,7 +171,7 @@ function newGovernancePoolsSpace() {
case 'node': {
if (node.type === 'Pools' && property.name === "votesDistribution") {
let childNode = node[property.name]
distributeTokenFlow(childNode, tokenFlow)
distributeTokens(childNode, tokenFlow)
}
}
break
@@ -181,7 +180,7 @@ function newGovernancePoolsSpace() {
if (propertyArray !== undefined) {
for (let m = 0; m < propertyArray.length; m++) {
let childNode = propertyArray[m]
distributeTokenFlow(childNode, tokenFlow)
distributeTokens(childNode, tokenFlow)
}
}
break
@@ -27,7 +27,15 @@ function newGovernancePositionsSpace() {
}
function physics() {
if (UI.projects.superalgos.spaces.designSpace.workspace === undefined) { return }
let positions = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('Positions')
/* Weight Calculation Follows */
for (let i = 0; i < positions.length; i++) {
let position = positions[i]
UI.projects.governance.functionLibraries.weights.calculateWeights(position)
}
}
function getContainer(point) {