Pools Implemented

This commit is contained in:
Luis Fernando Molina committed 2021-06-04 00:21:27 +02:00
1 parent 4994f03ff4
commit 4186fac706
22 files changed
+308 -85

No files matched your search

@@ -42,7 +42,7 @@
"compatibleTypes": "->Assets->Asset Class->"
},
"referencingRules": {
"compatibleTypes": "->Team->Position->"
"compatibleTypes": "->Position Class->Position->"
},
"propertyNameAtParent": "assetClasses",
"childrenNodesProperties": [
@@ -23,8 +23,8 @@
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Time Contributions Folder",
"relatedUiObject": "Time Contributions Folder"
"label": "Add Position Contributions Folder",
"relatedUiObject": "Position Contributions Folder"
},
{
"action": "Delete UI Object",
@@ -62,9 +62,9 @@
"autoAdd": false
},
{
"name": "timeContributionsFolder",
"name": "positionContributionsFolder",
"type": "array",
"childType": "Time Contributions Folder",
"childType": "Position Contributions Folder",
"autoAdd": false
}
],
@@ -42,7 +42,7 @@
"compatibleTypes": "->Features->Feature Class->"
},
"referencingRules": {
"compatibleTypes": "->Team->Position->"
"compatibleTypes": "->Position Class->Position->"
},
"propertyNameAtParent": "featureClasses",
"childrenNodesProperties": [
@@ -21,8 +21,8 @@
},
{
"action": "Add UI Object",
"label": "Add Organization Chart",
"relatedUiObject": "Organization Chart",
"label": "Add Positions",
"relatedUiObject": "Positions",
"actionFunction": "payload.executeAction"
},
{
@@ -1,5 +1,5 @@
{
"type": "Pool Class",
"type": "Tokens Switch",
"menuItems": [
{
"action": "Configure",
@@ -11,8 +11,8 @@
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Pool Class",
"relatedUiObject": "Pool Class"
"label": "Add Tokens Switch",
"relatedUiObject": "Tokens Switch"
},
{
"action": "Add UI Object",
@@ -39,17 +39,17 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Pools->Pool Class->"
"compatibleTypes": "->Pools->Tokens Switch->"
},
"referencingRules": {
"compatibleTypes": "->Team->Position->"
"compatibleTypes": "->Position Class->Position->"
},
"propertyNameAtParent": "poolClasses",
"propertyNameAtParent": "tokensSwitches",
"childrenNodesProperties": [
{
"name": "poolClasses",
"name": "tokensSwitches",
"type": "array",
"childType": "Pool Class",
"childType": "Tokens Switch",
"autoAdd": false
},
{
@@ -19,10 +19,8 @@
}
],
"title": [
"Use Reference Parent Parent Parent Parent",
"Use Reference Parent Parent Parent",
"Use Reference Parent Parent",
"Use Reference Parent"
"Use Reference Parent",
"Use Reference Parent Type"
],
"editors": {
"config": true
@@ -36,7 +34,7 @@
"compatibleTypes": "->Votes Switch->"
},
"referencingRules": {
"compatibleTypes": "->Pool Class->Pool->"
"compatibleTypes": "->Tokens Switch->Pool->"
},
"propertyNameAtParent": "poolWeightVotes"
}
@@ -11,8 +11,8 @@
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Pool Class",
"relatedUiObject": "Pool Class"
"label": "Add Tokens Switch",
"relatedUiObject": "Tokens Switch"
},
{
"action": "Add UI Object",
@@ -39,17 +39,17 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Pool Class->Pool->"
"compatibleTypes": "->Tokens Switch->Pool->"
},
"referencingRules": {
"compatibleTypes": "->Organization Chart->Assets->Features->"
"compatibleTypes": "->Positions->Assets->Features->"
},
"propertyNameAtParent": "pools",
"childrenNodesProperties": [
{
"name": "poolClasses",
"name": "tokensSwitches",
"type": "array",
"childType": "Pool Class",
"childType": "Tokens Switch",
"autoAdd": false
},
{
@@ -11,8 +11,8 @@
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Pool Class",
"relatedUiObject": "Pool Class"
"label": "Add Tokens Switch",
"relatedUiObject": "Tokens Switch"
},
{
"action": "Add UI Object",
@@ -41,9 +41,9 @@
"level": 0,
"childrenNodesProperties": [
{
"name": "poolClasses",
"name": "tokensSwitches",
"type": "array",
"childType": "Pool Class",
"childType": "Tokens Switch",
"autoAdd": false
},
{
@@ -1,5 +1,5 @@
{
"type": "Time Claim Vote",
"type": "Position Claim Vote",
"menuItems": [
{
"action": "Configure",
@@ -34,8 +34,8 @@
"compatibleTypes": "->Votes Switch->"
},
"referencingRules": {
"compatibleTypes": "->Time Contribution Claim->"
"compatibleTypes": "->Position Contribution Claim->"
},
"propertyNameAtParent": "timeClaimVotes",
"propertyNameAtParent": "positionClaimVotes",
"icon": "dogecoin"
}
@@ -1,5 +1,5 @@
{
"type": "Team",
"type": "Position Class",
"menuItems": [
{
"action": "Configure",
@@ -17,8 +17,8 @@
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Team",
"relatedUiObject": "Team"
"label": "Add Position Class",
"relatedUiObject": "Position Class"
},
{
"action": "Delete UI Object",
@@ -39,9 +39,9 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Position->Team->"
"compatibleTypes": "->Position->Position Class->"
},
"propertyNameAtParent": "teams",
"propertyNameAtParent": "positionClasss",
"childrenNodesProperties": [
{
"name": "positions",
@@ -50,9 +50,9 @@
"autoAdd": false
},
{
"name": "teams",
"name": "positionClasss",
"type": "array",
"childType": "Team",
"childType": "Position Class",
"autoAdd": false
}
],
@@ -1,5 +1,5 @@
{
"type": "Time Contribution Claim",
"type": "Position Contribution Claim",
"menuItems": [
{
"action": "Configure",
@@ -31,11 +31,11 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Time Contributions Folder->"
"compatibleTypes": "->Position Contributions Folder->"
},
"referencingRules": {
"compatibleTypes": "->Position->"
},
"propertyNameAtParent": "timeContributionClaims",
"propertyNameAtParent": "positionContributionClaims",
"icon": "dogecoin"
}
@@ -1,5 +1,5 @@
{
"type": "Time Contributions Folder",
"type": "Position Contributions Folder",
"menuItems": [
{
"action": "Configure",
@@ -11,14 +11,14 @@
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Time Contributions Folder",
"relatedUiObject": "Time Contributions Folder"
"label": "Add Position Contributions Folder",
"relatedUiObject": "Position Contributions Folder"
},
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Time Contribution Claim",
"relatedUiObject": "Time Contribution Claim"
"label": "Add Position Contribution Claim",
"relatedUiObject": "Position Contribution Claim"
},
{
"action": "Delete UI Object",
@@ -39,20 +39,20 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Contribution Claims->Time Contributions Folder->"
"compatibleTypes": "->Contribution Claims->Position Contributions Folder->"
},
"propertyNameAtParent": "timeContributionsFolder",
"propertyNameAtParent": "positionContributionsFolder",
"childrenNodesProperties": [
{
"name": "timeContributionsFolder",
"name": "positionContributionsFolder",
"type": "array",
"childType": "Time Contributions Folder",
"childType": "Position Contributions Folder",
"autoAdd": false
},
{
"name": "timeContributionClaims",
"name": "positionContributionClaims",
"type": "array",
"childType": "Time Contribution Claim",
"childType": "Position Contribution Claim",
"autoAdd": false
}
],
@@ -34,7 +34,7 @@
"compatibleTypes": "->Votes Switch->"
},
"referencingRules": {
"compatibleTypes": "->Team->Position->"
"compatibleTypes": "->Position Class->Position->"
},
"propertyNameAtParent": "positionWeightVotes",
"icon": "bitfinex"
@@ -17,8 +17,8 @@
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Team",
"relatedUiObject": "Team"
"label": "Add Position Class",
"relatedUiObject": "Position Class"
},
{
"action": "Delete UI Object",
@@ -39,7 +39,7 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Organization Chart->Position->Team->"
"compatibleTypes": "->Positions->Position->Position Class->"
},
"propertyNameAtParent": "positions",
"childrenNodesProperties": [
@@ -50,9 +50,9 @@
"autoAdd": false
},
{
"name": "teams",
"name": "positionClasss",
"type": "array",
"childType": "Team",
"childType": "Position Class",
"autoAdd": false
}
],
@@ -1,11 +1,11 @@
{
"type": "Organization Chart",
"type": "Positions",
"menuItems": [
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Team",
"relatedUiObject": "Team"
"label": "Add Position Class",
"relatedUiObject": "Position Class"
},
{
"action": "Add UI Object",
@@ -28,9 +28,9 @@
"level": 0,
"childrenNodesProperties": [
{
"name": "teams",
"name": "positionClasss",
"type": "array",
"childType": "Team",
"childType": "Position Class",
"autoAdd": false
},
{
@@ -14,6 +14,12 @@
"label": "Add Votes Switch",
"relatedUiObject": "Votes Switch"
},
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Pool Weight Vote",
"relatedUiObject": "Pool Weight Vote"
},
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
@@ -35,8 +41,8 @@
{
"action": "Add UI Object",
"actionFunction": "payload.executeAction",
"label": "Add Time Claim Vote",
"relatedUiObject": "Time Claim Vote"
"label": "Add Position Claim Vote",
"relatedUiObject": "Position Claim Vote"
},
{
"action": "Add UI Object",
@@ -85,6 +91,12 @@
"childType": "Votes Switch",
"autoAdd": false
},
{
"name": "poolWeightVotes",
"type": "array",
"childType": "Pool Weight Vote",
"autoAdd": false
},
{
"name": "assetWeightVotes",
"type": "array",
@@ -98,9 +110,9 @@
"autoAdd": false
},
{
"name": "timeClaimVotes",
"name": "positionClaimVotes",
"type": "array",
"childType": "Time Claim Vote",
"childType": "Position Claim Vote",
"autoAdd": false
},
{
@@ -1,4 +1,4 @@
function newGovernanceUserFeaturesSpace() {
function newGovernanceFeaturesSpace() {
const MODULE_NAME = 'Features Space'
let thisObject = {
@@ -0,0 +1,185 @@
function newGovernancePoolsSpace() {
const MODULE_NAME = 'Pool Space'
let thisObject = {
container: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
finalize: finalize,
initialize: initialize
}
thisObject.container = newContainer()
thisObject.container.initialize(MODULE_NAME)
return thisObject
function initialize() {
}
function finalize() {
thisObject.container.finalize()
thisObject.container = undefined
}
function getContainer(point) {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
thisObject.container.space = MODULE_NAME
return thisObject.container
} else {
return undefined
}
}
function physics() {
if (UI.projects.superalgos.spaces.designSpace.workspace === undefined) { return }
let pools = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('Pools')
/*
We will first reset all the token flows, and then distribute it.
*/
for (let i = 0; i < pools.length; i++) {
let poolsNode = pools[i]
poolsReset(poolsNode)
}
for (let i = 0; i < pools.length; i++) {
let poolsNode = pools[i]
poolsDistribute(poolsNode)
}
}
function poolsReset(pools) {
resetTokenFlow(pools)
}
function poolsDistribute(pools) {
let tokenFlow = UI.projects.superalgos.utilities.nodeConfig.loadPropertyFromNodeConfig(pools.payload, 'tokens')
distributeTokenFlow(pools, tokenFlow)
}
function resetTokenFlow(node) {
if (node === undefined) { return }
if (node.payload === undefined) { return }
node.payload.tokenFlow = 0
/*
If there is a reference parent defined, this means that the token flow is
transfered to it and not distributed among children.
*/
if (node.payload.referenceParent !== undefined) {
resetTokenFlow(node.payload.referenceParent)
return
}
/*
When we reach certain node types, we will halt the distribution, because thse are targets for
token flow.
*/
if (
node.type === 'Position' ||
node.type === 'Asset' ||
node.type === 'Feature'
) { return }
/*
If there is no reference parent we will redistribute token flow among children.
*/
let schemaDocument = getSchemaDocument(node)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
for (let i = 0; i < schemaDocument.childrenNodesProperties.length; i++) {
let property = schemaDocument.childrenNodesProperties[i]
switch (property.type) {
case 'node': {
if (node.type === 'Pools' && property.name === "votesDistribution") {
let childNode = node[property.name]
resetTokenFlow(childNode)
}
}
break
case 'array': {
let propertyArray = node[property.name]
if (propertyArray !== undefined) {
for (let m = 0; m < propertyArray.length; m++) {
let childNode = propertyArray[m]
resetTokenFlow(childNode)
}
}
break
}
}
}
}
}
function distributeTokenFlow(node, tokenFlow) {
if (node === undefined) { return }
if (node.payload === undefined) { return }
node.payload.tokenFlow = node.payload.tokenFlow + tokenFlow
drawTokenFlow(node, node.payload.tokenFlow)
/*
If there is a reference parent defined, this means that the token flow is
transfered to it and not distributed among children.
*/
if (node.payload.referenceParent !== undefined) {
distributeTokenFlow(node.payload.referenceParent, tokenFlow)
return
}
/*
When we reach certain node types, we will halt the distribution, because thse are targets for
token flow.
*/
if (
node.type === 'Asset' ||
node.type === 'Feature'
) { return }
/*
If there is no reference parent we will redistribute token flow among children.
*/
let schemaDocument = getSchemaDocument(node)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
for (let i = 0; i < schemaDocument.childrenNodesProperties.length; i++) {
let property = schemaDocument.childrenNodesProperties[i]
switch (property.type) {
case 'node': {
if (node.type === 'Pools' && property.name === "votesDistribution") {
let childNode = node[property.name]
distributeTokenFlow(childNode, tokenFlow)
}
}
break
case 'array': {
let propertyArray = node[property.name]
if (propertyArray !== undefined) {
for (let m = 0; m < propertyArray.length; m++) {
let childNode = propertyArray[m]
distributeTokenFlow(childNode, tokenFlow / propertyArray.length)
}
}
break
}
}
}
}
}
function drawTokenFlow(node, tokenFlow) {
tokenFlow = new Intl.NumberFormat().format(tokenFlow) + ' ' + 'SA Tokens'
if (node.payload !== undefined) {
if (node.type === 'Pools') {
return
}
node.payload.uiObject.setStatus(tokenFlow)
}
}
function draw() {
}
}
@@ -1,5 +1,5 @@
function newGovernanceRankingSpace() {
const MODULE_NAME = 'Ranking Space'
function newGovernancePositionsSpace() {
const MODULE_NAME = 'Positions Space'
let thisObject = {
container: undefined,
@@ -27,7 +27,7 @@ function newGovernanceRankingSpace() {
}
function physics() {
}
function getContainer(point) {
@@ -175,13 +175,28 @@ function newGovernanceUserProfileSpace() {
}
function drawVotingPower(node, votingPower) {
votingPower = new Intl.NumberFormat().format(votingPower) + ' ' + 'SA'
votingPower = new Intl.NumberFormat().format(votingPower) + ' ' + 'Votes'
if (node.payload !== undefined) {
if (node.type === 'User Profile') {
return
}
node.payload.uiObject.valueAngleOffset = 180
node.payload.uiObject.valueAtAngle = true
if (
node.type === 'Position' ||
node.type === 'Position Class' ||
node.type === 'Pool' ||
node.type === 'Tokens Switch' ||
node.type === 'Asset' ||
node.type === 'Asset Class' ||
node.type === 'Feature' ||
node.type === 'Feature Class'
) {
node.payload.uiObject.valueAngleOffset = 0
node.payload.uiObject.valueAtAngle = false
} else{
node.payload.uiObject.valueAngleOffset = 180
node.payload.uiObject.valueAtAngle = true
}
node.payload.uiObject.setValue(votingPower)
}
}
+21 -8
View File
@@ -1036,10 +1036,10 @@
"onMouseDownIndex": 1
},
{
"name": "User Features Space",
"folderName": "User-Features-Space",
"propertyName": "userFeaturesSpace",
"functionName": "newGovernanceUserFeaturesSpace",
"name": "Features Space",
"folderName": "Features-Space",
"propertyName": "featuresSpace",
"functionName": "newGovernanceFeaturesSpace",
"initializationIndex": 2,
"animationPhysicsIndex": 2,
"animationDrawIndex": 2,
@@ -1049,10 +1049,10 @@
"onMouseDownIndex": 2
},
{
"name": "Ranking Space",
"folderName": "Ranking-Space",
"propertyName": "rankingSpace",
"functionName": "newGovernanceRankingSpace",
"name": "Positions Space",
"folderName": "Positions-Space",
"propertyName": "positionsSpace",
"functionName": "newGovernancePositionsSpace",
"initializationIndex": 3,
"animationPhysicsIndex": 3,
"animationDrawIndex": 3,
@@ -1060,6 +1060,19 @@
"onMouseOverIndex": 3,
"onMouseClickIndex": 3,
"onMouseDownIndex": 3
},
{
"name": "Pools Space",
"folderName": "Pools-Space",
"propertyName": "poolsSpace",
"functionName": "newGovernancePoolsSpace",
"initializationIndex": 4,
"animationPhysicsIndex": 4,
"animationDrawIndex": 4,
"onMouseWheelIndex": 4,
"onMouseOverIndex": 4,
"onMouseClickIndex": 4,
"onMouseDownIndex": 4
}
]
},