liquidity Balances Laoding Well

This commit is contained in:
Luis Fernando Molina committed 2021-10-23 14:49:22 +02:00
1 parent 815c642304
commit 80920eabb3
9 files changed
+41 -31

No files matched your search

@@ -11653,7 +11653,7 @@
"liquidityPrograms": {
"type": "Liquidity Programs",
"name": "New Liquidity Programs",
"config": "{}",
"config": "{\n \"percentage\": 0\n}",
"project": "Governance",
"liquidityProgram": [
{
@@ -11668,12 +11668,12 @@
"id": "5fd55dc1-69c8-473e-9d3d-b39b58818b07",
"savedPayload": {
"position": {
"x": 38426.01200417474,
"y": 19425.064478540568
"x": 38529.55549577344,
"y": 19215.099048196847
},
"targetPosition": {
"x": 38188.00600208737,
"y": 19242.43604983795
"x": 38239.77774788672,
"y": 19137.45333466609
},
"floatingObject": {
"isPinned": false,
@@ -11691,8 +11691,8 @@
"id": "a081e0a9-ee60-4a56-b5a6-aadb7bd8b052",
"savedPayload": {
"position": {
"x": 38188.00600208737,
"y": 19242.43604983795
"x": 38239.77774788672,
"y": 19137.45333466609
},
"targetPosition": {
"x": 37950,
@@ -11702,7 +11702,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -11757,7 +11757,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -11778,12 +11778,12 @@
"id": "b66c668c-8411-4401-8aa7-10d8b2c4c233",
"savedPayload": {
"position": {
"x": 38028.315715332035,
"y": 19654.674537959618
"x": 37794.708572938485,
"y": 19639.363116908775
},
"targetPosition": {
"x": 37989.15785766602,
"y": 19357.241079547475
"x": 37872.35428646924,
"y": 19349.585369022054
},
"floatingObject": {
"isPinned": false,
@@ -11801,8 +11801,8 @@
"id": "8c213687-2520-41ff-8b89-f5abaf6f2f2e",
"savedPayload": {
"position": {
"x": 37989.15785766602,
"y": 19357.241079547475
"x": 37872.35428646924,
"y": 19349.585369022054
},
"targetPosition": {
"x": 37950,
@@ -11812,7 +11812,7 @@
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -35,7 +35,7 @@
"initialValues": {
"config": "{\n\"asset\": \"BTCB\"\n}" },
"attachingRules": {
"compatibleTypes": "->Financial Programs->"
"compatibleTypes": "->Liquidity Programs->"
},
"addLeftIcons": true,
"level": 1,
@@ -107,7 +107,7 @@ function newGovernanceFunctionLibraryAirdropProgram() {
) {
node.payload.airdropProgram.isActive = false
userProfile.payload.uiObject.setErrorMessage(
"Waiting for blockchain balance. It takes 6 seconds to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
"Waiting for blockchain balance. It takes 1 minute to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
return
@@ -107,7 +107,7 @@ function newGovernanceFunctionLibraryGithubProgram() {
) {
node.payload.githubProgram.isActive = false
userProfile.payload.uiObject.setErrorMessage(
"Waiting for blockchain balance. It takes 6 seconds to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
"Waiting for blockchain balance. It takes 1 minute to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
return
@@ -108,7 +108,7 @@ function newGovernanceFunctionLibraryLiquidityProgram() {
) {
node.payload.liquidityProgram.isActive = false
userProfile.payload.uiObject.setErrorMessage(
"Waiting for liquidity balance. It takes 6 seconds to load the liquidity provided by each profile, bacause you are using a free API provided by BSC Scan.",
"Waiting for liquidity balance. It takes 1 minute to load the liquidity provided by each profile, bacause you are using a free API provided by BSC Scan.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
return
@@ -107,7 +107,7 @@ function newGovernanceFunctionLibraryStakingProgram() {
) {
node.payload.stakingProgram.isActive = false
userProfile.payload.uiObject.setErrorMessage(
"Waiting for blockchain balance. It takes 6 seconds to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
"Waiting for blockchain balance. It takes 1 minute to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
return
@@ -15,7 +15,7 @@ function newGovernanceUserProfileSpace() {
}
let waitingForResponses = 0
const BSC_SCAN_RATE_LIMIT_DELAY = 6000 * 4
const BSC_SCAN_RATE_LIMIT_DELAY = 6000 * 5
let reputationByAddress = new Map()
return thisObject
@@ -373,7 +373,12 @@ function newGovernanceUserProfileSpace() {
let userProfile = userProfiles[i]
if (userProfile.payload === undefined) { continue }
if (userProfile.payload.bloackchainBalancesLoading === true) {
return
}
if (userProfile.payload.blockchainTokens === undefined) {
userProfile.payload.bloackchainBalancesLoading = true
getBlockchainAccount(userProfile)
return
}
@@ -394,6 +399,7 @@ function newGovernanceUserProfileSpace() {
httpRequest(JSON.stringify(request.params), request.url, onResponse)
function onResponse(err, data) {
/* Lets check the result of the call through the http interface */
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
userProfile.payload.uiObject.setErrorMessage(
@@ -422,13 +428,16 @@ function newGovernanceUserProfileSpace() {
blockchainAccount !== "" &&
userProfile.payload.blockchainTokens === undefined
) {
waitingForResponses++
userProfile.payload.liquidityTokens = {
BTCB: 0,
BNB: 0,
BUSD: 0
}
waitingForResponses++
waitingForResponses++
waitingForResponses++
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 4 * 1, userProfile, blockchainAccount, 'BTCB', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BTCB_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 4 * 2, userProfile, blockchainAccount, 'BNB', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BNB_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 4 * 3, userProfile, blockchainAccount, 'BUSD', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BUSD_CONTRACT_ADDRESS)
@@ -437,7 +446,6 @@ function newGovernanceUserProfileSpace() {
Now we get the SA Tokens Balance.
*/
waitingForResponses++
userProfile.payload.blockchainTokens = 0 // We need to set this value here so that the next call to BSCSCAN is not done more than once.
setTimeout(getBlockchainTokens, BSC_SCAN_RATE_LIMIT_DELAY / 4 * 4, userProfile, blockchainAccount)
}
}
@@ -450,14 +458,15 @@ function newGovernanceUserProfileSpace() {
fetch(url).then(function (response) {
return response.json();
}).then(function (data) {
//console.log(data)
userProfile.payload.bloackchainBalancesLoading = false
if (data.result === "Max rate limit reached, please use API Key for higher rate limit") {
userProfile.payload.blockchainTokens = undefined // This enables this profile to query the blockchain again.
userProfile.payload.blockchainTokens = undefined
} else {
userProfile.payload.uiObject.setInfoMessage('Blockchan Balance Succesfully Loaded.',
UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR
)
userProfile.payload.blockchainTokens = Number(data.result) / 1000000000000000000
console.log('[INFO] SA Balance of ' + userProfile.name + ' is ', userProfile.payload.blockchainTokens)
userProfile.payload.reputation = Math.min(reputationByAddress.get(blockchainAccount.toLowerCase()) | 0, userProfile.payload.blockchainTokens)
console.log('[INFO] Reputation of ' + userProfile.name + ' is ', userProfile.payload.reputation)
}
@@ -475,7 +484,7 @@ function newGovernanceUserProfileSpace() {
}
function getBPancakeTokens(userProfile, blockchainAccount, asset, marketContract) {
console.log('[INFO] Loading Pancake Balance for User Profile: ', userProfile.name, 'blockchainAccount: ', blockchainAccount)
console.log('[INFO] Loading Pancake Balance for User Profile: ', userProfile.name, 'blockchainAccount: ', blockchainAccount, 'asset: ', asset)
const url = "https://api.bscscan.com/api?module=account&action=tokenbalance&contractaddress=" + marketContract + "&address=" + blockchainAccount + "&tag=latest&apikey=YourApiKeyToken"
fetch(url).then(function (response) {
@@ -483,9 +492,10 @@ function newGovernanceUserProfileSpace() {
}).then(function (data) {
//console.log(data)
if (data.result === "Max rate limit reached, please use API Key for higher rate limit") {
userProfile.payload.liquidityTokens = undefined // This enables this profile to query the blockchain again.
console.log('[WARN] Rate Limit Reached fetching liquidity tokens for asset ' + asset + ' of user profile ' + userProfile.name)
userProfile.payload.blockchainTokens = undefined
} else {
userProfile.payload.uiObject.setInfoMessage('Pancake Balance Succesfully Loaded.',
userProfile.payload.uiObject.setInfoMessage('Pancake Balance Succesfully Loaded for asset ' + asset,
UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR
)
userProfile.payload.liquidityTokens[asset] = Number(data.result) / 1000000000000000000
@@ -102,7 +102,7 @@ function newGovernanceUtilitiesBonusProgram() {
) {
node.payload[programPropertyName].isActive = false
userProfile.payload.uiObject.setErrorMessage(
"Waiting for blockchain balance. It takes 6 seconds to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
"Waiting for blockchain balance. It takes 1 minute to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
return
@@ -169,7 +169,7 @@ function newGovernanceUtilitiesDecendentProgram() {
) {
node.payload[programPropertyName].isActive = false
userProfile.payload.uiObject.setErrorMessage(
"Waiting for blockchain balance. It takes 6 seconds to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
"Waiting for blockchain balance. It takes 1 minute to load the balance of each profile, bacause you are using a free API provided by BSC Scan.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
return