Cherry-picked commit 26f4718.

Creating default dividend asset
This commit is contained in:
Roman Olearski 2016-11-07 10:18:18 +01:00
parent da5ef56a35
commit dac9d8b61b
4 changed files with 61 additions and 0 deletions

View file

@ -372,6 +372,16 @@ void database::init_genesis(const genesis_state_type& genesis_state)
a.network_fee_percentage = 0; a.network_fee_percentage = 0;
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT; a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT;
}).get_id() == GRAPHENE_PROXY_TO_SELF_ACCOUNT); }).get_id() == GRAPHENE_PROXY_TO_SELF_ACCOUNT);
FC_ASSERT(create<account_object>([this](account_object& a) {
a.name = "default-dividend-distribution";
a.statistics = create<account_statistics_object>([&](account_statistics_object& s){s.owner = a.id;}).id;
a.owner.weight_threshold = 1;
a.active.weight_threshold = 1;
a.registrar = a.lifetime_referrer = a.referrer = GRAPHENE_PROXY_TO_SELF_ACCOUNT;
a.membership_expiration_date = time_point_sec::maximum();
a.network_fee_percentage = 0;
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT;
}).get_id() == TOURNAMENT_RAKE_FEE_ACCOUNT_ID);
// Create more special accounts // Create more special accounts
while( true ) while( true )
@ -414,6 +424,46 @@ void database::init_genesis(const genesis_state_type& genesis_state)
}); });
assert( asset_id_type(core_asset.id) == asset().asset_id ); assert( asset_id_type(core_asset.id) == asset().asset_id );
assert( get_balance(account_id_type(), asset_id_type()) == asset(dyn_asset.current_supply) ); assert( get_balance(account_id_type(), asset_id_type()) == asset(dyn_asset.current_supply) );
// Create default dividend asset
const asset_dynamic_data_object& dyn_asset1 =
create<asset_dynamic_data_object>([&](asset_dynamic_data_object& a) {
a.current_supply = GRAPHENE_MAX_SHARE_SUPPLY;
});
const asset_dividend_data_object& div_asset1 =
create<asset_dividend_data_object>([&](asset_dividend_data_object& a) {
a.options.minimum_distribution_interval = 3*24*60*60;
a.options.minimum_fee_percentage = 10*GRAPHENE_1_PERCENT;
a.options.next_payout_time = genesis_state.initial_timestamp + fc::hours(1);
a.options.payout_interval = 7*24*60*60;
a.dividend_distribution_account = TOURNAMENT_RAKE_FEE_ACCOUNT_ID;
});
const asset_bitasset_data_object& bit_asset1 =
create<asset_bitasset_data_object>([&](asset_bitasset_data_object& a) {
a.current_feed.maintenance_collateral_ratio = 1750;
a.current_feed.maximum_short_squeeze_ratio = 1500;
a.current_feed_publication_time = genesis_state.initial_timestamp + fc::hours(1);
});
const asset_object& default_asset =
create<asset_object>( [&]( asset_object& a ) {
a.symbol = "DEF";
a.options.max_market_fee =
a.options.max_supply = genesis_state.max_core_supply;
a.precision = GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS;
a.options.flags = 0;
a.options.issuer_permissions = 79;
a.issuer = TOURNAMENT_RAKE_FEE_ACCOUNT_ID;
a.options.core_exchange_rate.base.amount = 1;
a.options.core_exchange_rate.base.asset_id = asset_id_type(0);
a.options.core_exchange_rate.quote.amount = 1;
a.options.core_exchange_rate.quote.asset_id = asset_id_type(1);
a.dynamic_asset_data_id = dyn_asset1.id;
a.dividend_data_id = div_asset1.id;
a.bitasset_data_id = bit_asset1.id;
});
assert( default_asset.id == asset_id_type(1) );
// Create more special assets // Create more special assets
while( true ) while( true )
{ {
@ -503,6 +553,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
const auto& accounts_by_name = get_index_type<account_index>().indices().get<by_name>(); const auto& accounts_by_name = get_index_type<account_index>().indices().get<by_name>();
auto get_account_id = [&accounts_by_name](const string& name) { auto get_account_id = [&accounts_by_name](const string& name) {
auto itr = accounts_by_name.find(name); auto itr = accounts_by_name.find(name);
if (itr == accounts_by_name.end()) return GRAPHENE_NULL_ACCOUNT;
FC_ASSERT(itr != accounts_by_name.end(), FC_ASSERT(itr != accounts_by_name.end(),
"Unable to find account '${acct}'. Did you forget to add a record for it to initial_accounts?", "Unable to find account '${acct}'. Did you forget to add a record for it to initial_accounts?",
("acct", name)); ("acct", name));
@ -635,6 +686,8 @@ void database::init_genesis(const genesis_state_type& genesis_state)
{ {
total_supplies[ asset_id_type(0) ] = GRAPHENE_MAX_SHARE_SUPPLY; total_supplies[ asset_id_type(0) ] = GRAPHENE_MAX_SHARE_SUPPLY;
} }
total_debts[ asset_id_type(1) ] =
total_supplies[ asset_id_type(1) ] = 0;
const auto& idx = get_index_type<asset_index>().indices().get<by_symbol>(); const auto& idx = get_index_type<asset_index>().indices().get<by_symbol>();
auto it = idx.begin(); auto it = idx.begin();
@ -654,6 +707,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
elog( "Genesis for asset ${aname} is not balanced\n" elog( "Genesis for asset ${aname} is not balanced\n"
" Debt is ${debt}\n" " Debt is ${debt}\n"
" Supply is ${supply}\n", " Supply is ${supply}\n",
("aname", debt_itr->first)
("debt", debt_itr->second) ("debt", debt_itr->second)
("supply", supply_itr->second) ("supply", supply_itr->second)
); );

View file

@ -354,6 +354,8 @@ FC_REFLECT_DERIVED( graphene::chain::asset_dividend_data_object, (graphene::db::
(options) (options)
(last_scheduled_payout_time) (last_scheduled_payout_time)
(last_payout_time ) (last_payout_time )
(last_scheduled_distribution_time)
(last_distribution_time)
(dividend_distribution_account) (dividend_distribution_account)
) )
@ -371,4 +373,5 @@ FC_REFLECT_DERIVED( graphene::chain::asset_object, (graphene::db::object),
(dynamic_asset_data_id) (dynamic_asset_data_id)
(bitasset_data_id) (bitasset_data_id)
(buyback_account) (buyback_account)
(dividend_data_id)
) )

View file

@ -164,6 +164,8 @@
#define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4)) #define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4))
/// Represents the canonical account for specifying you will vote directly (as opposed to a proxy) /// Represents the canonical account for specifying you will vote directly (as opposed to a proxy)
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5)) #define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5))
///
#define TOURNAMENT_RAKE_FEE_ACCOUNT_ID (graphene::chain::account_id_type(6))
/// Sentinel value used in the scheduler. /// Sentinel value used in the scheduler.
#define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0)) #define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0))
///@} ///@}

View file

@ -595,6 +595,8 @@ FC_REFLECT( graphene::chain::asset_options,
FC_REFLECT( graphene::chain::dividend_asset_options, FC_REFLECT( graphene::chain::dividend_asset_options,
(next_payout_time) (next_payout_time)
(payout_interval) (payout_interval)
(minimum_fee_percentage)
(minimum_distribution_interval)
(extensions) (extensions)
) )