29 #include <boost/multi_index/composite_key.hpp> 41 namespace graphene {
namespace chain {
42 class asset_bitasset_data_object;
57 implementation_ids, impl_asset_dynamic_data_object_type>
117 asset amount_from_string(
string amount_string)
const;
119 string amount_to_string(
share_type amount)
const;
125 {
return amount_to_string(amount) +
" " + symbol; }
133 uint8_t precision = 0;
150 uint32_t creation_block_num = 0;
157 if( !is_market_issued() )
169 "Asset ${a} (${id}) is not a market issued asset.",
170 (
"a",this->symbol)(
"id",this->
id) );
171 return db.get( *bitasset_data_id );
176 {
return db.get(dynamic_asset_data_id); }
183 {
return options.
max_supply - dynamic_data(db).current_supply; }
189 ( is_market_issued() && fee.
asset_id == bitasset_data(db).options.short_backing_asset ));
203 if (fee.
amount == 0)
return;
205 const auto& dyn_data = dynamic_asset_data_id(db);
212 "Asset ${a} (${id}) cannot accept fee of asset (${fid}).",
213 (
"a",this->symbol)(
"id",this->
id)(
"fid",fee.
asset_id) );
214 const auto & bad = bitasset_data(db);
216 "Asset ${a} (${id}) cannot accept fee of asset (${fid}).",
217 (
"a",this->symbol)(
"id",this->id)(
"fid",fee.
asset_id) );
237 :
price_feed(), initial_collateral_ratio( maintenance_collateral_ratio )
246 price get_initial_collateralization()
const;
256 implementation_ids, impl_asset_bitasset_data_object_type>
268 flat_map<account_id_type, pair<time_point_sec,price_feed_with_icr>>
feeds;
291 bool is_prediction_market =
false;
306 price settlement_price;
329 return asset( individual_settlement_debt, asset_id )
358 bool asset_cer_updated =
false;
361 bool feed_cer_updated =
false;
372 uint32_t current_feed_seconds = current_feed_publication_time.sec_since_epoch();
373 if( (std::numeric_limits<uint32_t>::max() - current_feed_seconds) <= options.
feed_lifetime_sec )
381 {
return feed_expiration_time() >= current_time; }
384 {
return feed_expiration_time() <= current_time; }
400 void update_median_feeds(time_point_sec current_time, time_point_sec next_maintenance_time);
404 void refresh_cache();
417 struct by_short_backing_asset;
418 struct by_feed_expiration;
419 struct by_cer_update;
424 ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
426 ordered_unique< tag<by_feed_expiration>,
427 composite_key< asset_bitasset_data_object,
430 member< asset_bitasset_data_object, asset_id_type, &asset_bitasset_data_object::asset_id >
433 ordered_non_unique< tag<by_cer_update>,
434 const_mem_fun< asset_bitasset_data_object, bool,
447 ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
448 ordered_unique< tag<by_symbol>, member<asset_object, string, &asset_object::symbol> >,
449 ordered_unique< tag<by_type>,
450 composite_key< asset_object,
451 const_mem_fun<asset_object, bool, &asset_object::is_market_issued>,
452 member< object, object_id_type, &object::id >
455 ordered_unique< tag<by_issuer>,
456 composite_key< asset_object,
457 member< asset_object, account_id_type, &asset_object::issuer >,
458 member< object, object_id_type, &object::id >
472 (initial_collateral_ratio) )
480 (dynamic_asset_data_id)
the max supply of the asset can not be updated
extension< ext > extensions
bool has_settlement() const
ratio_type get_margin_call_order_ratio() const
Get margin call order ratio (MCOR) of this bitasset.
bool charges_market_fees() const
asset_id_type asset_id
The asset this object belong to.
multi_index_container< asset_object, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > >, ordered_unique< tag< by_symbol >, member< asset_object, string, &asset_object::symbol > >, ordered_unique< tag< by_type >, composite_key< asset_object, const_mem_fun< asset_object, bool, &asset_object::is_market_issued >, member< object, object_id_type, &object::id > > >, ordered_unique< tag< by_issuer >, composite_key< asset_object, member< asset_object, account_id_type, &asset_object::issuer >, member< object, object_id_type, &object::id > > > > > asset_object_multi_index_type
black_swan_response_type get_black_swan_response_method() const
Get the effective black swan response method.
price get_margin_call_order_price() const
Get margin call order price (MCOP) of this bitasset.
price get_individual_settlement_price() const
Get the price of the individual settlement pool.
require the issuer to be one party to every transfer
share_type reserved(const DB &db) const
contains properties that only apply to bitassets (market issued assets)
black_swan_response_type
Defines how a BitAsset would respond to black swan events.
share_type force_settled_volume
This is the volume of this asset which has been force-settled this maintanence interval.
bool can_accumulate_fee(const DB &db, const asset &fee) const
boost::rational< int32_t > ratio_type
bool can_owner_update_icr() const
bitasset_options::black_swan_response_type get_black_swan_response_method() const
Get the effective black swan response method of this bitasset.
ratio_type margin_call_pays_ratio(const fc::optional< uint16_t > &margin_call_fee_ratio) const
The asset_options struct contains options available on all assets in the network. ...
bool has_individual_settlement() const
#define MAP_OBJECT_ID_TO_TYPE(OBJECT)
multi_index_container< asset_bitasset_data_object, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > >, ordered_non_unique< tag< by_short_backing_asset >, bitasset_backing_asst_extractor >, ordered_unique< tag< by_feed_expiration >, composite_key< asset_bitasset_data_object, const_mem_fun< asset_bitasset_data_object, time_point_sec, &asset_bitasset_data_object::feed_expiration_time >, member< asset_bitasset_data_object, asset_id_type, &asset_bitasset_data_object::asset_id > > >, ordered_non_unique< tag< by_cer_update >, const_mem_fun< asset_bitasset_data_object, bool, &asset_bitasset_data_object::need_to_update_cer > > > > bitasset_data_multi_index_type
#define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO
Call when collateral only pays off 175% the debt.
the bitasset owner can not update MSSR, permission only
ratio_type margin_call_order_ratio(const fc::optional< uint16_t > &margin_call_fee_ratio) const
const asset_dynamic_data_object & dynamic_data(const DB &db) const
optional< account_id_type > buyback_account
time_point_sec creation_time
The time when the asset object was created.
defines market parameters for margin positions, extended with an initial_collateral_ratio field ...
void accumulate_fee(DB &db, const asset &fee) const
string amount_to_string(const asset &amount) const
Convert an asset to a textual representation, i.e. "123.45".
account_id_type issuer
ID of the account which issued this asset.
the bitasset owner can not update MCR, permission only
optional< liquidity_pool_id_type > for_liquidity_pool
The ID of the liquidity pool if the asset is the share asset of a liquidity pool. ...
bool can_bid_collateral() const
price_feed_with_icr(const price_feed &pf, const optional< uint16_t > &icr={})
share_type accumulated_collateral_fees
accumulated collateral-denominated fees (for bitassets)
bool feed_is_expired(time_point_sec current_time) const
provides stack-based nullable value similar to boost::optional
unable to create new supply for the asset
const asset_bitasset_data_object & bitasset_data(const DB &db) const
FC_REFLECT_TYPENAME(fc::log_message)
asset amount(share_type a) const
Helper function to get an asset object with the given amount in this asset's type.
share_type individual_settlement_debt
bool can_override() const
price current_maintenance_collateralization
bool allow_confidential() const
bool can_force_settle() const
static time_point_sec maximum()
object_id< SpaceID, TypeID > get_id() const
price margin_call_order_price(const fc::optional< uint16_t > &margin_call_fee_ratio) const
time_point_sec feed_expiration_time() const
The time when current_feed would expire.
uint16_t maintenance_collateral_ratio
string amount_to_pretty_string(share_type amount) const
Convert an asset to a textual representation with symbol, i.e. "123.45 USD".
ratio_type get_margin_call_pays_ratio() const
Get margin call pays ratio (MCPR) of this bitasset.
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
The price struct stores asset prices in the BitShares system.
uint16_t issuer_permissions
The flags which the issuer has permission to update. See asset_issuer_permission_flags.
bool is_transfer_restricted() const
asset_dynamic_data_id_type dynamic_asset_data_id
Current supply, fee pool, and collected fees are stored in a separate object as they change frequentl...
bool is_market_issued() const
string symbol
Ticker symbol for this asset, i.e. "USD".
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
price_feed_with_icr current_feed
This is the currently active price feed, calculated from median_feed and other parameters.
bool need_to_update_cer() const
Whether need to update core_exchange_rate in asset_object.
tracks the asset information that changes frequentlyBecause the asset_object is very large it doesn't...
the bitasset owner can not update ICR, permission only
uint32_t feed_lifetime_sec
Time before a price feed expires.
bool can_owner_update_bsrm() const
market trades in this asset may be charged
share_type individual_settlement_fund
Amount of collateral which is available for force settlement due to individual settlements.
Can not bid collateral after a global settlement.
share_type fee_pool
in core asset
bool can_global_settle() const
share_type accumulated_fees
fees accumulate to be paid out over time
tracks the parameters of an assetAll assets have a globally unique symbol name that controls how they...
defines market parameters for margin positions
bool can_create_new_supply() const
allow the bitasset owner to force a global settlement, permission only
bitasset_options options
The tunable options for BitAssets are stored in this field.
#define FC_REFLECT_DERIVED(TYPE, INHERITS, MEMBERS)
Specializes fc::reflector for TYPE where type inherits other reflected classes.
string amount_to_pretty_string(const asset &amount) const
Convert an asset to a textual representation with symbol, i.e. "123.45 USD".
share_type confidential_supply
total asset held in confidential balances
uint16_t flags
The currently active flags on this permission. See asset_issuer_permission_flags. ...
issuer may transfer asset back to himself
price current_initial_collateralization
bool is_liquidity_pool_share_asset() const
optional< asset_bitasset_data_id_type > bitasset_data_id
Extra data associated with BitAssets. This field is non-null if and only if is_market_issued() return...
base for all database objects
share_type current_supply
The number of shares currently in existence.
flat_map< account_id_type, pair< time_point_sec, price_feed_with_icr > > feeds
bool can_owner_update_mssr() const
bool is_current_feed_price_capped() const
bool feed_is_expired_before_hf_615(time_point_sec current_time) const
the bitasset owner can not update BSRM, permission only
asset_id_type short_backing_asset
time_point_sec current_feed_publication_time
This is the publication time of the oldest feed which was factored into current_feed.
share_type settlement_fund
Amount of collateral which is available for force settlement due to global settlement.
The bitasset_options struct contains configurable options available only to BitAssets.
bool is_valid_symbol(const string &symbol)
bool can_owner_update_mcr() const
price_feed_with_icr median_feed
This is the median of values from the currently active feeds.
disallow the asset to be used with confidential transactions
bool can_update_max_supply() const
price core_exchange_rate
Price at which automatically exchanging this asset for CORE from fee pool occurs (used for paying fee...