Commit 1070972f authored by roadscape's avatar roadscape
Browse files

Merge branch '78-steem-power-apr' of https://github.com/quochuy/wallet into...

Merge branch '78-steem-power-apr' of https://github.com/quochuy/wallet into quochuy-78-steem-power-apr
parents 8bba9856 c1c9ac54
......@@ -30,6 +30,8 @@ module.exports = {
current_reserve_ratio: 200000000,
average_block_size: 15136,
max_virtual_bandwidth: '264241152000000000000',
vesting_reward_percent: 1500,
// @TODO: add other extended fields from https://github.com/steemit/steem/pull/3484/commits/47dc797f59be23a9db8493958748956b8b73750a
},
tag_idx: {
trending: [
......
......@@ -37,6 +37,8 @@ module.exports = {
current_reserve_ratio: 200000000,
average_block_size: 15410,
max_virtual_bandwidth: '264241152000000000000',
vesting_reward_percent: 1500,
// @TODO: add other extended fields from https://github.com/steemit/steem/pull/3484/commits/47dc797f59be23a9db8493958748956b8b73750a
},
current_route: '/',
};
......@@ -83,6 +83,44 @@ 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 vestingRewardPercent = gprops.vesting_reward_percent / 10000;
const virtualSupply = gprops.virtual_supply.split(' ').shift();
const totalVestingFunds = gprops.total_vesting_fund_steem
.split(' ')
.shift();
return (
virtualSupply *
currentInflationRate *
vestingRewardPercent /
totalVestingFunds
);
};
render() {
const {
onShowDepositSteem,
......@@ -503,6 +541,8 @@ class UserWallet extends React.Component {
);
}
const spApr = this.getCurrentApr(gprops);
return (
<div className="UserWallet">
{claimbox}
......@@ -580,6 +620,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 from an estimate APR of %(value)s&#37;, subject to blockchain variance. 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