mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-02 11:15:35 +03:00
commit
f89fa6925d
@ -1671,4 +1671,12 @@ const getActiveKey = (local, pin) => {
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export const votingPower = (account) => {
|
||||
// @ts-ignore "Account" is compatible with dhive's "ExtendedAccount"
|
||||
const calc = client.rc.calculateVPMana(account);
|
||||
const { percentage } = calc;
|
||||
|
||||
return percentage / 100;
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
@ -1,20 +1,23 @@
|
||||
import parseToken from './parseToken';
|
||||
import { GlobalProps } from '../redux/reducers/accountReducer';
|
||||
import { votingPower } from '../providers/hive/dhive';
|
||||
|
||||
export const getEstimatedAmount = (account, globalProps:GlobalProps, sliderValue:number = 1) => {
|
||||
|
||||
const { fundRecentClaims, fundRewardBalance, base, quote } = globalProps;
|
||||
const votingPower:number = account.voting_power;
|
||||
const _votingPower:number = Number((100 * votingPower(account)).toFixed(0));
|
||||
/*
|
||||
const vestingShares = parseToken(account.vesting_shares);
|
||||
const receievedVestingShares = parseToken(account.received_vesting_shares);
|
||||
const delegatedVestingShared = parseToken(account.delegated_vesting_shares);
|
||||
const totalVests = vestingShares + receievedVestingShares - delegatedVestingShared;
|
||||
*/
|
||||
const vestingShares = parseToken(account.post_voting_power);
|
||||
const totalVests = vestingShares;
|
||||
const weight = sliderValue * 10000;
|
||||
const hbdMedian = base / quote;
|
||||
|
||||
const totalVests = vestingShares + receievedVestingShares - delegatedVestingShared;
|
||||
|
||||
const voteEffectiveShares = calculateVoteRshares(totalVests, votingPower, weight)
|
||||
const voteValue = (voteEffectiveShares / fundRecentClaims) * fundRewardBalance * hbdMedian;
|
||||
const voteEffectiveShares = calculateVoteRshares(totalVests, _votingPower, weight)
|
||||
const voteValue = (voteEffectiveShares / fundRecentClaims) * fundRewardBalance * hbdMedian / 4;
|
||||
const estimatedAmount = weight < 0 ? Math.min(voteValue * -1, 0) : Math.max(voteValue, 0)
|
||||
|
||||
return Number.isNaN(estimatedAmount) ? '0.00000' : estimatedAmount.toFixed(5);
|
||||
|
Loading…
Reference in New Issue
Block a user