23 : _dprops_service(services.dynamic_global_property_service())
24 , _withdraw_scorumpower_service(services.withdraw_scorumpower_service())
25 , _lock_withdraw_sp_until_timestamp(services.genesis_state_service().get_lock_withdraw_sp_until_timestamp())
29 template <
typename FromObjectType>
void do_apply(
const FromObjectType& from_object,
const asset& scorumpower)
31 FC_ASSERT(_dprops_service.
head_block_time() > _lock_withdraw_sp_until_timestamp,
32 "Withdraw scorumpower operation is locked until ${t}.", (
"t", _lock_withdraw_sp_until_timestamp));
33 FC_ASSERT(scorumpower.
amount >= 0);
36 if (_withdraw_scorumpower_service.
is_exists(from_object.id))
41 if (scorumpower.
amount == 0)
43 FC_ASSERT(vesting_withdraw_rate.
amount != 0,
"This operation would not change the vesting withdraw rate.");
53 if (new_vesting_withdraw_rate.amount == 0)
54 new_vesting_withdraw_rate.amount = 1;
57 wv.from_id = from_object.id;
58 wv.vesting_withdraw_rate = new_vesting_withdraw_rate;
59 wv.next_vesting_withdrawal
61 wv.to_withdraw = scorumpower;
65 if (!_withdraw_scorumpower_service.
is_exists(from_object.id))
67 _withdraw_scorumpower_service.
create(lmbNewVesting);
72 _withdraw_scorumpower_service.
update(wv, lmbNewVesting);
79 if (_withdraw_scorumpower_service.
is_exists(from_object.id))
82 _withdraw_scorumpower_service.
remove(wv);
89 const fc::time_point_sec _lock_withdraw_sp_until_timestamp;
97 , _account_service(db().account_service())
98 , _dprops_service(db().dynamic_global_property_service())
111 "Account does not have sufficient Scorum Power for withdraw.");
112 FC_ASSERT(account.scorumpower - account.delegated_scorumpower >= o.
scorumpower,
113 "Account does not have sufficient Scorum Power for withdraw.");
115 if (!account.created_by_genesis)
117 const auto& dprops = _dprops_service.
get();
118 asset min_scorumpower =
asset(dprops.median_chain_props.account_creation_fee.amount,
SP_SYMBOL);
122 "Account registered by another account requires 10x account creation fee worth of Scorum Power "
123 "before it can be powered down.");
132 : _services(services)
133 , _scorumpower(scorumpower)
143 const auto& pool = dev_pool_service.
get();
145 FC_ASSERT(pool.sp_balance >= ctx.
scorumpower(),
"Dev pool does not have sufficient Scorum Power for withdraw.");
data_service_factory_i & services() const
const asset & scorumpower() const
withdraw_scorumpower_context(data_service_factory_i &services, const asset &scorumpower)
void on_apply(withdraw_scorumpower_context &ctx)
~withdraw_scorumpower_evaluator()
void do_apply(const operation_type &op)
withdraw_scorumpower_evaluator(data_service_factory_i &services)
void remove_withdraw_scorumpower(const FromObjectType &from_object)
withdraw_scorumpower_impl(data_service_factory_i &services)
void do_apply(const FromObjectType &from_object, const asset &scorumpower)
asset vesting_withdraw_rate
at the time this is updated it can be at most scorumpower/104
#define SCORUM_START_WITHDRAW_COEFFICIENT
#define SCORUM_VESTING_WITHDRAW_INTERVALS
#define SCORUM_VESTING_WITHDRAW_INTERVAL_SECONDS
virtual const account_object & get_account(const account_name_type &) const =0
virtual void update(const modifier_type &modifier)=0
virtual const object_type & get() const =0
virtual const object_type & create(const modifier_type &modifier)=0
virtual fc::time_point_sec head_block_time() const =0
virtual const withdraw_scorumpower_object & get(const account_id_type &from) const =0
virtual bool is_exists(const account_id_type &from) const =0
account_name_type account