Governance: Referral Program fully reimplemented.

This commit is contained in:
Luis Fernando Molina committed 2021-06-17 16:02:25 +02:00
1 parent 805f6d48f3
commit 226205413a
11 files changed
+213 -35

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -21,8 +21,8 @@
"id": "0d0b04ff-034b-4b02-8351-67d621d514c0",
"savedPayload": {
"position": {
"x": 25503.74798740812,
"y": 23618.43086266558
"x": 25532.618466191747,
"y": 23465.846712854385
},
"targetPosition": {
"x": 25233.45732703739,
@@ -44,6 +44,31 @@
}
}
},
"tokensAwarded": {
"type": "Tokens Awarded",
"name": "New Tokens Awarded",
"project": "Governance",
"id": "208f866a-459d-4dd8-93ea-1a2b8bfa3dac",
"savedPayload": {
"position": {
"x": 25402.453344456477,
"y": 23736.137373225112
},
"targetPosition": {
"x": 25233.45732703739,
"y": 23488.265740930314
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {}
}
},
"id": "a9ddce61-97b0-47e8-ad6c-e9438aca3913",
"savedPayload": {
"position": {
@@ -208,7 +233,9 @@
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {}
"uiObject": {
"isRunning": false
}
}
},
"id": "86a8ca4c-76d4-4eb0-9acb-5650095c6667",
@@ -21,8 +21,8 @@
"id": "c96ae419-54ad-4d70-94fe-38833288d471",
"savedPayload": {
"position": {
"x": 30785.098889480818,
"y": 23025.90611888476
"x": 30660.151752050326,
"y": 22933.690934849117
},
"targetPosition": {
"x": 30550.54944474041,
@@ -44,6 +44,31 @@
}
}
},
"tokensAwarded": {
"type": "Tokens Awarded",
"name": "New Tokens Awarded",
"project": "Governance",
"id": "56ac3eb9-2d72-4a8d-99bc-3221819ce995",
"savedPayload": {
"position": {
"x": 30847.198692607948,
"y": 23168.240379589526
},
"targetPosition": {
"x": 30550.54944474041,
"y": 23212.953059442378
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {}
}
},
"id": "43a24543-03cf-4511-b670-63566159dbd7",
"savedPayload": {
"position": {
@@ -1473,7 +1498,9 @@
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {}
"uiObject": {
"isRunning": false
}
}
},
"id": "f8182a9c-f830-4ec1-a238-ac3a5efd69e6",
@@ -0,0 +1,21 @@
{
"type": "Tokens Awarded",
"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->Claims Program->Staking Program->"
},
"propertyNameAtParent": "tokensAwarded"
}
@@ -29,6 +29,15 @@
"label": "Add Position Contributions Folder",
"relatedUiObject": "Position Contributions Folder"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensAwarded",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -70,6 +79,12 @@
"type": "array",
"childType": "Position Contributions Folder",
"autoAdd": false
},
{
"name": "tokensAwarded",
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
}
]
}
@@ -11,12 +11,19 @@
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "userMentor",
"actionFunction": "payload.executeAction",
"label": "Add User Mentor",
"relatedUiObject": "User Mentor"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensAwarded",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -46,6 +53,12 @@
"type": "array",
"childType": "User Mentor",
"autoAdd": false
},
{
"name": "tokensAwarded",
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
}
]
}
@@ -17,6 +17,15 @@
"label": "Add User Referrer",
"relatedUiObject": "User Referrer"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensAwarded",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -46,6 +55,12 @@
"type": "node",
"childType": "User Referrer",
"autoAdd": true
},
{
"name": "tokensAwarded",
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
}
]
}
@@ -8,6 +8,15 @@
"iconPathOn": "configuration",
"iconPathOff": "configuration"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensAwarded",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -30,5 +39,13 @@
},
"addLeftIcons": true,
"level": 1,
"propertyNameAtParent": "stakingProgram"
"propertyNameAtParent": "stakingProgram",
"childrenNodesProperties": [
{
"name": "tokensAwarded",
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
}
]
}
@@ -11,12 +11,19 @@
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "userSupport",
"actionFunction": "payload.executeAction",
"label": "Add User Support",
"relatedUiObject": "User Support"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensAwarded",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -46,6 +53,12 @@
"type": "array",
"childType": "User Support",
"autoAdd": false
},
{
"name": "tokensAwarded",
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
}
]
}
@@ -15,6 +15,15 @@
"label": "Add Votes Switch",
"relatedUiObject": "Votes Switch"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensAwarded",
"actionFunction": "payload.executeAction",
"label": "Add Tokens Awarded",
"relatedUiObject": "Tokens Awarded"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -44,6 +53,12 @@
"type": "array",
"childType": "Votes Switch",
"autoAdd": false
},
{
"name": "tokensAwarded",
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
}
]
}
@@ -156,9 +156,9 @@ function newGovernanceFunctionLibraryUserReferrals() {
if (referralProgram === undefined || referralProgram.payload === undefined) { return }
/*
Here we will convert Token Power into Referral Power.
As per system rules referringPower = tokensPower / 10
As per system rules referringPower = tokensPower
*/
let referringPower = referralProgram.payload.tokenPower / 10
let referringPower = referralProgram.payload.tokenPower
/*
We will also reseet the count of referrals here.
*/
@@ -241,12 +241,41 @@ function newGovernanceFunctionLibraryUserReferrals() {
}
function calculateForReferralProgram(referralProgram) {
/*
Here we will calculate which share of the Referral Program Pool this user will get in tokens.
To do that, we use the incomingPower, to se which proportion of the accumulatedIncomingReferralPower
represents.
*/
if (referralProgram.payload === undefined) { return }
/*
If the accumulatedIncomingReferralPower is not grater the amount of tokens at the Referral Program Pool, then
this user will get the exact amount of tokens from the pool as incomingPower he has.
let totalPowerRewardRatio = referralProgramPoolTokenReward / accumulatedIncomingReferralPower
If the accumulatedIncomingReferralPower is grater the amount of tokens at the Referral Program Pool, then
the amount ot tokens to be received is a proportional to the share of incomingPower in accumulatedIncomingReferralPower.
*/
let totalPowerRewardRatio = accumulatedIncomingReferralPower / referralProgramPoolTokenReward
if (totalPowerRewardRatio < 1) { totalPowerRewardRatio = 1 }
if (referralProgram.tokensAwarded === undefined || referralProgram.tokensAwarded.payload === undefined) {
referralProgram.payload.uiObject.setErrorMessage("Tokens Awarded Node is needed in order for this Program to get Tokens from the Referral Program Pool.")
return
}
referralProgram.payload.referrals.awarded.tokens = referralProgram.payload.referrals.incomingPower * totalPowerRewardRatio
/*
As per the system rules, the Referral Program will not give tokens to users that do not ha their own Referrer set up,
unless it has a big amount of tokens (this last condition is for the edge case where a user it at the top of the
referral pyramid.)
*/
if (
referralProgram.payload.referrals.ownPower < 1000000 &&
(referralProgram.userReferrer === undefined || referralProgram.userReferrer.payload.referenceParent === undefined)
) {
referralProgram.payload.uiObject.setErrorMessage("In order to be awarded " + referralProgram.payload.referrals.awarded.tokens + " SA Tokens from your referrals, you need first to define yourself who your referrer is.")
referralProgram.payload.referrals.awarded.tokens = 0
}
drawReferralProgram(referralProgram)
}
@@ -274,30 +303,16 @@ function newGovernanceFunctionLibraryUserReferrals() {
node.payload.uiObject.statusAngleOffset = 0
node.payload.uiObject.statusAtAngle = false
node.payload.uiObject.setStatus("Referring Power = Token Power / 10")
node.payload.uiObject.setStatus("Referring Power = Token Power")
}
if (node.tokensAwarded !== undefined && node.tokensAwarded.payload !== undefined) {
return
const tokensAwardedText = new Intl.NumberFormat().format(node.payload.referrals.awarded.tokens)
if (
(
node.userReferrer !== undefined &&
node.userReferrer.payload !== undefined &&
node.userReferrer.payload.referenceParent !== undefined)
||
node.payload.referrals.outgoingPower >= 10000000
) {
let status =
powerText + ' ' + 'Combined Referring Power' + ' - ' +
node.payload.referrals.count + ' Referrals' + ' - ' +
referralPower + ' Referrals Power' + ' - ' +
awardedTokens + ' ' + 'SA Tokens Awarded'
node.tokensAwarded.payload.uiObject.statusAngleOffset = 0
node.tokensAwarded.payload.uiObject.statusAtAngle = false
node.payload.uiObject.setStatus(status)
return
} else {
node.payload.referrals.awarded.tokens = 0
node.payload.uiObject.setStatus(awardedTokens + ' SA Tokens not Awarded, because you have not defined your referrer yet.')
}
node.tokensAwarded.payload.uiObject.setValue(tokensAwardedText + ' SA Tokens')
}
}
}