Skip to content

Commit

Permalink
Merge pull request steemit#3603 from steemit/3595-rename-steem-units
Browse files Browse the repository at this point in the history
Rename steem units to steem satoshi
  • Loading branch information
Michael Vandeberg authored Feb 10, 2020
2 parents 8b49220 + f36d5b0 commit 218cd0b
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class smt_ico_object : public object< smt_ico_object_type, smt_ico_object >
time_point_sec contribution_begin_time;
time_point_sec contribution_end_time;
time_point_sec launch_time;
share_type steem_units_min = -1;
share_type steem_satoshi_min = -1;
uint32_t min_unit_ratio = 0;
uint32_t max_unit_ratio = 0;
asset contributed = asset( 0, STEEM_SYMBOL );
Expand Down Expand Up @@ -217,7 +217,7 @@ class smt_ico_tier_object : public object< smt_ico_tier_object_type, smt_ico_tie

id_type id;
asset_symbol_type symbol;
share_type steem_units_cap = -1;
share_type steem_satoshi_cap = -1;
shared_smt_generation_unit generation_unit;
};

Expand Down Expand Up @@ -379,17 +379,17 @@ typedef multi_index_container <
allocator< smt_ico_object >
> smt_ico_index;

struct by_symbol_steem_units_cap;
struct by_symbol_steem_satoshi_cap;

