Flex
Flex exchange system
FlexClientTestUpdate.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 
21 using DFlexClient0 = DFlexClientStub;
22 
24 struct FlexClientDetails {
25  uint256 owner;
26  FlexVersion triplet;
27  opt<FlexVersion> ex_triplet;
28  cell auth_index_code;
29  cell user_id_index_code;
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 evers_value,
166  uint256 out_pubkey,
167  address_opt out_owner,
168  address my_tip3_addr,
169  uint128 tokens,
170  opt<cell> notify
172  ) = 20;
173 
175  [[external]]
177  uint128 evers,
178  address my_tip3_addr,
179  bool set_binding,
180  opt<bind_info> binding,
181  bool set_trader,
182  opt<uint256> trader
183  ) = 21;
184 
187  [[internal, answer_id]]
188  resumable<void> onTip3Transfer(
189  uint128 balance,
190  uint128 new_tokens,
191  uint128 evers_balance,
192  Tip3Config tip3cfg,
193  opt<Tip3Creds> sender,
194  Tip3Creds receiver,
195  cell payload,
196  address answer_addr
197  ) = 202;
198 
200  [[external]]
201  resumable<void> upgrade(
202  uint128 request_evers,
203  address user_data_cfg
204  ) = 22;
205 
208  [[getter]]
210  uint256 owner_pubkey,
211  address_opt owner_addr,
212  uint128 evers,
213  uint128 keep_evers
214  ) = 23;
215 
217  [[getter]]
219  uint128 wallet_deploy_evers,
220  uint128 wallet_keep_evers
221  ) = 24;
222 
224  [[getter]]
226  uint128 price_num,
227  cell salted_price_code
228  ) = 25;
229 
231  [[getter]]
232  address getUserIdIndex(
233  uint256 user_id
234  ) = 26;
235 
237  [[getter]]
239 
241  [[getter]]
242  uint32 getTestValue() = 28;
243 };
244 using IFlexClientPtr = handle<IFlexClient>;
245 
247 struct DFlexClient1 {
248  uint256 owner_;
251  optcell auth_index_code_;
252  optcell user_id_index_code_;
253  opt<bind_info> binding_;
254  bool_t packet_burning_;
255  uint128 burn_ev_;
256  dict_array<BurnInfo> burns_;
257 };
258 
259 using DFlexClient = DFlexClient1;
260 
263 __interface EFlexClient {
264 };
265 
266 } // namespace tvm
267 
FlexClientStub contract interfaces and data-structs.
DFlexClientStub DFlexClient0
Initial persistent data structure.
Definition: FlexClient.hpp:21
Flex version structure.
PriceXchg contract interfaces and data-structs PriceXchg - contract to enqueue and process tip3-tip3 ...
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
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
FlexVersion triplet_
Version triplet.
Definition: FlexClient.hpp:257
bool_t packet_burning_
When burnThemAll was postponed into continueBurnThemAll call.
Definition: FlexClient.hpp:262
opt< bind_info > binding_
Binding info for exchange.
Definition: FlexClient.hpp:261
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
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.
uint32 getTestValue()
Get Test value.
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.
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.
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.