26 #include <graphene/chain/hardfork.hpp> 31 namespace graphene {
namespace chain {
40 fc::uint128_t volume = current_supply.
value;
41 volume += force_settled_volume.value;
44 return static_cast<uint64_t
>(volume);
48 time_point_sec next_maintenance_time )
50 bool after_core_hardfork_1270 = ( next_maintenance_time > HARDFORK_CORE_1270_TIME );
52 vector<std::reference_wrapper<const price_feed_with_icr>> effective_feeds;
54 for(
const pair<account_id_type, pair<time_point_sec,price_feed_with_icr>>& f :
feeds )
57 f.second.first != time_point_sec() )
59 effective_feeds.emplace_back(f.second.second);
72 if( after_core_hardfork_1270 )
80 if( 1U == effective_feeds.size() )
86 if( after_core_hardfork_1270 )
89 if( exts.maintenance_collateral_ratio.valid() )
91 if( exts.maximum_short_squeeze_ratio.valid() )
93 if( exts.initial_collateral_ratio.valid() )
103 const auto median_itr = effective_feeds.begin() + ( effective_feeds.size() / 2 );
104 #define CALCULATE_MEDIAN_VALUE(r, data, field_name) \ 105 std::nth_element( effective_feeds.begin(), median_itr, effective_feeds.end(), \ 106 [](const price_feed_with_icr& a, const price_feed_with_icr& b) { \ 107 return a.field_name < b.field_name; \ 109 tmp_median_feed.field_name = median_itr->get().field_name; 111 #define CHECK_AND_CALCULATE_MEDIAN_VALUE(r, data, field_name) \ 112 if( options.extensions.value.field_name.valid() ) { \ 113 tmp_median_feed.field_name = *options.extensions.value.field_name; \ 115 CALCULATE_MEDIAN_VALUE(r, data, field_name); \ 120 (maintenance_collateral_ratio)(maximum_short_squeeze_ratio)(initial_collateral_ratio) )
121 #undef CHECK_AND_CALCULATE_MEDIAN_VALUE 122 #undef CALCULATE_MEDIAN_VALUE 129 if( after_core_hardfork_1270 )
136 void asset_bitasset_data_object::refresh_cache()
154 bool negative_found =
false;
155 bool decimal_found =
false;
156 for(
const char c : amount_string )
161 if( c ==
'-' && !negative_found )
163 negative_found =
true;
167 if( c ==
'.' && !decimal_found )
169 decimal_found =
true;
180 const auto decimal_pos = amount_string.find(
'.' );
181 const string lhs = amount_string.substr( negative_found, decimal_pos );
189 string rhs = amount_string.substr( decimal_pos + 1 );
192 while( rhs.size() < max_rhs_size )
196 satoshis += std::stoll( rhs );
204 return amount(satoshis);
212 auto decimals = abs( amount.
value % scaled_precision.
value );
215 if( amount < 0 && result ==
"0" )
225 (current_supply)(confidential_supply)(accumulated_fees)(accumulated_collateral_fees)(fee_pool) )
extension< ext > extensions
#define CALCULATE_MEDIAN_VALUE(r, data, field_name)
uint16_t maximum_force_settlement_volume
#define GRAPHENE_COLLATERAL_RATIO_DENOM
asset_id_type asset_id
The asset this object belong to.
uint16_t maximum_short_squeeze_ratio
contains properties that only apply to bitassets (market issued assets)
share_type force_settled_volume
This is the volume of this asset which has been force-settled this maintanence interval.
boost::rational< int32_t > ratio_type
#define FC_REFLECT_DERIVED_NO_TYPENAME(TYPE, INHERITS, MEMBERS)
share_type max_force_settlement_volume(share_type current_supply) const
Calculate the maximum force settlement volume per maintenance interval, given the current share suppl...
defines market parameters for margin positions, extended with an initial_collateral_ratio field ...
#define CHECK_AND_CALCULATE_MEDIAN_VALUE(r, data, field_name)
bool is_prediction_market
True if this asset implements a Prediction Market.
void update_median_feeds(time_point_sec current_time, time_point_sec next_maintenance_time)
share_type individual_settlement_debt
price current_maintenance_collateralization
static share_type scaled_precision(uint8_t precision)
bool feed_cer_updated
Track whether core exchange rate in current feed has updated.
uint16_t maintenance_collateral_ratio
The price struct stores asset prices in the BitShares system.
#define GRAPHENE_100_PERCENT
uint8_t minimum_feeds
Minimum number of unexpired feeds required to extract a median feed from.
#define FC_CAPTURE_AND_RETHROW(...)
price get_initial_collateralization() const
#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.
tracks the asset information that changes frequentlyBecause the asset_object is very large it doesn't...
string amount_to_string(share_type amount) const
Convert an asset to a textual representation, i.e. "123.45".
#define GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION(type)
uint32_t feed_lifetime_sec
Time before a price feed expires.
share_type individual_settlement_fund
Amount of collateral which is available for force settlement due to individual settlements.
price maintenance_collateralization() const
uint16_t initial_collateral_ratio
tracks the parameters of an assetAll assets have a globally unique symbol name that controls how they...
std::string to_string(double)
bitasset_options options
The tunable options for BitAssets are stored in this field.
constexpr int64_t GRAPHENE_MAX_SHARE_SUPPLY(1000000000000000LL)
price current_initial_collateralization
base for all database objects
flat_map< account_id_type, pair< time_point_sec, price_feed_with_icr > > feeds
bool asset_cer_updated
Track whether core_exchange_rate in corresponding asset_object has updated.
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.
price_feed_with_icr median_feed
This is the median of values from the currently active feeds.
asset amount_from_string(string amount_string) const
price core_exchange_rate
Price at which automatically exchanging this asset for CORE from fee pool occurs (used for paying fee...