Skip to content

Commit

Permalink
Merge branch '20190522-sps-inflation' into 3328-adjust-reward-fund
Browse files Browse the repository at this point in the history
  • Loading branch information
sgerbino committed Jun 5, 2019
2 parents 004670c + a19350e commit 3b21cb3
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 10 deletions.
21 changes: 17 additions & 4 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,7 @@ void database::process_funds()
{
const auto& props = get_dynamic_global_properties();
const auto& wso = get_witness_schedule_object();
const auto& feed = get_feed_history();

if( has_hardfork( STEEM_HARDFORK_0_16__551) )
{
Expand All @@ -2170,11 +2171,12 @@ void database::process_funds()
int64_t current_inflation_rate = std::max( start_inflation_rate - inflation_rate_adjustment, inflation_rate_floor );

auto new_steem = ( props.virtual_supply.amount * current_inflation_rate ) / ( int64_t( STEEM_100_PERCENT ) * int64_t( STEEM_BLOCKS_PER_YEAR ) );
auto content_reward = ( new_steem * STEEM_CONTENT_REWARD_PERCENT ) / STEEM_100_PERCENT;
auto content_reward = ( new_steem * props.content_reward_percent ) / STEEM_100_PERCENT;
if( has_hardfork( STEEM_HARDFORK_0_17__774 ) )
content_reward = pay_reward_funds( content_reward ); /// 75% to content creator
auto vesting_reward = ( new_steem * STEEM_VESTING_FUND_PERCENT ) / STEEM_100_PERCENT; /// 15% to vesting fund
auto witness_reward = new_steem - content_reward - vesting_reward; /// Remaining 10% to witness pay
content_reward = pay_reward_funds( content_reward );
auto vesting_reward = ( new_steem * props.vesting_reward_percent ) / STEEM_100_PERCENT;
auto sps_fund = ( new_steem * props.sps_fund_percent ) / STEEM_100_PERCENT;
auto witness_reward = new_steem - content_reward - vesting_reward;

const auto& cwit = get_witness( props.current_witness );
witness_reward *= STEEM_MAX_WITNESSES;
Expand All @@ -2190,6 +2192,14 @@ void database::process_funds()

witness_reward /= wso.witness_pay_normalization_factor;

auto new_sbd = asset( 0, SBD_SYMBOL );

if( sps_fund.value )
{
new_sbd = asset( sps_fund, STEEM_SYMBOL ) * feed.current_median_history;
adjust_balance( STEEM_TREASURY_ACCOUNT, new_sbd );
}

new_steem = content_reward + vesting_reward + witness_reward;

modify( props, [&]( dynamic_global_property_object& p )
Expand All @@ -2198,6 +2208,7 @@ void database::process_funds()
if( !has_hardfork( STEEM_HARDFORK_0_17__774 ) )
p.total_reward_fund_steem += asset( content_reward, STEEM_SYMBOL );
p.current_supply += asset( new_steem, STEEM_SYMBOL );
p.current_sbd_supply += new_sbd;
p.virtual_supply += asset( new_steem, STEEM_SYMBOL );
});

Expand Down Expand Up @@ -5199,6 +5210,8 @@ void database::apply_hardfork( uint32_t hardfork )
modify( get_dynamic_global_properties(), [&]( dynamic_global_property_object& gpo )
{
gpo.sbd_stop_adjust = STEEM_SBD_STOP_ADJUST;
gpo.sps_fund_percent = STEEM_PROPOSAL_FUND_PERCENT_HF21;
gpo.content_reward_percent = STEEM_CONTENT_REWARD_PERCENT_HF21;
});

auto account_auth = find< account_authority_object, by_account >( STEEM_TREASURY_ACCOUNT );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ namespace steem { namespace chain {
time_point_sec next_maintenance_time;
time_point_sec last_budget_time;

uint16_t content_reward_percent = STEEM_CONTENT_REWARD_PERCENT_HF16;
uint16_t vesting_reward_percent = STEEM_VESTING_FUND_PERCENT_HF16;
uint16_t sps_fund_percent = STEEM_PROPOSAL_FUND_PERCENT_HF0;

#ifdef STEEM_ENABLE_SMT
asset smt_creation_fee = asset( 1000, SBD_SYMBOL );
#endif
Expand Down Expand Up @@ -201,6 +205,9 @@ FC_REFLECT( steem::chain::dynamic_global_property_object,
(sbd_stop_adjust)
(next_maintenance_time)
(last_budget_time)
(content_reward_percent)
(vesting_reward_percent)
(sps_fund_percent)
#ifdef STEEM_ENABLE_SMT
(smt_creation_fee)
#endif
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/util/sps_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ void sps_processor::transfer_daily_inflation_to_treasury( const asset& daily_inf
{
const auto& treasury_account = db.get_account( STEEM_TREASURY_ACCOUNT );
db.adjust_balance( treasury_account, daily_inflation );
operation vop = sps_fund_operation( daily_inflation );
db.push_virtual_operation( vop );
}
#endif
}
Expand Down
3 changes: 2 additions & 1 deletion libraries/plugins/rc/resource_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ struct count_operation_visitor
void operator()( const comment_benefactor_reward_operation& ) const {}
void operator()( const producer_reward_operation& ) const {}
void operator()( const clear_null_account_balance_operation& ) const {}
void operator()(const proposal_pay_operation&) const {}
void operator()( const proposal_pay_operation& ) const {}
void operator()( const sps_fund_operation& ) const {}

// Optional Actions
#ifdef IS_TEST_NET
Expand Down
7 changes: 5 additions & 2 deletions libraries/protocol/get_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ fc::variant_object get_config()
result["STEEM_COMMENT_TITLE_LIMIT"] = STEEM_COMMENT_TITLE_LIMIT;
result["STEEM_CONTENT_APR_PERCENT"] = STEEM_CONTENT_APR_PERCENT;
result["STEEM_CONTENT_CONSTANT_HF0"] = STEEM_CONTENT_CONSTANT_HF0;
result["STEEM_CONTENT_REWARD_PERCENT"] = STEEM_CONTENT_REWARD_PERCENT;
result["STEEM_CONTENT_REWARD_PERCENT_HF16"] = STEEM_CONTENT_REWARD_PERCENT_HF16;
result["STEEM_CONTENT_REWARD_PERCENT_HF21"] = STEEM_CONTENT_REWARD_PERCENT_HF21;
result["STEEM_CONVERSION_DELAY"] = STEEM_CONVERSION_DELAY;
result["STEEM_CONVERSION_DELAY_PRE_HF_16"] = STEEM_CONVERSION_DELAY_PRE_HF_16;
result["STEEM_CREATE_ACCOUNT_DELEGATION_RATIO"] = STEEM_CREATE_ACCOUNT_DELEGATION_RATIO;
Expand Down Expand Up @@ -175,6 +176,8 @@ fc::variant_object get_config()
result["STEEM_PROXY_TO_SELF_ACCOUNT"] = STEEM_PROXY_TO_SELF_ACCOUNT;
result["STEEM_SBD_INTEREST_COMPOUND_INTERVAL_SEC"] = STEEM_SBD_INTEREST_COMPOUND_INTERVAL_SEC;
result["STEEM_SECONDS_PER_YEAR"] = STEEM_SECONDS_PER_YEAR;
result["STEEM_PROPOSAL_FUND_PERCENT_HF0"] = STEEM_PROPOSAL_FUND_PERCENT_HF0;
result["STEEM_PROPOSAL_FUND_PERCENT_HF21"] = STEEM_PROPOSAL_FUND_PERCENT_HF21;
result["STEEM_RECENT_RSHARES_DECAY_TIME_HF19"] = STEEM_RECENT_RSHARES_DECAY_TIME_HF19;
result["STEEM_RECENT_RSHARES_DECAY_TIME_HF17"] = STEEM_RECENT_RSHARES_DECAY_TIME_HF17;
result["STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF6"] = STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF6;
Expand All @@ -195,7 +198,7 @@ fc::variant_object get_config()
result["STEEM_UPVOTE_LOCKOUT_HF7"] = STEEM_UPVOTE_LOCKOUT_HF7;
result["STEEM_UPVOTE_LOCKOUT_HF17"] = STEEM_UPVOTE_LOCKOUT_HF17;
result["STEEM_UPVOTE_LOCKOUT_SECONDS"] = STEEM_UPVOTE_LOCKOUT_SECONDS;
result["STEEM_VESTING_FUND_PERCENT"] = STEEM_VESTING_FUND_PERCENT;
result["STEEM_VESTING_FUND_PERCENT_HF16"] = STEEM_VESTING_FUND_PERCENT_HF16;
result["STEEM_VESTING_WITHDRAW_INTERVALS"] = STEEM_VESTING_WITHDRAW_INTERVALS;
result["STEEM_VESTING_WITHDRAW_INTERVALS_PRE_HF_16"] = STEEM_VESTING_WITHDRAW_INTERVALS_PRE_HF_16;
result["STEEM_VESTING_WITHDRAW_INTERVAL_SECONDS"] = STEEM_VESTING_WITHDRAW_INTERVAL_SECONDS;
Expand Down
8 changes: 6 additions & 2 deletions libraries/protocol/include/steem/protocol/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@
#define STEEM_INFLATION_RATE_START_PERCENT (978) // Fixes block 7,000,000 to 9.5%
#define STEEM_INFLATION_RATE_STOP_PERCENT (95) // 0.95%
#define STEEM_INFLATION_NARROWING_PERIOD (250000) // Narrow 0.01% every 250k blocks
#define STEEM_CONTENT_REWARD_PERCENT (75*STEEM_1_PERCENT) //75% of inflation, 7.125% inflation
#define STEEM_VESTING_FUND_PERCENT (15*STEEM_1_PERCENT) //15% of inflation, 1.425% inflation
#define STEEM_CONTENT_REWARD_PERCENT_HF16 (75*STEEM_1_PERCENT) //75% of inflation, 7.125% inflation
#define STEEM_VESTING_FUND_PERCENT_HF16 (15*STEEM_1_PERCENT) //15% of inflation, 1.425% inflation
#define STEEM_PROPOSAL_FUND_PERCENT_HF0 (0)

#define STEEM_CONTENT_REWARD_PERCENT_HF21 (65*STEEM_1_PERCENT)
#define STEEM_PROPOSAL_FUND_PERCENT_HF21 (10*STEEM_1_PERCENT)

#define STEEM_MINER_PAY_PERCENT (STEEM_1_PERCENT) // 1%
#define STEEM_MAX_RATION_DECAY_RATE (1000000)
Expand Down
3 changes: 2 additions & 1 deletion libraries/protocol/include/steem/protocol/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ namespace steem { namespace protocol {
comment_benefactor_reward_operation,
producer_reward_operation,
clear_null_account_balance_operation,
proposal_pay_operation
proposal_pay_operation,
sps_fund_operation
> operation;

/*void operation_get_required_authorities( const operation& op,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ namespace steem { namespace protocol {
vector< asset > total_cleared;
};

struct sps_fund_operation : public virtual_operation
{
sps_fund_operation() {}
sps_fund_operation( const asset& v ) : additional_funds( v ) {}

asset additional_funds;
};

} } //steem::protocol

FC_REFLECT( steem::protocol::author_reward_operation, (author)(permlink)(sbd_payout)(steem_payout)(vesting_payout) )
Expand All @@ -201,3 +209,4 @@ FC_REFLECT( steem::protocol::return_vesting_delegation_operation, (account)(vest
FC_REFLECT( steem::protocol::comment_benefactor_reward_operation, (benefactor)(author)(permlink)(sbd_payout)(steem_payout)(vesting_payout) )
FC_REFLECT( steem::protocol::producer_reward_operation, (producer)(vesting_shares) )
FC_REFLECT( steem::protocol::clear_null_account_balance_operation, (total_cleared) )
FC_REFLECT( steem::protocol::sps_fund_operation, (additional_funds) )

0 comments on commit 3b21cb3

Please sign in to comment.