4 #include <fc/exception/exception.hpp>
5 #include <fc/uint128.hpp>
22 if (!is_founders_pool_exists(ctx))
24 dlog(
"There is no founders supply.");
35 asset founders_supply_rest = distribure_sp_by_percent(ctx, pitiful);
38 distribure_sp_rest(ctx, founders_supply_rest, pitiful);
47 void founders_initializator_impl::check_founders(initializator_context& ctx)
51 uint16_t total_sp_percent = 0u;
52 for (
auto& founder : ctx.genesis_state().founders)
54 FC_ASSERT(!founder.name.empty(),
"Founder 'name' should not be empty.");
58 FC_ASSERT(founder.sp_percent >= 0.f && founder.sp_percent <= 100.f,
59 "Founder 'sp_percent' should be in range [0, 100]. ${1} received.", (
"1", founder.sp_percent));
63 FC_ASSERT(total_sp_percent <= (uint16_t)
SCORUM_100_PERCENT,
"Total 'sp_percent' more then 100%.");
65 FC_ASSERT(total_sp_percent > 0u,
"Total 'sp_percent' less or equal zerro.");
68 asset founders_initializator_impl::distribure_sp_by_percent(initializator_context& ctx,
account_name_type& pitiful)
70 asset founders_supply_rest = ctx.genesis_state().founders_supply;
71 for (
auto& founder : ctx.genesis_state().founders)
75 asset sp_bonus = ctx.genesis_state().founders_supply * utils::make_fraction(percent,
SCORUM_100_PERCENT);
79 feed_account(ctx, founder.name, sp_bonus);
80 founders_supply_rest -= sp_bonus;
82 else if (founder.sp_percent > 0.f)
84 pitiful = founder.name;
87 return founders_supply_rest;
90 void founders_initializator_impl::distribure_sp_rest(initializator_context& ctx,
94 static const float sp_percent_limit_for_pitiful = 0.02f;
96 FC_ASSERT(rest < ctx.genesis_state().founders_supply
98 "Too big rest ${r} for single pitiful. There are many pitiful members in genesis maybe.", (
"r", rest));
100 asset founders_supply_rest = rest;
103 feed_account(ctx, pitiful, founders_supply_rest);
104 founders_supply_rest.amount = 0;
107 FC_ASSERT(!founders_supply_rest.amount.value);
110 void founders_initializator_impl::feed_account(initializator_context& ctx,
114 account_service_i& account_service = ctx.services().account_service();
116 const auto& founder_obj = account_service.
get_account(name);
117 account_service.increase_scorumpower(founder_obj,
sp);
const genesis_state_type & genesis_state() const
#define SCORUM_PERCENT(X)
#define SCORUM_100_PERCENT
fc::fixed_string_16 account_name_type
virtual const account_object & get_account(const account_name_type &) const =0
virtual void check_account_existence(const account_name_type &, const optional< const char * > &context_type_name=optional< const char * >()) const =0
virtual void on_apply(initializator_context &)
std::vector< founder_type > founders
asset_symbol_type symbol() const