30 namespace graphene {
namespace protocol {
40 static const std::locale& loc = std::locale::classic();
44 if( symbol.substr(0,3) ==
"BIT" )
50 if( !isalpha( symbol.front(), loc ) )
53 if( !isalnum( symbol.back(), loc ) )
56 bool dot_already_present =
false;
57 for(
const auto c : symbol )
59 if( (isalpha( c, loc ) && isupper( c, loc )) || isdigit( c, loc ) )
64 if( dot_already_present )
67 dot_already_present =
true;
87 if( sub_asset_creation_fee.
valid() && symbol.find(
'.') != std::string::npos )
89 core_fee_required = *sub_asset_creation_fee;
93 switch( symbol.size() )
95 case 3: core_fee_required = param.
symbol3;
97 case 4: core_fee_required = param.
symbol4;
107 return core_fee_required;
114 common_options.validate();
116 if( 0 != ( common_options.issuer_permissions & NON_UIA_ONLY_ISSUER_PERMISSION_MASK
119 if( is_prediction_market )
121 FC_ASSERT( bitasset_opts.valid(),
"Cannot have a User-Issued Asset implement a prediction market." );
124 FC_ASSERT( !bitasset_opts->extensions.value.black_swan_response_method.valid(),
125 "Can not set black_swan_response_method for Prediction Markets" );
127 if( bitasset_opts ) bitasset_opts->validate();
129 asset dummy =
asset(1) * common_options.core_exchange_rate;
139 new_options.validate();
141 asset dummy =
asset(1, asset_to_update) * new_options.core_exchange_rate;
147 if(
extensions.value.skip_core_exchange_rate.valid() )
150 "If skip_core_exchange_rate is specified, it can only be true" );
172 if( !feed.core_exchange_rate.is_null() )
174 feed.core_exchange_rate.validate();
176 if( (!feed.settlement_price.is_null()) && (!feed.core_exchange_rate.is_null()) )
178 FC_ASSERT( feed.settlement_price.base.asset_id == feed.core_exchange_rate.base.asset_id );
181 FC_ASSERT( !feed.settlement_price.is_null() );
182 FC_ASSERT( !feed.core_exchange_rate.is_null() );
185 if(
extensions.value.initial_collateral_ratio.valid() )
196 FC_ASSERT( amount_to_reserve.amount.value > 0 );
223 new_options.validate();
234 FC_ASSERT( asset_to_settle == settle_price.base.asset_id );
243 if(
extensions.value.margin_call_fee_ratio.valid() )
246 if(
extensions.value.initial_collateral_ratio.valid() )
251 if(
extensions.value.maintenance_collateral_ratio.valid() )
256 if(
extensions.value.maximum_short_squeeze_ratio.valid() )
262 if(
extensions.value.force_settle_fee_percent.valid() )
265 if(
extensions.value.black_swan_response_method.valid() )
267 auto bsrm_count =
static_cast<uint8_t
>( black_swan_response_type::BSRM_TYPE_COUNT );
269 "black_swan_response_method should be less than ${c}", (
"c",bsrm_count) );
281 if(
extensions.value.taker_fee_percent.valid() )
286 FC_ASSERT( 0 == (issuer_permissions & (uint16_t)(~ASSET_ISSUER_PERMISSION_MASK)) );
289 "Can not set global_settle flag, it is for issuer permission only" );
293 core_exchange_rate.validate();
294 FC_ASSERT( core_exchange_rate.base.asset_id.instance.value == 0 ||
295 core_exchange_rate.quote.asset_id.instance.value == 0 );
297 if(!whitelist_authorities.empty() || !blacklist_authorities.empty())
299 for(
auto item : whitelist_markets )
301 FC_ASSERT( blacklist_markets.find(item) == blacklist_markets.end() );
303 for(
auto item : blacklist_markets )
305 FC_ASSERT( whitelist_markets.find(item) == whitelist_markets.end() );
314 FC_ASSERT( 0 == (flags & (uint16_t)(~ASSET_ISSUER_PERMISSION_MASK)),
315 "Can not set an unknown bit in flags" );
316 if( !allow_disable_collateral_bid )
318 "Can not set the 'disable_collateral_bidding' bit in flags between the core-2281 hardfork " 319 "and the BSIP_48_75 hardfork" );
322 "Can not set disable_mcr_update flag, it is for issuer permission only" );
324 "Can not set disable_icr_update flag, it is for issuer permission only" );
326 "Can not set disable_mssr_update flag, it is for issuer permission only" );
328 "Can not set disable_bsrm_update flag, it is for issuer permission only" );
329 if( !is_market_issued )
331 FC_ASSERT( 0 == (flags & (uint16_t)(~UIA_ASSET_ISSUER_PERMISSION_MASK)),
332 "Can not set a flag for bitassets only to UIA" );
338 return ( (issuer_permissions & ASSET_ISSUER_PERMISSION_ENABLE_BITS_MASK)
339 | ((uint16_t)(~issuer_permissions) & ASSET_ISSUER_PERMISSION_DISABLE_BITS_MASK) );
345 if(
extensions.value.claim_from_asset_id.valid() )
353 FC_ASSERT( amount_to_claim.asset_id == asset_id_type());
share_type calculate_fee(const fee_parameters_type &k, const optional< uint64_t > &sub_asset_creation_fee) const
Update the set of feed-producing accounts for a BitAssetBitAssets have price feeds selected by taking...
optional< memo_data > memo
extensions_type extensions
The asset_options struct contains options available on all assets in the network. ...
used to transfer accumulated fees back to the issuer's balance.
Schedules a market-issued asset for automatic settlementHolders of market-issued assests may request ...
the bitasset owner can not update MSSR, permission only
the bitasset owner can not update MCR, permission only
Publish price feeds for market-issued assetsPrice feed providers use this operation to publish their ...
provides stack-based nullable value similar to boost::optional
size_t pack_size(const T &v)
used to take an asset out of circulation, returning to the issuer
void validate_flags(bool is_market_issued, bool allow_disable_collateral_bid=true) const
#define GRAPHENE_MAX_COLLATERAL_RATIO
higher than this is unnecessary and may exceed int16 storage
share_type calculate_fee(const fee_parameters_type &k) const
#define GRAPHENE_100_PERCENT
Update options specific to BitAssetsBitAssets have some options which are not relevant to other asset...
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
share_type calculate_fee(const fee_parameters_type &k) const
the bitasset owner can not update ICR, permission only
#define GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION(type)
account_id_type issuer
Must be asset_to_issue->asset_id->issuer.
Update options common to all assetsThere are a number of options which all assets in the network use...
uint16_t get_enabled_issuer_permissions_mask() const
accounts must be whitelisted in order to hold or transact this asset
Can not bid collateral after a global settlement.
Transfers BTS from the fee pool of a specified asset back to the issuer's balance.
#define GRAPHENE_MIN_COLLATERAL_RATIO
lower than this could result in divide by 0
the bitasset is to be fed by witnesses
allow the bitasset owner to force a global settlement, permission only
static uint64_t calculate_data_fee(uint64_t bytes, uint64_t price_per_kbyte)
constexpr int64_t GRAPHENE_MAX_SHARE_SUPPLY(1000000000000000LL)
#define GRAPHENE_MAX_ASSET_SYMBOL_LENGTH
Update issuer of an assetAn issuer has general administrative power of an asset and in some cases als...
the bitasset is to be fed by the committee
#define GRAPHENE_MIN_ASSET_SYMBOL_LENGTH
the bitasset owner can not update BSRM, permission only
The bitasset_options struct contains configurable options available only to BitAssets.
bool is_valid_symbol(const string &symbol)
allows global settling of bitassets (black swan or prediction markets)