Commit 1930d7ac authored by Quoc Huy Nguyen Dinh's avatar Quoc Huy Nguyen Dinh
Browse files

Closes #78 - Show stakeholder interest APR on UI

parent 66469e1b
......@@ -83,6 +83,38 @@ class UserWallet extends React.Component {
this.props.claimRewards(account);
};
getCurrentApr = gprops => {
// The inflation was set to 9.5% at block 7m
const initialInflationRate = 9.5;
const initialBlock = 7000000;
// It decreases by 0.01% every 250k blocks
const decreaseRate = 250000;
const decreasePercentPerIncrement = 0.01;
// How many increments have happened since block 7m?
const headBlock = gprops.head_block_number;
const deltaBlocks = headBlock - initialBlock;
const decreaseIncrements = deltaBlocks / decreaseRate;
// Current inflation rate
let currentInflationRate =
initialInflationRate -
decreaseIncrements * decreasePercentPerIncrement;
// Cannot go lower than 0.95%
if (currentInflationRate < 0.95) {
currentInflationRate = 0.95;
}
// Now lets calculate the "APR"
const virtualSupply = gprops.virtual_supply.split(' ').shift();
const totalVestingFunds = gprops.total_vesting_fund_steem
.split(' ')
.shift();
return virtualSupply * currentInflationRate * 0.15 / totalVestingFunds;
};
render() {
const {
onShowDepositSteem,
......@@ -503,6 +535,8 @@ class UserWallet extends React.Component {
);
}
const spApr = this.getCurrentApr(gprops);
return (
<div className="UserWallet">
{claimbox}
......@@ -580,6 +614,11 @@ class UserWallet extends React.Component {
)}
</span>
) : null}
<FormattedHTMLMessage
className="secondary"
id="tips_js.steem_power_apr"
params={{ value: spApr.toFixed(2) }}
/>{' '}
</div>
<div className="column small-12 medium-4">
{isMyAccount ? (
......
......@@ -550,7 +550,9 @@
"converted_VESTING_TOKEN_can_be_sent_to_yourself_but_can_not_transfer_again":
"Converted %(VESTING_TOKEN)s can be sent to yourself or someone else but can not transfer again without converting back to %(LIQUID_TOKEN)s.",
"part_of_your_steem_power_is_currently_delegated":
"Part of %(user_name)s's STEEM POWER is currently delegated. Delegation is donated for influence or to help new users perform actions on steemit. Your delegation amount can fluctuate."
"Part of %(user_name)s's STEEM POWER is currently delegated. Delegation is donated for influence or to help new users perform actions on steemit. Your delegation amount can fluctuate.",
"steem_power_apr":
"By holding STEEM POWER, you currently benefit of an APR of approximately %(value)s&#37;. For more information about STEEM economics, check the <a href=\"http://localhost/faq.html#How_many_new_tokens_are_generated_by_the_blockchain\">FAQ</a>"
},
"promote_post_jsx": {
"promote_post": "Promote Post",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment