Flex
Flex exchange system
SuperRoot.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 #include <tvm/replay_attack_protection/timestamp.hpp>
13 #include "FlexVersion.hpp"
14 #include "EversConfig.hpp"
15 #include "WICCloneEvers.hpp"
16 #include "PairCloneEvers.hpp"
17 #include "Tip3Config.hpp"
18 #include "bind_info.hpp"
19 
20 namespace tvm {
21 
24  uint256 pubkey;
25  bool stop_trade_;
28  address owner;
29  address_opt update_team;
32  int8 workchain_id;
33  opt<FlexVersion> version;
34  opt<FlexVersion> beta_version;
35  address_opt deploying_cfg;
36  address_opt cur_cfg;
37  address_opt beta_cfg;
38  address_opt prev_super_root;
39  address_opt next_super_root;
40  uint32 revision;
41 };
42 
47 __interface ISuperRoot {
48 
50  [[internal]]
51  void onDeploy(
52  cell global_config_code,
53  cell flex_client_stub,
54  address_opt prev_super_root
55  ) = 10;
56 
61  [[internal]]
62  void update(
63  uint128 cfg_deploy_evers,
64  uint128 cfg_keep_evers,
65  FlexVersion version,
66  address wrappers_cfg,
67  address flex,
68  address user_cfg,
69  string description
70  ) = 11;
71 
74  [[internal]]
76  FlexVersion version
77  ) = 12;
78 
80  [[internal]]
81  void release() = 13;
82 
84  [[internal]]
85  void proxy(
86  cell msg,
87  bool cant_work_during_update,
88  bool starting_update
89  ) = 14;
90 
92  [[internal, answer_id]]
94  uint128 deploy_evers,
95  uint128 wrappers_cfg_keep_evers,
96  uint32 token_version,
97  cell wrappers_cfg_code,
98  cell wic_code
99  ) = 15;
100 
102  [[internal, answer_id]]
103  address deployFlex(
104  uint128 deploy_evers,
105  uint128 keep_evers,
106  PairCloneEvers evers,
107  address_opt old_flex,
108  uint32 exchange_version,
109  cell flex_code,
110  cell xchg_pair_code,
111  cell xchg_price_code,
112  EversConfig ev_cfg,
113  uint8 deals_limit
114  ) = 16;
115 
117  [[internal, answer_id]]
119  uint128 deploy_evers,
120  FlexVersion triplet,
121  bind_info binding,
122  cell user_data_cfg_code,
123  cell flex_client_code,
124  cell auth_index_code,
125  cell user_id_index_code
126  ) = 17;
127 
129  [[internal, answer_id]]
131  address wrappers_cfg,
132  uint128 wrapper_cfg_keep_evers,
133  uint128 clone_deploy_evers,
134  WICCloneEvers wic_evers,
135  uint32 new_token_version,
136  dict_array<address> wrapper_deployers
137  ) = 18;
138 
140  [[internal]]
141  void transfer(
142  address to,
143  uint128 evers
144  ) = 19;
145 
147  [[internal]]
149  address wrapper,
150  uint128 tokens,
151  address to
152  ) = 20;
153 
155  [[internal]]
156  void setFlags(
157  opt<bool> stop_trade,
158  opt<bool> abandon_ship,
159  opt<bool> update_started
160  ) = 21;
161 
163  [[internal]]
164  void setOwner(
165  address owner
166  ) = 22;
167 
169  [[internal]]
171  address_opt team
172  ) = 23;
173 
175  [[internal]]
177  address next_super_root
178  ) = 24;
179 
181  [[getter]]
183 
185  [[getter]]
186  address getGlobalConfig(FlexVersion version) = 26;
187 
189  [[getter]]
190  address getCurrentGlobalConfig() = 27;
191 };
192 using ISuperRootPtr = handle<ISuperRoot>;
193 
195 struct DSuperRoot {
196  uint256 pubkey_;
197  bool_t stop_trade_;
198  bool_t abandon_ship_;
200  address owner_;
201  address_opt update_team_;
205  opt<FlexVersion> version_;
206  opt<FlexVersion> beta_version_;
207  address_opt deploying_cfg_;
208  address_opt prev_super_root_;
209  address_opt next_super_root_;
210  uint32 revision_;
211 };
212 
215 __interface ESuperRoot {
216 };
217 
219 template<>
220 struct preparer<ISuperRoot, DSuperRoot> {
221  __always_inline
222  static std::pair<StateInit, uint256> execute(DSuperRoot data, cell code) {
223  cell data_cl = prepare_persistent_data<ISuperRoot, void>({}, data);
224  StateInit init { {}, {}, code, data_cl, {} };
225  cell init_cl = build(init).make_cell();
226  return { init, uint256(tvm_hash(init_cl)) };
227  }
228 };
229 
230 } // namespace tvm
Flex evers configuration (processing costs)
Flex version structure.
Pair clone evers configuration structure.
WIC clone evers configuration structure.
SuperRoot persistent data struct.
Definition: SuperRoot.hpp:195
opt< FlexVersion > beta_version_
Beta Flex version.
Definition: SuperRoot.hpp:206
uint32 revision_
SuperRoot revision.
Definition: SuperRoot.hpp:210
address_opt deploying_cfg_
Deploying GlobalConfig contract.
Definition: SuperRoot.hpp:207
opt< FlexVersion > version_
Latest Flex version.
Definition: SuperRoot.hpp:205
bool_t stop_trade_
Recommendation to stop trading (in case if problem found in trading algorithms)
Definition: SuperRoot.hpp:197
address_opt next_super_root_
Will be set up if new super root is deployed and should be used instead.
Definition: SuperRoot.hpp:209
address_opt prev_super_root_
Will point to the previous super root.
Definition: SuperRoot.hpp:208
bool_t update_started_
Update procedures started (Wrappers/Flex/UI cloning started).
Definition: SuperRoot.hpp:199
optcell flex_client_stub_
Code of FlexClientStub (salted)
Definition: SuperRoot.hpp:203
uint256 pubkey_
Deployer public key.
Definition: SuperRoot.hpp:196
address_opt update_team_
Update team address. Update team is allowed to deploy beta versions and related contracts.
Definition: SuperRoot.hpp:201
int8 workchain_id_
Workchain id.
Definition: SuperRoot.hpp:204
optcell global_config_code_
Code of GlobalConfig (salted)
Definition: SuperRoot.hpp:202
bool_t abandon_ship_
Recommendation to cancel all orders and withdraw funds (in case if critical problem found)
Definition: SuperRoot.hpp:198
address owner_
Owner contract address.
Definition: SuperRoot.hpp:200
SuperRoot events interface.
Definition: SuperRoot.hpp:215
Processing native funds value ...
Definition: EversConfig.hpp:12
Flex version triplet.
Definition: FlexVersion.hpp:14
SuperRoot contract interface. SuperRoot is an immutable flex super root contract, persistent through ...
Definition: SuperRoot.hpp:47
void update(uint128 cfg_deploy_evers, uint128 cfg_keep_evers, FlexVersion version, address wrappers_cfg, address flex, address user_cfg, string description)
void onDeploy(cell global_config_code, cell flex_client_stub, address_opt prev_super_root)
Deploy processing.
void release()
Convert beta-version into release. Not allowed for the update team.
address getCurrentGlobalConfig()
Get current GlobalConfig address.
void setUpdateTeam(address_opt team)
Set update team address. Update team is allowed to deploy beta versions and related contracts....
address deployWrappersConfig(uint128 deploy_evers, uint128 wrappers_cfg_keep_evers, uint32 token_version, cell wrappers_cfg_code, cell wic_code)
Deploy WrappersConfig contract. Allowed also for the update team if set.
address getGlobalConfig(FlexVersion version)
Get GlobalConfig address for specified version.
SuperRootDetails getDetails()
Get contract details.
void cloneWrappersConfig(address wrappers_cfg, uint128 wrapper_cfg_keep_evers, uint128 clone_deploy_evers, WICCloneEvers wic_evers, uint32 new_token_version, dict_array< address > wrapper_deployers)
Clone WrappersConfig to the new version. Allowed also for the update team if set.
void setFlags(opt< bool > stop_trade, opt< bool > abandon_ship, opt< bool > update_started)
Set flags. If optional is not set, flag will not be changed. Not allowed for the update team.
void transfer(address to, uint128 evers)
Transfer native evers from super root. Not allowed for the update team.
void setOwner(address owner)
Set owner contract. Pubkey access will be unavailable after this. Not allowed for the update team.
void setNextSuperRoot(address next_super_root)
Set next (updated) super root. Not allowed for the update team.
void updateConfirmed(FlexVersion version)
void transferReserveTokens(address wrapper, uint128 tokens, address to)
Transfer flex tip3 tokens from a reserve wallet. Not allowed for the update team.
address deployUserDataConfig(uint128 deploy_evers, FlexVersion triplet, bind_info binding, cell user_data_cfg_code, cell flex_client_code, cell auth_index_code, cell user_id_index_code)
Deploy UserDataConfig contract. Allowed also for the update team if set.
address deployFlex(uint128 deploy_evers, uint128 keep_evers, PairCloneEvers evers, address_opt old_flex, uint32 exchange_version, cell flex_code, cell xchg_pair_code, cell xchg_price_code, EversConfig ev_cfg, uint8 deals_limit)
Deploy Flex contract. Allowed also for the update team if set.
void proxy(cell msg, bool cant_work_during_update, bool starting_update)
Perform proxy call from SuperRoot to an owned subpart (WrappersConfig, Flex, UserDataConfig)
Evers configuration for pair clone procedure.
Definition: PairCloneEvers.hpp:12
SuperRoot details for getter.
Definition: SuperRoot.hpp:23
address_opt prev_super_root
Will point to the previous super root.
Definition: SuperRoot.hpp:38
address_opt deploying_cfg
Deploying GlobalConfig contract.
Definition: SuperRoot.hpp:35
bool abandon_ship_
Recommendation to cancel all orders and withdraw funds (in case if critical problem found)
Definition: SuperRoot.hpp:26
uint256 global_config_hash
Code hash of GlobalConfig (of salted code)
Definition: SuperRoot.hpp:31
bool stop_trade_
Recommendation to stop trading (in case if problem found in trading algorithms)
Definition: SuperRoot.hpp:25
address_opt next_super_root
Will be set up if new super root is deployed and should be used instead.
Definition: SuperRoot.hpp:39
address_opt beta_cfg
Address of the beta GlobalConfig (for beta version, if not null)
Definition: SuperRoot.hpp:37
address_opt update_team
Update team address. Update team is allowed to deploy beta versions and related contracts.
Definition: SuperRoot.hpp:29
bool update_started_
Update procedures started (Wrappers/Flex/UI cloning started)
Definition: SuperRoot.hpp:27
uint256 pubkey
Deployer public key.
Definition: SuperRoot.hpp:24
opt< FlexVersion > beta_version
Beta Flex version.
Definition: SuperRoot.hpp:34
uint32 revision
SuperRoot revision.
Definition: SuperRoot.hpp:40
cell global_config_code
Code of GlobalConfig (salted)
Definition: SuperRoot.hpp:30
address owner
Owner contract address.
Definition: SuperRoot.hpp:28
int8 workchain_id
Workchain id.
Definition: SuperRoot.hpp:32
address_opt cur_cfg
Address of the current GlobalConfig (for current version, if not null)
Definition: SuperRoot.hpp:36
opt< FlexVersion > version
Latest Flex version.
Definition: SuperRoot.hpp:33
Evers configuration for clone procedure.
Definition: WICCloneEvers.hpp:12
Binding to allow orders only to specific flex root and with specific unsalted PriceXchg code hash.
Definition: bind_info.hpp:8