Flex
Flex exchange system
FlexClient.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <tvm/schema/message.hpp>
10 #include <tvm/smart_switcher.hpp>
11 #include <tvm/contract_handle.hpp>
12 
13 #include "PriceXchg.hpp"
14 #include "FlexVersion.hpp"
15 #include "FlexClientStub.hpp"
16 #include "EverReTransferArgs.hpp"
17 
18 namespace tvm {
19 
22 
25  uint256 owner;
27  opt<FlexVersion> ex_triplet;
30 };
31 
33 struct BurnInfo {
34  uint256 out_pubkey;
35  address_opt out_owner;
36  address wallet;
37  opt<cell> notify;
39 };
40 
42 
45 __interface IFlexClient {
46 
48  [[external]]
49  address deployPriceXchg(
50  bool sell,
51  bool immediate_client,
53  bool post_order,
54  uint128 price_num,
55  uint128 amount,
56  uint128 lend_amount,
57  uint32 lend_finish_time,
58  uint128 evers,
59  cell unsalted_price_code,
60  cell price_salt,
61  address my_tip3_addr,
62  uint256 user_id,
63  uint256 order_id
64  ) = 10;
65 
67  [[external]]
69  bool sell,
70  uint128 price_num,
71  uint128 value,
72  cell salted_price_code,
73  opt<uint256> user_id,
74  opt<uint256> order_id
75  ) = 11;
76 
78  [[external]]
79  void transfer(
80  address dest,
81  uint128 value,
82  bool bounce
83  ) = 12;
84 
86  [[external]]
88  address src,
89  Tip3Creds dst,
90  uint128 tokens,
91  uint128 evers,
92  uint128 keep_evers
93  ) = 13;
94 
96  [[external]]
98  uint256 pubkey,
99  uint128 evers_to_wallet,
100  Tip3Config tip3cfg,
101  uint256 trader,
102  cell flex_wallet_code
103  ) = 14;
104 
106  [[external]]
108  uint256 user_id,
109  uint256 lend_pubkey,
110  string name,
111  uint128 evers_all,
112  uint128 evers_to_auth_idx,
113  uint128 refill_wallet,
114  uint128 min_refill
115  ) = 15;
116 
119  [[external]]
121  uint256 user_id,
122  bool set_binding,
123  opt<bind_info> binding,
124  bool set_trader,
125  opt<uint256> trader,
126  dict_array<address> wallets,
127  uint128 evers_relend_call,
128  uint128 evers_each_wallet_call,
129  uint128 evers_to_remove,
130  uint128 evers_to_auth_idx
131  ) = 16;
132 
134  [[external]]
136  uint256 user_id,
137  uint128 evers
138  ) = 17;
139 
141  [[external]]
143  uint128 evers_value,
144  uint256 out_pubkey,
145  address_opt out_owner,
146  address my_tip3_addr,
147  opt<cell> notify
149  ) = 18;
150 
152  [[external]]
154  uint128 burn_ev,
155  dict_array<BurnInfo> burns
156  ) = 19;
157 
159  [[internal]]
161 
163  [[external]]
165  uint128 cancel_ev,
167  dict_array<address> prices
168  ) = 20;
169 
171  [[internal]]
173 
175  [[external]]
177  uint128 evers_value,
178  uint256 out_pubkey,
179  address_opt out_owner,
180  address my_tip3_addr,
181  uint128 tokens,
182  opt<cell> notify
184  ) = 21;
185 
187  [[external]]
189  uint128 evers,
190  address my_tip3_addr,
191  bool set_binding,
192  opt<bind_info> binding,
193  bool set_trader,
194  opt<uint256> trader
195  ) = 22;
196 
199  [[internal, answer_id]]
200  resumable<void> onTip3Transfer(
201  uint128 balance,
202  uint128 new_tokens,
203  uint128 evers_balance,
204  Tip3Config tip3cfg,
205  opt<Tip3Creds> sender,
206  Tip3Creds receiver,
207  cell payload,
208  address answer_addr
209  ) = 202;
210 
212  [[external]]
213  resumable<void> upgrade(
214  uint128 request_evers,
215  address user_data_cfg
216  ) = 23;
217 
220  [[getter]]
222  uint256 owner_pubkey,
223  address_opt owner_addr,
224  uint128 evers,
225  uint128 keep_evers
226  ) = 24;
227 
229  [[getter]]
231  uint128 wallet_deploy_evers,
232  uint128 wallet_keep_evers
233  ) = 25;
234 
236  [[getter]]
238  uint128 price_num,
239  cell salted_price_code
240  ) = 26;
241 
243  [[getter]]
244  address getUserIdIndex(
245  uint256 user_id
246  ) = 27;
247 
249  [[getter]]
251 };
252 using IFlexClientPtr = handle<IFlexClient>;
253 
255 struct DFlexClient1 {
256  uint256 owner_;
261  opt<bind_info> binding_;
263  uint128 burn_ev_;
264  dict_array<BurnInfo> burns_;
266  uint128 cancel_ev_;
267  dict_array<address> prices_;
268 };
269 
270 using DFlexClient = DFlexClient1;
271 
274 __interface EFlexClient {
275 };
276 
277 } // namespace tvm
278 
FlexClientStub contract interfaces and data-structs.
Flex version structure.
PriceXchg contract interfaces and data-structs PriceXchg - contract to enqueue and process tip3-tip3 ...
Burn parameters for each wallet in burnThemAll
Definition: FlexClient.hpp:33
uint256 out_pubkey
Public key for external wallet (out)
Definition: FlexClient.hpp:34
address_opt out_owner
Internal (contract) owner for external wallet (out)
Definition: FlexClient.hpp:35
address wallet
Wallet address.
Definition: FlexClient.hpp:36
opt< cell > notify
Definition: FlexClient.hpp:37
FlexClient persistent data struct.
Definition: FlexClient.hpp:255
uint256 owner_
Owner's public key.
Definition: FlexClient.hpp:256
dict_array< BurnInfo > burns_
Array of burn parameters for each wallet.
Definition: FlexClient.hpp:264
bool_t packet_canceling_
When cancelThemAll was postponed into continueCancelThemAll call.
Definition: FlexClient.hpp:265
optcell auth_index_code_
AuthIndex code.
Definition: FlexClient.hpp:259
uint128 burn_ev_
Processing evers for each wallet burn call.
Definition: FlexClient.hpp:263
FlexVersion ex_triplet_
Ex-version triplet (initialized during code upgrade)
Definition: FlexClient.hpp:258
optcell user_id_index_code_
UserIdIndex code.
Definition: FlexClient.hpp:260
uint128 cancel_ev_
Processing evers for each wallet cancelOrder call.
Definition: FlexClient.hpp:266
FlexVersion triplet_
Version triplet.
Definition: FlexClient.hpp:257
bool_t packet_burning_
When burnThemAll was postponed into continueBurnThemAll call.
Definition: FlexClient.hpp:262
dict_array< address > prices_
Array of PriceXchg addresses.
Definition: FlexClient.hpp:267
opt< bind_info > binding_
Binding info for exchange.
Definition: FlexClient.hpp:261
FlexClientStub persistent data struct.
Definition: FlexClientStub.hpp:47
FlexClient events interface.
Definition: FlexClient.hpp:274
FlexClient details (for getter)
Definition: FlexClient.hpp:24
FlexVersion triplet
Version triplet.
Definition: FlexClient.hpp:26
cell user_id_index_code
UserIdIndex code.
Definition: FlexClient.hpp:29
cell auth_index_code
AuthIndex code.
Definition: FlexClient.hpp:28
uint256 owner
Owner's public key.
Definition: FlexClient.hpp:25
opt< FlexVersion > ex_triplet
Ex-version triplet (initialized during code upgrade)
Definition: FlexClient.hpp:27
Flex version triplet.
Definition: FlexVersion.hpp:14
FlexClient is client contract for Flex.
Definition: FlexClient.hpp:45
void unwrapWallet(uint128 evers_value, uint256 out_pubkey, address_opt out_owner, address my_tip3_addr, uint128 tokens, opt< cell > notify)
To convert some flex tip3 tokens back to external tip3 tokens.
void burnThemAll(uint128 burn_ev, dict_array< BurnInfo > burns)
To convert many flex tip3 tokens back to external tip3 tokens (with destruction of the wallets).
void reBindWallets(uint256 user_id, bool set_binding, opt< bind_info > binding, bool set_trader, opt< uint256 > trader, dict_array< address > wallets, uint128 evers_relend_call, uint128 evers_each_wallet_call, uint128 evers_to_remove, uint128 evers_to_auth_idx)
cell getPayloadForEverReTransferArgs(uint128 wallet_deploy_evers, uint128 wallet_keep_evers)
Prepare payload for burn for WrapperEver -> WrapperEver transfer (EverReTransferArgs struct)
void burnWallet(uint128 evers_value, uint256 out_pubkey, address_opt out_owner, address my_tip3_addr, opt< cell > notify)
To convert flex tip3 tokens back to external tip3 tokens (with destruction of the wallet).
cell getPayloadForDeployInternalWallet(uint256 owner_pubkey, address_opt owner_addr, uint128 evers, uint128 keep_evers)
address deployPriceXchg(bool sell, bool immediate_client, bool post_order, uint128 price_num, uint128 amount, uint128 lend_amount, uint32 lend_finish_time, uint128 evers, cell unsalted_price_code, cell price_salt, address my_tip3_addr, uint256 user_id, uint256 order_id)
Deploy tip3-tip3 PriceXchg contract with sell or buy order.
void deployIndex(uint256 user_id, uint256 lend_pubkey, string name, uint128 evers_all, uint128 evers_to_auth_idx, uint128 refill_wallet, uint128 min_refill)
Deploy UserIdIndex contract.
void destroyIndex(uint256 user_id, uint128 evers)
Remove UserIdIndex contract.
void cancelThemAll(uint128 cancel_ev, dict_array< address > prices)
To cancel all orders for the provided wallets.
address deployEmptyFlexWallet(uint256 pubkey, uint128 evers_to_wallet, Tip3Config tip3cfg, uint256 trader, cell flex_wallet_code)
Deploy an empty flex tip3 token wallet, owned by FlexClient contract.
void transfer(address dest, uint128 value, bool bounce)
Transfer evers.
FlexClientDetails getDetails()
Get contract state details.
address getPriceXchgAddress(uint128 price_num, cell salted_price_code)
Get PriceXchg address.
resumable< void > onTip3Transfer(uint128 balance, uint128 new_tokens, uint128 evers_balance, Tip3Config tip3cfg, opt< Tip3Creds > sender, Tip3Creds receiver, cell payload, address answer_addr)
void transferTokens(address src, Tip3Creds dst, uint128 tokens, uint128 evers, uint128 keep_evers)
Transfer tokens.
void continueCancelThemAll()
Will send to itself from cancelThemAll if prices are more than 255 / 2 (we need two messages per pric...
address getUserIdIndex(uint256 user_id)
Return UserIdIndex address.
void bindWallet(uint128 evers, address my_tip3_addr, bool set_binding, opt< bind_info > binding, bool set_trader, opt< uint256 > trader)
Bind trading wallet to a specific flex and PriceXchg code hash and set trader (lend pubkey)
void cancelXchgOrder(bool sell, uint128 price_num, uint128 value, cell salted_price_code, opt< uint256 > user_id, opt< uint256 > order_id)
Cancel tip3-tip sell or buy order.
void continueBurnThemAll()
Will send to itself from burnThemAll if wallets are more than 255.
resumable< void > upgrade(uint128 request_evers, address user_data_cfg)
Upgrade FlexClient to the specific UserDataConfig.