Governance: Liquidity Program Implemented.
This commit is contained in:
1 parent
a9570d699b
commit
36744390b8
6 files changed
+142
-6
No files matched your search
@@ -11985,17 +11985,17 @@
|
||||
"id": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
|
||||
"savedPayload": {
|
||||
"position": {
|
||||
"x": 37500,
|
||||
"x": 33333.333333333336,
|
||||
"y": 18800
|
||||
},
|
||||
"targetPosition": {
|
||||
"x": 37500,
|
||||
"x": 33333.333333333336,
|
||||
"y": 18800
|
||||
},
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"isCollapsed": true,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"arrangementStyle": 0
|
||||
|
||||
@@ -153,7 +153,7 @@ function newGovernanceFunctionLibraryLiquidityProgram() {
|
||||
function drawProgram(node) {
|
||||
if (node.payload !== undefined) {
|
||||
|
||||
const ownPowerText = parseFloat(node.payload.liquidityProgram.ownPower.toFixed(0)).toLocaleString('en')
|
||||
const ownPowerText = parseFloat(node.payload.liquidityProgram.ownPower.toFixed(2)).toLocaleString('en')
|
||||
const percentageText = parseFloat(node.payload.liquidityProgram.awarded.percentage.toFixed(2)).toLocaleString('en')
|
||||
|
||||
node.payload.uiObject.statusAngleOffset = 0
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
function newGovernanceReportsLiquidity() {
|
||||
let thisObject = {
|
||||
addHTML: addHTML,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function addHTML(tabIndex, filters) {
|
||||
/*
|
||||
Parameters
|
||||
*/
|
||||
let table = 'Liquidity'
|
||||
let programName = 'Liquidity Program'
|
||||
let programPropertyName = 'liquidityProgram'
|
||||
/*
|
||||
Setup Filters
|
||||
*/
|
||||
let filtersObject
|
||||
if (filters !== undefined) {
|
||||
try {
|
||||
filtersObject = JSON.parse(filters)
|
||||
} catch (err) { }
|
||||
}
|
||||
/*
|
||||
Other Variables
|
||||
*/
|
||||
let tableRecords = []
|
||||
let tableRecordDefinition = {
|
||||
"properties": [
|
||||
{
|
||||
"name": "name",
|
||||
"label": "User Profile",
|
||||
"type": "string",
|
||||
"order": "ascending",
|
||||
"textAlign": "left"
|
||||
},
|
||||
{
|
||||
"name": "LiquidityPower",
|
||||
"label": "Liquidity Power",
|
||||
"type": "number",
|
||||
"order": "descending",
|
||||
"textAlign": "center",
|
||||
"format": "2 decimals"
|
||||
},
|
||||
{
|
||||
"name": "Percentage",
|
||||
"label": "Percentage",
|
||||
"type": "number",
|
||||
"order": "descending",
|
||||
"textAlign": "center",
|
||||
"format": "percentage"
|
||||
},
|
||||
{
|
||||
"name": "tokensAwarded",
|
||||
"label": "Awarded",
|
||||
"type": "number",
|
||||
"order": "descending",
|
||||
"textAlign": "center",
|
||||
"format": "2 decimals"
|
||||
}
|
||||
]
|
||||
}
|
||||
/*
|
||||
Here we get from the workspace all User Profiles.
|
||||
*/
|
||||
let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile')
|
||||
/*
|
||||
Transform the result array into table records.
|
||||
*/
|
||||
for (let j = 0; j < userProfiles.length; j++) {
|
||||
let userProfile = userProfiles[j]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, programName)
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
if (program.payload[programPropertyName] === undefined) { continue }
|
||||
|
||||
let tableRecord = {
|
||||
"name": userProfile.name,
|
||||
"LiquidityPower": program.payload[programPropertyName].ownPower,
|
||||
"percentage": program.payload[programPropertyName].awarded.percentage,
|
||||
"tokensAwarded": program.payload[programPropertyName].awarded.tokens | 0
|
||||
}
|
||||
|
||||
if (UI.projects.governance.utilities.filters.applyFilters(filters, filtersObject, tableRecord) === true) {
|
||||
tableRecords.push(tableRecord)
|
||||
}
|
||||
}
|
||||
/*
|
||||
Get the sorting order for this table.
|
||||
*/
|
||||
let sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
|
||||
/*
|
||||
Set the default sorting order for this table.
|
||||
*/
|
||||
if (sortingOrder === undefined) {
|
||||
UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table] = {
|
||||
property: 'tokensAwarded',
|
||||
order: 'descending'
|
||||
}
|
||||
sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
|
||||
}
|
||||
return UI.projects.governance.utilities.tables.addHTML(
|
||||
table,
|
||||
tableRecords,
|
||||
tableRecordDefinition,
|
||||
sortingOrder,
|
||||
tabIndex
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ function newGovernanceReportsReportsPage() {
|
||||
'Claims',
|
||||
'Votes',
|
||||
'Staking',
|
||||
'Liquidity',
|
||||
'Delegation',
|
||||
'Pools',
|
||||
'Assets',
|
||||
@@ -133,6 +134,12 @@ function newGovernanceReportsReportsPage() {
|
||||
resultCounter = response.resultCounter
|
||||
break
|
||||
}
|
||||
case 'Liquidity': {
|
||||
let response = UI.projects.governance.spaces.reportsSpace.liquidity.addHTML(10, filters)
|
||||
HTML = HTML + response.HTML
|
||||
resultCounter = response.resultCounter
|
||||
break
|
||||
}
|
||||
case 'Delegation': {
|
||||
let response = UI.projects.governance.spaces.reportsSpace.delegation.addHTML(11, filters)
|
||||
HTML = HTML + response.HTML
|
||||
|
||||
@@ -15,6 +15,7 @@ function newGobernanceReportsSpace() {
|
||||
claims: undefined,
|
||||
votes: undefined,
|
||||
staking: undefined,
|
||||
liquidity: undefined,
|
||||
delegations: undefined,
|
||||
github: undefined,
|
||||
airdrop: undefined,
|
||||
@@ -91,6 +92,9 @@ function newGobernanceReportsSpace() {
|
||||
thisObject.staking.finalize()
|
||||
thisObject.staking = undefined
|
||||
|
||||
thisObject.liquidity.finalize()
|
||||
thisObject.liquidity = undefined
|
||||
|
||||
thisObject.delegation.finalize()
|
||||
thisObject.delegation = undefined
|
||||
|
||||
@@ -150,6 +154,7 @@ function newGobernanceReportsSpace() {
|
||||
thisObject.claims = newGovernanceReportsClaims()
|
||||
thisObject.votes = newGovernanceReportsVotes()
|
||||
thisObject.staking = newGovernanceReportsStaking()
|
||||
thisObject.liquidity = newGovernanceReportsLiquidity()
|
||||
thisObject.delegation = newGovernanceReportsDelegation()
|
||||
thisObject.github = newGovernanceReportsGithub()
|
||||
thisObject.airdrop = newGovernanceReportsAirdrop()
|
||||
@@ -171,6 +176,7 @@ function newGobernanceReportsSpace() {
|
||||
thisObject.claims.initialize()
|
||||
thisObject.votes.initialize()
|
||||
thisObject.staking.initialize()
|
||||
thisObject.liquidity.initialize()
|
||||
thisObject.delegation.initialize()
|
||||
thisObject.github.initialize()
|
||||
thisObject.airdrop.initialize()
|
||||
|
||||
@@ -135,17 +135,18 @@ function newGovernanceUtilitiesTables() {
|
||||
}
|
||||
}
|
||||
let value = tableRecord[property]
|
||||
if (value === undefined) { value = 0 }
|
||||
switch (format) {
|
||||
case 'text': {
|
||||
|
||||
break
|
||||
}
|
||||
case 'integer': {
|
||||
value = parseFloat(parseFloat(value | 0).toFixed(0)).toLocaleString('en')
|
||||
value = parseFloat(parseFloat(value).toFixed(0)).toLocaleString('en')
|
||||
break
|
||||
}
|
||||
case '2 decimals': {
|
||||
value = parseFloat(parseFloat(value | 0).toFixed(2)).toLocaleString('en')
|
||||
value = parseFloat(parseFloat(value).toFixed(2)).toLocaleString('en')
|
||||
break
|
||||
}
|
||||
case 'percentage': {
|
||||
|
||||
Reference in new issue
Block a user