BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
Go to the documentation of this file.
31 #include <graphene/chain/hardfork.hpp>
36 namespace graphene {
namespace chain {
43 FC_ASSERT( HARDFORK_CORE_2362_PASSED(block_time),
"Not allowed until the core-2362 hardfork" );
49 "Auto-disable time should not be later than ${d} days in the future",
66 "The account is unauthorized by the asset" );
81 obj.current_balance = op.
balance;
90 return new_credit_offer_object.
id;
102 "Can only delete a credit offer when the unpaid amount is zero" );
142 "The account is unauthorized by the asset" );
147 "Should leave some funds in the credit offer when updating" );
156 FC_ASSERT( auto_disable_time > block_time,
"Auto-disable time should be in the future" );
158 "Auto-disable time should not be later than ${d} days in the future",
169 "Asset type mismatch in a price of acceptable collateral" );
194 coo.total_balance += op.delta_amount->amount;
195 coo.current_balance += op.delta_amount->amount;
217 "Total balance in the credit offer should not be less than current balance" );
221 "Auto-disable time should be in the future if the credit offer is enabled" );
223 "Auto-disable time should not be too late in the future" );
234 if( !HARDFORK_CORE_2595_PASSED(block_time) )
237 "auto_repay unavailable until the core-2595 hardfork");
247 "Insufficient balance in the credit offer thus unable to borrow" );
250 "Borrowing amount should not be less than minimum deal amount" );
253 "The maximum accceptable fee rate is lower than offered" );
256 "The minimum accceptable duration is longer than offered" );
260 "Collateral asset type is not acceptable by the credit offer" );
266 "The borrower is unauthorized by the borrowing asset" );
268 "The borrower is unauthorized by the collateral asset" );
273 "The owner of the credit offer is unauthorized by the borrowing asset" );
275 "The owner of the credit offer is unauthorized by the collateral asset" );
279 "Insufficient collateral provided, requires ${r}, provided ${p}",
287 max_allowed = itr->second;
292 auto summ_itr = deal_summary_idx.find( boost::make_tuple( op.
offer_id, op.
borrower ) );
293 if( summ_itr != deal_summary_idx.end() )
299 if( max_allowed.
valid() )
302 "Unable to borrow ${b}, already borrowed ${a}, maximum allowed ${m}",
330 obj.debt_amount = op.borrow_amount.amount;
334 obj.latest_repay_time = repay_time;
335 obj.auto_repay = ( op.extensions.value.
auto_repay.valid() ? *op.extensions.value.
auto_repay : 0 );
351 obj.total_debt_amount = op.borrow_amount.amount;
359 "Total balance in the credit offer should not be less than current balance" );
360 FC_ASSERT( new_deal.latest_repay_time > block_time,
361 "Latest repayment time should be in the future" );
363 "Latest repayment time should not be too late in the future" );
367 result.
value.new_objects = flat_set<object_id_type>({ new_deal.id });
384 "Repay amount should not be greater than unpaid amount" );
391 "Insuffient credit fee, requires ${r}, offered ${p}",
398 "The account is unauthorized by the repaying asset" );
400 "The owner of the credit offer is unauthorized by the repaying asset" );
421 "Total balance in the credit offer should not be less than current balance" );
425 result.
value.updated_objects = flat_set<object_id_type>({ offer.
id });
430 FC_ASSERT( summ_itr != deal_summary_idx.end(),
"Internal error" );
448 result.
value.removed_objects = flat_set<object_id_type>({
_deal->
id });
459 collateral_released.
amount =
static_cast<int64_t
>( amount_to_release );
470 result.
value.received = vector<asset>({ collateral_released });
480 FC_ASSERT( HARDFORK_CORE_2595_PASSED(block_time),
"Not allowed until the core-2595 hardfork" );
extendable_operation_result do_apply(const credit_offer_accept_operation &op) const
constexpr int64_t GRAPHENE_MAX_CREDIT_OFFER_DAYS
How long a credit offer will be kept active, in days.
account_id_type borrower
The account who accepts the offer.
#define FC_CAPTURE_AND_RETHROW(...)
extension< ext > extensions
Extensions.
extendable_operation_result do_apply(const credit_deal_repay_operation &op) const
account_id_type owner_account
Owner of the credit offer.
share_type collateral_amount
How much funds in collateral.
tracks the blockchain state in an extensible manner
time_point_sec auto_disable_time
The time when this offer will be disabled automatically.
share_type balance
Usable amount in the credit offer.
A credit deal describes the details of a borrower's borrowing of funds from a credit offer.
time_point_sec head_block_time() const
A credit offer is a fund that can be used by other accounts who provide certain collateral.
share_type total_balance
Total size of the fund.
optional< flat_map< account_id_type, share_type > > acceptable_borrowers
New allowed borrowers and their maximum amounts to borrow, optional.
credit_deal_id_type deal_id
ID of the credit deal.
uint8_t auto_repay
The specified automatic repayment type.
asset_id_type asset_type
Asset type in the fund.
Create a new credit offer.
flat_map< account_id_type, share_type > acceptable_borrowers
Allowed borrowers and their maximum amounts to borrow. No limitation if empty.
void_result do_evaluate(const credit_deal_update_operation &op)
const credit_offer_object * _offer
share_type total_debt_amount
How much funds borrowed.
optional< share_type > min_deal_amount
Minimum amount to borrow for each new deal, optional.
tracks the parameters of an asset
const T & create(F &&constructor)
void adjust_balance(account_id_type account, asset delta)
Adjust a particular account's balance in a given asset by a delta.
void_result do_evaluate(const credit_offer_create_operation &op) const
account_id_type owner_account
Owner of the fund.
static time_point_sec maximum()
optional< bool > enabled
Whether this offer is available, optional.
share_type min_deal_amount
Minimum amount to borrow for each new deal.
asset do_apply(const credit_offer_delete_operation &op) const
microseconds seconds(int64_t s)
flat_map< asset_id_type, price > acceptable_collateral
Types and rates of acceptable collateral.
bool enabled
Whether this offer is available.
bool enabled
Whether this offer is available.
asset repay_amount
The amount to repay.
credit_offer_id_type offer_id
ID of the credit offer.
uint32_t fee_rate
Fee rate, the demominator is GRAPHENE_FEE_RATE_DENOM.
optional< uint32_t > fee_rate
New fee rate, optional.
void_result do_evaluate(const credit_offer_accept_operation &op)
asset credit_fee
The credit fee relative to the amount to repay.
account_id_type borrower
Borrower.
microseconds days(int64_t d)
void_result do_evaluate(const credit_offer_delete_operation &op)
const object & get(object_id_type id) const
asset multiply_and_round_up(const price &p) const
Multiply and round up.
credit_offer_id_type offer_id
ID of the credit offer.
This class represents an account on the object graph.
uint8_t auto_repay
The specified automatic repayment type.
Accept a credit offer, thereby creating a credit deal.
optional< flat_map< asset_id_type, price > > acceptable_collateral
New types and rates of acceptable collateral, optional.
A credit deal summary describes the summary of a borrower's borrowing of funds from a credit offer.
flat_map< asset_id_type, price > acceptable_collateral
Types and rates of acceptable collateral.
constexpr int64_t GRAPHENE_MAX_CREDIT_DEAL_DAYS
How long a credit deal will be kept, in days.
const credit_deal_object * _deal
credit_offer_id_type offer_id
ID of the credit offer.
asset_id_type debt_asset
Asset type of the debt, redundant info for ease of querying.
bool is_authorized_asset(const database &d, const account_object &acct, const asset_object &asset_obj)
account_id_type borrower
Borrower.
time_point_sec auto_disable_time
The time when this offer will be disabled automatically.
object_id_type do_apply(const credit_offer_create_operation &op) const
asset_id_type asset_type
Asset type in the credit offer.
constexpr uint32_t GRAPHENE_FEE_RATE_DENOM
Denominator for SameT Fund fee calculation.
credit_offer_id_type offer_id
ID of the credit offer.
credit_offer_id_type offer_id
ID of the credit offer.
asset borrow_amount
The amount to borrow.
share_type debt_amount
How much funds borrowed.
void_result do_evaluate(const credit_offer_update_operation &op)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
uint32_t max_duration_seconds
The time limit that borrowed funds should be repaid.
const credit_offer_object * _offer
flat_map< account_id_type, share_type > acceptable_borrowers
Allowed borrowers and their maximum amounts to borrow. No limitation if empty.
uint32_t fee_rate
Fee rate, the demominator is GRAPHENE_FEE_RATE_DENOM.
const credit_offer_object * _offer
credit_deal_id_type deal_id
ID of the credit deal.
uint32_t fee_rate
Fee rate, the demominator is GRAPHENE_FEE_RATE_DENOM.
optional< asset > delta_amount
Delta amount, optional.
account_id_type account
The account who owns the credit deal.
void_result do_apply(const credit_offer_update_operation &op) const
provides stack-based nullable value similar to boost::optional
void_result do_evaluate(const credit_deal_repay_operation &op)
uint32_t max_fee_rate
The maximum acceptable fee rate.
optional< time_point_sec > auto_disable_time
New time to disable automatically, optional.
asset_id_type collateral_asset
Asset type of the collateral.
const account_object * fee_paying_account
uint32_t max_duration_seconds
The time limit that borrowed funds should be repaid.
asset collateral
The collateral.
const credit_deal_object * _deal
account_id_type offer_owner
Owner of the credit offer, redundant info for ease of querying.
void remove(const object &obj)
const IndexType & get_index_type() const
uint32_t min_duration_seconds
The minimum acceptable duration.
void_result do_apply(const credit_deal_update_operation &op) const
account_id_type owner_account
Owner of the credit offer.
share_type current_balance
Usable amount in the fund.
share_type min_deal_amount
Minimum amount to borrow for each new deal.
account_id_type owner_account
The account who owns the credit offer.
const credit_deal_summary_object * _deal_summary
optional< uint32_t > max_duration_seconds
New repayment time limit, optional.
void modify(const T &obj, const Lambda &m)
account_id_type account
The account who repays to the credit offer.