Bonus Program Implemented

This commit is contained in:
Luis Fernando Molina committed 2021-06-24 11:35:18 +02:00
1 parent 26c58ea965
commit d56ec6855f
15 files changed
+451 -87

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@@ -642,7 +642,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": true,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
@@ -1274,8 +1274,8 @@
},
{
"type": "Pool",
"name": "Referrals Participation Bonus",
"config": "{\n \"codeName\": \"Referrals-Participation-Bonus\"\n}",
"name": "Referrals Bonus",
"config": "{\n \"codeName\": \"Referrals-Bonus\"\n}",
"project": "Governance",
"poolClasses": [],
"pools": [],
@@ -1365,8 +1365,8 @@
},
{
"type": "Pool",
"name": "Support Participation Bonus",
"config": "{\n \"codeName\": \"Support-Participation-Bonus\"\n}",
"name": "Support Bonus",
"config": "{\n \"codeName\": \"Support-Bonus\"\n}",
"project": "Governance",
"poolClasses": [],
"pools": [],
@@ -1457,7 +1457,7 @@
{
"type": "Pool",
"name": "Mentorship Participation Bonus",
"config": "{\n \"codeName\": \"Mentorship-Participation-Bonus\"\n}",
"config": "{\n \"codeName\": \"Mentorship-Bonus\"\n}",
"project": "Governance",
"poolClasses": [],
"pools": [],
@@ -1547,8 +1547,8 @@
"pools": [
{
"type": "Pool",
"name": "Voting Participation Bonus",
"config": "{\n \"codeName\": \"Voting-Participation-Bonus\"\n}",
"name": "Voting Bonus",
"config": "{\n \"codeName\": \"Voting-Bonus\"\n}",
"project": "Governance",
"poolClasses": [],
"pools": [],
@@ -1608,8 +1608,8 @@
"pools": [
{
"type": "Pool",
"name": "Liquid Democracy Participation Bonus",
"config": "{\n \"codeName\": \"Liquid-Democracy-Participation-Bonus\"\n}",
"name": "Liquid Democracy Bonus",
"config": "{\n \"codeName\": \"Liquid-Democracy-Bonus\"\n}",
"project": "Governance",
"poolClasses": [],
"pools": [],
@@ -22,8 +22,8 @@
"id": "fb0a076c-b0a8-4f16-9a47-10a3f3489a0a",
"savedPayload": {
"position": {
"x": 30660.151752050326,
"y": 22933.690934849117
"x": 30695.66511087198,
"y": 22950.386032869752
},
"targetPosition": {
"x": 30550.54944474041,
@@ -33,7 +33,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -53,8 +53,8 @@
"id": "56ac3eb9-2d72-4a8d-99bc-3221819ce995",
"savedPayload": {
"position": {
"x": 30847.198692607948,
"y": 23168.240379589526
"x": 30785.098889480818,
"y": 23025.90611888476
},
"targetPosition": {
"x": 30550.54944474041,
@@ -64,7 +64,32 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {}
}
},
"tokensBonus": {
"type": "Tokens Bonus",
"name": "New Tokens Bonus",
"project": "Governance",
"id": "2d205ae2-9158-4b36-a8cb-f9d5c5061342",
"savedPayload": {
"position": {
"x": 30838.82464132394,
"y": 23129.902406014924
},
"targetPosition": {
"x": 30550.54944474041,
"y": 23212.953059442378
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -108,8 +133,8 @@
"id": "2a038796-fccd-4a5a-b943-116ccca91b1d",
"savedPayload": {
"position": {
"x": 30895.15021539039,
"y": 23378.32972786362
"x": 30904.23967921002,
"y": 23416.50441319547
},
"targetPosition": {
"x": 30608.478373654547,
@@ -119,7 +144,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -139,8 +164,8 @@
"id": "c6367a1d-4bc7-4348-8309-a3e6f3fcdd50",
"savedPayload": {
"position": {
"x": 30828.393935203494,
"y": 23670.808101518167
"x": 30900.956747309094,
"y": 23533.512560373787
},
"targetPosition": {
"x": 30608.478373654547,
@@ -150,7 +175,32 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {}
}
},
"tokensBonus": {
"type": "Tokens Bonus",
"name": "New Tokens Bonus",
"project": "Governance",
"id": "3d5e14b8-8187-4f3b-8142-8daa540977a7",
"savedPayload": {
"position": {
"x": 30853.146634342324,
"y": 23640.357669040834
},
"targetPosition": {
"x": 30608.478373654547,
"y": 23466.75628018689
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -194,8 +244,8 @@
"id": "97483d0f-35ec-4471-a981-0d22565e0d63",
"savedPayload": {
"position": {
"x": 30729.330120827777,
"y": 23769.374378957273
"x": 30684.8524863998,
"y": 23852.02767352297
},
"targetPosition": {
"x": 30446.165121735266,
@@ -205,7 +255,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -225,8 +275,8 @@
"id": "8adecfda-c803-400c-acde-c34bda09e39b",
"savedPayload": {
"position": {
"x": 30576.330243470533,
"y": 23940.58132074145
"x": 30617.010469685803,
"y": 23916.891283005098
},
"targetPosition": {
"x": 30446.165121735266,
@@ -236,7 +286,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -256,8 +306,8 @@
"id": "09648f99-1bf8-4d53-9d20-f15cc8c71508",
"savedPayload": {
"position": {
"x": 30347.081403148717,
"y": 23953.455659463234
"x": 30532.444919964873,
"y": 23957.615905376202
},
"targetPosition": {
"x": 30446.165121735266,
@@ -267,7 +317,32 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {}
}
},
"tokensBonus": {
"type": "Tokens Bonus",
"name": "New Tokens Bonus",
"project": "Governance",
"id": "4113b77f-b7f4-41d2-8603-3784b2b65412",
"savedPayload": {
"position": {
"x": 30439.433702446524,
"y": 23970.215130853474
},
"targetPosition": {
"x": 30446.165121735266,
"y": 23670.290660370723
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -287,7 +362,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": true,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
@@ -325,12 +400,12 @@
"id": "edf1a5c9-7802-4856-918c-3cd5a7a9caf7",
"savedPayload": {
"position": {
"x": 30718.661945753065,
"y": 24284.862061411382
"x": 30541.44352053292,
"y": 24401.82684154666
},
"targetPosition": {
"x": 30463.457926046864,
"y": 24127.15693046823
"x": 30335.75245832439,
"y": 24183.443721943684
},
"floatingObject": {
"isPinned": false,
@@ -352,12 +427,12 @@
"id": "ebad23ed-1a02-4edf-a9d7-fc4b2fd0dacb",
"savedPayload": {
"position": {
"x": 30463.457926046864,
"y": 24127.15693046823
"x": 30335.75245832439,
"y": 24183.443721943684
},
"targetPosition": {
"x": 30208.253906340662,
"y": 23969.45179952508
"x": 30130.06139611586,
"y": 23965.06060234071
},
"floatingObject": {
"isPinned": false,
@@ -387,12 +462,12 @@
"id": "e745f3cd-4cd9-421b-b9ab-f62650fb56f8",
"savedPayload": {
"position": {
"x": 30322.02154513654,
"y": 24247.043089667277
"x": 30168.106583981345,
"y": 24262.63843027868
},
"targetPosition": {
"x": 30208.253906340662,
"y": 23969.45179952508
"x": 30130.06139611586,
"y": 23965.06060234071
},
"floatingObject": {
"isPinned": false,
@@ -422,12 +497,12 @@
"id": "3ae7f0f9-be37-4e6c-b3b1-4343e51f80a9",
"savedPayload": {
"position": {
"x": 30137.12979302601,
"y": 24260.89881101294
"x": 29985.928740982057,
"y": 24228.16852263974
},
"targetPosition": {
"x": 30208.253906340662,
"y": 23969.45179952508
"x": 30130.06139611586,
"y": 23965.06060234071
},
"floatingObject": {
"isPinned": false,
@@ -457,12 +532,12 @@
"id": "d8ab7844-f98f-4ce1-a634-c0ff98af28ca",
"savedPayload": {
"position": {
"x": 29979.405034781983,
"y": 24163.431679889818
"x": 29858.804673355116,
"y": 24093.20033215587
},
"targetPosition": {
"x": 30208.253906340662,
"y": 23969.45179952508
"x": 30130.06139611586,
"y": 23965.06060234071
},
"floatingObject": {
"isPinned": false,
@@ -487,8 +562,8 @@
"id": "f8a482c4-dee0-475a-831b-7514fd255ba6",
"savedPayload": {
"position": {
"x": 30208.253906340662,
"y": 23969.45179952508
"x": 30130.06139611586,
"y": 23965.06060234071
},
"targetPosition": {
"x": 30185.834878264734,
@@ -498,7 +573,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -521,8 +596,8 @@
"id": "5011109c-3f87-471a-b786-5fd371f53853",
"savedPayload": {
"position": {
"x": 29937.963245969935,
"y": 23839.28667778981
"x": 29990.148654881297,
"y": 23897.68217731436
},
"targetPosition": {
"x": 30185.834878264734,
@@ -532,7 +607,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -592,12 +667,12 @@
"id": "4381f059-44c8-4843-9cac-8a7cf41fa14c",
"savedPayload": {
"position": {
"x": 29291.212129593012,
"y": 23941.616203036338
"x": 29439.067762384868,
"y": 24114.971388205784
},
"targetPosition": {
"x": 29511.12769114196,
"y": 23737.564381705062
"x": 29598.67738533947,
"y": 23860.954128437297
},
"floatingObject": {
"isPinned": false,
@@ -619,12 +694,12 @@
"id": "d69739f9-958e-480e-95e3-a72bb5f6ceab",
"savedPayload": {
"position": {
"x": 29511.12769114196,
"y": 23737.564381705062
"x": 29598.67738533947,
"y": 23860.954128437297
},
"targetPosition": {
"x": 29731.043252690906,
"y": 23533.512560373787
"x": 29758.28700829407,
"y": 23606.93686866881
},
"floatingObject": {
"isPinned": false,
@@ -1990,12 +2065,12 @@
"id": "e059f5c4-9132-4d76-9f3e-1060658fa704",
"savedPayload": {
"position": {
"x": 29151.893037300517,
"y": 23511.84228823741
"x": 29193.26217880617,
"y": 23735.90009886783
},
"targetPosition": {
"x": 29444.371410955064,
"y": 23445.086008050515
"x": 29458.49679685755,
"y": 23595.719510385912
},
"floatingObject": {
"isPinned": false,
@@ -2027,12 +2102,12 @@
"id": "7607658c-f3ad-42de-a316-35dd052e0477",
"savedPayload": {
"position": {
"x": 29240.31958962379,
"y": 23225.17044650157
"x": 29204.479537089064,
"y": 23436.10988743131
},
"targetPosition": {
"x": 29444.371410955064,
"y": 23445.086008050515
"x": 29458.49679685755,
"y": 23595.719510385912
},
"floatingObject": {
"isPinned": false,
@@ -2055,12 +2130,12 @@
"id": "1d398124-3f36-40a1-8b3b-6c77ad489b92",
"savedPayload": {
"position": {
"x": 29444.371410955064,
"y": 23445.086008050515
"x": 29458.49679685755,
"y": 23595.719510385912
},
"targetPosition": {
"x": 29731.043252690906,
"y": 23533.512560373787
"x": 29758.28700829407,
"y": 23606.93686866881
},
"floatingObject": {
"isPinned": false,
@@ -2080,8 +2155,8 @@
"id": "2b8d3ce7-515c-44ad-8d80-3c2be6d7736f",
"savedPayload": {
"position": {
"x": 29731.043252690906,
"y": 23533.512560373787
"x": 29758.28700829407,
"y": 23606.93686866881
},
"targetPosition": {
"x": 30023.521626345453,
@@ -2091,7 +2166,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -2101,6 +2176,31 @@
}
}
],
"tokensBonus": {
"type": "Tokens Bonus",
"name": "New Tokens Bonus",
"project": "Governance",
"id": "e9c0e495-7985-4381-bf75-865d87289038",
"savedPayload": {
"position": {
"x": 29723.731414908932,
"y": 23455.538921903993
},
"targetPosition": {
"x": 30023.521626345453,
"y": 23466.75628018689
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {}
}
},
"id": "d5ed432e-78bf-432e-be3b-8649932f7a65",
"savedPayload": {
"position": {
@@ -24,6 +24,15 @@
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensBonus",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Bonus",
"relatedUiObject": "Tokens Bonus"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -59,6 +68,12 @@
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
},
{
"name": "tokensBonus",
"type": "node",
"childType": "Tokens Bonus",
"autoAdd": true
}
]
}
@@ -24,6 +24,15 @@
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensBonus",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Bonus",
"relatedUiObject": "Tokens Bonus"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -59,6 +68,12 @@
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
},
{
"name": "tokensBonus",
"type": "node",
"childType": "Tokens Bonus",
"autoAdd": true
}
]
}
@@ -24,6 +24,15 @@
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensBonus",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Bonus",
"relatedUiObject": "Tokens Bonus"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -59,6 +68,12 @@
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
},
{
"name": "tokensBonus",
"type": "node",
"childType": "Tokens Bonus",
"autoAdd": true
}
]
}
@@ -0,0 +1,21 @@
{
"type": "Tokens Bonus",
"menuItems": [
{
"action": "Delete UI Object",
"actionProject": "Foundations",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete-entity",
"iconPathOff": "delete-entity",
"actionFunction": "payload.executeAction"
}
],
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Referral Program->Mentorship Program->Support Program->Voting Program->"
},
"propertyNameAtParent": "tokensBonus"
}
@@ -24,6 +24,15 @@
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensBonus",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Bonus",
"relatedUiObject": "Tokens Bonus"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -59,6 +68,12 @@
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
},
{
"name": "tokensBonus",
"type": "node",
"childType": "Tokens Bonus",
"autoAdd": true
}
]
}
@@ -9,11 +9,19 @@ function newGovernanceFunctionLibraryMentorshipProgram() {
pools,
userProfiles
) {
UI.projects.governance.utilities.bonusProgram.run(
pools,
userProfiles,
"mentorshipProgram",
"Mentorship-Bonus"
)
UI.projects.governance.utilities.decendentProgram.run(
pools,
userProfiles,
"mentorshipProgram",
"Mentorship-Program",
"Mentorship-Rewards",
"Mentorship Program",
"Mentorship Power",
"userMentors",
@@ -9,11 +9,19 @@ function newGovernanceFunctionLibraryReferralProgram() {
pools,
userProfiles
) {
UI.projects.governance.utilities.bonusProgram.run(
pools,
userProfiles,
"referralProgram",
"Referrals-Bonus"
)
UI.projects.governance.utilities.decendentProgram.run(
pools,
userProfiles,
"referralProgram",
"Referral-Program",
"Referrals-Rewards",
"Referral Program",
"Referral Power",
"userReferrers",
@@ -9,11 +9,19 @@ function newGovernanceFunctionLibrarySupportProgram() {
pools,
userProfiles
) {
UI.projects.governance.utilities.bonusProgram.run(
pools,
userProfiles,
"supportProgram",
"Support-Bonus"
)
UI.projects.governance.utilities.decendentProgram.run(
pools,
userProfiles,
"supportProgram",
"Support-Program",
"Support-Rewards",
"Support Program",
"Support Power",
"userSupporters",
@@ -13,6 +13,15 @@ function newGovernanceFunctionLibraryVotingProgram() {
positions,
userProfiles
) {
/* Bonus Calculation is here */
UI.projects.governance.utilities.bonusProgram.run(
pools,
userProfiles,
"votingtProgram",
"Voting-Bonus"
)
/* Reset Votes at Pools */
for (let i = 0; i < pools.length; i++) {
let poolsNode = pools[i]
@@ -0,0 +1,145 @@
function newFoundationsUtilitiesBonusProgram() {
let thisObject = {
run: run
}
return thisObject
function run(
pools,
userProfiles,
programPropertyName,
programCodeName
) {
let programPoolTokenReward
/*
In order to be able to calculate the share of the Program Pool for each User Profile,
we need to accumulate all the Participation Power that each User Profile at their Program
node has, because with that Power is that each Program node gets a share of the pool.
*/
let accumulatedProgramPower = 0
/* Scan Pools Until finding the Mentoship-Program Pool */
for (let i = 0; i < pools.length; i++) {
let poolsNode = pools[i]
programPoolTokenReward = UI.projects.governance.utilities.pools.findPool(poolsNode, programCodeName)
}
if (programPoolTokenReward === undefined || programPoolTokenReward === 0) { return }
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue }
resetProgram(userProfile.tokenPowerSwitch[programPropertyName])
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue }
validateProgram(userProfile.tokenPowerSwitch[programPropertyName])
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName].payload[programPropertyName].isActive === false) { continue }
distributeProgram(userProfile.tokenPowerSwitch[programPropertyName])
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue }
if (userProfile.tokenPowerSwitch[programPropertyName].payload[programPropertyName].isActive === false) { continue }
calculateProgram(userProfile.tokenPowerSwitch[programPropertyName])
}
function resetProgram(node) {
if (node === undefined) { return }
if (node.payload === undefined) { return }
node.payload[programPropertyName] = {
bonusPower: 0,
bonus: {
tokens: 0,
percentage: 0
}
}
}
function validateProgram(node) {
/*
This program is not going to run unless the Profile has Tokens, and for
that users needs to execute the setup procedure of signing their Github
username with their private key.
*/
if (
node.payload.parentNode.payload.parentNode.payload.blockchainTokens === undefined
) {
node.payload[programPropertyName].isActive = false
node.payload.parentNode.payload.parentNode.payload.uiObject.setErrorMessage("You need to setup this profile with the Profile Constructor, to access the Token Power of your account at the Blockchain.")
return
}
}
function distributeProgram(programNode) {
if (programNode === undefined || programNode.payload === undefined) { return }
/*
Here we will convert Token Power into Participation Power.
As per system rules Participation Powar = tokensPower
*/
let programPower = programNode.payload.tokenPower
programNode.payload[programPropertyName].bonusPower = programPower
accumulatedProgramPower = accumulatedProgramPower + programPower
}
function calculateProgram(programNode) {
/*
Here we will calculate which share of the Program Pool this user will get in tokens.
To do that, we use the bonusPower, to see which proportion of the accumulatedProgramPower
represents.
*/
if (programNode.payload === undefined) { return }
/*
If the accumulatedProgramPower is not grater the amount of tokens at the Program Pool, then
this user will get the exact amount of tokens from the pool as incomingPower he has.
If the accumulatedProgramPower is grater the amount of tokens at the Program Pool, then
the amount ot tokens to be received is a proportional to the share of incomingPower in accumulatedProgramPower.
*/
let totalPowerRewardRatio = accumulatedProgramPower / programPoolTokenReward
if (totalPowerRewardRatio < 1) { totalPowerRewardRatio = 1 }
if (programNode.tokensBonus === undefined || programNode.tokensBonus.payload === undefined) {
programNode.payload.uiObject.setErrorMessage("Tokens Bonus Node is needed in order for this Program to get Tokens from the Program Pool.")
return
}
programNode.payload[programPropertyName].bonus.tokens = programNode.payload[programPropertyName].bonusPower * totalPowerRewardRatio
drawProgram(programNode)
}
function drawProgram(node) {
if (node.tokensBonus !== undefined && node.tokensBonus.payload !== undefined) {
const tokensBonusText = parseFloat(node.payload[programPropertyName].bonus.tokens.toFixed(2)).toLocaleString('en')
node.tokensBonus.payload.uiObject.valueAngleOffset = 0
node.tokensBonus.payload.uiObject.valueAtAngle = false
node.tokensBonus.payload.uiObject.setValue(tokensBonusText + ' SA Tokens')
}
}
}
}
@@ -9,7 +9,7 @@ function newFoundationsUtilitiesDecendentProgram() {
pools,
userProfiles,
programPropertyName,
programName,
programCodeName,
programNodeType,
programPowerName,
usersArrayPropertyName,
@@ -18,7 +18,7 @@ function newFoundationsUtilitiesDecendentProgram() {
/*
Here we will store the total amount of tokens that is going to be distributed among all participants
of the Program. This will come from a Pool that is configured wiht a codeName config property
with the value programName
with the value programCodeName
*/
let programPoolTokenReward
/*
@@ -32,7 +32,7 @@ function newFoundationsUtilitiesDecendentProgram() {
/* Scan Pools Until finding the Mentoship-Program Pool */
for (let i = 0; i < pools.length; i++) {
let poolsNode = pools[i]
programPoolTokenReward = UI.projects.governance.utilities.pools.findPool(poolsNode, programName)
programPoolTokenReward = UI.projects.governance.utilities.pools.findPool(poolsNode, programCodeName)
}
if (programPoolTokenReward === undefined || programPoolTokenReward === 0) { return }
/*
+5
View File
@@ -1034,6 +1034,11 @@
"name": "Decendent Program",
"propertyName": "decendentProgram",
"functionName": "newFoundationsUtilitiesDecendentProgram"
},
{
"name": "Bonus Program",
"propertyName": "bonusProgram",
"functionName": "newFoundationsUtilitiesBonusProgram"
}
],
"spaces": [