typedef multi_index_container <
smt_ico_tier_object,
indexed_by <
ordered_unique< tag< by_id >,
member< smt_ico_tier_object, smt_ico_tier_object_id_type, &smt_ico_tier_object::id > >,
ordered_unique< tag< by_symbol_steem_units_cap >,
ordered_unique< tag< by_symbol_steem_satoshi_cap >,
composite_key< smt_ico_tier_object,
member< smt_ico_tier_object, asset_symbol_type, &smt_ico_tier_object::symbol >,
member< smt_ico_tier_object, share_type, &smt_ico_tier_object::steem_units_cap >
member< smt_ico_tier_object, share_type, &smt_ico_tier_object::steem_satoshi_cap >
>,
composite_key_compare< std::less< asset_symbol_type >, std::less< share_type > >
>
Expand Down Expand Up @@ -475,7 +475,7 @@ FC_REFLECT( steem::chain::smt_ico_object,
(contribution_begin_time)
(contribution_end_time)
(launch_time)
(steem_units_min)
(steem_satoshi_min)
(min_unit_ratio)
(max_unit_ratio)
(contributed)
Expand All @@ -489,7 +489,7 @@ FC_REFLECT( steem::chain::shared_smt_generation_unit,
FC_REFLECT( steem::chain::smt_ico_tier_object,
(id)
(symbol)
(steem_units_cap)
(steem_satoshi_cap)
(generation_unit)
)

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/steem/chain/util/smt_token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bool schedule_next_contributor_payout( database& db, const asset_symbol_type& a
bool schedule_founder_payout( database& db, const asset_symbol_type& a );

share_type payout( database& db, const asset_symbol_type& symbol, const account_object& account, const std::vector< contribution_payout >& payouts );
fc::optional< share_type > steem_units_hard_cap( database& db, const asset_symbol_type& a );
fc::optional< share_type > steem_hard_cap( database& db, const asset_symbol_type& a );
std::size_t ico_tier_size( database& db, const asset_symbol_type& symbol );
void remove_ico_objects( database& db, const asset_symbol_type& symbol );

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/required_action_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void smt_ico_evaluation_evaluator::do_apply( const smt_ico_evaluation_action& a
const smt_token_object& token = _db.get< smt_token_object, by_symbol >( a.symbol );
const smt_ico_object& ico = _db.get< smt_ico_object, by_symbol >( token.liquid_symbol );

if ( ico.contributed.amount >= ico.steem_units_min )
if ( ico.contributed.amount >= ico.steem_satoshi_min )
{
_db.modify( token, []( smt_token_object& o )
{
Expand Down
26 changes: 13 additions & 13 deletions libraries/chain/smt_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,18 @@ void smt_setup_evaluator::do_apply( const smt_setup_operation& o )

const smt_token_object& _token = common_pre_setup_evaluation( _db, o.symbol, o.control_account );

if ( o.steem_units_min > 0 )
if ( o.steem_satoshi_min > 0 )
{
auto possible_hard_cap = util::smt::ico::steem_units_hard_cap( _db, o.symbol );
auto possible_hard_cap = util::smt::ico::steem_hard_cap( _db, o.symbol );

FC_ASSERT( possible_hard_cap.valid(),
"An SMT with a Steem Units Minimum of ${s} cannot succeed without an ICO tier.", ("s", o.steem_units_min) );
"An SMT with a Steem Satoshi Minimum of ${s} cannot succeed without an ICO tier.", ("s", o.steem_satoshi_min) );

share_type hard_cap = *possible_hard_cap;

FC_ASSERT( o.steem_units_min <= hard_cap,
"The Steem Units Minimum must be less than the hard cap. Steem Units Minimum: ${s}, Hard Cap: ${c}",
("s", o.steem_units_min)("c", hard_cap) );
FC_ASSERT( o.steem_satoshi_min <= hard_cap,
"The Steem Satoshi Minimum must be less than the hard cap. Steem Satoshi Minimum: ${s}, Hard Cap: ${c}",
("s", o.steem_satoshi_min)("c", hard_cap) );
}

_db.modify( _token, [&]( smt_token_object& token )
Expand All @@ -196,7 +196,7 @@ void smt_setup_evaluator::do_apply( const smt_setup_operation& o )
token_ico_obj.contribution_begin_time = o.contribution_begin_time;
token_ico_obj.contribution_end_time = o.contribution_end_time;
token_ico_obj.launch_time = o.launch_time;
token_ico_obj.steem_units_min = o.steem_units_min;
token_ico_obj.steem_satoshi_min = o.steem_satoshi_min;
token_ico_obj.min_unit_ratio = o.min_unit_ratio;
token_ico_obj.max_unit_ratio = o.max_unit_ratio;
} );
Expand All @@ -219,12 +219,12 @@ void smt_setup_ico_tier_evaluator::do_apply( const smt_setup_ico_tier_operation&

if ( o.remove )
{
auto key = boost::make_tuple( token.liquid_symbol, o.steem_units_cap );
const auto* ito = _db.find< smt_ico_tier_object, by_symbol_steem_units_cap >( key );
auto key = boost::make_tuple( token.liquid_symbol, o.steem_satoshi_cap );
const auto* ito = _db.find< smt_ico_tier_object, by_symbol_steem_satoshi_cap >( key );

FC_ASSERT( ito != nullptr,
"The specified ICO tier does not exist. Symbol: ${s}, Steem Units Cap: ${c}",
("s", token.liquid_symbol)("c", o.steem_units_cap)
"The specified ICO tier does not exist. Symbol: ${s}, Steem Satoshi Cap: ${c}",
("s", token.liquid_symbol)("c", o.steem_satoshi_cap)
);

_db.remove( *ito );
Expand All @@ -241,7 +241,7 @@ void smt_setup_ico_tier_evaluator::do_apply( const smt_setup_ico_tier_operation&
_db.create< smt_ico_tier_object >( [&]( smt_ico_tier_object& ito )
{
ito.symbol = token.liquid_symbol;
ito.steem_units_cap = o.steem_units_cap;
ito.steem_satoshi_cap = o.steem_satoshi_cap;
ito.generation_unit = generation_policy.generation_unit;
});
}
Expand Down Expand Up @@ -385,7 +385,7 @@ void smt_contribute_evaluator::do_apply( const smt_contribute_operation& o )
FC_ASSERT( token->phase >= smt_phase::ico, "SMT has not begun accepting contributions" );
FC_ASSERT( token->phase < smt_phase::ico_completed, "SMT is no longer accepting contributions" );

auto possible_hard_cap = util::smt::ico::steem_units_hard_cap( _db, o.symbol );
auto possible_hard_cap = util::smt::ico::steem_hard_cap( _db, o.symbol );
FC_ASSERT( possible_hard_cap.valid(), "The specified token does not feature an ICO" );
share_type hard_cap = *possible_hard_cap;

Expand Down
26 changes: 13 additions & 13 deletions libraries/chain/util/smt_token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static payout_vars calculate_payout_vars( database& db, const smt_ico_object& ic
{
payout_vars vars;

auto hard_cap = util::smt::ico::steem_units_hard_cap( db, ico.symbol );
auto hard_cap = util::smt::ico::steem_hard_cap( db, ico.symbol );
FC_ASSERT( hard_cap.valid(), "Unable to find ICO hard cap." );
share_type steem_hard_cap = *hard_cap;

Expand Down Expand Up @@ -239,7 +239,7 @@ bool schedule_next_contributor_payout( database& db, const asset_symbol_type& a
payout_action.symbol = itr->symbol;

const auto& ico = db.get< smt_ico_object, by_symbol >( itr->symbol );
const auto& ico_tier_idx = db.get_index< smt_ico_tier_index, by_symbol_steem_units_cap >();
const auto& ico_tier_idx = db.get_index< smt_ico_tier_index, by_symbol_steem_satoshi_cap >();

using generation_unit_share = std::tuple< smt_generation_unit, share_type >;

Expand All @@ -251,8 +251,8 @@ bool schedule_next_contributor_payout( database& db, const asset_symbol_type& a
{
auto tier_contributions = unprocessed_contributions;

if ( ico.processed_contributions + unprocessed_contributions > ico_tier->steem_units_cap )
tier_contributions = ico_tier->steem_units_cap - ico.processed_contributions;
if ( ico.processed_contributions + unprocessed_contributions > ico_tier->steem_satoshi_cap )
tier_contributions = ico_tier->steem_satoshi_cap - ico.processed_contributions;

generation_unit_shares.push_back( std::make_tuple( ico_tier->generation_unit, tier_contributions ) );

Expand Down Expand Up @@ -322,7 +322,7 @@ bool schedule_founder_payout( database& db, const asset_symbol_type& a )
{
bool action_scheduled = false;
const auto& ico = db.get< smt_ico_object, by_symbol >( a );
const auto& ico_tier_idx = db.get_index< smt_ico_tier_index, by_symbol_steem_units_cap >();
const auto& ico_tier_idx = db.get_index< smt_ico_tier_index, by_symbol_steem_satoshi_cap >();

using generation_unit_share = std::tuple< smt_generation_unit, share_type >;

Expand All @@ -334,12 +334,12 @@ bool schedule_founder_payout( database& db, const asset_symbol_type& a )
{
auto tier_contributions = unprocessed_contributions;

if ( ico.contributed.amount > ico_tier->steem_units_cap )
if ( ico.contributed.amount > ico_tier->steem_satoshi_cap )
{
if ( last_ico_tier != ico_tier_idx.end() )
tier_contributions = last_ico_tier->steem_units_cap - ico_tier->steem_units_cap;
tier_contributions = last_ico_tier->steem_satoshi_cap - ico_tier->steem_satoshi_cap;
else
tier_contributions = ico_tier->steem_units_cap;
tier_contributions = ico_tier->steem_satoshi_cap;
}

generation_unit_shares.push_back( std::make_tuple( ico_tier->generation_unit, tier_contributions ) );
Expand Down Expand Up @@ -443,17 +443,17 @@ bool schedule_founder_payout( database& db, const asset_symbol_type& a )
return action_scheduled;
}

fc::optional< share_type > steem_units_hard_cap( database& db, const asset_symbol_type& a )
fc::optional< share_type > steem_hard_cap( database& db, const asset_symbol_type& a )
{
const auto& idx = db.get_index< smt_ico_tier_index, by_symbol_steem_units_cap >();
const auto& idx = db.get_index< smt_ico_tier_index, by_symbol_steem_satoshi_cap >();

const auto range = idx.equal_range( a );

auto itr = range.second;
while ( itr != range.first )
{
--itr;
return itr->steem_units_cap;
return itr->steem_satoshi_cap;
}

return {};
Expand All @@ -463,7 +463,7 @@ void remove_ico_objects( database& db, const asset_symbol_type& symbol )
{
db.remove( db.get< smt_ico_object, by_symbol >( symbol ) );

const auto& ico_tier_idx = db.get_index< smt_ico_tier_index, by_symbol_steem_units_cap >();
const auto& ico_tier_idx = db.get_index< smt_ico_tier_index, by_symbol_steem_satoshi_cap >();
auto itr = ico_tier_idx.lower_bound( symbol );
while( itr != ico_tier_idx.end() && itr->symbol == symbol )
{
Expand All @@ -478,7 +478,7 @@ std::size_t ico_tier_size( database& db, const asset_symbol_type& symbol )
{
std::size_t num_ico_tiers = 0;

const auto& ico_tier_idx = db.get_index< smt_ico_tier_index, by_symbol_steem_units_cap >();
const auto& ico_tier_idx = db.get_index< smt_ico_tier_index, by_symbol_steem_satoshi_cap >();
auto ico_tier_itr = ico_tier_idx.lower_bound( symbol );
while ( ico_tier_itr != ico_tier_idx.end() && ico_tier_itr->symbol == symbol )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ namespace steem { namespace plugins { namespace condenser_api {
contribution_begin_time( op.contribution_begin_time ),
contribution_end_time( op.contribution_end_time ),
launch_time( op.launch_time ),
steem_units_min( op.steem_units_min ),
steem_satoshi_min( op.steem_satoshi_min ),
min_unit_ratio( op.min_unit_ratio ),
max_unit_ratio( op.max_unit_ratio )
{
Expand All @@ -748,7 +748,7 @@ namespace steem { namespace plugins { namespace condenser_api {
op.contribution_begin_time = contribution_begin_time;
op.contribution_end_time = contribution_end_time;
op.launch_time = launch_time;
op.steem_units_min = steem_units_min;
op.steem_satoshi_min = steem_satoshi_min;
op.min_unit_ratio = min_unit_ratio;
op.max_unit_ratio = max_unit_ratio;

Expand All @@ -764,7 +764,7 @@ namespace steem { namespace plugins { namespace condenser_api {
time_point_sec contribution_end_time;
time_point_sec launch_time;

share_type steem_units_min;
share_type steem_satoshi_min;
uint32_t min_unit_ratio = 0;
uint32_t max_unit_ratio = 0;

Expand All @@ -777,7 +777,7 @@ namespace steem { namespace plugins { namespace condenser_api {
legacy_smt_setup_ico_tier_operation( const smt_setup_ico_tier_operation& op ) :
control_account( op.control_account ),
symbol( op.symbol ),
steem_units_cap( op.steem_units_cap ),
steem_satoshi_cap( op.steem_satoshi_cap ),
remove( op.remove )
{
op.generation_policy.visit( convert_to_legacy_static_variant< legacy_smt_generation_policy >( generation_policy ) );
Expand All @@ -788,7 +788,7 @@ namespace steem { namespace plugins { namespace condenser_api {
smt_setup_ico_tier_operation op;
op.control_account = control_account;
op.symbol = symbol;
op.steem_units_cap = steem_units_cap;
op.steem_satoshi_cap = steem_satoshi_cap;
op.generation_policy = generation_policy;
op.remove = remove;

Expand All @@ -798,7 +798,7 @@ namespace steem { namespace plugins { namespace condenser_api {
account_name_type control_account;
asset_symbol_type symbol;

share_type steem_units_cap;
share_type steem_satoshi_cap;
legacy_smt_generation_policy generation_policy;
bool remove = false;
extensions_type extensions;
Expand Down Expand Up @@ -1908,9 +1908,9 @@ FC_REFLECT( steem::plugins::condenser_api::legacy_delegate_vesting_shares_operat
FC_REFLECT( steem::plugins::condenser_api::legacy_author_reward_operation, (author)(permlink)(sbd_payout)(steem_payout)(vesting_payout) )
FC_REFLECT( steem::plugins::condenser_api::legacy_curation_reward_operation, (curator)(reward)(comment_author)(comment_permlink) )
FC_REFLECT( steem::plugins::condenser_api::legacy_comment_reward_operation, (author)(permlink)(payout) )
FC_REFLECT( steem::plugins::condenser_api::legacy_smt_setup_operation, (control_account)(symbol)(max_supply)(contribution_begin_time)(contribution_end_time)(launch_time)(steem_units_min)(min_unit_ratio)(max_unit_ratio)(extensions) )
FC_REFLECT( steem::plugins::condenser_api::legacy_smt_setup_operation, (control_account)(symbol)(max_supply)(contribution_begin_time)(contribution_end_time)(launch_time)(steem_satoshi_min)(min_unit_ratio)(max_unit_ratio)(extensions) )
FC_REFLECT( steem::plugins::condenser_api::legacy_smt_set_setup_parameters_operation, (control_account)(symbol)(setup_parameters)(extensions) )
FC_REFLECT( steem::plugins::condenser_api::legacy_smt_setup_ico_tier_operation, (control_account)(symbol)(steem_units_cap)(generation_policy)(remove)(extensions) )
FC_REFLECT( steem::plugins::condenser_api::legacy_smt_setup_ico_tier_operation, (control_account)(symbol)(steem_satoshi_cap)(generation_policy)(remove)(extensions) )
FC_REFLECT( steem::plugins::condenser_api::legacy_smt_set_runtime_parameters_operation, (control_account)(symbol)(runtime_parameters)(extensions))
FC_REFLECT( steem::plugins::condenser_api::legacy_fill_convert_request_operation, (owner)(requestid)(amount_in)(amount_out) )
FC_REFLECT( steem::plugins::condenser_api::legacy_liquidity_reward_operation, (owner)(payout) )
Expand Down
8 changes: 4 additions & 4 deletions libraries/protocol/include/steem/protocol/smt_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct smt_setup_operation : public base_operation
time_point_sec contribution_end_time;
time_point_sec launch_time;

share_type steem_units_min;
share_type steem_satoshi_min;

uint32_t min_unit_ratio = 0;
uint32_t max_unit_ratio = 0;
Expand All @@ -96,7 +96,7 @@ struct smt_setup_ico_tier_operation : public base_operation
account_name_type control_account;
asset_symbol_type symbol;

share_type steem_units_cap;
share_type steem_satoshi_cap;
smt_generation_policy generation_policy;
bool remove = false;

Expand Down Expand Up @@ -239,7 +239,7 @@ FC_REFLECT(
(contribution_begin_time)
(contribution_end_time)
(launch_time)
(steem_units_min)
(steem_satoshi_min)
(min_unit_ratio)
(max_unit_ratio)
(extensions)
Expand Down Expand Up @@ -267,7 +267,7 @@ FC_REFLECT(
steem::protocol::smt_setup_ico_tier_operation,
(control_account)
(symbol)
(steem_units_cap)
(steem_satoshi_cap)
(generation_policy)
(remove)
(extensions)
Expand Down
6 changes: 3 additions & 3 deletions libraries/protocol/smt_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ void smt_setup_ico_tier_operation::validate()const
{
smt_admin_operation_validate( *this );

FC_ASSERT( steem_units_cap >= 0, "Steem units cap must be greater than or equal to 0" );
FC_ASSERT( steem_units_cap <= STEEM_MAX_SHARE_SUPPLY, "Steem units cap must be less than or equal to ${n}", ("n", STEEM_MAX_SHARE_SUPPLY) );
FC_ASSERT( steem_satoshi_cap >= 0, "Steem satoshi cap must be greater than or equal to 0" );
FC_ASSERT( steem_satoshi_cap <= STEEM_MAX_SHARE_SUPPLY, "Steem satoshi cap must be less than or equal to ${n}", ("n", STEEM_MAX_SHARE_SUPPLY) );

validate_visitor vtor;
generation_policy.visit( vtor );
Expand Down Expand Up @@ -221,7 +221,7 @@ void smt_setup_operation::validate()const
FC_ASSERT( contribution_begin_time > STEEM_GENESIS_TIME, "Contribution begin time must be greater than ${t}", ("t", STEEM_GENESIS_TIME) );
FC_ASSERT( contribution_end_time >= contribution_begin_time, "Contribution end time must be equal to or later than contribution begin time" );
FC_ASSERT( launch_time >= contribution_end_time, "Launch time must be equal to or later than the contribution end time" );
FC_ASSERT( steem_units_min >= 0, "Steem units min must be greater than or equal to 0" );
FC_ASSERT( steem_satoshi_min >= 0, "Steem satoshi minimum must be greater than or equal to 0" );
}

struct smt_set_runtime_parameters_operation_visitor
Expand Down
Loading

0 comments on commit 218cd0b

Please sign in to comment.