BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
market.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., 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 
34  {
36  asset_id_type fee_asset_id;
38  uint16_t spread_percent = 0;
42  uint32_t expiration_seconds = 0;
44  bool repeat = false;
45 
47 
48  void validate()const;
49  };
50 
53 
73  {
79  struct options_type
80  {
83  };
84 
85  struct fee_params_t { uint64_t fee = 5 * GRAPHENE_BLOCKCHAIN_PRECISION; };
86 
88  account_id_type seller;
91 
95 
97  bool fill_or_kill = false;
98 
99  using extensions_type = extension<options_type>; // note: will be jsonified to {...} but not [...]
101 
102  pair<asset_id_type,asset_id_type> get_market()const
103  {
107  }
108  account_id_type fee_payer()const { return seller; }
109  void validate()const;
111  };
112 
118  {
119  struct fee_params_t {
120  uint64_t fee = ( GRAPHENE_BLOCKCHAIN_PRECISION * 3 ) / 8;
121  };
122 
124  account_id_type seller;
125  limit_order_id_type order;
131 
133 
134  account_id_type fee_payer() const { return seller; }
135  void validate() const override;
136  };
137 
146  {
147  struct fee_params_t { uint64_t fee = 0; };
148 
150  limit_order_id_type order;
152  account_id_type fee_paying_account;
154 
155  account_id_type fee_payer()const { return fee_paying_account; }
156  void validate()const;
157  };
158 
172  {
179  {
182  };
183 
185  struct fee_params_t { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; };
186 
188  account_id_type funding_account;
191 
192  using extensions_type = extension<options_type>; // note: this will be jsonified to {...} but no longer [...]
194 
195  account_id_type fee_payer()const { return funding_account; }
196  void validate()const;
197  };
198 
207  {
208  struct fee_params_t {};
209 
211  fill_order_operation( object_id_type o, account_id_type a, asset p, asset r, asset f, price fp, bool m )
212  :order_id(o),account_id(a),pays(p),receives(r),fee(f),fill_price(fp),is_maker(m) {}
213 
215  account_id_type account_id;
218  asset fee; // paid by receiving account
220  bool is_maker = true;
221 
222  pair<asset_id_type,asset_id_type> get_market()const
223  {
224  return pays.asset_id < receives.asset_id ?
225  std::make_pair( pays.asset_id, receives.asset_id ) :
226  std::make_pair( receives.asset_id, pays.asset_id );
227  }
228  account_id_type fee_payer()const { return account_id; }
229  void validate()const { FC_ASSERT( !"virtual operation" ); }
230 
232  share_type calculate_fee(const fee_params_t&)const { return 0; }
233  };
234 
242  {
244  struct fee_params_t { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; };
245 
247  account_id_type bidder;
251 
252  account_id_type fee_payer()const { return bidder; }
253  void validate()const;
254  };
255 
263  {
264  struct fee_params_t {};
265 
267  execute_bid_operation( account_id_type a, asset d, asset c )
268  : bidder(a), debt(d), collateral(c) {}
269 
270  account_id_type bidder;
274 
275  account_id_type fee_payer()const { return bidder; }
276  void validate()const { FC_ASSERT( !"virtual operation" ); }
277 
279  share_type calculate_fee(const fee_params_t&)const { return 0; }
280  };
281 } } // graphene::protocol
282 
284  (fee_asset_id)(spread_percent)(size_percent)(expiration_seconds)(repeat)(extensions) )
285 
292 FC_REFLECT( graphene::protocol::execute_bid_operation::fee_params_t, ) // VIRTUAL
293 
294 FC_REFLECT( graphene::protocol::limit_order_create_operation::options_type, (on_fill) )
295 FC_REFLECT( graphene::protocol::call_order_update_operation::options_type, (target_collateral_ratio) )
296 
297 FC_REFLECT( graphene::protocol::limit_order_create_operation,
298  (fee)(seller)(amount_to_sell)(min_to_receive)(expiration)(fill_or_kill)(extensions))
299 FC_REFLECT( graphene::protocol::limit_order_update_operation,
300  (fee)(seller)(order)(new_price)(delta_amount_to_sell)(new_expiration)(on_fill)(extensions))
301 FC_REFLECT( graphene::protocol::limit_order_cancel_operation,
302  (fee)(fee_paying_account)(order)(extensions) )
303 FC_REFLECT( graphene::protocol::call_order_update_operation,
304  (fee)(funding_account)(delta_collateral)(delta_debt)(extensions) )
305 FC_REFLECT( graphene::protocol::fill_order_operation,
306  (fee)(order_id)(account_id)(pays)(receives)(fill_price)(is_maker) )
307 FC_REFLECT( graphene::protocol::bid_collateral_operation,
308  (fee)(bidder)(additional_collateral)(debt_covered)(extensions) )
309 FC_REFLECT( graphene::protocol::execute_bid_operation,
310  (fee)(bidder)(debt)(collateral) )
311 
312 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::create_take_profit_order_action)
313 
314 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_create_operation::options_type )
315 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation::options_type )
316 
317 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_create_operation::fee_params_t )
318 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_update_operation::fee_params_t )
319 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_cancel_operation::fee_params_t )
320 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation::fee_params_t )
321 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::bid_collateral_operation::fee_params_t )
322 
323 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_create_operation )
324 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_update_operation )
325 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_cancel_operation )
326 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation )
327 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::bid_collateral_operation )
328 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::fill_order_operation )
329 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::execute_bid_operation )
graphene::protocol::limit_order_update_operation::fee_payer
account_id_type fee_payer() const
Definition: market.hpp:134
graphene::protocol::bid_collateral_operation::bidder
account_id_type bidder
pays fee and additional collateral
Definition: market.hpp:247
graphene::protocol::execute_bid_operation::execute_bid_operation
execute_bid_operation(account_id_type a, asset d, asset c)
Definition: market.hpp:267
graphene::protocol::fill_order_operation::fee_payer
account_id_type fee_payer() const
Definition: market.hpp:228
graphene::protocol::limit_order_update_operation::new_price
optional< price > new_price
Definition: market.hpp:126
graphene::protocol::execute_bid_operation::debt
asset debt
Definition: market.hpp:271
graphene::protocol::extension< options_type >
graphene::protocol::execute_bid_operation::fee_params_t
Definition: market.hpp:264
graphene::protocol::execute_bid_operation
Definition: market.hpp:262
graphene::protocol::call_order_update_operation::delta_debt
asset delta_debt
the amount of the debt to be paid off, may be negative to issue new debt
Definition: market.hpp:190
graphene::protocol::limit_order_create_operation::amount_to_sell
asset amount_to_sell
Definition: market.hpp:89
graphene::protocol::limit_order_update_operation::seller
account_id_type seller
Definition: market.hpp:124
graphene::protocol::create_take_profit_order_action::extensions
extensions_type extensions
Unused. Reserved for future use.
Definition: market.hpp:46
graphene::protocol::execute_bid_operation::fee
asset fee
Definition: market.hpp:273
graphene::protocol::fill_order_operation
Definition: market.hpp:206
graphene::protocol::bid_collateral_operation
Definition: market.hpp:241
graphene::protocol::price
The price struct stores asset prices in the BitShares system.
Definition: asset.hpp:108
fc::static_variant
Definition: raw_fwd.hpp:27
graphene::protocol::limit_order_update_operation::extensions
extensions_type extensions
Definition: market.hpp:132
graphene::protocol::create_take_profit_order_action
Definition: market.hpp:33
graphene::protocol::fill_order_operation::fee_params_t
Definition: market.hpp:208
graphene::protocol::call_order_update_operation::validate
void validate() const
Definition: market.cpp:89
graphene::protocol::limit_order_cancel_operation::validate
void validate() const
Definition: market.cpp:84
graphene::protocol::fill_order_operation::fill_price
price fill_price
Definition: market.hpp:219
graphene::protocol::bid_collateral_operation::fee_payer
account_id_type fee_payer() const
Definition: market.hpp:252
graphene::protocol::create_take_profit_order_action::fee_asset_id
asset_id_type fee_asset_id
Asset ID that will be used to pay operation fee for placing the take profit order.
Definition: market.hpp:36
graphene::protocol::limit_order_create_operation::fee_params_t
Definition: market.hpp:85
graphene::protocol::limit_order_create_operation::fee_params_t::fee
uint64_t fee
Definition: market.hpp:85
graphene::protocol::execute_bid_operation::fee_payer
account_id_type fee_payer() const
Definition: market.hpp:275
graphene::protocol::call_order_update_operation::fee
asset fee
Definition: market.hpp:187
graphene::protocol::fill_order_operation::is_maker
bool is_maker
Definition: market.hpp:220
graphene::protocol::limit_order_create_operation::options_type
Definition: market.hpp:79
graphene::protocol::limit_order_update_operation::on_fill
optional< vector< limit_order_auto_action > > on_fill
Automatic actions when the limit order is filled or partially filled.
Definition: market.hpp:130
graphene::protocol::call_order_update_operation::fee_params_t::fee
uint64_t fee
Definition: market.hpp:185
graphene::protocol::bid_collateral_operation::debt_covered
asset debt_covered
the amount of debt to take over
Definition: market.hpp:249
fc::time_point_sec::maximum
static time_point_sec maximum()
Definition: time.hpp:86
graphene::protocol::call_order_update_operation::delta_collateral
asset delta_collateral
the amount of collateral to add to the margin position
Definition: market.hpp:189
graphene::protocol::bid_collateral_operation::additional_collateral
asset additional_collateral
the amount of collateral to bid for the debt
Definition: market.hpp:248
graphene::protocol::limit_order_update_operation::fee
asset fee
Definition: market.hpp:123
graphene::protocol::fill_order_operation::fee
asset fee
Definition: market.hpp:218
graphene::protocol::base_operation
Definition: base.hpp:124
graphene::protocol::limit_order_create_operation::get_market
pair< asset_id_type, asset_id_type > get_market() const
Definition: market.hpp:102
graphene::protocol::limit_order_cancel_operation::fee_params_t::fee
uint64_t fee
Definition: market.hpp:147
graphene::protocol::bid_collateral_operation::fee_params_t
Definition: market.hpp:244
graphene::protocol::fill_order_operation::pays
asset pays
Definition: market.hpp:216
graphene::protocol::call_order_update_operation::options_type::target_collateral_ratio
optional< uint16_t > target_collateral_ratio
Maximum CR to maintain when selling collateral on margin call.
Definition: market.hpp:181
graphene::protocol::limit_order_create_operation::seller
account_id_type seller
Definition: market.hpp:88
graphene::protocol::limit_order_update_operation::new_expiration
optional< time_point_sec > new_expiration
Definition: market.hpp:128
GRAPHENE_BLOCKCHAIN_PRECISION
#define GRAPHENE_BLOCKCHAIN_PRECISION
Definition: config.hpp:29
graphene::protocol::limit_order_create_operation::extensions
extensions_type extensions
Definition: market.hpp:100
graphene::protocol::bid_collateral_operation::validate
void validate() const
Definition: market.cpp:99
graphene::protocol::call_order_update_operation
Definition: market.hpp:171
graphene::protocol::limit_order_update_operation
Definition: market.hpp:117
graphene::protocol::create_take_profit_order_action::size_percent
uint16_t size_percent
A percentage indicating how much amount to sell in the take profit order.
Definition: market.hpp:40
fc::time_point_sec
Definition: time.hpp:74
graphene::protocol::asset::asset_id
asset_id_type asset_id
Definition: asset.hpp:37
graphene::protocol::call_order_update_operation::fee_params_t
Definition: market.hpp:185
graphene::protocol::fill_order_operation::account_id
account_id_type account_id
Definition: market.hpp:215
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
graphene::protocol::limit_order_cancel_operation::fee_params_t
Definition: market.hpp:147
graphene::protocol::create_take_profit_order_action::expiration_seconds
uint32_t expiration_seconds
How long the take profit order to be kept on the market.
Definition: market.hpp:42
graphene::protocol::limit_order_create_operation::validate
void validate() const
Definition: market.cpp:49
graphene::protocol::execute_bid_operation::validate
void validate() const
Definition: market.hpp:276
graphene::protocol::limit_order_cancel_operation
Definition: market.hpp:145
graphene::protocol::call_order_update_operation::extensions
extensions_type extensions
Definition: market.hpp:193
graphene::protocol::limit_order_create_operation::expiration
time_point_sec expiration
Definition: market.hpp:94
graphene::protocol::limit_order_update_operation::order
limit_order_id_type order
Definition: market.hpp:125
graphene::protocol::fill_order_operation::fill_order_operation
fill_order_operation()
Definition: market.hpp:210
graphene::protocol::limit_order_create_operation::fee_payer
account_id_type fee_payer() const
Definition: market.hpp:108
graphene::protocol::fill_order_operation::validate
void validate() const
Definition: market.hpp:229
graphene::protocol::limit_order_create_operation::min_to_receive
asset min_to_receive
Definition: market.hpp:90
graphene::protocol::call_order_update_operation::fee_payer
account_id_type fee_payer() const
Definition: market.hpp:195
graphene::protocol::create_take_profit_order_action::spread_percent
uint16_t spread_percent
A percentage indicating how far the price of the take profit order differs from the original order.
Definition: market.hpp:38
graphene::protocol::limit_order_cancel_operation::fee_payer
account_id_type fee_payer() const
Definition: market.hpp:155
graphene::protocol::limit_order_create_operation::fee
asset fee
Definition: market.hpp:87
FC_ASSERT
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
graphene::protocol::execute_bid_operation::bidder
account_id_type bidder
Definition: market.hpp:270
graphene::protocol::bid_collateral_operation::fee_params_t::fee
uint64_t fee
Definition: market.hpp:244
base.hpp
graphene::protocol::create_take_profit_order_action::validate
void validate() const
Definition: market.cpp:30
graphene::protocol::limit_order_cancel_operation::fee
asset fee
Definition: market.hpp:149
graphene::db::object_id_type
Definition: object_id.hpp:30
graphene::protocol::call_order_update_operation::options_type
Definition: market.hpp:178
graphene::protocol::fill_order_operation::get_market
pair< asset_id_type, asset_id_type > get_market() const
Definition: market.hpp:222
graphene::protocol::limit_order_update_operation::fee_params_t
Definition: market.hpp:119
graphene::protocol::execute_bid_operation::collateral
asset collateral
Definition: market.hpp:272
graphene::protocol::bid_collateral_operation::fee
asset fee
Definition: market.hpp:246
graphene::protocol::limit_order_cancel_operation::fee_paying_account
account_id_type fee_paying_account
Definition: market.hpp:152
graphene::protocol::execute_bid_operation::calculate_fee
share_type calculate_fee(const fee_params_t &) const
This is a virtual operation; there is no fee.
Definition: market.hpp:279
graphene::protocol::fill_order_operation::receives
asset receives
Definition: market.hpp:217
graphene::protocol::limit_order_cancel_operation::extensions
extensions_type extensions
Definition: market.hpp:153
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::protocol::limit_order_cancel_operation::order
limit_order_id_type order
Definition: market.hpp:150
graphene::protocol::limit_order_create_operation
instructs the blockchain to attempt to sell one asset for another
Definition: market.hpp:72
graphene::protocol::fill_order_operation::fill_order_operation
fill_order_operation(object_id_type o, account_id_type a, asset p, asset r, asset f, price fp, bool m)
Definition: market.hpp:211
graphene::protocol::limit_order_update_operation::fee_params_t::fee
uint64_t fee
Definition: market.hpp:120
fc::optional
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
graphene::protocol::limit_order_create_operation::options_type::on_fill
optional< vector< limit_order_auto_action > > on_fill
Automatic actions when the limit order is filled or partially filled.
Definition: market.hpp:82
graphene::protocol::limit_order_create_operation::get_price
price get_price() const
Definition: market.hpp:110
graphene::protocol::asset
Definition: asset.hpp:31
graphene::protocol::limit_order_create_operation::fill_or_kill
bool fill_or_kill
If this flag is set the entire order must be filled or the operation is rejected.
Definition: market.hpp:97
asset.hpp
graphene::protocol::execute_bid_operation::execute_bid_operation
execute_bid_operation()
Definition: market.hpp:266
graphene::protocol::bid_collateral_operation::extensions
extensions_type extensions
Definition: market.hpp:250
graphene::protocol::limit_order_update_operation::delta_amount_to_sell
optional< asset > delta_amount_to_sell
Definition: market.hpp:127
graphene::protocol::fill_order_operation::calculate_fee
share_type calculate_fee(const fee_params_t &) const
This is a virtual operation; there is no fee.
Definition: market.hpp:232
graphene::protocol::fill_order_operation::order_id
object_id_type order_id
Definition: market.hpp:214
graphene::protocol::call_order_update_operation::funding_account
account_id_type funding_account
pays fee, collateral, and cover
Definition: market.hpp:188
GRAPHENE_100_PERCENT
#define GRAPHENE_100_PERCENT
Definition: config.hpp:102
graphene
Definition: api.cpp:48
graphene::protocol::limit_order_update_operation::validate
void validate() const override
Definition: market.cpp:65
graphene::protocol::create_take_profit_order_action::repeat
bool repeat
Whether to create another take profit order for this take profit order if this take profit order is m...
Definition: market.hpp:44
graphene::protocol::extensions_type
future_extensions::flat_set_type extensions_type
Definition: base.hpp:156
fc::safe
Definition: safe.hpp:26