Airdrop and Influencer programs implemented

This commit is contained in:
Luis Fernando Molina committed 2021-07-30 12:48:00 +02:00
1 parent 03ce51e39b
commit 44fe0c6f90
18 files changed
+2159 -902

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,51 @@
{
"type": "Airdrop Program",
"menuItems": [
{
"action": "Configure",
"actionFunction": "uiObject.configEditor.activate",
"label": "Configure",
"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",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete-entity",
"iconPathOff": "delete-entity",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{}"
},
"attachingRules": {
"compatibleTypes": "->Token Power Switch->"
},
"addLeftIcons": true,
"level": 1,
"propertyNameAtParent": "airdropProgram",
"childrenNodesProperties": [
{
"name": "tokensAwarded",
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
}
]
}
@@ -0,0 +1,79 @@
{
"type": "Influencer Program",
"menuItems": [
{
"action": "Configure",
"actionFunction": "uiObject.configEditor.activate",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"actionFunction": "payload.executeAction",
"label": "Add User Influencer",
"relatedUiObject": "User Influencer"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "tokensAwarded",
"actionFunction": "payload.executeAction",
"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",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete-entity",
"iconPathOff": "delete-entity",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{}"
},
"attachingRules": {
"compatibleTypes": "->Token Power Switch->"
},
"addLeftIcons": true,
"level": 1,
"propertyNameAtParent": "influencerProgram",
"childrenNodesProperties": [
{
"name": "userInfluencers",
"type": "array",
"childType": "User Influencer",
"autoAdd": false
},
{
"name": "tokensAwarded",
"type": "node",
"childType": "Tokens Awarded",
"autoAdd": true
},
{
"name": "tokensBonus",
"type": "node",
"childType": "Tokens Bonus",
"autoAdd": true
}
]
}
@@ -15,6 +15,24 @@
"label": "Add Token Power Switch",
"relatedUiObject": "Token Power Switch"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"actionFunction": "payload.executeAction",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "airdropProgram",
"label": "Add Airdrop Program",
"relatedUiObject": "Airdrop Program"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"actionFunction": "payload.executeAction",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "githubProgram",
"label": "Add Github Program",
"relatedUiObject": "Github Program"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
@@ -42,6 +60,15 @@
"label": "Add Mentorship Program",
"relatedUiObject": "Mentorship Program"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"actionFunction": "payload.executeAction",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "influencerProgram",
"label": "Add Influencer Program",
"relatedUiObject": "Influencer Program"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
@@ -78,15 +105,6 @@
"label": "Add Delegation Program",
"relatedUiObject": "Delegation Program"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"actionFunction": "payload.executeAction",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "githubProgram",
"label": "Add Github Program",
"relatedUiObject": "Github Program"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
@@ -107,7 +125,7 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->User Profile->"
"compatibleTypes": "->User Profile->Token Power Switch->"
},
"propertyNameAtParent": "tokenPowerSwitch",
"childrenNodesProperties": [
@@ -117,6 +135,18 @@
"childType": "Token Power Switch",
"autoAdd": false
},
{
"name": "airdropProgram",
"type": "node",
"childType": "Airdrop Program",
"autoAdd": false
},
{
"name": "githubProgram",
"type": "node",
"childType": "Github Program",
"autoAdd": false
},
{
"name": "referralProgram",
"type": "node",
@@ -135,6 +165,12 @@
"childType": "Mentorship Program",
"autoAdd": false
},
{
"name": "influencerProgram",
"type": "node",
"childType": "Influencer Program",
"autoAdd": false
},
{
"name": "claimsProgram",
"type": "node",
@@ -158,12 +194,6 @@
"type": "node",
"childType": "Delegation Program",
"autoAdd": false
},
{
"name": "githubProgram",
"type": "node",
"childType": "Github Program",
"autoAdd": false
}
]
}
@@ -15,7 +15,7 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Referral Program->Mentorship Program->Support Program->Claims Program->Staking Program->Github Program->"
"compatibleTypes": "->Referral Program->Mentorship Program->Support Program->Claims Program->Staking Program->Github Program->Airdrop Program->Influencer Program->"
},
"propertyNameAtParent": "tokensAwarded"
}
@@ -15,7 +15,7 @@
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Referral Program->Mentorship Program->Support Program->Voting Program->"
"compatibleTypes": "->Referral Program->Mentorship Program->Support Program->Voting Program->Influencer Program->"
},
"propertyNameAtParent": "tokensBonus"
}
@@ -0,0 +1,40 @@
{
"type": "User Influencer",
"menuItems": [
{
"action": "Configure",
"actionFunction": "uiObject.configEditor.activate",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration"
},
{
"action": "Delete UI Object",
"actionProject": "Foundations",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete-entity",
"iconPathOff": "delete-entity",
"actionFunction": "payload.executeAction"
}
],
"title": [
"Use Reference Parent"
],
"editors": {
"config": true
},
"initialValues": {
"config": "{}"
},
"addLeftIcons": true,
"level": 2,
"attachingRules": {
"compatibleTypes": "->Support Program->"
},
"referencingRules": {
"compatibleTypes": "->User Profile->"
},
"propertyNameAtParent": "userInfluencers"
}
@@ -0,0 +1,191 @@
function newGovernanceFunctionLibraryAirdropProgram() {
let thisObject = {
calculate: calculate
}
return thisObject
function calculate(
pools,
userProfiles
) {
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 Airdrop 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, "Airdrop-Rewards")
}
if (programPoolTokenReward === undefined || programPoolTokenReward === 0) { return }
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Airdrop Program")
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
resetProgram(program)
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Airdrop Program")
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
validateProgram(program, userProfile)
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Airdrop Program")
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
if (program.payload.airdropProgram.isActive === false) { continue }
distributeProgram(program)
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Airdrop Program")
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
if (program.payload.airdropProgram.isActive === false) { continue }
calculateProgram(program)
}
function resetProgram(node) {
if (node === undefined) { return }
if (node.payload === undefined) { return }
if (node.payload.airdropProgram === undefined) {
node.payload.airdropProgram = {
count: 0,
percentage: 0,
outgoingPower: 0,
ownPower: 0,
incomingPower: 0,
awarded: {
tokens: 0,
percentage: 0
}
}
} else {
node.payload.airdropProgram.count = 0
node.payload.airdropProgram.percentage = 0
node.payload.airdropProgram.outgoingPower = 0
node.payload.airdropProgram.ownPower = 0
node.payload.airdropProgram.incomingPower = 0
node.payload.airdropProgram.awarded = {
tokens: 0,
percentage: 0
}
}
}
function validateProgram(node, userProfile) {
/*
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 Airdrop
username with their private key.
*/
if (
userProfile.payload.blockchainTokens === undefined
) {
node.payload.airdropProgram.isActive = false
userProfile.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
}
/*
Next thing to do is to validate if the airdrop user profile has a star at the Superalgos repository.
*/
let profileSignature = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(userProfile.payload, 'signature')
if (
profileSignature === undefined
) {
node.payload.airdropProgram.isActive = false
userProfile.payload.uiObject.setErrorMessage("You need to setup this profile with the Profile Constructor, and produce a signature of your Airdrop Username.")
return
}
node.payload.airdropProgram.isActive = true
}
function distributeProgram(programNode) {
if (programNode === undefined || programNode.payload === undefined) { return }
/*
Here we will convert Token Power into Airdrop Power.
As per system rules Airdrop Powar = 1000 SA Tokens.
*/
let programPower = 1000
programNode.payload.airdropProgram.ownPower = 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 ownPower, 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.tokensAwarded === undefined || programNode.tokensAwarded.payload === undefined) {
programNode.payload.uiObject.setErrorMessage("Tokens Awarded Node is needed in order for this Program to get Tokens from the Program Pool.")
return
}
programNode.payload.airdropProgram.awarded.tokens = programNode.payload.airdropProgram.ownPower / totalPowerRewardRatio
drawProgram(programNode)
}
function drawProgram(node) {
if (node.payload !== undefined) {
const ownPowerText = parseFloat(node.payload.airdropProgram.ownPower.toFixed(0)).toLocaleString('en')
node.payload.uiObject.statusAngleOffset = 0
node.payload.uiObject.statusAtAngle = false
node.payload.uiObject.setStatus(ownPowerText + ' Airdrop Power')
}
if (node.tokensAwarded !== undefined && node.tokensAwarded.payload !== undefined) {
const tokensAwardedText = parseFloat(node.payload.airdropProgram.awarded.tokens.toFixed(0)).toLocaleString('en')
const tokensAwardedBTC = ' ≃ ' + UI.projects.governance.utilities.conversions.estimateSATokensInBTC(node.payload.airdropProgram.awarded.tokens | 0) + ' BTC'
node.tokensAwarded.payload.uiObject.valueAngleOffset = 0
node.tokensAwarded.payload.uiObject.valueAtAngle = false
node.tokensAwarded.payload.uiObject.setValue(tokensAwardedText + ' SA Tokens' + tokensAwardedBTC)
node.tokensAwarded.payload.uiObject.statusAngleOffset = 0
node.tokensAwarded.payload.uiObject.statusAtAngle = false
node.tokensAwarded.payload.uiObject.setStatus('For creating your Superalgos profile!')
}
}
}
}
@@ -75,6 +75,13 @@ function newGovernanceFunctionLibraryDistributionProcess() {
userProfiles
)
/*
Run the Influencer Program
*/
UI.projects.governance.functionLibraries.influencerProgram.calculate(
pools,
userProfiles
)
/*
Run the Mentorship Program
*/
UI.projects.governance.functionLibraries.mentorshipProgram.calculate(
@@ -105,6 +112,13 @@ function newGovernanceFunctionLibraryDistributionProcess() {
userProfiles
)
/*
Run the Airdrop Program
*/
UI.projects.governance.functionLibraries.airdropProgram.calculate(
pools,
userProfiles
)
/*
After all the programs were ran, we can calculate the tokens mining
calculation each profile.
*/
@@ -141,9 +141,9 @@ function newGovernanceFunctionLibraryGithubProgram() {
if (programNode === undefined || programNode.payload === undefined) { return }
/*
Here we will convert Token Power into Github Power.
As per system rules Github Powar = 1000 SA Tokens.
As per system rules Github Powar = 1200 SA Tokens.
*/
let programPower = 1000
let programPower = 3000
programNode.payload.githubProgram.ownPower = programPower
accumulatedProgramPower = accumulatedProgramPower + programPower
@@ -0,0 +1,31 @@
function newGovernanceFunctionLibraryInfluencerProgram() {
let thisObject = {
calculate: calculate
}
return thisObject
function calculate(
pools,
userProfiles
) {
UI.projects.governance.utilities.decendentProgram.run(
pools,
userProfiles,
"influencerProgram",
"Influencer-Rewards",
"Influencer Program",
"Influencer Power",
"userInfluencerers",
"User Influencerer"
)
UI.projects.governance.utilities.bonusProgram.run(
pools,
userProfiles,
"influencerProgram",
"Influencer-Bonus",
"Influencer Program"
)
}
}
@@ -46,6 +46,16 @@ function newGovernanceFunctionLibraryTokenMining() {
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Influencer Program")
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
calculateProgram(userProfile, program, "influencerProgram")
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Claims Program")
if (program === undefined) { continue }
@@ -93,6 +103,16 @@ function newGovernanceFunctionLibraryTokenMining() {
calculateProgram(userProfile, program, "githubProgram")
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
if (userProfile.tokenPowerSwitch === undefined) { continue }
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Airdrop Program")
if (program === undefined) { continue }
if (program.payload === undefined) { continue }
calculateProgram(userProfile, program, "airdropProgram")
}
for (let i = 0; i < userProfiles.length; i++) {
let userProfile = userProfiles[i]
@@ -46,11 +46,13 @@ function newGovernanceFunctionLibraryTokenPower() {
node.type === 'Referral Program' ||
node.type === 'Mentorship Program' ||
node.type === 'Support Program' ||
node.type === 'Influencer Program' ||
node.type === 'Voting Program' ||
node.type === 'Claims Program' ||
node.type === 'Staking Program' ||
node.type === 'Delegation Program' ||
node.type === 'Github Program'
node.type === 'Github Program' ||
node.type === 'Airdrop Program'
) { return }
/*
We will reset token power of children.
@@ -147,11 +149,13 @@ function newGovernanceFunctionLibraryTokenPower() {
node.type === 'Referral Program' ||
node.type === 'Mentorship Program' ||
node.type === 'Support Program' ||
node.type === 'Influencer Program' ||
node.type === 'Voting Program' ||
node.type === 'Claims Program' ||
node.type === 'Staking Program' ||
node.type === 'Delegation Program' ||
node.type === 'Github Program'
node.type === 'Github Program' ||
node.type === 'Airdrop Program'
) { return }
/*
We will redistribute token power among children.
+10
View File
@@ -1037,6 +1037,11 @@
"propertyName": "supportProgram",
"functionName": "newGovernanceFunctionLibrarySupportProgram"
},
{
"name": "Influencer Program",
"propertyName": "influencerProgram",
"functionName": "newGovernanceFunctionLibraryInfluencerProgram"
},
{
"name": "Mentorship Program",
"propertyName": "mentorshipProgram",
@@ -1056,6 +1061,11 @@
"name": "Github Program",
"propertyName": "githubProgram",
"functionName": "newGovernanceFunctionLibraryGithubProgram"
},
{
"name": "Airdrop Program",
"propertyName": "airdropProgram",
"functionName": "newGovernanceFunctionLibraryAirdropProgram"
}
],
"utilities": [