Governance: Mentorship Program Implementation
This commit is contained in:
1 parent
24d6947d36
commit
83dd0e6174
2 files changed
+46
-40
No files matched your search
@@ -39,7 +39,7 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
if (userProfile.tokenSwitch.referralProgram === undefined) { continue }
|
||||
if (userProfile.tokenSwitch.referralProgram.payload === undefined) { continue }
|
||||
|
||||
resetUserReferrals(userProfile.tokenSwitch.referralProgram)
|
||||
reserReferralProgram(userProfile.tokenSwitch.referralProgram)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
@@ -60,10 +60,10 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
calculateReferralProgram(userProfile.tokenSwitch.referralProgram)
|
||||
}
|
||||
|
||||
function resetUserReferrals(node) {
|
||||
function reserReferralProgram(node) {
|
||||
if (node === undefined) { return }
|
||||
if (node.payload === undefined) { return }
|
||||
node.payload.referrals = {
|
||||
node.payload.referralProgram = {
|
||||
count: 0,
|
||||
outgoingPower: 0,
|
||||
ownPower: 0,
|
||||
@@ -81,7 +81,7 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
node.tokenSwitch !== undefined &&
|
||||
node.tokenSwitch.referralProgram !== undefined
|
||||
) {
|
||||
resetUserReferrals(node.tokenSwitch.referralProgram)
|
||||
reserReferralProgram(node.tokenSwitch.referralProgram)
|
||||
return
|
||||
}
|
||||
/*
|
||||
@@ -91,7 +91,7 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
node.type === 'Referral Program' &&
|
||||
node.userReferrer !== undefined
|
||||
) {
|
||||
resetUserReferrals(node.userReferrer)
|
||||
reserReferralProgram(node.userReferrer)
|
||||
return
|
||||
}
|
||||
/*
|
||||
@@ -102,7 +102,7 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
node.type === 'User Referrer' &&
|
||||
node.payload.referenceParent !== undefined
|
||||
) {
|
||||
resetUserReferrals(node.payload.referenceParent)
|
||||
reserReferralProgram(node.payload.referenceParent)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
/*
|
||||
The Own Power is the power generated by the same User Profile tokens, not inherited from others.
|
||||
*/
|
||||
referralProgram.payload.referrals.ownPower = referringPower
|
||||
referralProgram.payload.referralProgram.ownPower = referringPower
|
||||
|
||||
distributeReferralPower(referralProgram, referringPower, count)
|
||||
}
|
||||
@@ -142,18 +142,18 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
at the count parameters. If we are processing the User Profile of this Referral Program
|
||||
then we will add zero, otherwise, 1.
|
||||
*/
|
||||
node.payload.referrals.count = node.payload.referrals.count + count
|
||||
node.payload.referralProgram.count = node.payload.referralProgram.count + count
|
||||
/*
|
||||
The outgoingPower of this node will be accumulating all the referringPower flowing
|
||||
through it, no matter from where it comes.
|
||||
*/
|
||||
node.payload.referrals.outgoingPower = node.payload.referrals.outgoingPower + referringPower
|
||||
node.payload.referralProgram.outgoingPower = node.payload.referralProgram.outgoingPower + referringPower
|
||||
/*
|
||||
We need to adjust the balance that holds the accumulationt of all incomingPower of all Referral Program
|
||||
nodes. To do this we will substratct the current incomingPower, bacause it is going to be recalculated
|
||||
inmediatelly after this, and then we will add it again after the recalcualtion.
|
||||
*/
|
||||
accumulatedIncomingReferralPower = accumulatedIncomingReferralPower - node.payload.referrals.incomingPower
|
||||
accumulatedIncomingReferralPower = accumulatedIncomingReferralPower - node.payload.referralProgram.incomingPower
|
||||
/*
|
||||
At any point in time, the incomingPower will be equal to the total of the outgoingPower minus
|
||||
the ownPower. This is like this because the outgoingPower is the accumulation of all the
|
||||
@@ -161,12 +161,12 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
substract the ownPower, we will have the accumulation of all the incomingPower, which
|
||||
means all the power coming from other User Profiles referencing this one.
|
||||
*/
|
||||
node.payload.referrals.incomingPower = node.payload.referrals.outgoingPower - node.payload.referrals.ownPower
|
||||
node.payload.referralProgram.incomingPower = node.payload.referralProgram.outgoingPower - node.payload.referralProgram.ownPower
|
||||
/*
|
||||
Now that we have the incomingPower calculated again, we can add it again to the balance of all the incomingPower
|
||||
of all Referral Program nodes.
|
||||
*/
|
||||
accumulatedIncomingReferralPower = accumulatedIncomingReferralPower + node.payload.referrals.incomingPower
|
||||
accumulatedIncomingReferralPower = accumulatedIncomingReferralPower + node.payload.referralProgram.incomingPower
|
||||
|
||||
if (node.userReferrer !== undefined) {
|
||||
distributeReferralPower(node.userReferrer, referringPower, 0)
|
||||
@@ -216,19 +216,19 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
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
|
||||
referralProgram.payload.referralProgram.awarded.tokens = referralProgram.payload.referralProgram.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.payload.referralProgram.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
|
||||
referralProgram.payload.uiObject.setErrorMessage("In order to be awarded " + referralProgram.payload.referralProgram.awarded.tokens + " SA Tokens from your referrals, you need first to define yourself who your referrer is.")
|
||||
referralProgram.payload.referralProgram.awarded.tokens = 0
|
||||
}
|
||||
|
||||
drawReferralProgram(referralProgram)
|
||||
@@ -236,9 +236,9 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
|
||||
function drawUserReferrer(node) {
|
||||
if (node.payload !== undefined) {
|
||||
const ownPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referrals.ownPower)
|
||||
const incomingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referrals.incomingPower)
|
||||
const outgoingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referrals.outgoingPower)
|
||||
const ownPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referralProgram.ownPower)
|
||||
const incomingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referralProgram.incomingPower)
|
||||
const outgoingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referralProgram.outgoingPower)
|
||||
|
||||
node.payload.uiObject.valueAngleOffset = 180
|
||||
node.payload.uiObject.valueAtAngle = true
|
||||
@@ -262,12 +262,15 @@ function newGovernanceFunctionLibraryReferralProgram() {
|
||||
}
|
||||
if (node.tokensAwarded !== undefined && node.tokensAwarded.payload !== undefined) {
|
||||
|
||||
const tokensAwardedText = new Intl.NumberFormat().format(node.payload.referrals.awarded.tokens)
|
||||
const tokensAwardedText = new Intl.NumberFormat().format(node.payload.referralProgram.awarded.tokens)
|
||||
|
||||
node.tokensAwarded.payload.uiObject.statusAngleOffset = 0
|
||||
node.tokensAwarded.payload.uiObject.statusAtAngle = false
|
||||
node.tokensAwarded.payload.uiObject.valueAngleOffset = 0
|
||||
node.tokensAwarded.payload.uiObject.valueAtAngle = false
|
||||
|
||||
node.tokensAwarded.payload.uiObject.setValue(tokensAwardedText + ' SA Tokens')
|
||||
node.tokensAwarded.payload.uiObject.setStatus('From '+ node.payload.referralProgram.count + ' Referrals.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user