BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
Go to the documentation of this file.
26 #include <graphene/chain/hardfork.hpp>
31 namespace graphene {
namespace chain {
40 fc::uint128_t volume = current_supply.
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 );
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) )
232 (current_feed_publication_time)
233 (current_maintenance_collateralization)
234 (current_initial_collateralization)
236 (force_settled_volume)
237 (is_prediction_market)
240 (individual_settlement_debt)
241 (individual_settlement_fund)
constexpr int64_t GRAPHENE_MAX_SHARE_SUPPLY(1000000000000000LL)
uint16_t initial_collateral_ratio
#define FC_CAPTURE_AND_RETHROW(...)
#define GRAPHENE_COLLATERAL_RATIO_DENOM
void update_median_feeds(time_point_sec current_time, time_point_sec next_maintenance_time)
std::string to_string(double)
price core_exchange_rate
Price at which automatically exchanging this asset for CORE from fee pool occurs (used for paying fee...
The price struct stores asset prices in the BitShares system.
uint16_t maximum_force_settlement_volume
static share_type scaled_precision(uint8_t precision)
price maintenance_collateralization() const
share_type force_settled_volume
This is the volume of this asset which has been force-settled this maintanence interval.
string amount_to_string(share_type amount) const
Convert an asset to a textual representation, i.e. "123.45".
tracks the parameters of an asset
uint32_t feed_lifetime_sec
Time before a price feed expires.
price current_maintenance_collateralization
#define GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION(type)
asset amount_from_string(string amount_string) const
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...
uint8_t precision
Maximum number of digits after the decimal point (must be <= 12)
tracks the asset information that changes frequently
uint16_t maximum_short_squeeze_ratio
#define FC_REFLECT_DERIVED_NO_TYPENAME(TYPE, INHERITS, MEMBERS)
contains properties that only apply to bitassets (market issued assets)
price_feed_with_icr median_feed
This is the median of values from the currently active feeds.
#define CHECK_AND_CALCULATE_MEDIAN_VALUE(r, data, field_name)
price get_initial_collateralization() const
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
uint16_t maintenance_collateral_ratio
time_point_sec current_feed_publication_time
This is the publication time of the oldest feed which was factored into current_feed.
asset amount(share_type a) const
Helper function to get an asset object with the given amount in this asset's type.
bool feed_cer_updated
Track whether core exchange rate in current feed has updated.
defines market parameters for margin positions, extended with an initial_collateral_ratio field
flat_map< account_id_type, pair< time_point_sec, price_feed_with_icr > > feeds
price current_initial_collateralization
boost::rational< int32_t > ratio_type
#define CALCULATE_MEDIAN_VALUE(r, data, field_name)
#define GRAPHENE_100_PERCENT
extension< ext > extensions
bitasset_options options
The tunable options for BitAssets are stored in this field.
base for all database objects
uint8_t minimum_feeds
Minimum number of unexpired feeds required to extract a median feed from.