BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
market_evaluator.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
26 #include <graphene/chain/types.hpp>
27 
28 namespace graphene { namespace chain {
29 
30  class account_object;
31  class asset_object;
32  class asset_bitasset_data_object;
33  class call_order_object;
34  class limit_order_object;
35  class collateral_bid_object;
36 
37  class limit_order_create_evaluator : public evaluator<limit_order_create_evaluator>
38  {
39  public:
41 
44 
47  void convert_fee() override;
48 
52  void pay_fee() override;
53 
54  private:
55  share_type _deferred_fee = 0;
56  asset _deferred_paid_fee;
57  const account_object* _seller = nullptr;
58  const asset_object* _sell_asset = nullptr;
59  const asset_object* _receive_asset = nullptr;
60  };
61 
62  class limit_order_update_evaluator : public evaluator<limit_order_update_evaluator>
63  {
64  public:
66 
69 
72  void convert_fee() override;
73 
77  void pay_fee() override;
78 
79  private:
80  void process_deferred_fee();
82  bool is_linked_tp_order_compatible( const limit_order_update_operation& o ) const;
83 
84  share_type _deferred_fee;
85  asset _deferred_paid_fee;
86  const limit_order_object* _order = nullptr;
87  const account_statistics_object* _seller_acc_stats = nullptr;
88  };
89 
90  class limit_order_cancel_evaluator : public evaluator<limit_order_cancel_evaluator>
91  {
92  public:
94 
97 
98  private:
99  const limit_order_object* _order = nullptr;
100  };
101 
102  class call_order_update_evaluator : public evaluator<call_order_update_evaluator>
103  {
104  public:
106 
109 
110  private:
111  bool _closing_order = false;
112  const asset_object* _debt_asset = nullptr;
113  const call_order_object* call_ptr = nullptr;
114  share_type new_debt;
115  share_type new_collateral;
116  const asset_bitasset_data_object* _bitasset_data = nullptr;
117  const asset_dynamic_data_object* _dynamic_data_obj = nullptr;
118  };
119 
120  class bid_collateral_evaluator : public evaluator<bid_collateral_evaluator>
121  {
122  public:
124 
127 
128  private:
129  const asset_object* _debt_asset = nullptr;
130  const asset_bitasset_data_object* _bitasset_data = nullptr;
131  const collateral_bid_object* _bid = nullptr;
132  };
133 
134 } } // graphene::chain
graphene::chain::limit_order_create_evaluator::convert_fee
void convert_fee() override
Definition: market_evaluator.cpp:90
graphene::chain::call_order_update_evaluator::do_evaluate
void_result do_evaluate(const call_order_update_operation &o)
Definition: market_evaluator.cpp:507
graphene::protocol::bid_collateral_operation
Definition: market.hpp:241
graphene::chain::limit_order_update_evaluator::do_apply
void_result do_apply(const limit_order_update_operation &o)
Definition: market_evaluator.cpp:399
graphene::chain::limit_order_update_evaluator::pay_fee
void pay_fee() override
Definition: market_evaluator.cpp:160
graphene::chain::asset_object
tracks the parameters of an asset
Definition: asset_object.hpp:75
graphene::chain::limit_order_update_evaluator
Definition: market_evaluator.hpp:62
graphene::chain::limit_order_update_evaluator::convert_fee
void convert_fee() override
Definition: market_evaluator.cpp:150
graphene::chain::limit_order_update_evaluator::do_evaluate
void_result do_evaluate(const limit_order_update_operation &o)
Definition: market_evaluator.cpp:167
graphene::chain::bid_collateral_evaluator::do_apply
void_result do_apply(const bid_collateral_operation &o) const
Definition: market_evaluator.cpp:862
graphene::chain::account_statistics_object
Definition: account_object.hpp:46
graphene::protocol::call_order_update_operation
Definition: market.hpp:171
graphene::chain::asset_dynamic_data_object
tracks the asset information that changes frequently
Definition: asset_object.hpp:56
graphene::chain::account_object
This class represents an account on the object graph.
Definition: account_object.hpp:180
evaluator.hpp
graphene::protocol::limit_order_update_operation
Definition: market.hpp:117
graphene::chain::evaluator
Definition: evaluator.hpp:142
graphene::chain::asset_bitasset_data_object
contains properties that only apply to bitassets (market issued assets)
Definition: asset_object.hpp:255
graphene::chain::collateral_bid_object
bids of collateral for debt after a black swan
Definition: market_object.hpp:206
graphene::protocol::limit_order_cancel_operation
Definition: market.hpp:145
graphene::chain::call_order_update_evaluator::do_apply
object_id_type do_apply(const call_order_update_operation &o)
Definition: market_evaluator.cpp:592
graphene::chain::bid_collateral_evaluator::do_evaluate
void_result do_evaluate(const bid_collateral_operation &o)
Definition: market_evaluator.cpp:799
graphene::chain::limit_order_cancel_evaluator::do_apply
asset do_apply(const limit_order_cancel_operation &o) const
Definition: market_evaluator.cpp:485
graphene::chain::limit_order_create_evaluator::do_apply
object_id_type do_apply(const limit_order_create_operation &o) const
Definition: market_evaluator.cpp:114
graphene::chain::bid_collateral_evaluator
Definition: market_evaluator.hpp:120
graphene::chain::call_order_update_evaluator
Definition: market_evaluator.hpp:102
graphene::db::object_id_type
Definition: object_id.hpp:30
graphene::chain::limit_order_create_evaluator::do_evaluate
void_result do_evaluate(const limit_order_create_operation &o)
Definition: market_evaluator.cpp:39
graphene::chain::limit_order_cancel_evaluator::do_evaluate
void_result do_evaluate(const limit_order_cancel_operation &o)
Definition: market_evaluator.cpp:466
types.hpp
graphene::chain::call_order_object
tracks debt and call price information
Definition: market_object.hpp:140
graphene::chain::limit_order_create_evaluator::pay_fee
void pay_fee() override
Definition: market_evaluator.cpp:102
graphene::protocol::limit_order_create_operation
instructs the blockchain to attempt to sell one asset for another
Definition: market.hpp:72
graphene::chain::limit_order_cancel_evaluator
Definition: market_evaluator.hpp:90
graphene::protocol::asset
Definition: asset.hpp:31
graphene::protocol::void_result
Definition: base.hpp:86
graphene::chain::limit_order_object
an offer to sell an amount of an asset at a specified exchange rate by a certain time
Definition: market_object.hpp:45
graphene
Definition: api.cpp:48
graphene::chain::limit_order_create_evaluator
Definition: market_evaluator.hpp:37
fc::safe
Definition: safe.hpp:26