@@ -49,6 +49,11 @@ contract RootSwapPairContract is
49
49
50
50
//============Constructor===========
51
51
52
+ /**
53
+ * @param minMsgValue minimal value required for pair deployment
54
+ * @param contractSP payment for pair deployment
55
+ * @param tip3Deployer_ address of tip3 tokens deployer
56
+ */
52
57
constructor (
53
58
uint256 minMsgValue ,
54
59
uint256 contractSP ,
@@ -71,6 +76,7 @@ contract RootSwapPairContract is
71
76
//============External functions============
72
77
73
78
/**
79
+ * @param tip3Deployer Address of new tip3 deployer contract
74
80
*/
75
81
function setTIP3DeployerAddress (
76
82
address tip3Deployer_
@@ -114,7 +120,7 @@ contract RootSwapPairContract is
114
120
swapPairID: uniqueID
115
121
},
116
122
code: swapPairCode
117
- }(address (this ), tip3Deployer);
123
+ }(address (this ), tip3Deployer, swapPairCodeVersions );
118
124
119
125
// Storing info about deployed swap pair contracts
120
126
SwapPairInfo info = SwapPairInfo (
@@ -197,6 +203,11 @@ contract RootSwapPairContract is
197
203
return swapPairDB.exists (uniqueID);
198
204
}
199
205
206
+ /**
207
+ * Get future address of swap pair
208
+ * @param tokenRootContract1 Address of token root contract
209
+ * @param tokenRootContract2 Address of token root contract
210
+ */
200
211
function getFutureSwapPairAddress (
201
212
address tokenRootContract1 ,
202
213
address tokenRootContract2
@@ -207,6 +218,10 @@ contract RootSwapPairContract is
207
218
208
219
//============Callback functions============
209
220
221
+ /**
222
+ * Callback called when swap pair is fully intialized and ready for swaps
223
+ * @param spi Swap pair information
224
+ */
210
225
function swapPairInitializedCallback (SwapPairInfo spi ) external pairWithAddressExists (msg .sender ) {
211
226
swapPairDB[addressToUniqueID[msg .sender ]] = spi;
212
227
emit SwapPairInitialized (msg .sender );
@@ -216,6 +231,8 @@ contract RootSwapPairContract is
216
231
217
232
/**
218
233
* Set new swap pair code
234
+ * @param code New swap pair code
235
+ * @param codeVersion New swap pair code version
219
236
*/
220
237
function setSwapPairCode (
221
238
TvmCell code ,
@@ -232,10 +249,18 @@ contract RootSwapPairContract is
232
249
emit SetSwapPairCode (codeVersion);
233
250
}
234
251
235
- function upgradeSwapPair (uint256 uniqueID )
252
+ /**
253
+ * Upgrade swap pair code
254
+ * @param tokenRootContract1 Address of token root contract
255
+ * @param tokenRootContract2 Address of token root contract
256
+ */
257
+ function upgradeSwapPair (
258
+ address tokenRootContract1 ,
259
+ address tokenRootContract2
260
+ )
236
261
external
237
262
override
238
- pairExists (uniqueID, true )
263
+ pairWithTokensExist (tokenRootContract1, tokenRootContract2 )
239
264
{
240
265
SwapPairInfo info = swapPairDB.at (uniqueID);
241
266
require (
@@ -255,6 +280,12 @@ contract RootSwapPairContract is
255
280
256
281
//============Private functions============
257
282
283
+ /**
284
+ * Calculate future swap pair contract address
285
+ * @param tokenRootContract1 Address of token root contract
286
+ * @param tokenRootContract2 Address of token root contract
287
+ * @param uniqueID ID of swap pair
288
+ */
258
289
function _calculateSwapPairContractAddress (
259
290
address tokenRootContract1 ,
260
291
address tokenRootContract2 ,
@@ -293,12 +324,12 @@ contract RootSwapPairContract is
293
324
_;
294
325
}
295
326
296
- modifier pairWithTokensDoesNotExist (address t1 , address t2 ) {
327
+ modifier pairWithTokensExist (address t1 , address t2 ) {
297
328
uint256 uniqueID = t1.value^ t2.value;
298
329
optional (SwapPairInfo) pairInfo = swapPairDB.fetch (uniqueID);
299
330
require (
300
- ! pairInfo.hasValue (),
301
- RootSwapPairContractErrors.ERROR_PAIR_ALREADY_EXISTS
331
+ pairInfo.hasValue (),
332
+ RootSwapPairContractErrors.ERROR_PAIR_DOES_NOT_EXIST
302
333
);
303
334
_;
304
335
}
0 commit comments