Skip to content

Conversation

@amisha120
Copy link
Contributor

No description provided.

@amisha120 amisha120 linked an issue May 11, 2021 that may be closed by this pull request
@amisha120 amisha120 marked this pull request as ready for review May 18, 2021 15:28
Comment on lines 138 to 161
const contractRegistry = await web3Func(deploy, "contractRegistry", "ContractRegistry", []);
const converterFactory = await web3Func(deploy, "converterFactory", "ConverterFactory", []);
const sovrynSwapFormula = await web3Func(deploy, "sovrynSwapFormula", "SovrynSwapFormula", []);
const sovrynSwapNetwork = await web3Func(deploy, "sovrynSwapNetwork", "SovrynSwapNetwork", [contractRegistry._address]);
const converterUpgrader = await web3Func(deploy, "converterUpgrader", "ConverterUpgrader", [contractRegistry._address, addresses.ETH]);
const converterRegistry = await web3Func(deploy, "converterRegistry", "ConverterRegistry", [contractRegistry._address]);
const liquidityPoolV1ConverterFactory = await web3Func(deploy, "liquidityPoolV1ConverterFactory", "LiquidityPoolV1ConverterFactory", []);
const smartToken = await web3Func(deploy, "smartToken", "SmartToken", ["TOKEN", "TKN", 1]);
const oracle = await web3Func(deploy, "oracle", "Oracle", []);
const liquidityPoolV1Converter = await web3Func(deploy, "liquidityPoolV1Converter", "LiquidityPoolV1Converter", [smartToken._address, contractRegistry._address, MAX_CONVERSION_FEE]);

//init sovryn swap formula
await execute(sovrynSwapFormula.methods.init());

// initialize contract registry
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex("ContractRegistry"), contractRegistry._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex("ConverterFactory"), converterFactory._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex("SovrynSwapFormula"), sovrynSwapFormula._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex("SovrynSwapNetwork"), sovrynSwapNetwork._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex("SovrynSwapConverterUpgrader"), converterUpgrader._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex("SovrynSwapConverterRegistry"), converterRegistry._address));

// initialize converter factory
await execute(converterFactory.methods.registerTypedConverterFactory(liquidityPoolV1ConverterFactory._address));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean this script not needed and I should add the oracle deployment to the test_deployment_rsk.js script?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean why would you register all of these addresses again although they already have been registered on deployment?

Copy link
Contributor Author

@amisha120 amisha120 May 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay. Adding oracle deployment to addConverter.js so this won't be needed.

@ororopickpocket
Copy link
Contributor

approved with one comment.
please do not merge before we got a review from @eMarchenko

@ororopickpocket
Copy link
Contributor

ororopickpocket commented May 27, 2021

would also be nice if

  1. the oracle deployment would be added to the addConverter script
  2. if it would be added to the script for upgrading converters - because that's what we'll need to do. you can use this script as a starting point: https://github.com/DistributedCollective/oracle-based-amm/blob/58e7724124f45839428c2faa3ca329f81ed2313f/solidity/utils/upgrade_converter.js

(the script is in an unmerged PR. we can't merge the whole PR, but you can copy the script)

Copy link

@korepkorep korepkorep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several code quality issues that don't endanger contracts` security


// ensure that the trade won't deplete the reserve balance
uint256 targetReserveBalance = reserveBalance(_targetToken);
assert(amount < targetReserveBalance);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using of assert in production source code is not the best practice. Same for other assert cases


uint256[] memory reserveMinReturnAmounts = new uint256[](reserveTokens.length);
for (uint256 i = 0; i < reserveMinReturnAmounts.length; i++)
reserveMinReturnAmounts[i] = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no protection from slippage

// transfer funds from the caller in the reserve token
if (reserveToken == ETH_RESERVE_ADDRESS) {
if (msg.value > reserveAmount) {
msg.sender.transfer(msg.value - reserveAmount);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some contracts may revert ether transfers due to lack of gas. Same for other .transfer cases

Copy link

@eMarchenko eMarchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@korepkorep has performed the review, no security issues have been discovered

@amisha120 amisha120 merged commit 7e927fb into master Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oracle for v1 AMM pools

6 participants