integrating powering down amounts

This commit is contained in:
Nouman Tahir 2022-03-23 19:57:37 +05:00
parent 9753f06f65
commit 7f0dd8b017
2 changed files with 21 additions and 5 deletions

View File

@ -51,6 +51,7 @@
"estimated_value": "Estimated value",
"vote_value": "Vote value",
"delegated_hive_power":"Delegated hive power",
"powering_down_hive_power":"Powering down",
"received_hive_power":"Received hive power",
"total_hive_power":"Total hive power",
"savings": "Savings",

View File

@ -572,6 +572,18 @@ export const fetchCoinsData = async ({
`${_getBalanceStr(parseToken(userdata.reward_vesting_hive), ' HP', ' | ')}`
).trim();
//calculate power down
const isPoweringDown = userdata.next_vesting_withdrawal
? parseDate(userdata.next_vesting_withdrawal) > new Date()
: false;
const nextVestingSharesWithdrawal = isPoweringDown
? Math.min(
parseAsset(userdata.vesting_withdraw_rate).amount,
(Number(userdata.to_withdraw) - Number(userdata.withdrawn)) / 1e6
) : 0;
const nextVestingSharesWithdrawalHive = isPoweringDown ? vestsToHp(nextVestingSharesWithdrawal, hivePerMVests) : 0;
//TODO: assess how we can make this value change live.
const estimateVoteValueStr = '$ ' + getEstimatedAmount(userdata, globalProps);
@ -589,10 +601,13 @@ export const fetchCoinsData = async ({
value: `- ${delegatedHP.toFixed(3)} HP`
}, {
labelId: 'received_hive_power',
value: `${receivedHP.toFixed(3)} HP`
value: `+ ${receivedHP.toFixed(3)} HP`
}, {
labelId: 'powering_down_hive_power',
value: `- ${nextVestingSharesWithdrawalHive.toFixed(3)} HP`
}, {
labelId: 'total_hive_power',
value: `${(balance - delegatedHP + receivedHP).toFixed(3)} HP`
value: `${(balance - delegatedHP + receivedHP - nextVestingSharesWithdrawalHive).toFixed(3)} HP`
}, {
labelId: 'vote_value',
value: estimateVoteValueStr