Skip to content

Commit edc7986

Browse files
committed
Docs, part 1
1 parent 0262e87 commit edc7986

File tree

4 files changed

+259
-102
lines changed

4 files changed

+259
-102
lines changed

contracts/SwapPair/RootSwapPairContract.sol

+37-6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ contract RootSwapPairContract is
4949

5050
//============Constructor===========
5151

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+
*/
5257
constructor(
5358
uint256 minMsgValue,
5459
uint256 contractSP,
@@ -71,6 +76,7 @@ contract RootSwapPairContract is
7176
//============External functions============
7277

7378
/**
79+
* @param tip3Deployer Address of new tip3 deployer contract
7480
*/
7581
function setTIP3DeployerAddress(
7682
address tip3Deployer_
@@ -114,7 +120,7 @@ contract RootSwapPairContract is
114120
swapPairID: uniqueID
115121
},
116122
code: swapPairCode
117-
}(address(this), tip3Deployer);
123+
}(address(this), tip3Deployer, swapPairCodeVersions);
118124

119125
// Storing info about deployed swap pair contracts
120126
SwapPairInfo info = SwapPairInfo(
@@ -197,6 +203,11 @@ contract RootSwapPairContract is
197203
return swapPairDB.exists(uniqueID);
198204
}
199205

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+
*/
200211
function getFutureSwapPairAddress(
201212
address tokenRootContract1,
202213
address tokenRootContract2
@@ -207,6 +218,10 @@ contract RootSwapPairContract is
207218

208219
//============Callback functions============
209220

221+
/**
222+
* Callback called when swap pair is fully intialized and ready for swaps
223+
* @param spi Swap pair information
224+
*/
210225
function swapPairInitializedCallback(SwapPairInfo spi) external pairWithAddressExists(msg.sender) {
211226
swapPairDB[addressToUniqueID[msg.sender]] = spi;
212227
emit SwapPairInitialized(msg.sender);
@@ -216,6 +231,8 @@ contract RootSwapPairContract is
216231

217232
/**
218233
* Set new swap pair code
234+
* @param code New swap pair code
235+
* @param codeVersion New swap pair code version
219236
*/
220237
function setSwapPairCode(
221238
TvmCell code,
@@ -232,10 +249,18 @@ contract RootSwapPairContract is
232249
emit SetSwapPairCode(codeVersion);
233250
}
234251

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+
)
236261
external
237262
override
238-
pairExists(uniqueID, true)
263+
pairWithTokensExist(tokenRootContract1, tokenRootContract2)
239264
{
240265
SwapPairInfo info = swapPairDB.at(uniqueID);
241266
require(
@@ -255,6 +280,12 @@ contract RootSwapPairContract is
255280

256281
//============Private functions============
257282

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+
*/
258289
function _calculateSwapPairContractAddress(
259290
address tokenRootContract1,
260291
address tokenRootContract2,
@@ -293,12 +324,12 @@ contract RootSwapPairContract is
293324
_;
294325
}
295326

296-
modifier pairWithTokensDoesNotExist(address t1, address t2) {
327+
modifier pairWithTokensExist(address t1, address t2) {
297328
uint256 uniqueID = t1.value^t2.value;
298329
optional(SwapPairInfo) pairInfo = swapPairDB.fetch(uniqueID);
299330
require(
300-
!pairInfo.hasValue(),
301-
RootSwapPairContractErrors.ERROR_PAIR_ALREADY_EXISTS
331+
pairInfo.hasValue(),
332+
RootSwapPairContractErrors.ERROR_PAIR_DOES_NOT_EXIST
302333
);
303334
_;
304335
}

0 commit comments

Comments
 (0)