BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
liquidity_pool_evaluator.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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
26 
28 
29 namespace graphene { namespace chain {
30 
31  class asset_object;
32  class asset_dynamic_data_object;
33  class liquidity_pool_object;
34 
35  class liquidity_pool_create_evaluator : public evaluator<liquidity_pool_create_evaluator>
36  {
37  public:
39 
42 
43  private:
44  const asset_object* _share_asset = nullptr;
45  };
46 
47  class liquidity_pool_delete_evaluator : public evaluator<liquidity_pool_delete_evaluator>
48  {
49  public:
51 
54 
55  private:
56  const liquidity_pool_object* _pool = nullptr;
57  const asset_object* _share_asset = nullptr;
58  };
59 
60  class liquidity_pool_update_evaluator : public evaluator<liquidity_pool_update_evaluator>
61  {
62  public:
64 
67 
68  private:
69  const liquidity_pool_object* _pool = nullptr;
70  };
71 
72  class liquidity_pool_deposit_evaluator : public evaluator<liquidity_pool_deposit_evaluator>
73  {
74  public:
76 
79 
80  private:
81  const liquidity_pool_object* _pool = nullptr;
82  const asset_dynamic_data_object* _share_asset_dyn_data = nullptr;
83  asset _account_receives;
84  asset _pool_receives_a;
85  asset _pool_receives_b;
86  };
87 
88  class liquidity_pool_withdraw_evaluator : public evaluator<liquidity_pool_withdraw_evaluator>
89  {
90  public:
92 
95 
96  private:
97  const liquidity_pool_object* _pool = nullptr;
98  const asset_dynamic_data_object* _share_asset_dyn_data = nullptr;
99  asset _pool_pays_a;
100  asset _pool_pays_b;
101  asset _fee_a;
102  asset _fee_b;
103  };
104 
105  class liquidity_pool_exchange_evaluator : public evaluator<liquidity_pool_exchange_evaluator>
106  {
107  public:
109 
112 
113  private:
114  const liquidity_pool_object* _pool = nullptr;
115  const asset_object* _pool_pays_asset = nullptr;
116  const asset_object* _pool_receives_asset = nullptr;
117  asset _pool_pays;
118  asset _pool_receives;
119  asset _account_receives;
120  asset _maker_market_fee;
121  asset _taker_market_fee;
122  asset _pool_taker_fee;
123  };
124 
125 } } // graphene::chain
graphene::chain::liquidity_pool_withdraw_evaluator::do_apply
generic_exchange_operation_result do_apply(const liquidity_pool_withdraw_operation &op)
Definition: liquidity_pool_evaluator.cpp:308
graphene::chain::liquidity_pool_create_evaluator::do_evaluate
void_result do_evaluate(const liquidity_pool_create_operation &op)
Definition: liquidity_pool_evaluator.cpp:38
graphene::chain::liquidity_pool_exchange_evaluator::do_evaluate
void_result do_evaluate(const liquidity_pool_exchange_operation &op)
Definition: liquidity_pool_evaluator.cpp:343
graphene::chain::liquidity_pool_exchange_evaluator
Definition: liquidity_pool_evaluator.hpp:105
graphene::protocol::liquidity_pool_exchange_operation
Exchange with a liquidity pool.
Definition: liquidity_pool.hpp:138
graphene::chain::asset_object
tracks the parameters of an asset
Definition: asset_object.hpp:75
graphene::chain::liquidity_pool_update_evaluator::do_evaluate
void_result do_evaluate(const liquidity_pool_update_operation &op)
Definition: liquidity_pool_evaluator.cpp:117
graphene::protocol::liquidity_pool_create_operation
Create a new liquidity pool.
Definition: liquidity_pool.hpp:34
graphene::chain::liquidity_pool_create_evaluator::do_apply
generic_operation_result do_apply(const liquidity_pool_create_operation &op)
Definition: liquidity_pool_evaluator.cpp:64
graphene::chain::liquidity_pool_delete_evaluator::do_apply
generic_operation_result do_apply(const liquidity_pool_delete_operation &op) const
Definition: liquidity_pool_evaluator.cpp:101
graphene::protocol::liquidity_pool_withdraw_operation
Withdraw from a liquidity pool.
Definition: liquidity_pool.hpp:114
graphene::chain::liquidity_pool_withdraw_evaluator
Definition: liquidity_pool_evaluator.hpp:88
graphene::chain::liquidity_pool_update_evaluator::do_apply
void_result do_apply(const liquidity_pool_update_operation &op) const
Definition: liquidity_pool_evaluator.cpp:141
graphene::chain::asset_dynamic_data_object
tracks the asset information that changes frequently
Definition: asset_object.hpp:56
evaluator.hpp
liquidity_pool.hpp
graphene::protocol::generic_exchange_operation_result
Definition: base.hpp:95
graphene::chain::liquidity_pool_delete_evaluator::do_evaluate
void_result do_evaluate(const liquidity_pool_delete_operation &op)
Definition: liquidity_pool_evaluator.cpp:86
graphene::protocol::liquidity_pool_deposit_operation
Deposit to a liquidity pool.
Definition: liquidity_pool.hpp:94
graphene::chain::evaluator
Definition: evaluator.hpp:142
graphene::chain::liquidity_pool_withdraw_evaluator::do_evaluate
void_result do_evaluate(const liquidity_pool_withdraw_operation &op)
Definition: liquidity_pool_evaluator.cpp:254
graphene::chain::liquidity_pool_update_evaluator
Definition: liquidity_pool_evaluator.hpp:60
graphene::protocol::liquidity_pool_update_operation
Update a liquidity pool.
Definition: liquidity_pool.hpp:74
graphene::chain::liquidity_pool_object
A liquidity pool.
Definition: liquidity_pool_object.hpp:44
graphene::protocol::liquidity_pool_delete_operation
Delete a liquidity pool.
Definition: liquidity_pool.hpp:56
graphene::chain::liquidity_pool_deposit_evaluator::do_evaluate
void_result do_evaluate(const liquidity_pool_deposit_operation &op)
Definition: liquidity_pool_evaluator.cpp:155
graphene::chain::liquidity_pool_create_evaluator
Definition: liquidity_pool_evaluator.hpp:35
graphene::chain::liquidity_pool_deposit_evaluator::do_apply
generic_exchange_operation_result do_apply(const liquidity_pool_deposit_operation &op)
Definition: liquidity_pool_evaluator.cpp:224
graphene::protocol::asset
Definition: asset.hpp:31
graphene::chain::liquidity_pool_deposit_evaluator
Definition: liquidity_pool_evaluator.hpp:72
graphene::protocol::void_result
Definition: base.hpp:86
graphene::chain::liquidity_pool_delete_evaluator
Definition: liquidity_pool_evaluator.hpp:47
graphene::protocol::generic_operation_result
Definition: base.hpp:88
graphene
Definition: api.cpp:48
graphene::chain::liquidity_pool_exchange_evaluator::do_apply
generic_exchange_operation_result do_apply(const liquidity_pool_exchange_operation &op)
Definition: liquidity_pool_evaluator.cpp:441