Token Power Improved

This commit is contained in:
Luis Fernando Molina committed 2021-10-24 10:25:46 +02:00
1 parent 86629256ca
commit e8809618d5
5 files changed
+440 -161

No files matched your search

@@ -1064,7 +1064,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"isCollapsed": true,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
@@ -4688,7 +4688,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"isCollapsed": true,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
File diff suppressed because it is too large. Load diff
@@ -4,6 +4,7 @@ function newGovernanceFunctionLibraryTokenPower() {
calculateDelegatedPower: calculateDelegatedPower
}
const OPAQUE_NODES_TYPES = ['Tokens Mined', 'Signing Accounts', 'Onboarding Programs', 'Liquidity Programs']
return thisObject
function calculateTokenPower(
@@ -99,7 +100,7 @@ function newGovernanceFunctionLibraryTokenPower() {
userProfile.payload.uiObject.setErrorMessage(
"You need to have a Token Power Switch child node.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
)
return
}
distributeTokenPower(
@@ -125,7 +126,7 @@ function newGovernanceFunctionLibraryTokenPower() {
userProfile.payload.uiObject.setErrorMessage(
"You need to have a Token Power Switch child node.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
)
return
}
distributeTokenPower(
@@ -186,8 +187,7 @@ function newGovernanceFunctionLibraryTokenPower() {
let childNode = node[property.name]
if (childNode === undefined) { continue }
if (childNode.type === "Delegation Program" && excludeDelegationProgram === true) { continue }
if (childNode.type === "Tokens Mined") { continue }
if (childNode.type === "Signing Accounts") { continue }
if (OPAQUE_NODES_TYPES.includes(childNode.type)) { continue }
let percentage = getPercentage(childNode)
@@ -205,8 +205,7 @@ function newGovernanceFunctionLibraryTokenPower() {
let childNode = propertyArray[m]
if (childNode === undefined) { continue }
if (childNode.type === "Delegation Program" && excludeDelegationProgram === true) { continue }
if (childNode.type === "Tokens Mined") { continue }
if (childNode.type === "Signing Accounts") { continue }
if (OPAQUE_NODES_TYPES.includes(childNode.type)) { continue }
let percentage = getPercentage(childNode)
if (percentage !== undefined && isNaN(percentage) !== true) {
@@ -224,7 +223,7 @@ function newGovernanceFunctionLibraryTokenPower() {
node.payload.uiObject.setErrorMessage(
'Token Power Switching Error. Total Percentage of children nodes is grater that 100.',
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
)
return
}
let defaultPercentage = 0
@@ -242,8 +241,7 @@ function newGovernanceFunctionLibraryTokenPower() {
let childNode = node[property.name]
if (childNode === undefined) { continue }
if (childNode.type === "Delegation Program" && excludeDelegationProgram === true) { continue }
if (childNode.type === "Tokens Mined") { continue }
if (childNode.type === "Signing Accounts") { continue }
if (OPAQUE_NODES_TYPES.includes(childNode.type)) { continue }
let percentage = getPercentage(childNode)
if (percentage === undefined || isNaN(percentage) === true) {
@@ -264,8 +262,7 @@ function newGovernanceFunctionLibraryTokenPower() {
let childNode = propertyArray[m]
if (childNode === undefined) { continue }
if (childNode.type === "Delegation Program" && excludeDelegationProgram === true) { continue }
if (childNode.type === "Tokens Mined") { continue }
if (childNode.type === "Signing Accounts") { continue }
if (OPAQUE_NODES_TYPES.includes(childNode.type)) { continue }
let percentage = getPercentage(childNode)
if (percentage === undefined || isNaN(percentage) === true) {
@@ -316,7 +313,7 @@ function newGovernanceFunctionLibraryTokenPower() {
node.payload.uiObject.percentageAngleOffset = 180
node.payload.uiObject.percentageAtAngle = true
node.payload.uiObject.setPercentage(percentage.toFixed(2),
UI.projects.governance.globals.designer.SET_PERCENTAGE_COUNTER
UI.projects.governance.globals.designer.SET_PERCENTAGE_COUNTER
)
}
}
@@ -378,7 +378,9 @@ function newGovernanceUserProfileSpace() {
}
if (userProfile.payload.blockchainTokens === undefined) {
userProfile.payload.bloackchainBalancesLoading = true
userProfile.payload.bloackchainBalancesLoading = true
UI.projects.foundations.spaces.cockpitSpace.setStatus('Loading blockchain balances for User Profile # ' + (i + 1) + ' / ' + userProfiles.length, 1500, UI.projects.foundations.spaces.cockpitSpace.statusTypes.ALL_GOOD)
getBlockchainAccount(userProfile)
return
}
@@ -428,7 +430,7 @@ function newGovernanceUserProfileSpace() {
blockchainAccount !== "" &&
userProfile.payload.blockchainTokens === undefined
) {
userProfile.payload.liquidityTokens = {
BTCB: 0,
BNB: 0,
@@ -460,7 +462,7 @@ function newGovernanceUserProfileSpace() {
}).then(function (data) {
userProfile.payload.bloackchainBalancesLoading = false
if (data.result === "Max rate limit reached, please use API Key for higher rate limit") {
userProfile.payload.blockchainTokens = undefined
userProfile.payload.blockchainTokens = undefined
} else {
userProfile.payload.uiObject.setInfoMessage('Blockchan Balance Succesfully Loaded.',
UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR
@@ -493,7 +495,7 @@ function newGovernanceUserProfileSpace() {
//console.log(data)
if (data.result === "Max rate limit reached, please use API Key for higher rate limit") {
console.log('[WARN] Rate Limit Reached fetching liquidity tokens for asset ' + asset + ' of user profile ' + userProfile.name)
userProfile.payload.blockchainTokens = undefined
userProfile.payload.blockchainTokens = undefined
} else {
userProfile.payload.uiObject.setInfoMessage('Pancake Balance Succesfully Loaded for asset ' + asset,
UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR