BitShares-Core  6.0.1
BitShares blockchain implementation and command-line interface software
credit_offer.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Abit More, and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
27 
28 namespace graphene { namespace protocol {
29 
37  {
41  };
42 
44  account_id_type owner_account;
45  asset_id_type asset_type;
47  uint32_t fee_rate = 0;
48  uint32_t max_duration_seconds = 0;
50  bool enabled = false;
52 
54  flat_map<asset_id_type, price> acceptable_collateral;
55 
57  flat_map<account_id_type, share_type> acceptable_borrowers;
58 
60 
61  account_id_type fee_payer()const { return owner_account; }
62  void validate()const override;
64  };
65 
71  {
72  struct fee_parameters_type { uint64_t fee = 0; };
73 
75  account_id_type owner_account;
76  credit_offer_id_type offer_id;
77 
79 
80  account_id_type fee_payer()const { return owner_account; }
81  void validate()const override;
82  };
83 
89  {
93  };
94 
96  account_id_type owner_account;
97  credit_offer_id_type offer_id;
104 
107 
110 
112 
113  account_id_type fee_payer()const { return owner_account; }
114  void validate()const override;
116  };
117 
123  {
125 
127  account_id_type borrower;
128  credit_offer_id_type offer_id;
131  uint32_t max_fee_rate = 0;
132  uint32_t min_duration_seconds = 0;
133 
135 
136  account_id_type fee_payer()const { return borrower; }
137  void validate()const override;
138  };
139 
145  {
147 
149  account_id_type account;
150  credit_deal_id_type deal_id;
153 
155 
156  account_id_type fee_payer()const { return account; }
157  void validate()const override;
158  };
159 
166  {
168 
169  credit_deal_expired_operation() = default;
170 
171  credit_deal_expired_operation( const credit_deal_id_type& did, const credit_offer_id_type& oid,
172  const account_id_type& o, const account_id_type& b, const asset& u, const asset& c, const uint32_t fr)
173  : deal_id(did), offer_id(oid), offer_owner(o), borrower(b), unpaid_amount(u), collateral(c), fee_rate(fr)
174  { /* Nothing to do */ }
175 
177  credit_deal_id_type deal_id;
178  credit_offer_id_type offer_id;
179  account_id_type offer_owner;
180  account_id_type borrower;
183  uint32_t fee_rate = 0;
184 
185  account_id_type fee_payer()const { return borrower; }
186  void validate()const override { FC_ASSERT( !"virtual operation" ); }
187 
189  share_type calculate_fee(const fee_parameters_type&)const { return 0; }
190  };
191 
192 } } // graphene::protocol
193 
200 
202  (fee)
203  (owner_account)
204  (asset_type)
205  (balance)
206  (fee_rate)
209  (enabled)
213  (extensions)
214  )
215 
217  (fee)
218  (owner_account)
219  (offer_id)
220  (extensions)
221  )
222 
224  (fee)
225  (owner_account)
226  (offer_id)
227  (delta_amount)
228  (fee_rate)
231  (enabled)
235  (extensions)
236  )
237 
239  (fee)
240  (borrower)
241  (offer_id)
242  (borrow_amount)
243  (collateral)
244  (max_fee_rate)
245  (min_duration_seconds)
246  (extensions)
247  )
248 
250  (fee)
251  (account)
252  (deal_id)
253  (repay_amount)
254  (credit_fee)
255  (extensions)
256  )
257 
259  (fee)
260  (deal_id)
261  (offer_id)
262  (offer_owner)
263  (borrower)
264  (unpaid_amount)
265  (collateral)
266  (fee_rate)
267  )
268 
274 // Note: credit_deal_expired_operation is virtual so no external serialization for its fee_parameters_type
275 
future_extensions::flat_set_type extensions_type
Definition: base.hpp:155
account_id_type account
The account who repays to the credit offer.
optional< asset > delta_amount
Delta amount, optional.
extensions_type extensions
Unused. Reserved for future use.
extensions_type extensions
Unused. Reserved for future use.
share_type balance
Usable amount in the credit offer.
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
extensions_type extensions
Unused. Reserved for future use.
account_id_type borrower
The account who repays to the credit offer.
Definition: api.cpp:56
extensions_type extensions
Unused. Reserved for future use.
asset collateral
The collateral liquidated.
credit_deal_expired_operation(const credit_deal_id_type &did, const credit_offer_id_type &oid, const account_id_type &o, const account_id_type &b, const asset &u, const asset &c, const uint32_t fr)
uint32_t fee_rate
Fee rate, the demominator is GRAPHENE_FEE_RATE_DENOM.
credit_deal_id_type deal_id
ID of the credit deal.
flat_map< asset_id_type, price > acceptable_collateral
Types and rates of acceptable collateral.
account_id_type offer_owner
Owner of the credit offer.
Accept a creadit offer and create a credit deal.
credit_offer_id_type offer_id
ID of the credit offer.
bool enabled
Whether this offer is available.
credit_deal_id_type deal_id
ID of the credit deal.
flat_map< account_id_type, share_type > acceptable_borrowers
Allowed borrowers and their maximum amounts to borrow. No limitation if empty.
optional< uint32_t > max_duration_seconds
New repayment time limit, optional.
asset unpaid_amount
The amount that is unpaid.
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
optional< time_point_sec > auto_disable_time
New time to disable automatically, optional.
optional< uint32_t > fee_rate
New fee rate, optional.
credit_offer_id_type offer_id
ID of the credit offer.
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
account_id_type owner_account
The account who owns the credit offer.
optional< flat_map< asset_id_type, price > > acceptable_collateral
New types and rates of acceptable collateral, optional.
time_point_sec auto_disable_time
The time when this offer will be disabled automatically.
optional< bool > enabled
Whether this offer is available, optional.
#define GRAPHENE_BLOCKCHAIN_PRECISION
Definition: config.hpp:29
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
credit_offer_id_type offer_id
ID of the credit offer.
A credit deal expired without being fully repaid.
optional< share_type > min_deal_amount
Minimum amount to borrow for each new deal, optional.
share_type calculate_fee(const fee_parameters_type &k) const
asset_id_type asset_type
Asset type in the credit offer.
share_type min_deal_amount
Minimum amount to borrow for each new deal.
optional< flat_map< account_id_type, share_type > > acceptable_borrowers
New allowed borrowers and their maximum amounts to borrow, optional.
extensions_type extensions
Unused. Reserved for future use.
account_id_type borrower
The account who accepts the offer.
asset fee
Only for compatibility, unused.
account_id_type owner_account
Owner of the credit offer.
asset credit_fee
The credit fee relative to the amount to repay.
account_id_type owner_account
Owner of the credit offer.
share_type calculate_fee(const fee_parameters_type &) const
This is a virtual operation; there is no fee.
uint32_t max_duration_seconds
The time limit that borrowed funds should be repaid.
credit_offer_id_type offer_id
ID of the credit offer.
Create a new credit offerA credit offer is a fund that can be used by other accounts who provide cert...