BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
liquidity_pool.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
27 
28 namespace graphene { namespace protocol {
29 
35  {
36  struct fee_params_t { uint64_t fee = 50 * GRAPHENE_BLOCKCHAIN_PRECISION; };
37 
39  account_id_type account;
40  asset_id_type asset_a;
41  asset_id_type asset_b;
42  asset_id_type share_asset;
43  uint16_t taker_fee_percent = 0;
44  uint16_t withdrawal_fee_percent = 0;
45 
47 
48  account_id_type fee_payer()const { return account; }
49  void validate()const;
50  };
51 
57  {
58  struct fee_params_t { uint64_t fee = 0; };
59 
61  account_id_type account;
62  liquidity_pool_id_type pool;
63 
65 
66  account_id_type fee_payer()const { return account; }
67  void validate()const;
68  };
69 
75  {
76  struct fee_params_t { uint64_t fee = 1 * GRAPHENE_BLOCKCHAIN_PRECISION; };
77 
79  account_id_type account;
80  liquidity_pool_id_type pool;
83 
85 
86  account_id_type fee_payer()const { return account; }
87  void validate()const;
88  };
89 
95  {
96  struct fee_params_t { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION / 10; };
97 
99  account_id_type account;
100  liquidity_pool_id_type pool;
103 
105 
106  account_id_type fee_payer()const { return account; }
107  void validate()const;
108  };
109 
115  {
116  struct fee_params_t { uint64_t fee = 5 * GRAPHENE_BLOCKCHAIN_PRECISION; };
117 
119  account_id_type account;
120  liquidity_pool_id_type pool;
122 
124 
125  account_id_type fee_payer()const { return account; }
126  void validate()const;
127  };
128 
139  {
140  struct fee_params_t { uint64_t fee = 1 * GRAPHENE_BLOCKCHAIN_PRECISION; };
141 
143  account_id_type account;
144  liquidity_pool_id_type pool;
147 
149 
150  account_id_type fee_payer()const { return account; }
151  void validate()const;
152  };
153 
154 } } // graphene::protocol
155 
162 
164  (fee)(account)(asset_a)(asset_b)(share_asset)
165  (taker_fee_percent)(withdrawal_fee_percent)(extensions) )
167  (fee)(account)(pool)(extensions) )
169  (fee)(account)(pool)(taker_fee_percent)(withdrawal_fee_percent)(extensions) )
171  (fee)(account)(pool)(amount_a)(amount_b)(extensions) )
173  (fee)(account)(pool)(share_amount)(extensions) )
175  (fee)(account)(pool)(amount_to_sell)(min_to_receive)(extensions) )
176 
183 
graphene::protocol::liquidity_pool_withdraw_operation::fee_params_t::fee
uint64_t fee
Definition: liquidity_pool.hpp:116
graphene::protocol::liquidity_pool_delete_operation::validate
void validate() const
Definition: liquidity_pool.cpp:40
graphene::protocol::liquidity_pool_exchange_operation::pool
liquidity_pool_id_type pool
ID of the liquidity pool.
Definition: liquidity_pool.hpp:144
graphene::protocol::liquidity_pool_update_operation::validate
void validate() const
Definition: liquidity_pool.cpp:45
graphene::protocol::liquidity_pool_update_operation::fee_payer
account_id_type fee_payer() const
Definition: liquidity_pool.hpp:86
graphene::protocol::liquidity_pool_delete_operation::extensions
extensions_type extensions
Unused. Reserved for future use.
Definition: liquidity_pool.hpp:64
graphene::protocol::liquidity_pool_withdraw_operation::account
account_id_type account
The account who withdraws from the liquidity pool.
Definition: liquidity_pool.hpp:119
graphene::protocol::liquidity_pool_create_operation::asset_a
asset_id_type asset_a
Type of the first asset in the pool.
Definition: liquidity_pool.hpp:40
graphene::protocol::liquidity_pool_deposit_operation::amount_b
asset amount_b
The amount of the second asset to deposit.
Definition: liquidity_pool.hpp:102
graphene::protocol::liquidity_pool_exchange_operation
Exchange with a liquidity pool.
Definition: liquidity_pool.hpp:138
graphene::protocol::liquidity_pool_create_operation::fee_params_t
Definition: liquidity_pool.hpp:36
graphene::protocol::liquidity_pool_withdraw_operation::fee_params_t
Definition: liquidity_pool.hpp:116
graphene::protocol::liquidity_pool_create_operation::asset_b
asset_id_type asset_b
Type of the second asset in the pool.
Definition: liquidity_pool.hpp:41
graphene::protocol::liquidity_pool_create_operation
Create a new liquidity pool.
Definition: liquidity_pool.hpp:34
graphene::protocol::liquidity_pool_update_operation::fee
asset fee
Operation fee.
Definition: liquidity_pool.hpp:78
graphene::protocol::liquidity_pool_update_operation::withdrawal_fee_percent
optional< uint16_t > withdrawal_fee_percent
Withdrawal fee percent.
Definition: liquidity_pool.hpp:82
graphene::protocol::base_operation
Definition: base.hpp:124
graphene::protocol::liquidity_pool_delete_operation::pool
liquidity_pool_id_type pool
ID of the liquidity pool.
Definition: liquidity_pool.hpp:62
graphene::protocol::liquidity_pool_deposit_operation::account
account_id_type account
The account who deposits to the liquidity pool.
Definition: liquidity_pool.hpp:99
graphene::protocol::liquidity_pool_create_operation::withdrawal_fee_percent
uint16_t withdrawal_fee_percent
Withdrawal fee percent.
Definition: liquidity_pool.hpp:44
graphene::protocol::liquidity_pool_update_operation::extensions
extensions_type extensions
Unused. Reserved for future use.
Definition: liquidity_pool.hpp:84
graphene::protocol::liquidity_pool_withdraw_operation
Withdraw from a liquidity pool.
Definition: liquidity_pool.hpp:114
graphene::protocol::liquidity_pool_withdraw_operation::share_amount
asset share_amount
The amount of the share asset to use.
Definition: liquidity_pool.hpp:121
graphene::protocol::liquidity_pool_delete_operation::fee
asset fee
Operation fee.
Definition: liquidity_pool.hpp:60
graphene::protocol::liquidity_pool_exchange_operation::extensions
extensions_type extensions
Unused. Reserved for future use.
Definition: liquidity_pool.hpp:148
graphene::protocol::liquidity_pool_create_operation::fee_params_t::fee
uint64_t fee
Definition: liquidity_pool.hpp:36
graphene::protocol::liquidity_pool_create_operation::fee_payer
account_id_type fee_payer() const
Definition: liquidity_pool.hpp:48
GRAPHENE_BLOCKCHAIN_PRECISION
#define GRAPHENE_BLOCKCHAIN_PRECISION
Definition: config.hpp:29
graphene::protocol::liquidity_pool_deposit_operation::validate
void validate() const
Definition: liquidity_pool.cpp:55
graphene::protocol::liquidity_pool_exchange_operation::fee_payer
account_id_type fee_payer() const
Definition: liquidity_pool.hpp:150
graphene::protocol::liquidity_pool_deposit_operation::fee_payer
account_id_type fee_payer() const
Definition: liquidity_pool.hpp:106
graphene::protocol::liquidity_pool_deposit_operation
Deposit to a liquidity pool.
Definition: liquidity_pool.hpp:94
graphene::protocol::liquidity_pool_exchange_operation::fee
asset fee
Operation fee.
Definition: liquidity_pool.hpp:142
graphene::protocol::liquidity_pool_create_operation::validate
void validate() const
Definition: liquidity_pool.cpp:30
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
graphene::protocol::liquidity_pool_deposit_operation::extensions
extensions_type extensions
Unused. Reserved for future use.
Definition: liquidity_pool.hpp:104
graphene::protocol::liquidity_pool_deposit_operation::fee
asset fee
Operation fee.
Definition: liquidity_pool.hpp:98
graphene::protocol::liquidity_pool_deposit_operation::fee_params_t::fee
uint64_t fee
Definition: liquidity_pool.hpp:96
graphene::protocol::liquidity_pool_withdraw_operation::pool
liquidity_pool_id_type pool
ID of the liquidity pool.
Definition: liquidity_pool.hpp:120
graphene::protocol::liquidity_pool_delete_operation::fee_params_t::fee
uint64_t fee
Definition: liquidity_pool.hpp:58
graphene::protocol::liquidity_pool_exchange_operation::min_to_receive
asset min_to_receive
The minimum amount of the other asset type to receive.
Definition: liquidity_pool.hpp:146
graphene::protocol::liquidity_pool_exchange_operation::amount_to_sell
asset amount_to_sell
The amount of one asset type to sell.
Definition: liquidity_pool.hpp:145
graphene::protocol::liquidity_pool_withdraw_operation::fee_payer
account_id_type fee_payer() const
Definition: liquidity_pool.hpp:125
graphene::protocol::liquidity_pool_delete_operation::account
account_id_type account
The account who owns the liquidity pool.
Definition: liquidity_pool.hpp:61
graphene::protocol::liquidity_pool_update_operation::taker_fee_percent
optional< uint16_t > taker_fee_percent
Taker fee percent.
Definition: liquidity_pool.hpp:81
graphene::protocol::liquidity_pool_deposit_operation::fee_params_t
Definition: liquidity_pool.hpp:96
graphene::protocol::liquidity_pool_update_operation::fee_params_t
Definition: liquidity_pool.hpp:76
graphene::protocol::liquidity_pool_create_operation::fee
asset fee
Operation fee.
Definition: liquidity_pool.hpp:38
graphene::protocol::liquidity_pool_deposit_operation::pool
liquidity_pool_id_type pool
ID of the liquidity pool.
Definition: liquidity_pool.hpp:100
graphene::protocol::liquidity_pool_create_operation::share_asset
asset_id_type share_asset
Type of the share asset aka the LP token.
Definition: liquidity_pool.hpp:42
graphene::protocol::liquidity_pool_create_operation::extensions
extensions_type extensions
Unused. Reserved for future use.
Definition: liquidity_pool.hpp:46
base.hpp
graphene::protocol::liquidity_pool_update_operation
Update a liquidity pool.
Definition: liquidity_pool.hpp:74
graphene::protocol::liquidity_pool_update_operation::fee_params_t::fee
uint64_t fee
Definition: liquidity_pool.hpp:76
graphene::protocol::liquidity_pool_deposit_operation::amount_a
asset amount_a
The amount of the first asset to deposit.
Definition: liquidity_pool.hpp:101
graphene::protocol::liquidity_pool_withdraw_operation::fee
asset fee
Operation fee.
Definition: liquidity_pool.hpp:118
graphene::protocol::liquidity_pool_delete_operation
Delete a liquidity pool.
Definition: liquidity_pool.hpp:56
graphene::protocol::liquidity_pool_withdraw_operation::validate
void validate() const
Definition: liquidity_pool.cpp:63
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::protocol::liquidity_pool_withdraw_operation::extensions
extensions_type extensions
Unused. Reserved for future use.
Definition: liquidity_pool.hpp:123
graphene::protocol::liquidity_pool_exchange_operation::validate
void validate() const
Definition: liquidity_pool.cpp:69
graphene::protocol::liquidity_pool_delete_operation::fee_payer
account_id_type fee_payer() const
Definition: liquidity_pool.hpp:66
graphene::protocol::liquidity_pool_exchange_operation::account
account_id_type account
The account who exchanges with the liquidity pool.
Definition: liquidity_pool.hpp:143
fc::optional
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
graphene::protocol::liquidity_pool_create_operation::account
account_id_type account
The account who creates the liquidity pool.
Definition: liquidity_pool.hpp:39
graphene::protocol::liquidity_pool_update_operation::pool
liquidity_pool_id_type pool
ID of the liquidity pool.
Definition: liquidity_pool.hpp:80
graphene::protocol::asset
Definition: asset.hpp:31
graphene::protocol::liquidity_pool_delete_operation::fee_params_t
Definition: liquidity_pool.hpp:58
graphene::protocol::liquidity_pool_exchange_operation::fee_params_t
Definition: liquidity_pool.hpp:140
asset.hpp
graphene::protocol::liquidity_pool_create_operation::taker_fee_percent
uint16_t taker_fee_percent
Taker fee percent.
Definition: liquidity_pool.hpp:43
graphene
Definition: api.cpp:48
graphene::protocol::extensions_type
future_extensions::flat_set_type extensions_type
Definition: base.hpp:156
graphene::protocol::liquidity_pool_exchange_operation::fee_params_t::fee
uint64_t fee
Definition: liquidity_pool.hpp:140
graphene::protocol::liquidity_pool_update_operation::account
account_id_type account
The account who owns the liquidity pool.
Definition: liquidity_pool.hpp:79