From c3336b54d34c573fe0859e774b48f2df25fba676 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Sun, 25 Nov 2018 20:00:50 +0000 Subject: [PATCH 1/9] WIP --- contracts/interfaces/IModuleFactory.sol | 8 ++- contracts/mocks/MockBurnFactory.sol | 6 +-- contracts/mocks/MockFactory.sol | 6 +-- contracts/mocks/MockWrongTypeFactory.sol | 4 +- contracts/mocks/TestSTOFactory.sol | 4 +- .../modules/Checkpoint/DividendCheckpoint.sol | 16 +++--- .../Checkpoint/ERC20DividendCheckpoint.sol | 50 +++++++++---------- .../ERC20DividendCheckpointFactory.sol | 9 ++-- .../EtherDividendCheckpointFactory.sol | 9 ++-- .../Burn/TrackedRedemptionFactory.sol | 9 ++-- .../Mixed/ScheduledCheckpointFactory.sol | 46 ++--------------- .../LockupVolumeRestrictionTMFactory.sol | 11 ++-- .../SingleTradeVolumeRestrictionTMFactory.sol | 9 ++-- contracts/modules/ModuleFactory.sol | 44 +++++++++------- .../GeneralPermissionManagerFactory.sol | 9 ++-- contracts/modules/STO/CappedSTOFactory.sol | 9 ++-- contracts/modules/STO/DummySTOFactory.sol | 9 ++-- contracts/modules/STO/PreSaleSTOFactory.sol | 12 ++--- contracts/modules/STO/USDTieredSTOFactory.sol | 9 ++-- .../CountTransferManagerFactory.sol | 9 ++-- .../GeneralTransferManagerFactory.sol | 9 ++-- .../ManualApprovalTransferManagerFactory.sol | 9 ++-- .../PercentageTransferManagerFactory.sol | 9 ++-- contracts/tokens/SecurityToken.sol | 2 +- migrations/2_deploy_contracts.js | 18 +++---- truffle-config.js | 2 +- 26 files changed, 151 insertions(+), 186 deletions(-) diff --git a/contracts/interfaces/IModuleFactory.sol b/contracts/interfaces/IModuleFactory.sol index 9c2ad6bf2..7cff93319 100644 --- a/contracts/interfaces/IModuleFactory.sol +++ b/contracts/interfaces/IModuleFactory.sol @@ -13,7 +13,8 @@ interface IModuleFactory { bytes32 indexed _moduleName, address indexed _moduleFactory, address _creator, - uint256 _setupCost, + uint256 _setupCostInPoly, + uint256 _setupCostInUSD, uint256 _timestamp ); event ChangeSTVersionBound(string _boundType, uint8 _major, uint8 _minor, uint8 _patch); @@ -71,6 +72,11 @@ interface IModuleFactory { */ function getSetupCost() external view returns (uint256); + /** + * @notice Get the setup cost of the module + */ + function getSetupCostInPoly() external view returns (uint256); + /** * @notice Used to get the lower bound * @return Lower bound diff --git a/contracts/mocks/MockBurnFactory.sol b/contracts/mocks/MockBurnFactory.sol index 31e5edafa..899ea5330 100644 --- a/contracts/mocks/MockBurnFactory.sol +++ b/contracts/mocks/MockBurnFactory.sol @@ -13,8 +13,8 @@ contract MockBurnFactory is TrackedRedemptionFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - TrackedRedemptionFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + TrackedRedemptionFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { } @@ -28,7 +28,7 @@ contract MockBurnFactory is TrackedRedemptionFactory { //Check valid bytes - can only call module init function MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(mockRedemptionManager), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(mockRedemptionManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(mockRedemptionManager); } diff --git a/contracts/mocks/MockFactory.sol b/contracts/mocks/MockFactory.sol index 627efb71c..1ad42844c 100644 --- a/contracts/mocks/MockFactory.sol +++ b/contracts/mocks/MockFactory.sol @@ -13,8 +13,8 @@ contract MockFactory is DummySTOFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - DummySTOFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + DummySTOFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { } @@ -32,7 +32,7 @@ contract MockFactory is DummySTOFactory { res[1] = 1; return res; } - + } function changeTypes() external onlyOwner { diff --git a/contracts/mocks/MockWrongTypeFactory.sol b/contracts/mocks/MockWrongTypeFactory.sol index f04a3a2de..fe5ffd562 100644 --- a/contracts/mocks/MockWrongTypeFactory.sol +++ b/contracts/mocks/MockWrongTypeFactory.sol @@ -14,8 +14,8 @@ contract MockWrongTypeFactory is MockBurnFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - MockBurnFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + MockBurnFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { } diff --git a/contracts/mocks/TestSTOFactory.sol b/contracts/mocks/TestSTOFactory.sol index a8bcbbeb6..ff93fdafe 100644 --- a/contracts/mocks/TestSTOFactory.sol +++ b/contracts/mocks/TestSTOFactory.sol @@ -8,8 +8,8 @@ contract TestSTOFactory is DummySTOFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - DummySTOFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + DummySTOFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "TestSTO"; diff --git a/contracts/modules/Checkpoint/DividendCheckpoint.sol b/contracts/modules/Checkpoint/DividendCheckpoint.sol index 9a804772f..a840d7b40 100644 --- a/contracts/modules/Checkpoint/DividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/DividendCheckpoint.sol @@ -62,9 +62,9 @@ contract DividendCheckpoint is ICheckpoint, Module { require(_dividendIndex < dividends.length, "Invalid dividend"); require(!dividends[_dividendIndex].reclaimed, "Dividend reclaimed"); /*solium-disable-next-line security/no-block-members*/ - require(now >= dividends[_dividendIndex].maturity, "Dividend maturity in future"); + require(now >= dividends[_dividendIndex].maturity, "Maturity in future"); /*solium-disable-next-line security/no-block-members*/ - require(now < dividends[_dividendIndex].expiry, "Dividend expiry in past"); + require(now < dividends[_dividendIndex].expiry, "Expiry in past"); _; } @@ -115,11 +115,11 @@ contract DividendCheckpoint is ICheckpoint, Module { * @param _withholding Withholding tax for individual investors (multiplied by 10**16) */ function setWithholding(address[] _investors, uint256[] _withholding) public withPerm(MANAGE) { - require(_investors.length == _withholding.length, "Mismatched input lengths"); + require(_investors.length == _withholding.length, "Mismatched input"); /*solium-disable-next-line security/no-block-members*/ emit SetWithholding(_investors, _withholding, now); for (uint256 i = 0; i < _investors.length; i++) { - require(_withholding[i] <= 10**18, "Incorrect withholding tax"); + require(_withholding[i] <= 10**18, "Invalid tax"); withholdingTax[_investors[i]] = _withholding[i]; } } @@ -130,7 +130,7 @@ contract DividendCheckpoint is ICheckpoint, Module { * @param _withholding Withholding tax for all investors (multiplied by 10**16) */ function setWithholdingFixed(address[] _investors, uint256 _withholding) public withPerm(MANAGE) { - require(_withholding <= 10**18, "Incorrect withholding tax"); + require(_withholding <= 10**18, "Invalid tax"); /*solium-disable-next-line security/no-block-members*/ emit SetWithholdingFixed(_investors, _withholding, now); for (uint256 i = 0; i < _investors.length; i++) { @@ -192,8 +192,8 @@ contract DividendCheckpoint is ICheckpoint, Module { function pullDividendPayment(uint256 _dividendIndex) public validDividendIndex(_dividendIndex) { Dividend storage dividend = dividends[_dividendIndex]; - require(!dividend.claimed[msg.sender], "Dividend already claimed"); - require(!dividend.dividendExcluded[msg.sender], "msg.sender excluded from Dividend"); + require(!dividend.claimed[msg.sender], "Already claimed"); + require(!dividend.dividendExcluded[msg.sender], "msg.sender excluded"); _payDividend(msg.sender, dividend, _dividendIndex); } @@ -218,7 +218,7 @@ contract DividendCheckpoint is ICheckpoint, Module { * @return claim, withheld amounts */ function calculateDividend(uint256 _dividendIndex, address _payee) public view returns(uint256, uint256) { - require(_dividendIndex < dividends.length, "Invalid dividend"); + require(_dividendIndex < dividends.length, "Invalid index"); Dividend storage dividend = dividends[_dividendIndex]; if (dividend.claimed[_payee] || dividend.dividendExcluded[_payee]) { return (0, 0); diff --git a/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol b/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol index 3a981ce28..1d4f81d5c 100644 --- a/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol @@ -68,8 +68,8 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { address _token, uint256 _amount, bytes32 _name - ) - external + ) + external withPerm(MANAGE) { createDividendWithExclusions(_maturity, _expiry, _token, _amount, excluded, _name); @@ -133,16 +133,16 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { * @param _name Name/Title for identification */ function createDividendWithCheckpointAndExclusions( - uint256 _maturity, - uint256 _expiry, - address _token, - uint256 _amount, - uint256 _checkpointId, + uint256 _maturity, + uint256 _expiry, + address _token, + uint256 _amount, + uint256 _checkpointId, address[] _excluded, bytes32 _name - ) + ) public - withPerm(MANAGE) + withPerm(MANAGE) { _createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, _checkpointId, _excluded, _name); } @@ -158,25 +158,25 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { * @param _name Name/Title for identification */ function _createDividendWithCheckpointAndExclusions( - uint256 _maturity, - uint256 _expiry, - address _token, - uint256 _amount, - uint256 _checkpointId, + uint256 _maturity, + uint256 _expiry, + address _token, + uint256 _amount, + uint256 _checkpointId, address[] _excluded, bytes32 _name - ) - internal + ) + internal { ISecurityToken securityTokenInstance = ISecurityToken(securityToken); require(_excluded.length <= EXCLUDED_ADDRESS_LIMIT, "Too many addresses excluded"); - require(_expiry > _maturity, "Expiry before maturity"); + require(_expiry > _maturity, "Expiry <= maturity"); /*solium-disable-next-line security/no-block-members*/ require(_expiry > now, "Expiry in past"); require(_amount > 0, "No dividend sent"); require(_token != address(0), "Invalid token"); require(_checkpointId <= securityTokenInstance.currentCheckpointId(), "Invalid checkpoint"); - require(IERC20(_token).transferFrom(msg.sender, address(this), _amount), "insufficent allowance"); + require(IERC20(_token).transferFrom(msg.sender, address(this), _amount), "Insufficent allowance"); require(_name[0] != 0); uint256 dividendIndex = dividends.length; uint256 currentSupply = securityTokenInstance.totalSupplyAt(_checkpointId); @@ -199,7 +199,7 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { for (uint256 j = 0; j < _excluded.length; j++) { require (_excluded[j] != address(0), "Invalid address"); - require(!dividends[dividendIndex].dividendExcluded[_excluded[j]], "duped exclude address"); + require(!dividends[dividendIndex].dividendExcluded[_excluded[j]], "Duped exclude address"); excludedSupply = excludedSupply.add(securityTokenInstance.balanceOfAt(_excluded[j], _checkpointId)); dividends[dividendIndex].dividendExcluded[_excluded[j]] = true; } @@ -210,7 +210,7 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { } /** - * @notice Emits the ERC20DividendDeposited event. + * @notice Emits the ERC20DividendDeposited event. * Seperated into a different function as a workaround for stack too deep error */ function _emitERC20DividendDepositedEvent( @@ -241,7 +241,7 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { _dividend.claimedAmount = claim.add(_dividend.claimedAmount); uint256 claimAfterWithheld = claim.sub(withheld); if (claimAfterWithheld > 0) { - require(IERC20(dividendTokens[_dividendIndex]).transfer(_payee, claimAfterWithheld), "transfer failed"); + require(IERC20(dividendTokens[_dividendIndex]).transfer(_payee, claimAfterWithheld), "Transfer failed"); _dividend.dividendWithheld = _dividend.dividendWithheld.add(withheld); investorWithheld[_payee] = investorWithheld[_payee].add(withheld); emit ERC20DividendClaimed(_payee, _dividendIndex, dividendTokens[_dividendIndex], claim, withheld); @@ -255,13 +255,13 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { function reclaimDividend(uint256 _dividendIndex) external withPerm(MANAGE) { require(_dividendIndex < dividends.length, "Invalid dividend"); /*solium-disable-next-line security/no-block-members*/ - require(now >= dividends[_dividendIndex].expiry, "Dividend expiry in future"); - require(!dividends[_dividendIndex].reclaimed, "already claimed"); + require(now >= dividends[_dividendIndex].expiry, "Expiry in future"); + require(!dividends[_dividendIndex].reclaimed, "Already claimed"); dividends[_dividendIndex].reclaimed = true; Dividend storage dividend = dividends[_dividendIndex]; uint256 remainingAmount = dividend.amount.sub(dividend.claimedAmount); address owner = IOwnable(securityToken).owner(); - require(IERC20(dividendTokens[_dividendIndex]).transfer(owner, remainingAmount), "transfer failed"); + require(IERC20(dividendTokens[_dividendIndex]).transfer(owner, remainingAmount), "Transfer failed"); emit ERC20DividendReclaimed(owner, _dividendIndex, dividendTokens[_dividendIndex], remainingAmount); } @@ -275,7 +275,7 @@ contract ERC20DividendCheckpoint is DividendCheckpoint { uint256 remainingWithheld = dividend.dividendWithheld.sub(dividend.dividendWithheldReclaimed); dividend.dividendWithheldReclaimed = dividend.dividendWithheld; address owner = IOwnable(securityToken).owner(); - require(IERC20(dividendTokens[_dividendIndex]).transfer(owner, remainingWithheld), "transfer failed"); + require(IERC20(dividendTokens[_dividendIndex]).transfer(owner, remainingWithheld), "Transfer failed"); emit ERC20DividendWithholdingWithdrawn(owner, _dividendIndex, dividendTokens[_dividendIndex], remainingWithheld); } diff --git a/contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol b/contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol index 10a1fc5a0..e5620375b 100644 --- a/contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol +++ b/contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol @@ -15,8 +15,8 @@ contract ERC20DividendCheckpointFactory is ModuleFactory { * @param _usageCost Usage cost of the module * @param _subscriptionCost Subscription cost of the module */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "ERC20DividendCheckpoint"; @@ -31,11 +31,10 @@ contract ERC20DividendCheckpointFactory is ModuleFactory { * @return Address Contract address of the Module */ function deploy(bytes /* _data */) external returns(address) { - if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "insufficent allowance"); + _takeSetupCost(); address erc20DividendCheckpoint = new ERC20DividendCheckpoint(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(erc20DividendCheckpoint, getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(erc20DividendCheckpoint, getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return erc20DividendCheckpoint; } diff --git a/contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol b/contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol index 69859c4f0..f719d5279 100644 --- a/contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol +++ b/contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol @@ -15,8 +15,8 @@ contract EtherDividendCheckpointFactory is ModuleFactory { * @param _usageCost Usage cost of the module * @param _subscriptionCost Subscription cost of the module */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "EtherDividendCheckpoint"; @@ -31,11 +31,10 @@ contract EtherDividendCheckpointFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes /* _data */) external returns(address) { - if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Insufficent allowance or balance"); + _takeSetupCost(); address ethDividendCheckpoint = new EtherDividendCheckpoint(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(ethDividendCheckpoint, getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(ethDividendCheckpoint, getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return ethDividendCheckpoint; } diff --git a/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol b/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol index 87f480e09..3f8d7508a 100644 --- a/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol +++ b/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol @@ -15,8 +15,8 @@ contract TrackedRedemptionFactory is ModuleFactory { * @param _usageCost Usage cost of module * @param _subscriptionCost Monthly cost of module */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "TrackedRedemption"; @@ -31,11 +31,10 @@ contract TrackedRedemptionFactory is ModuleFactory { * @return Address Contract address of the Module */ function deploy(bytes /* _data */) external returns(address) { - if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Insufficent allowance or balance"); + _takeSetupCost(); address trackedRedemption = new TrackedRedemption(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(trackedRedemption), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(trackedRedemption), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(trackedRedemption); } diff --git a/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol b/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol index c3ec735cc..2322610fe 100644 --- a/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol +++ b/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol @@ -15,8 +15,8 @@ contract ScheduledCheckpointFactory is ModuleFactory { * @param _usageCost Usage cost of the module * @param _subscriptionCost Subscription cost of the module */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "ScheduledCheckpoint"; @@ -31,10 +31,9 @@ contract ScheduledCheckpointFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes /* _data */) external returns(address) { - if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + _takeSetupCost(); address scheduledCheckpoint = new ScheduledCheckpoint(msg.sender, address(polyToken)); - emit GenerateModuleFromFactory(scheduledCheckpoint, getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(scheduledCheckpoint, getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return scheduledCheckpoint; } @@ -47,42 +46,7 @@ contract ScheduledCheckpointFactory is ModuleFactory { res[1] = 2; return res; } - - /** - * @notice Get the name of the Module - */ - function getName() public view returns(bytes32) { - return name; - } - - /** - * @notice Get the description of the Module - */ - function getDescription() external view returns(string) { - return description; - } - - /** - * @notice Get the title of the Module - */ - function getTitle() external view returns(string) { - return title; - } - - /** - * @notice Get the version of the Module - */ - function getVersion() external view returns(string) { - return version; - } - - /** - * @notice Get the setup cost of the module - */ - function getSetupCost() external view returns (uint256) { - return setupCost; - } - + /** * @notice Get the Instructions that helped to used the module */ diff --git a/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol b/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol index 9ad339be3..7d78cafc7 100644 --- a/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol +++ b/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol @@ -15,8 +15,8 @@ contract LockupVolumeRestrictionTMFactory is ModuleFactory { * @param _usageCost Usage cost of the module * @param _subscriptionCost Subscription cost of the module */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "LockupVolumeRestrictionTM"; @@ -31,11 +31,10 @@ contract LockupVolumeRestrictionTMFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes /* _data */) external returns(address) { - if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + _takeSetupCost(); LockupVolumeRestrictionTM lockupVolumeRestrictionTransferManager = new LockupVolumeRestrictionTM(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(lockupVolumeRestrictionTransferManager), getName(), address(this), msg.sender, now); + emit GenerateModuleFromFactory(address(lockupVolumeRestrictionTransferManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(lockupVolumeRestrictionTransferManager); } @@ -48,7 +47,7 @@ contract LockupVolumeRestrictionTMFactory is ModuleFactory { res[0] = 2; return res; } - + /** * @notice Returns the instructions associated with the module */ diff --git a/contracts/modules/Experimental/TransferManager/SingleTradeVolumeRestrictionTMFactory.sol b/contracts/modules/Experimental/TransferManager/SingleTradeVolumeRestrictionTMFactory.sol index 346fe9997..a63c6463b 100644 --- a/contracts/modules/Experimental/TransferManager/SingleTradeVolumeRestrictionTMFactory.sol +++ b/contracts/modules/Experimental/TransferManager/SingleTradeVolumeRestrictionTMFactory.sol @@ -17,8 +17,8 @@ contract SingleTradeVolumeRestrictionTMFactory is ModuleFactory { * @param _usageCost Usage cost of the module * @param _subscriptionCost Subscription cost of the module */ - constructor(address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor(address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "SingleTradeVolumeRestrictionTM"; @@ -33,15 +33,14 @@ contract SingleTradeVolumeRestrictionTMFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes _data) external returns(address) { - if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + _takeSetupCost(); SingleTradeVolumeRestrictionTM singleTradeVolumeRestrictionManager = new SingleTradeVolumeRestrictionTM(msg.sender, address(polyToken)); require(Util.getSig(_data) == singleTradeVolumeRestrictionManager.getInitFunction(), "Provided data is not valid"); /*solium-disable-next-line security/no-low-level-calls*/ require(address(singleTradeVolumeRestrictionManager).call(_data), "Unsuccessful call"); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(singleTradeVolumeRestrictionManager), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(singleTradeVolumeRestrictionManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(singleTradeVolumeRestrictionManager); } diff --git a/contracts/modules/ModuleFactory.sol b/contracts/modules/ModuleFactory.sol index 99e0f2d9d..656ceb249 100644 --- a/contracts/modules/ModuleFactory.sol +++ b/contracts/modules/ModuleFactory.sol @@ -2,8 +2,11 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "../interfaces/IModuleFactory.sol"; +import "../interfaces/IOracle.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "../libraries/VersionUtils.sol"; +import "../PolymathRegistry.sol"; +import "../libraries/DecimalMath.sol"; /** * @title Interface that any module factory contract should implement @@ -14,6 +17,7 @@ contract ModuleFactory is IModuleFactory, Ownable { IERC20 public polyToken; uint256 public usageCost; uint256 public monthlySubscriptionCost; + address public polymathRegistry; uint256 public setupCost; string public description; @@ -21,34 +25,25 @@ contract ModuleFactory is IModuleFactory, Ownable { bytes32 public name; string public title; + string constant POLY_ORACLE = "PolyUsdOracle"; + // @notice Allow only two variables to be stored - // 1. lowerBound + // 1. lowerBound // 2. upperBound - // @dev (0.0.0 will act as the wildcard) + // @dev (0.0.0 will act as the wildcard) // @dev uint24 consists packed value of uint8 _major, uint8 _minor, uint8 _patch mapping(string => uint24) compatibleSTVersionRange; - event ChangeFactorySetupFee(uint256 _oldSetupCost, uint256 _newSetupCost, address _moduleFactory); - event ChangeFactoryUsageFee(uint256 _oldUsageCost, uint256 _newUsageCost, address _moduleFactory); - event ChangeFactorySubscriptionFee(uint256 _oldSubscriptionCost, uint256 _newMonthlySubscriptionCost, address _moduleFactory); - event GenerateModuleFromFactory( - address _module, - bytes32 indexed _moduleName, - address indexed _moduleFactory, - address _creator, - uint256 _timestamp - ); - event ChangeSTVersionBound(string _boundType, uint8 _major, uint8 _minor, uint8 _patch); - /** * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public { + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public { polyToken = IERC20(_polyAddress); setupCost = _setupCost; usageCost = _usageCost; monthlySubscriptionCost = _subscriptionCost; + polymathRegistry = _polymathRegistry; } /** @@ -127,7 +122,7 @@ contract ModuleFactory is IModuleFactory, Ownable { "Must be a valid bound type" ); require(_newVersion.length == 3); - if (compatibleSTVersionRange[_boundType] != uint24(0)) { + if (compatibleSTVersionRange[_boundType] != uint24(0)) { uint8[] memory _currentVersion = VersionUtils.unpack(compatibleSTVersionRange[_boundType]); require(VersionUtils.isValidVersion(_currentVersion, _newVersion), "Failed because of in-valid version"); } @@ -154,10 +149,18 @@ contract ModuleFactory is IModuleFactory, Ownable { /** * @notice Get the setup cost of the module */ - function getSetupCost() external view returns (uint256) { + function getSetupCost() public view returns (uint256) { return setupCost; } + /** + * @notice Get the setup cost of the module + */ + function getSetupCostInPoly() public view returns (uint256) { + uint256 polyRate = IOracle(PolymathRegistry(polymathRegistry).getAddress(POLY_ORACLE)).getPrice(); + return DecimalMath.mul(setupCost, polyRate); + } + /** * @notice Get the name of the Module */ @@ -165,4 +168,11 @@ contract ModuleFactory is IModuleFactory, Ownable { return name; } + function _takeSetupCost() internal { + uint256 setupCostInPoly = getSetupCostInPoly(); + if (setupCostInPoly > 0) { + require(polyToken.transferFrom(msg.sender, owner(), setupCostInPoly), "Failed transferFrom because of sufficent Allowance is not provided"); + } + } + } diff --git a/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol b/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol index 900fcef1c..e1b7d82f2 100644 --- a/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol +++ b/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol @@ -12,8 +12,8 @@ contract GeneralPermissionManagerFactory is ModuleFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "GeneralPermissionManager"; @@ -28,11 +28,10 @@ contract GeneralPermissionManagerFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes /* _data */) external returns(address) { - if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom due to insufficent Allowance provided"); + _takeSetupCost(); address permissionManager = new GeneralPermissionManager(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(permissionManager), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(permissionManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return permissionManager; } diff --git a/contracts/modules/STO/CappedSTOFactory.sol b/contracts/modules/STO/CappedSTOFactory.sol index 37cf37f21..da2aced1f 100644 --- a/contracts/modules/STO/CappedSTOFactory.sol +++ b/contracts/modules/STO/CappedSTOFactory.sol @@ -13,8 +13,8 @@ contract CappedSTOFactory is ModuleFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "CappedSTO"; @@ -29,8 +29,7 @@ contract CappedSTOFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes _data) external returns(address) { - if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Sufficent Allowance is not provided"); + _takeSetupCost(); //Check valid bytes - can only call module init function CappedSTO cappedSTO = new CappedSTO(msg.sender, address(polyToken)); //Checks that _data is valid (not calling anything it shouldn't) @@ -38,7 +37,7 @@ contract CappedSTOFactory is ModuleFactory { /*solium-disable-next-line security/no-low-level-calls*/ require(address(cappedSTO).call(_data), "Unsuccessfull call"); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(cappedSTO), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(cappedSTO), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(cappedSTO); } diff --git a/contracts/modules/STO/DummySTOFactory.sol b/contracts/modules/STO/DummySTOFactory.sol index 02b55fe08..bf327d2cd 100644 --- a/contracts/modules/STO/DummySTOFactory.sol +++ b/contracts/modules/STO/DummySTOFactory.sol @@ -13,8 +13,8 @@ contract DummySTOFactory is ModuleFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "DummySTO"; @@ -28,8 +28,7 @@ contract DummySTOFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes _data) external returns(address) { - if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Sufficent Allowance is not provided"); + _takeSetupCost(); //Check valid bytes - can only call module init function DummySTO dummySTO = new DummySTO(msg.sender, address(polyToken)); //Checks that _data is valid (not calling anything it shouldn't) @@ -37,7 +36,7 @@ contract DummySTOFactory is ModuleFactory { /*solium-disable-next-line security/no-low-level-calls*/ require(address(dummySTO).call(_data), "Unsuccessfull call"); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(dummySTO), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(dummySTO), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(dummySTO); } diff --git a/contracts/modules/STO/PreSaleSTOFactory.sol b/contracts/modules/STO/PreSaleSTOFactory.sol index b78a208ed..3d713b979 100644 --- a/contracts/modules/STO/PreSaleSTOFactory.sol +++ b/contracts/modules/STO/PreSaleSTOFactory.sol @@ -13,8 +13,8 @@ contract PreSaleSTOFactory is ModuleFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "PreSaleSTO"; @@ -30,9 +30,7 @@ contract PreSaleSTOFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes _data) external returns(address) { - if (setupCost > 0) { - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Sufficent Allowance is not provided"); - } + _takeSetupCost(); //Check valid bytes - can only call module init function PreSaleSTO preSaleSTO = new PreSaleSTO(msg.sender, address(polyToken)); //Checks that _data is valid (not calling anything it shouldn't) @@ -40,7 +38,7 @@ contract PreSaleSTOFactory is ModuleFactory { /*solium-disable-next-line security/no-low-level-calls*/ require(address(preSaleSTO).call(_data), "Unsuccessfull call"); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(preSaleSTO), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(preSaleSTO), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(preSaleSTO); } @@ -52,7 +50,7 @@ contract PreSaleSTOFactory is ModuleFactory { res[0] = 3; return res; } - + /** * @notice Returns the instructions associated with the module */ diff --git a/contracts/modules/STO/USDTieredSTOFactory.sol b/contracts/modules/STO/USDTieredSTOFactory.sol index 51dbbc87f..0276e2a58 100644 --- a/contracts/modules/STO/USDTieredSTOFactory.sol +++ b/contracts/modules/STO/USDTieredSTOFactory.sol @@ -15,8 +15,8 @@ contract USDTieredSTOFactory is ModuleFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _proxyFactoryAddress) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _proxyFactoryAddress, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { require(_proxyFactoryAddress != address(0), "0x address is not allowed"); USDTieredSTOProxyAddress = _proxyFactoryAddress; @@ -34,8 +34,7 @@ contract USDTieredSTOFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes _data) external returns(address) { - if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Sufficent Allowance is not provided"); + _takeSetupCost(); require(USDTieredSTOProxyAddress != address(0), "Proxy contract should be pre-set"); //Check valid bytes - can only call module init function address usdTieredSTO = IUSDTieredSTOProxy(USDTieredSTOProxyAddress).deploySTO(msg.sender, address(polyToken), address(this)); @@ -44,7 +43,7 @@ contract USDTieredSTOFactory is ModuleFactory { /*solium-disable-next-line security/no-low-level-calls*/ require(address(usdTieredSTO).call(_data), "Unsuccessfull call"); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(usdTieredSTO, getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(usdTieredSTO, getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(usdTieredSTO); } diff --git a/contracts/modules/TransferManager/CountTransferManagerFactory.sol b/contracts/modules/TransferManager/CountTransferManagerFactory.sol index 48c2f3705..c54fbb37f 100644 --- a/contracts/modules/TransferManager/CountTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/CountTransferManagerFactory.sol @@ -13,8 +13,8 @@ contract CountTransferManagerFactory is ModuleFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "CountTransferManager"; @@ -30,14 +30,13 @@ contract CountTransferManagerFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes _data) external returns(address) { - if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom due to insufficent Allowance provided"); + _takeSetupCost(); CountTransferManager countTransferManager = new CountTransferManager(msg.sender, address(polyToken)); require(Util.getSig(_data) == countTransferManager.getInitFunction(), "Provided data is not valid"); /*solium-disable-next-line security/no-low-level-calls*/ require(address(countTransferManager).call(_data), "Unsuccessful call"); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(countTransferManager), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(countTransferManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(countTransferManager); } diff --git a/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol b/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol index f073dee6f..a2659395b 100644 --- a/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol @@ -12,8 +12,8 @@ contract GeneralTransferManagerFactory is ModuleFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "GeneralTransferManager"; @@ -29,11 +29,10 @@ contract GeneralTransferManagerFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes /* _data */) external returns(address) { - if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + _takeSetupCost(); address generalTransferManager = new GeneralTransferManager(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(generalTransferManager), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(generalTransferManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(generalTransferManager); } diff --git a/contracts/modules/TransferManager/ManualApprovalTransferManagerFactory.sol b/contracts/modules/TransferManager/ManualApprovalTransferManagerFactory.sol index f2a3ddd6a..7a8e1192c 100644 --- a/contracts/modules/TransferManager/ManualApprovalTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/ManualApprovalTransferManagerFactory.sol @@ -15,8 +15,8 @@ contract ManualApprovalTransferManagerFactory is ModuleFactory { * @param _usageCost Usage cost of the module * @param _subscriptionCost Subscription cost of the module */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "ManualApprovalTransferManager"; @@ -31,11 +31,10 @@ contract ManualApprovalTransferManagerFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes /* _data */) external returns(address) { - if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + _takeSetupCost(); address manualTransferManager = new ManualApprovalTransferManager(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(manualTransferManager), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(manualTransferManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(manualTransferManager); } diff --git a/contracts/modules/TransferManager/PercentageTransferManagerFactory.sol b/contracts/modules/TransferManager/PercentageTransferManagerFactory.sol index 81a9a01fd..effce999e 100644 --- a/contracts/modules/TransferManager/PercentageTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/PercentageTransferManagerFactory.sol @@ -13,8 +13,8 @@ contract PercentageTransferManagerFactory is ModuleFactory { * @notice Constructor * @param _polyAddress Address of the polytoken */ - constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public - ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost, address _polymathRegistry) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost, _polymathRegistry) { version = "1.0.0"; name = "PercentageTransferManager"; @@ -30,14 +30,13 @@ contract PercentageTransferManagerFactory is ModuleFactory { * @return address Contract address of the Module */ function deploy(bytes _data) external returns(address) { - if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + _takeSetupCost(); PercentageTransferManager percentageTransferManager = new PercentageTransferManager(msg.sender, address(polyToken)); require(Util.getSig(_data) == percentageTransferManager.getInitFunction(), "Provided data is not valid"); /*solium-disable-next-line security/no-low-level-calls*/ require(address(percentageTransferManager).call(_data), "Unsuccessful call"); /*solium-disable-next-line security/no-block-members*/ - emit GenerateModuleFromFactory(address(percentageTransferManager), getName(), address(this), msg.sender, setupCost, now); + emit GenerateModuleFromFactory(address(percentageTransferManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now); return address(percentageTransferManager); } diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 9cb54865c..71d1da81d 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -232,7 +232,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater IModuleRegistry(moduleRegistry).useModule(_moduleFactory); IModuleFactory moduleFactory = IModuleFactory(_moduleFactory); uint8[] memory moduleTypes = moduleFactory.getTypes(); - uint256 moduleCost = moduleFactory.getSetupCost(); + uint256 moduleCost = moduleFactory.getSetupCostInPoly(); require(moduleCost <= _maxCost, "Invalid cost"); //Approve fee for module ERC20(polyToken).approve(_moduleFactory, moduleCost); diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 14bdf9fed..4d047975c 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -149,31 +149,31 @@ module.exports = function (deployer, network, accounts) { }).then(() => { // B) Deploy the GeneralTransferManagerFactory Contract (Factory used to generate the GeneralTransferManager contract and this // manager attach with the securityToken contract at the time of deployment) - return deployer.deploy(GeneralTransferManagerFactory, PolyToken, 0, 0, 0, {from: PolymathAccount}); + return deployer.deploy(GeneralTransferManagerFactory, PolyToken, 0, 0, 0, PolymathRegistry.address, {from: PolymathAccount}); }).then(() => { // C) Deploy the GeneralPermissionManagerFactory Contract (Factory used to generate the GeneralPermissionManager contract and // this manager attach with the securityToken contract at the time of deployment) - return deployer.deploy(GeneralPermissionManagerFactory, PolyToken, 0, 0, 0, {from: PolymathAccount}); + return deployer.deploy(GeneralPermissionManagerFactory, PolyToken, 0, 0, 0, PolymathRegistry.address, {from: PolymathAccount}); }).then(() => { // D) Deploy the CountTransferManagerFactory Contract (Factory used to generate the CountTransferManager contract use // to track the counts of the investors of the security token) - return deployer.deploy(CountTransferManagerFactory, PolyToken, 0, 0, 0, {from: PolymathAccount}); + return deployer.deploy(CountTransferManagerFactory, PolyToken, 0, 0, 0, PolymathRegistry.address, {from: PolymathAccount}); }).then(() => { // D) Deploy the PercentageTransferManagerFactory Contract (Factory used to generate the PercentageTransferManager contract use // to track the percentage of investment the investors could do for a particular security token) - return deployer.deploy(PercentageTransferManagerFactory, PolyToken, 0, 0, 0, {from: PolymathAccount}); + return deployer.deploy(PercentageTransferManagerFactory, PolyToken, 0, 0, 0, PolymathRegistry.address, {from: PolymathAccount}); }).then(() => { // D) Deploy the EtherDividendCheckpointFactory Contract (Factory used to generate the EtherDividendCheckpoint contract use // to provide the functionality of the dividend in terms of ETH) - return deployer.deploy(EtherDividendCheckpointFactory, PolyToken, 0, 0, 0, {from: PolymathAccount}); + return deployer.deploy(EtherDividendCheckpointFactory, PolyToken, 0, 0, 0, PolymathRegistry.address, {from: PolymathAccount}); }).then(() => { // D) Deploy the ERC20DividendCheckpointFactory Contract (Factory used to generate the ERC20DividendCheckpoint contract use // to provide the functionality of the dividend in terms of ERC20 token) - return deployer.deploy(ERC20DividendCheckpointFactory, PolyToken, 0, 0, 0, {from: PolymathAccount}); + return deployer.deploy(ERC20DividendCheckpointFactory, PolyToken, 0, 0, 0, PolymathRegistry.address, {from: PolymathAccount}); }).then(() => { // D) Deploy the ManualApprovalTransferManagerFactory Contract (Factory used to generate the ManualApprovalTransferManager contract use // to manual approve the transfer that will overcome the other transfer restrictions) - return deployer.deploy(ManualApprovalTransferManagerFactory, PolyToken, 0, 0, 0, {from: PolymathAccount}); + return deployer.deploy(ManualApprovalTransferManagerFactory, PolyToken, 0, 0, 0, PolymathRegistry.address, {from: PolymathAccount}); }).then(() => { // H) Deploy the STVersionProxy001 Contract which contains the logic of deployment of securityToken. return deployer.deploy(STFactory, GeneralTransferManagerFactory.address, {from: PolymathAccount}); @@ -262,7 +262,7 @@ module.exports = function (deployer, network, accounts) { return moduleRegistry.verifyModule(ManualApprovalTransferManagerFactory.address, true, {from: PolymathAccount}); }).then(() => { // M) Deploy the CappedSTOFactory (Use to generate the CappedSTO contract which will used to collect the funds ). - return deployer.deploy(CappedSTOFactory, PolyToken, cappedSTOSetupCost, 0, 0, {from: PolymathAccount}) + return deployer.deploy(CappedSTOFactory, PolyToken, cappedSTOSetupCost, 0, 0, PolymathRegistry.address, {from: PolymathAccount}) }).then(() => { // N) Register the CappedSTOFactory in the ModuleRegistry to make the factory available at the protocol level. // So any securityToken can use that factory to generate the CappedSTOFactory contract. @@ -277,7 +277,7 @@ module.exports = function (deployer, network, accounts) { return deployer.deploy(USDTieredSTOProxyFactory, {from: PolymathAccount}); }).then(() => { // H) Deploy the USDTieredSTOFactory (Use to generate the USDTieredSTOFactory contract which will used to collect the funds ). - return deployer.deploy(USDTieredSTOFactory, PolyToken, usdTieredSTOSetupCost, 0, 0, USDTieredSTOProxyFactory.address, {from: PolymathAccount}) + return deployer.deploy(USDTieredSTOFactory, PolyToken, usdTieredSTOSetupCost, 0, 0, USDTieredSTOProxyFactory.address, PolymathRegistry.address, {from: PolymathAccount}) }).then(() => { // I) Register the USDTieredSTOFactory in the ModuleRegistry to make the factory available at the protocol level. // So any securityToken can use that factory to generate the USDTieredSTOFactory contract. diff --git a/truffle-config.js b/truffle-config.js index c993327ea..a5236608b 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -11,7 +11,7 @@ module.exports = { host: 'localhost', port: 8545, network_id: '*', // Match any network id - gas: 7900000, + gas: 99000000, }, mainnet: { host: 'localhost', From a73a76309470389c0ad9ff856a76edf08ac5610b Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Thu, 31 Jan 2019 15:00:48 -0400 Subject: [PATCH 2/9] Remove old file --- .../TransferManager/LockupVolumeRestrictionTMFactory.sol | 1 - 1 file changed, 1 deletion(-) delete mode 100644 contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol diff --git a/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol b/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol deleted file mode 100644 index 257cc5642..000000000 --- a/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol +++ /dev/null @@ -1 +0,0 @@ -foo From 560f69fc4cecb42f30ab7f3d8c41520d51c6d9be Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Thu, 31 Jan 2019 15:14:44 -0400 Subject: [PATCH 3/9] Fix migrations --- migrations/2_deploy_contracts.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index d6bd8efcd..dae22700d 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -270,54 +270,54 @@ module.exports = function(deployer, network, accounts) { .then(() => { // B) Deploy the GeneralTransferManagerFactory Contract (Factory used to generate the GeneralTransferManager contract and this // manager attach with the securityToken contract at the time of deployment) - return deployer.deploy(GeneralTransferManagerFactory, new BN(0), new BN(0), new BN(0), GeneralTransferManagerLogic.address, { + return deployer.deploy(GeneralTransferManagerFactory, new BN(0), new BN(0), GeneralTransferManagerLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // C) Deploy the GeneralPermissionManagerFactory Contract (Factory used to generate the GeneralPermissionManager contract and // this manager attach with the securityToken contract at the time of deployment) - return deployer.deploy(GeneralPermissionManagerFactory, new BN(0), new BN(0), new BN(0), GeneralPermissionManagerLogic.address, { + return deployer.deploy(GeneralPermissionManagerFactory, new BN(0), new BN(0), GeneralPermissionManagerLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // D) Deploy the CountTransferManagerFactory Contract (Factory used to generate the CountTransferManager contract use // to track the counts of the investors of the security token) - return deployer.deploy(CountTransferManagerFactory, new BN(0), new BN(0), new BN(0), CountTransferManagerLogic.address, { + return deployer.deploy(CountTransferManagerFactory, new BN(0), new BN(0), CountTransferManagerLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // D) Deploy the PercentageTransferManagerFactory Contract (Factory used to generate the PercentageTransferManager contract use // to track the percentage of investment the investors could do for a particular security token) - return deployer.deploy(PercentageTransferManagerFactory, new BN(0), new BN(0), new BN(0), PercentageTransferManagerLogic.address, { + return deployer.deploy(PercentageTransferManagerFactory, new BN(0), new BN(0), PercentageTransferManagerLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // D) Deploy the EtherDividendCheckpointFactory Contract (Factory used to generate the EtherDividendCheckpoint contract use // to provide the functionality of the dividend in terms of ETH) - return deployer.deploy(EtherDividendCheckpointFactory, new BN(0), new BN(0), new BN(0), EtherDividendCheckpointLogic.address, { + return deployer.deploy(EtherDividendCheckpointFactory, new BN(0), new BN(0), EtherDividendCheckpointLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // D) Deploy the ERC20DividendCheckpointFactory Contract (Factory used to generate the ERC20DividendCheckpoint contract use // to provide the functionality of the dividend in terms of ERC20 token) - return deployer.deploy(ERC20DividendCheckpointFactory, new BN(0), new BN(0), new BN(0), ERC20DividendCheckpointLogic.address, { + return deployer.deploy(ERC20DividendCheckpointFactory, new BN(0), new BN(0), ERC20DividendCheckpointLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // D) Deploy the VolumeRestrictionTMFactory Contract (Factory used to generate the VolumeRestrictionTM contract use // to provide the functionality of restricting the token volume) - return deployer.deploy(VolumeRestrictionTMFactory, new BN(0), new BN(0), new BN(0), VolumeRestrictionTMLogic.address, { from: PolymathAccount }); + return deployer.deploy(VolumeRestrictionTMFactory, new BN(0), new BN(0), VolumeRestrictionTMLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // D) Deploy the ManualApprovalTransferManagerFactory Contract (Factory used to generate the ManualApprovalTransferManager contract use // to manual approve the transfer that will overcome the other transfer restrictions) - return deployer.deploy(ManualApprovalTransferManagerFactory, new BN(0), new BN(0), new BN(0), ManualApprovalTransferManagerLogic.address, { + return deployer.deploy(ManualApprovalTransferManagerFactory, new BN(0), new BN(0), ManualApprovalTransferManagerLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) @@ -457,7 +457,7 @@ module.exports = function(deployer, network, accounts) { }) .then(() => { // M) Deploy the CappedSTOFactory (Use to generate the CappedSTO contract which will used to collect the funds ). - return deployer.deploy(CappedSTOFactory, cappedSTOSetupCost, new BN(0), new BN(0), CappedSTOLogic.address, { from: PolymathAccount }); + return deployer.deploy(CappedSTOFactory, cappedSTOSetupCost, new BN(0), CappedSTOLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // N) Register the CappedSTOFactory in the ModuleRegistry to make the factory available at the protocol level. @@ -472,7 +472,7 @@ module.exports = function(deployer, network, accounts) { }) .then(() => { // H) Deploy the USDTieredSTOFactory (Use to generate the USDTieredSTOFactory contract which will used to collect the funds ). - return deployer.deploy(USDTieredSTOFactory, usdTieredSTOSetupCost, new BN(0), new BN(0), USDTieredSTOLogic.address, { from: PolymathAccount }); + return deployer.deploy(USDTieredSTOFactory, usdTieredSTOSetupCost, new BN(0), USDTieredSTOLogic.address, polymathRegistry.address, { from: PolymathAccount }); }) .then(() => { // I) Register the USDTieredSTOFactory in the ModuleRegistry to make the factory available at the protocol level. From a889af3e86dec79e7503509b23a9d374bdad9eac Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Fri, 1 Feb 2019 09:31:10 -0400 Subject: [PATCH 4/9] Fixes and test cases --- contracts/PolymathRegistry.sol | 2 +- contracts/SecurityTokenRegistry.sol | 45 ++++++++++++++-------- contracts/modules/ModuleFactory.sol | 8 ++-- test/b_capped_sto.js | 29 +++++++------- test/helpers/createInstances.js | 59 ++++++++++++++++++----------- 5 files changed, 88 insertions(+), 55 deletions(-) diff --git a/contracts/PolymathRegistry.sol b/contracts/PolymathRegistry.sol index 15e34ff6f..f80144b43 100644 --- a/contracts/PolymathRegistry.sol +++ b/contracts/PolymathRegistry.sol @@ -17,7 +17,7 @@ contract PolymathRegistry is ReclaimTokens { */ function getAddress(string calldata _nameKey) external view returns(address) { bytes32 key = keccak256(bytes(_nameKey)); - require(storedAddresses[key] != address(0), "Invalid address key"); + require(storedAddresses[key] != address(0), "Invalid key"); return storedAddresses[key]; } diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index 60c085e72..7de9c3be8 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -11,6 +11,8 @@ import "./libraries/Util.sol"; import "./libraries/Encoder.sol"; import "./libraries/VersionUtils.sol"; import "./proxy/Proxy.sol"; +import "./interfaces/IOracle.sol"; +import "./libraries/DecimalMath.sol"; /** * @title Registry contract for issuers to register their tickers and security tokens @@ -74,6 +76,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { bytes32 constant POLYMATHREGISTRY = 0x90eeab7c36075577c7cc5ff366e389fefa8a18289b949bab3529ab4471139d4d; bytes32 constant STRGETTER = 0x982f24b3bd80807ec3cb227ba152e15c07d66855fa8ae6ca536e689205c0e2e9; + string constant POLY_ORACLE = "PolyUsdOracle"; + // Emit when network becomes paused event Pause(uint256 _timestammp); // Emit when network becomes unpaused @@ -99,7 +103,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { uint256 _addedAt, address _registrant, bool _fromAdmin, - uint256 _registrationFee + uint256 _usdFee, + uint256 _polyFee ); // Emit after ticker registration event RegisterTicker( @@ -109,7 +114,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { uint256 indexed _registrationDate, uint256 indexed _expiryDate, bool _fromAdmin, - uint256 _registrationFee + uint256 _usdFee, + uint256 _polyFee ); ///////////////////////////// @@ -205,6 +211,19 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { set(POLYTOKEN, IPolymathRegistry(polymathRegistry).getAddress("PolyToken")); } + /** + * @notice Converts USD fees into POLY amounts + */ + function _takeFee(bytes32 _feeType) internal returns (uint256, uint256){ + address polymathRegistry = getAddressValue(POLYMATHREGISTRY); + uint256 polyRate = IOracle(IPolymathRegistry(polymathRegistry).getAddress(POLY_ORACLE)).getPrice(); + uint256 usdFee = getUintValue(_feeType); + uint256 polyFee = DecimalMath.div(usdFee, polyRate); + if (polyFee > 0) + require(IERC20(getAddressValue(POLYTOKEN)).transferFrom(msg.sender, address(this), polyFee), "Insufficent allowance"); + return (usdFee, polyFee); + } + /** * @notice Set the getter contract address * @param _getterContract Address of the contract @@ -234,9 +253,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { require(_owner != address(0), "Owner should not be 0x"); require(bytes(_ticker).length > 0 && bytes(_ticker).length <= 10, "Ticker length range (0,10]"); // Attempt to charge the reg fee if it is > 0 POLY - uint256 tickerFee = getUintValue(TICKERREGFEE); - if (tickerFee > 0) - require(IERC20(getAddressValue(POLYTOKEN)).transferFrom(msg.sender, address(this), tickerFee), "Insufficent allowance"); + (uint256 _usdFee, uint256 _polyFee) = _takeFee(TICKERREGFEE); string memory ticker = Util.upper(_ticker); require(_tickerAvailable(ticker), "Ticker is reserved"); // Check whether ticker was previously registered (and expired) @@ -245,7 +262,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { _deleteTickerOwnership(previousOwner, ticker); } /*solium-disable-next-line security/no-block-members*/ - _addTicker(_owner, ticker, _tokenName, now, now.add(getUintValue(EXPIRYLIMIT)), false, false, tickerFee); + _addTicker(_owner, ticker, _tokenName, now, now.add(getUintValue(EXPIRYLIMIT)), false, false, _usdFee, _polyFee); } /** @@ -259,13 +276,14 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { uint256 _expiryDate, bool _status, bool _fromAdmin, - uint256 _fee + uint256 _usdFee, + uint256 _polyFee ) internal { _setTickerOwnership(_owner, _ticker); _storeTickerDetails(_ticker, _owner, _registrationDate, _expiryDate, _tokenName, _status); - emit RegisterTicker(_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _fromAdmin, _fee); + emit RegisterTicker(_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _fromAdmin, _usdFee, _polyFee); } /** @@ -321,7 +339,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { if (_status) { require(getAddressValue(Encoder.getKey("tickerToSecurityToken", _ticker)) != address(0), "Token not registered"); } - _addTicker(_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _status, true, uint256(0)); + _addTicker(_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _status, true, uint256(0), uint256(0)); } function _tickerOwner(string memory _ticker) internal view returns(address) { @@ -478,10 +496,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { require(_tickerOwner(ticker) == msg.sender, "Not authorised"); /*solium-disable-next-line security/no-block-members*/ require(getUintValue(Encoder.getKey("registeredTickers_expiryDate", ticker)) >= now, "Ticker gets expired"); - - uint256 launchFee = getUintValue(STLAUNCHFEE); - if (launchFee > 0) - require(IERC20(getAddressValue(POLYTOKEN)).transferFrom(msg.sender, address(this), launchFee), "Insufficient allowance"); + (uint256 _usdFee, uint256 _polyFee) = _takeFee(STLAUNCHFEE); address newSecurityTokenAddress = ISTFactory(getAddressValue(Encoder.getKey("protocolVersionST", getUintValue(Encoder.getKey("latestVersion"))))).deployToken( _name, @@ -497,7 +512,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { _storeSecurityTokenData(newSecurityTokenAddress, ticker, _tokenDetails, now); set(Encoder.getKey("tickerToSecurityToken", ticker), newSecurityTokenAddress); /*solium-disable-next-line security/no-block-members*/ - emit NewSecurityToken(ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, launchFee); + emit NewSecurityToken(ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee); } /** @@ -535,7 +550,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { set(Encoder.getKey("tickerToSecurityToken", ticker), _securityToken); _modifyTicker(_owner, ticker, _name, registrationTime, expiryTime, true); _storeSecurityTokenData(_securityToken, ticker, _tokenDetails, _deployedAt); - emit NewSecurityToken(ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, getUintValue(STLAUNCHFEE)); + emit NewSecurityToken(ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0)); } /** diff --git a/contracts/modules/ModuleFactory.sol b/contracts/modules/ModuleFactory.sol index e148b7644..b8a2c8398 100644 --- a/contracts/modules/ModuleFactory.sol +++ b/contracts/modules/ModuleFactory.sol @@ -6,7 +6,7 @@ import "../interfaces/IModuleFactory.sol"; import "../interfaces/IOracle.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "../libraries/VersionUtils.sol"; -import "../PolymathRegistry.sol"; +import "../interfaces/IPolymathRegistry.sol"; import "../libraries/DecimalMath.sol"; /** @@ -142,8 +142,8 @@ contract ModuleFactory is IModuleFactory, Ownable { * @notice Get the setup cost of the module */ function getSetupCostInPoly() public view returns (uint256) { - uint256 polyRate = IOracle(PolymathRegistry(polymathRegistry).getAddress(POLY_ORACLE)).getPrice(); - return DecimalMath.mul(setupCost, polyRate); + uint256 polyRate = IOracle(IPolymathRegistry(polymathRegistry).getAddress(POLY_ORACLE)).getPrice(); + return DecimalMath.div(setupCost, polyRate); } /** @@ -159,7 +159,7 @@ contract ModuleFactory is IModuleFactory, Ownable { */ function _takeFee() internal returns(address) { uint256 setupCostInPoly = getSetupCostInPoly(); - address polyToken = PolymathRegistry(polymathRegistry).getAddress("PolyToken"); + address polyToken = IPolymathRegistry(polymathRegistry).getAddress("PolyToken"); if (setupCostInPoly > 0) { require(IERC20(polyToken).transferFrom(msg.sender, owner(), setupCostInPoly), "Insufficient allowance for module fee"); } diff --git a/test/b_capped_sto.js b/test/b_capped_sto.js index d98271c7e..1a65d76ce 100644 --- a/test/b_capped_sto.js +++ b/test/b_capped_sto.js @@ -80,7 +80,7 @@ contract("CappedSTO", async (accounts) => { const budget = 0; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); // Capped STO details let startTime_ETH1; @@ -101,7 +101,8 @@ contract("CappedSTO", async (accounts) => { const P_fundRaiseType = 1; const P_rate = new BN(web3.utils.toWei("5")); const cappedSTOSetupCost = new BN(web3.utils.toWei("20000", "ether")); - const maxCost = cappedSTOSetupCost; + const cappedSTOSetupCostPOLY = new BN(web3.utils.toWei("80000", "ether")); + const maxCost = cappedSTOSetupCostPOLY; const STOParameters = ["uint256", "uint256", "uint256", "uint256", "uint8[]", "address"]; let currentTime; @@ -193,7 +194,7 @@ contract("CappedSTO", async (accounts) => { it("Should fail to launch the STO due to security token doesn't have the sufficient POLY", async () => { let startTime = await latestTime() + duration.days(1); let endTime = startTime + duration.days(30); - await I_PolyToken.getTokens(cappedSTOSetupCost, token_owner); + await I_PolyToken.getTokens(cappedSTOSetupCostPOLY, token_owner); let bytesSTO = encodeModuleCall(STOParameters, [startTime, endTime, cap, new BN(0), [E_fundRaiseType], account_fundsReceiver]); @@ -203,7 +204,7 @@ contract("CappedSTO", async (accounts) => { it("Should fail to launch the STO due to rate is 0", async () => { let startTime = await latestTime() + duration.days(1); let endTime = startTime + duration.days(30); - await I_PolyToken.transfer(I_SecurityToken_ETH.address, cappedSTOSetupCost, { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken_ETH.address, cappedSTOSetupCostPOLY, { from: token_owner }); let bytesSTO = encodeModuleCall(STOParameters, [startTime, endTime, cap, new BN(0), [E_fundRaiseType], account_fundsReceiver]); @@ -497,8 +498,8 @@ contract("CappedSTO", async (accounts) => { startTime_ETH2 = await latestTime() + duration.days(1); endTime_ETH2 = startTime_ETH2 + duration.days(30); - await I_PolyToken.getTokens(cappedSTOSetupCost, token_owner); - await I_PolyToken.transfer(I_SecurityToken_ETH.address, cappedSTOSetupCost, { from: token_owner }); + await I_PolyToken.getTokens(cappedSTOSetupCostPOLY, token_owner); + await I_PolyToken.transfer(I_SecurityToken_ETH.address, cappedSTOSetupCostPOLY, { from: token_owner }); let bytesSTO = encodeModuleCall(STOParameters, [ startTime_ETH2, endTime_ETH2, @@ -574,9 +575,10 @@ contract("CappedSTO", async (accounts) => { const MAX_MODULES = 10; let startTime = await latestTime() + duration.days(1); let endTime = startTime + duration.days(30); - - await I_PolyToken.getTokens(new BN(cappedSTOSetupCost.mul(new BN(19))), token_owner); - await I_PolyToken.transfer(I_SecurityToken_ETH.address, new BN(cappedSTOSetupCost.mul(new BN(19))), { from: token_owner }); + for (var i = 0; i < MAX_MODULES; i++) { + await I_PolyToken.getTokens(new BN(cappedSTOSetupCostPOLY), token_owner); + }; + await I_PolyToken.transfer(I_SecurityToken_ETH.address, new BN(cappedSTOSetupCostPOLY.mul(new BN(MAX_MODULES))), { from: token_owner }); let bytesSTO = encodeModuleCall(STOParameters, [startTime, endTime, cap, rate, [E_fundRaiseType], account_fundsReceiver]); for (var STOIndex = 2; STOIndex < MAX_MODULES; STOIndex++) { @@ -639,8 +641,8 @@ contract("CappedSTO", async (accounts) => { startTime_POLY1 = await latestTime() + duration.days(2); endTime_POLY1 = startTime_POLY1 + duration.days(30); - await I_PolyToken.getTokens(cappedSTOSetupCost, token_owner); - await I_PolyToken.transfer(I_SecurityToken_POLY.address, cappedSTOSetupCost, { from: token_owner }); + await I_PolyToken.getTokens(cappedSTOSetupCostPOLY, token_owner); + await I_PolyToken.transfer(I_SecurityToken_POLY.address, cappedSTOSetupCostPOLY, { from: token_owner }); let bytesSTO = encodeModuleCall(STOParameters, [ startTime_POLY1, @@ -821,6 +823,7 @@ contract("CappedSTO", async (accounts) => { describe("Test cases for the CappedSTOFactory", async () => { it("should get the exact details of the factory", async () => { assert.equal((await I_CappedSTOFactory.getSetupCost.call()).toString(), cappedSTOSetupCost.toString()); + assert.equal((await I_CappedSTOFactory.getSetupCostInPoly.call()).toString(), cappedSTOSetupCostPOLY.toString()); assert.equal((await I_CappedSTOFactory.getTypes.call())[0], 3); assert.equal(web3.utils.hexToString(await I_CappedSTOFactory.getName.call()), "CappedSTO", "Wrong Module added"); assert.equal( @@ -918,8 +921,8 @@ contract("CappedSTO", async (accounts) => { startTime_POLY2 = await latestTime() + duration.days(1); endTime_POLY2 = startTime_POLY2 + duration.days(30); - await I_PolyToken.getTokens(cappedSTOSetupCost, token_owner); - await I_PolyToken.transfer(I_SecurityToken_POLY.address, cappedSTOSetupCost, { from: token_owner }); + await I_PolyToken.getTokens(cappedSTOSetupCostPOLY, token_owner); + await I_PolyToken.transfer(I_SecurityToken_POLY.address, cappedSTOSetupCostPOLY, { from: token_owner }); let bytesSTO = encodeModuleCall(STOParameters, [ startTime_POLY2, diff --git a/test/helpers/createInstances.js b/test/helpers/createInstances.js index f9d0ab10c..1c3a0fe6b 100644 --- a/test/helpers/createInstances.js +++ b/test/helpers/createInstances.js @@ -1,6 +1,7 @@ import { encodeProxyCall, encodeModuleCall } from "./encodeCall"; const PolymathRegistry = artifacts.require("./PolymathRegistry.sol"); +const MockOracle = artifacts.require("./MockOracle.sol"); const ModuleRegistry = artifacts.require("./ModuleRegistry.sol"); const ModuleRegistryProxy = artifacts.require("./ModuleRegistryProxy.sol"); const SecurityToken = artifacts.require("./SecurityToken.sol"); @@ -100,6 +101,8 @@ let I_STRProxied; let I_MRProxied; let I_STRGetter; let I_SignedTransferManagerFactory; +let I_USDOracle; +let I_POLYOracle; // Initial fee for ticker registry and security token registry const initRegFee = new BN(web3.utils.toWei("250")); @@ -129,6 +132,9 @@ export async function setUpPolymathNetwork(account_polymath, token_owner) { await setInPolymathRegistry(account_polymath); // STEP 9: Register the Modules with the ModuleRegistry contract await registerGTM(account_polymath); + // STEP 10: Add dummy oracles + await addOracles(account_polymath); + let tempArray = new Array( I_PolymathRegistry, I_PolyToken, @@ -146,6 +152,15 @@ export async function setUpPolymathNetwork(account_polymath, token_owner) { return Promise.all(tempArray); } +export async function addOracles(account_polymath) { + let USDETH = new BN(500).mul(new BN(10).pow(new BN(18))); // 500 USD/ETH + let USDPOLY = new BN(25).mul(new BN(10).pow(new BN(16))); // 0.25 USD/POLY + I_USDOracle = await MockOracle.new("0x0000000000000000000000000000000000000000", web3.utils.fromAscii("ETH"), web3.utils.fromAscii("USD"), USDETH, { from: account_polymath }); // 500 dollars per POLY + I_POLYOracle = await MockOracle.new(I_PolyToken.address, web3.utils.fromAscii("POLY"), web3.utils.fromAscii("USD"), USDPOLY, { from: account_polymath }); // 25 cents per POLY + await I_PolymathRegistry.changeAddress("EthUsdOracle", I_USDOracle.address, { from: account_polymath }); + await I_PolymathRegistry.changeAddress("PolyUsdOracle", I_POLYOracle.address, { from: account_polymath }); +} + export async function deployPolyRegistryAndPolyToken(account_polymath, token_owner) { // Step 0: Deploy the PolymathRegistry I_PolymathRegistry = await PolymathRegistry.new({ from: account_polymath }); @@ -195,7 +210,7 @@ async function deployGTMLogic(account_polymath) { } async function deployGTM(account_polymath) { - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(new BN(0), new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, { + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, { from: account_polymath }); @@ -266,7 +281,7 @@ async function registerAndVerifyByMR(factoryAdrress, owner, mr) { /// Deploy the TransferManagers export async function deployGTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(setupCost, new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, { + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(setupCost, new BN(0), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); @@ -284,7 +299,7 @@ export async function deployGTMAndVerifyed(accountPolymath, MRProxyInstance, set export async function deployVRTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { I_VolumeRestrictionTMLogic = await VolumeRestrictionTM.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_VolumeRestrictionTMFactory = await VolumeRestrictionTMFactory.new(setupCost, new BN(0), new BN(0), I_VolumeRestrictionTMLogic.address, { from: accountPolymath }); + I_VolumeRestrictionTMFactory = await VolumeRestrictionTMFactory.new(setupCost, new BN(0), I_VolumeRestrictionTMLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_VolumeRestrictionTMFactory.address.valueOf(), @@ -299,7 +314,7 @@ export async function deployVRTMAndVerifyed(accountPolymath, MRProxyInstance, se export async function deployCountTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { I_CountTransferManagerLogic = await CountTransferManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_CountTransferManagerFactory = await CountTransferManagerFactory.new(setupCost, new BN(0), new BN(0), I_CountTransferManagerLogic.address, { from: accountPolymath }); + I_CountTransferManagerFactory = await CountTransferManagerFactory.new(setupCost, new BN(0), I_CountTransferManagerLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_CountTransferManagerFactory.address.valueOf(), @@ -313,7 +328,7 @@ export async function deployCountTMAndVerifyed(accountPolymath, MRProxyInstance, export async function deployManualApprovalTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { I_ManualApprovalTransferManagerLogic = await ManualApprovalTransferManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_ManualApprovalTransferManagerFactory = await ManualApprovalTransferManagerFactory.new(setupCost, new BN(0), new BN(0), ManualApprovalTransferManager.address, { from: accountPolymath }); + I_ManualApprovalTransferManagerFactory = await ManualApprovalTransferManagerFactory.new(setupCost, new BN(0), ManualApprovalTransferManager.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_ManualApprovalTransferManagerFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -326,7 +341,7 @@ export async function deployManualApprovalTMAndVerifyed(accountPolymath, MRProxy export async function deployPercentageTMAndVerified(accountPolymath, MRProxyInstance, setupCost) { I_PercentageTransferManagerLogic = await PercentageTransferManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_PercentageTransferManagerFactory = await PercentageTransferManagerFactory.new(setupCost, new BN(0), new BN(0), I_PercentageTransferManagerLogic.address, { from: accountPolymath }); + I_PercentageTransferManagerFactory = await PercentageTransferManagerFactory.new(setupCost, new BN(0), I_PercentageTransferManagerLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_PercentageTransferManagerFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -339,7 +354,7 @@ export async function deployPercentageTMAndVerified(accountPolymath, MRProxyInst export async function deployBlacklistTMAndVerified(accountPolymath, MRProxyInstance, setupCost) { - I_BlacklistTransferManagerFactory = await BlacklistTransferManagerFactory.new(setupCost, new BN(0), new BN(0), { from: accountPolymath }); + I_BlacklistTransferManagerFactory = await BlacklistTransferManagerFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_BlacklistTransferManagerFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -351,7 +366,7 @@ export async function deployBlacklistTMAndVerified(accountPolymath, MRProxyInsta } export async function deployLockupVolumeRTMAndVerified(accountPolymath, MRProxyInstance, setupCost) { - I_VolumeRestrictionTransferManagerFactory = await LockUpTransferManagerFactory.new(setupCost, new BN(0), new BN(0), { + I_VolumeRestrictionTransferManagerFactory = await LockUpTransferManagerFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( @@ -365,7 +380,7 @@ export async function deployLockupVolumeRTMAndVerified(accountPolymath, MRProxyI } export async function deployScheduleCheckpointAndVerified(accountPolymath, MRProxyInstance, setupCost) { - I_ScheduledCheckpointFactory = await ScheduledCheckpointFactory.new(setupCost, new BN(0), new BN(0), { from: accountPolymath }); + I_ScheduledCheckpointFactory = await ScheduledCheckpointFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_ScheduledCheckpointFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -380,7 +395,7 @@ export async function deployScheduleCheckpointAndVerified(accountPolymath, MRPro export async function deployGPMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { I_GeneralPermissionManagerLogic = await GeneralPermissionManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(setupCost, new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, { from: accountPolymath }); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(setupCost, new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -397,7 +412,7 @@ export async function deployGPMAndVerifyed(accountPolymath, MRProxyInstance, set export async function deployDummySTOAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { I_DummySTOLogic = await DummySTO.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_DummySTOFactory = await DummySTOFactory.new(setupCost, new BN(0), new BN(0), I_DummySTOLogic.address,{ from: accountPolymath }); + I_DummySTOFactory = await DummySTOFactory.new(setupCost, new BN(0), I_DummySTOLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_DummySTOFactory.address.valueOf(), @@ -410,7 +425,7 @@ export async function deployDummySTOAndVerifyed(accountPolymath, MRProxyInstance export async function deployCappedSTOAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { I_CappedSTOLogic = await CappedSTO.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_CappedSTOFactory = await CappedSTOFactory.new(setupCost, new BN(0), new BN(0), I_CappedSTOLogic.address, { from: accountPolymath }); + I_CappedSTOFactory = await CappedSTOFactory.new(setupCost, new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_CappedSTOFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -423,7 +438,7 @@ export async function deployCappedSTOAndVerifyed(accountPolymath, MRProxyInstanc export async function deployPresaleSTOAndVerified(accountPolymath, MRProxyInstance, setupCost) { I_PreSaleSTOLogic = await PreSaleSTO.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_PreSaleSTOFactory = await PreSaleSTOFactory.new(setupCost, new BN(0), new BN(0), I_PreSaleSTOLogic.address, { from: accountPolymath }); + I_PreSaleSTOFactory = await PreSaleSTOFactory.new(setupCost, new BN(0), I_PreSaleSTOLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_PreSaleSTOFactory.address.valueOf(), @@ -442,7 +457,7 @@ export async function deployUSDTieredSTOAndVerified(accountPolymath, MRProxyInst { from: accountPolymath } ); - I_USDTieredSTOFactory = await USDTieredSTOFactory.new(setupCost, new BN(0), new BN(0), I_USDTieredSTOLogic.address, { from: accountPolymath }); + I_USDTieredSTOFactory = await USDTieredSTOFactory.new(setupCost, new BN(0), I_USDTieredSTOLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_USDTieredSTOFactory.address.valueOf(), @@ -462,7 +477,7 @@ export async function deployERC20DividendAndVerifyed(accountPolymath, MRProxyIns "0x0000000000000000000000000000000000000000", { from: accountPolymath } ); - I_ERC20DividendCheckpointFactory = await ERC20DividendCheckpointFactory.new(setupCost, new BN(0), new BN(0), I_ERC20DividendCheckpointLogic.address, { + I_ERC20DividendCheckpointFactory = await ERC20DividendCheckpointFactory.new(setupCost, new BN(0), I_ERC20DividendCheckpointLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); @@ -481,7 +496,7 @@ export async function deployEtherDividendAndVerifyed(accountPolymath, MRProxyIns "0x0000000000000000000000000000000000000000", { from: accountPolymath } ); - I_EtherDividendCheckpointFactory = await EtherDividendCheckpointFactory.new(setupCost, new BN(0), new BN(0), I_EtherDividendCheckpointLogic.address, { + I_EtherDividendCheckpointFactory = await EtherDividendCheckpointFactory.new(setupCost, new BN(0), I_EtherDividendCheckpointLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); @@ -498,7 +513,7 @@ export async function deployEtherDividendAndVerifyed(accountPolymath, MRProxyIns /// Deploy the Burn Module export async function deployRedemptionAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { - I_TrackedRedemptionFactory = await TrackedRedemptionFactory.new(setupCost, new BN(0), new BN(0), { from: accountPolymath }); + I_TrackedRedemptionFactory = await TrackedRedemptionFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_TrackedRedemptionFactory.address.valueOf(), @@ -512,7 +527,7 @@ export async function deployRedemptionAndVerifyed(accountPolymath, MRProxyInstan export async function deployVestingEscrowWalletAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { I_VestingEscrowWalletLogic = await VestingEscrowWallet.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_VestingEscrowWalletFactory = await VestingEscrowWalletFactory.new(setupCost, new BN(0), new BN(0), I_VestingEscrowWalletLogic.address, { from: accountPolymath }); + I_VestingEscrowWalletFactory = await VestingEscrowWalletFactory.new(setupCost, new BN(0), I_VestingEscrowWalletLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_VestingEscrowWalletFactory.address.valueOf(), @@ -525,7 +540,7 @@ export async function deployVestingEscrowWalletAndVerifyed(accountPolymath, MRPr } export async function deployMockRedemptionAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { - I_MockBurnFactory = await MockBurnFactory.new(setupCost, new BN(0), new BN(0), { from: accountPolymath }); + I_MockBurnFactory = await MockBurnFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_MockBurnFactory.address.valueOf(), @@ -538,7 +553,7 @@ export async function deployMockRedemptionAndVerifyed(accountPolymath, MRProxyIn } export async function deployMockWrongTypeRedemptionAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { - I_MockWrongTypeBurnFactory = await MockWrongTypeFactory.new(setupCost, new BN(0), new BN(0), { from: accountPolymath }); + I_MockWrongTypeBurnFactory = await MockWrongTypeFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_MockWrongTypeBurnFactory.address.valueOf(), @@ -551,7 +566,7 @@ export async function deployMockWrongTypeRedemptionAndVerifyed(accountPolymath, } export async function deploySignedTMAndVerifyed(accountPolymath, MRProxyInstance, polyToken, setupCost) { - I_SignedTransferManagerFactory = await SignedTransferManagerFactory.new(setupCost, 0, 0, { from: accountPolymath }); + I_SignedTransferManagerFactory = await SignedTransferManagerFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); assert.notEqual( I_SignedTransferManagerFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -560,4 +575,4 @@ export async function deploySignedTMAndVerifyed(accountPolymath, MRProxyInstance await registerAndVerifyByMR(I_SignedTransferManagerFactory.address, accountPolymath, MRProxyInstance); return new Array(I_SignedTransferManagerFactory); -} \ No newline at end of file +} From 56e8c7b11213ed8034732f973c6c0fb9430b45f2 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Fri, 1 Feb 2019 11:20:10 -0400 Subject: [PATCH 5/9] Some fixes --- contracts/modules/ModuleFactory.sol | 1 + test/b_capped_sto.js | 1 + 2 files changed, 2 insertions(+) diff --git a/contracts/modules/ModuleFactory.sol b/contracts/modules/ModuleFactory.sol index b8a2c8398..fb93587c5 100644 --- a/contracts/modules/ModuleFactory.sol +++ b/contracts/modules/ModuleFactory.sol @@ -163,6 +163,7 @@ contract ModuleFactory is IModuleFactory, Ownable { if (setupCostInPoly > 0) { require(IERC20(polyToken).transferFrom(msg.sender, owner(), setupCostInPoly), "Insufficient allowance for module fee"); } + return polyToken; } } diff --git a/test/b_capped_sto.js b/test/b_capped_sto.js index 1a65d76ce..f0b7cb24d 100644 --- a/test/b_capped_sto.js +++ b/test/b_capped_sto.js @@ -717,6 +717,7 @@ contract("CappedSTO", async (accounts) => { (await I_SecurityToken_POLY.balanceOf(account_investor1)).div(new BN(10).pow(new BN(18))).toNumber(), 5000 ); + }); it("Verification of the event Token Purchase", async () => { From 7fc38514f691a67d0c1fafd588215dd5ea542882 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Mon, 4 Feb 2019 07:32:30 -0500 Subject: [PATCH 6/9] Fix lots of tests --- test/c_checkpoints.js | 2 +- test/d_count_transfer_manager.js | 33 +++++++------------ test/e_erc20_dividends.js | 10 +++--- test/f_ether_dividends.js | 10 +++--- test/g_general_permission_manager.js | 12 +++---- test/h_general_transfer_manager.js | 16 ++++----- test/i_Issuance.js | 11 ++++--- test/j_manual_approval_transfer_manager.js | 10 +++--- test/k_module_registry.js | 20 +++++------ test/l_percentage_transfer_manager.js | 10 +++--- test/m_presale_sto.js | 2 +- test/n_security_token_registry.js | 12 +++---- test/o_security_token.js | 2 +- test/p_usd_tiered_sto.js | 6 ++-- test/r_concurrent_STO.js | 2 +- test/u_module_registry_proxy.js | 4 +-- test/v_tracked_redemptions.js | 6 ++-- test/w_lockup_transfer_manager.js | 8 ++--- test/z_blacklist_transfer_manager.js | 10 +++--- .../z_fuzz_test_adding_removing_modules_ST.js | 10 +++--- ...zer_volumn_restriction_transfer_manager.js | 2 +- test/z_general_permission_manager_fuzzer.js | 8 ++--- test/zb_signed_transfer_manager.js | 2 +- 23 files changed, 99 insertions(+), 109 deletions(-) diff --git a/test/c_checkpoints.js b/test/c_checkpoints.js index d50620db6..f115d9c1c 100644 --- a/test/c_checkpoints.js +++ b/test/c_checkpoints.js @@ -59,7 +59,7 @@ contract("Checkpoints", async function(accounts) { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); before(async () => { fromTime = await latestTime(); diff --git a/test/d_count_transfer_manager.js b/test/d_count_transfer_manager.js index d6de7c581..a742f8990 100644 --- a/test/d_count_transfer_manager.js +++ b/test/d_count_transfer_manager.js @@ -65,7 +65,7 @@ contract("CountTransferManager", async (accounts) => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); // CountTransferManager details const holderCount = 2; // Maximum number of token holders @@ -156,9 +156,9 @@ contract("CountTransferManager", async (accounts) => { }); it("Should successfully attach the CountTransferManager factory with the security token", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500", "ether")), token_owner); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000", "ether")), token_owner); await catchRevert( - I_SecurityToken.addModule(P_CountTransferManagerFactory.address, bytesSTO, new BN(web3.utils.toWei("500", "ether")), new BN(0), { + I_SecurityToken.addModule(P_CountTransferManagerFactory.address, bytesSTO, new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }) ); @@ -166,11 +166,11 @@ contract("CountTransferManager", async (accounts) => { it("Should successfully attach the CountTransferManager factory with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("500", "ether")), { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("2000", "ether")), { from: token_owner }); const tx = await I_SecurityToken.addModule( P_CountTransferManagerFactory.address, bytesSTO, - new BN(web3.utils.toWei("500", "ether")), + new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner } ); @@ -434,9 +434,9 @@ contract("CountTransferManager", async (accounts) => { }); it("Should successfully attach the CountTransferManager factory with the security token", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500", "ether")), token_owner); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000", "ether")), token_owner); await catchRevert( - I_SecurityToken2.addModule(P_CountTransferManagerFactory.address, bytesSTO, new BN(web3.utils.toWei("500", "ether")), new BN(0), { + I_SecurityToken2.addModule(P_CountTransferManagerFactory.address, bytesSTO, new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }) ); @@ -496,37 +496,26 @@ contract("CountTransferManager", async (accounts) => { describe("Test cases for the ModuleFactory", async () => { it("Should successfully change the SetupCost -- fail beacuse of bad owner", async () => { await catchRevert( - I_CountTransferManagerFactory.changeFactorySetupFee(new BN(web3.utils.toWei("500")), { from: account_investor3 }) + I_CountTransferManagerFactory.changeSetupCost(new BN(web3.utils.toWei("500")), { from: account_investor3 }) ); }); it("Should successfully change the setupCost", async () => { - await I_CountTransferManagerFactory.changeFactorySetupFee(new BN(web3.utils.toWei("800")), { from: account_polymath }); + await I_CountTransferManagerFactory.changeSetupCost(new BN(web3.utils.toWei("800")), { from: account_polymath }); assert.equal((await I_CountTransferManagerFactory.getSetupCost.call()).toString(), new BN(web3.utils.toWei("800")).toString()); }); it("Should successfully change the usage fee -- fail beacuse of bad owner", async () => { await catchRevert( - I_CountTransferManagerFactory.changeFactoryUsageFee(new BN(web3.utils.toWei("500")), { from: account_investor3 }) + I_CountTransferManagerFactory.changeUsageCost(new BN(web3.utils.toWei("500")), { from: account_investor3 }) ); }); it("Should successfully change the usage fee", async () => { - await I_CountTransferManagerFactory.changeFactoryUsageFee(new BN(web3.utils.toWei("800")), { from: account_polymath }); + await I_CountTransferManagerFactory.changeUsageCost(new BN(web3.utils.toWei("800")), { from: account_polymath }); assert.equal((await I_CountTransferManagerFactory.usageCost.call()).toString(), new BN(web3.utils.toWei("800")).toString()); }); - it("Should successfully change the subscription fee -- fail beacuse of bad owner", async () => { - await catchRevert( - I_CountTransferManagerFactory.changeFactorySubscriptionFee(new BN(web3.utils.toWei("500")), { from: account_investor3 }) - ); - }); - - it("Should successfully change the subscription fee", async () => { - await I_CountTransferManagerFactory.changeFactorySubscriptionFee(new BN(web3.utils.toWei("800")), { from: account_polymath }); - assert.equal((await I_CountTransferManagerFactory.monthlySubscriptionCost.call()), new BN(web3.utils.toWei("800")).toString()); - }); - it("Should successfully change the version of the factory -- failed because of bad owner", async () => { await catchRevert(I_CountTransferManagerFactory.changeVersion("5.0.0", { from: account_investor3 })); }); diff --git a/test/e_erc20_dividends.js b/test/e_erc20_dividends.js index f17bd200a..cc1f8f891 100644 --- a/test/e_erc20_dividends.js +++ b/test/e_erc20_dividends.js @@ -70,7 +70,7 @@ contract("ERC20DividendCheckpoint", async (accounts) => { const managerDetails = web3.utils.fromAscii("Hello"); // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); const one_address = "0x0000000000000000000000000000000000000001"; const address_zero = "0x0000000000000000000000000000000000000000"; @@ -168,7 +168,7 @@ contract("ERC20DividendCheckpoint", async (accounts) => { it("Should successfully attach the ERC20DividendCheckpoint with the security token - fail insufficient payment", async () => { let bytesDividend = encodeModuleCall(DividendParameters, [wallet]); await catchRevert( - I_SecurityToken.addModule(P_ERC20DividendCheckpointFactory.address, bytesDividend, new BN(web3.utils.toWei("500", "ether")), new BN(0), { + I_SecurityToken.addModule(P_ERC20DividendCheckpointFactory.address, bytesDividend, new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }) ); @@ -176,10 +176,10 @@ contract("ERC20DividendCheckpoint", async (accounts) => { it("Should successfully attach the ERC20DividendCheckpoint with the security token with budget", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500", "ether")), token_owner); - await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("500", "ether")), { from: token_owner }); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000", "ether")), token_owner); + await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("2000", "ether")), { from: token_owner }); let bytesDividend = encodeModuleCall(DividendParameters, [wallet]); - const tx = await I_SecurityToken.addModule(P_ERC20DividendCheckpointFactory.address, bytesDividend, new BN(web3.utils.toWei("500", "ether")), new BN(0), { + const tx = await I_SecurityToken.addModule(P_ERC20DividendCheckpointFactory.address, bytesDividend, new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }); assert.equal(tx.logs[3].args._types[0].toNumber(), checkpointKey, "ERC20DividendCheckpoint doesn't get deployed"); diff --git a/test/f_ether_dividends.js b/test/f_ether_dividends.js index dae87c572..a6ace6440 100644 --- a/test/f_ether_dividends.js +++ b/test/f_ether_dividends.js @@ -71,7 +71,7 @@ contract("EtherDividendCheckpoint", async (accounts) => { const DividendParameters = ["address"]; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); let currentTime; @@ -160,10 +160,10 @@ contract("EtherDividendCheckpoint", async (accounts) => { }); it("Should successfully attach the ERC20DividendCheckpoint with the security token", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500", "ether")), token_owner); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000", "ether")), token_owner); let bytesDividend = encodeModuleCall(DividendParameters, [wallet]); await catchRevert( - I_SecurityToken.addModule(P_EtherDividendCheckpointFactory.address, bytesDividend, new BN(web3.utils.toWei("500", "ether")), new BN(0), { + I_SecurityToken.addModule(P_EtherDividendCheckpointFactory.address, bytesDividend, new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }) ); @@ -171,9 +171,9 @@ contract("EtherDividendCheckpoint", async (accounts) => { it("Should successfully attach the EtherDividendCheckpoint with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("500", "ether")), { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("2000", "ether")), { from: token_owner }); let bytesDividend = encodeModuleCall(DividendParameters, [wallet]); - const tx = await I_SecurityToken.addModule(P_EtherDividendCheckpointFactory.address, bytesDividend, new BN(web3.utils.toWei("500", "ether")), new BN(0), { + const tx = await I_SecurityToken.addModule(P_EtherDividendCheckpointFactory.address, bytesDividend, new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }); assert.equal(tx.logs[3].args._types[0].toNumber(), checkpointKey, "EtherDividendCheckpoint doesn't get deployed"); diff --git a/test/g_general_permission_manager.js b/test/g_general_permission_manager.js index 6792d6d17..b339376f2 100644 --- a/test/g_general_permission_manager.js +++ b/test/g_general_permission_manager.js @@ -66,7 +66,7 @@ contract("GeneralPermissionManager", async (accounts) => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); let currentTime; const address_zero = "0x0000000000000000000000000000000000000000"; @@ -136,7 +136,7 @@ contract("GeneralPermissionManager", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token @@ -158,9 +158,9 @@ contract("GeneralPermissionManager", async (accounts) => { it("Should successfully attach the General permission manager factory with the security token -- failed because Token is not paid", async () => { let errorThrown = false; - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500", "ether")), token_owner); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000", "ether")), token_owner); await catchRevert( - I_SecurityToken.addModule(P_GeneralPermissionManagerFactory.address, "0x", new BN(web3.utils.toWei("500", "ether")), new BN(0), { + I_SecurityToken.addModule(P_GeneralPermissionManagerFactory.address, "0x", new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }) ); @@ -168,11 +168,11 @@ contract("GeneralPermissionManager", async (accounts) => { it("Should successfully attach the General permission manager factory with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("500", "ether")), { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("2000", "ether")), { from: token_owner }); const tx = await I_SecurityToken.addModule( P_GeneralPermissionManagerFactory.address, "0x", - new BN(web3.utils.toWei("500", "ether")), + new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner } ); diff --git a/test/h_general_transfer_manager.js b/test/h_general_transfer_manager.js index 03c22b23f..3feae6422 100644 --- a/test/h_general_transfer_manager.js +++ b/test/h_general_transfer_manager.js @@ -72,7 +72,7 @@ contract("GeneralTransferManager", async (accounts) => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); // Dummy STO details let startTime; @@ -189,14 +189,14 @@ contract("GeneralTransferManager", async (accounts) => { it("Should attach the paid GTM -- failed because of no tokens", async () => { await catchRevert( - I_SecurityToken.addModule(P_GeneralTransferManagerFactory.address, "0x0", new BN(web3.utils.toWei("500")), new BN(0), { from: account_issuer }) + I_SecurityToken.addModule(P_GeneralTransferManagerFactory.address, "0x0", new BN(web3.utils.toWei("2000")), new BN(0), { from: account_issuer }) ); }); it("Should attach the paid GTM", async () => { let snap_id = await takeSnapshot(); - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500")), I_SecurityToken.address); - await I_SecurityToken.addModule(P_GeneralTransferManagerFactory.address, "0x0", new BN(web3.utils.toWei("500")), new BN(0), { + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000")), I_SecurityToken.address); + await I_SecurityToken.addModule(P_GeneralTransferManagerFactory.address, "0x0", new BN(web3.utils.toWei("2000")), new BN(0), { from: account_issuer }); await revertToSnapshot(snap_id); @@ -257,7 +257,7 @@ contract("GeneralTransferManager", async (accounts) => { someString ]); await catchRevert( - I_SecurityToken.addModule(P_DummySTOFactory.address, bytesSTO, new BN(web3.utils.toWei("500")), new BN(0), { from: token_owner }) + I_SecurityToken.addModule(P_DummySTOFactory.address, bytesSTO, new BN(web3.utils.toWei("2000")), new BN(0), { from: token_owner }) ); }); @@ -269,8 +269,8 @@ contract("GeneralTransferManager", async (accounts) => { cap, someString ]); - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500")), I_SecurityToken.address); - const tx = await I_SecurityToken.addModule(P_DummySTOFactory.address, bytesSTO, new BN(web3.utils.toWei("500")), new BN(0), { + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000")), I_SecurityToken.address); + const tx = await I_SecurityToken.addModule(P_DummySTOFactory.address, bytesSTO, new BN(web3.utils.toWei("2000")), new BN(0), { from: token_owner }); assert.equal(tx.logs[3].args._types[0].toNumber(), stoKey, "DummySTO doesn't get deployed"); @@ -306,7 +306,7 @@ contract("GeneralTransferManager", async (accounts) => { }); it("Should successfully attach the permission manager factory with the security token", async () => { - const tx = await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, new BN(0), new BN(0), new BN(0), { from: token_owner }); + const tx = await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, "0x0", new BN(0), new BN(0), { from: token_owner }); assert.equal(tx.logs[2].args._types[0].toNumber(), delegateManagerKey, "GeneralPermissionManager doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[2].args._name).replace(/\u0000/g, ""), diff --git a/test/i_Issuance.js b/test/i_Issuance.js index 7b62336bd..15f68fc2a 100644 --- a/test/i_Issuance.js +++ b/test/i_Issuance.js @@ -68,7 +68,7 @@ contract("Issuance", async (accounts) => { const one_address = "0x0000000000000000000000000000000000000001"; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); // Capped STO details //let startTime; // Start time will be 5000 seconds more than the latest time @@ -77,7 +77,8 @@ contract("Issuance", async (accounts) => { const rate = new BN(web3.utils.toWei("1000")); const fundRaiseType = [0]; const cappedSTOSetupCost = new BN(web3.utils.toWei("20000", "ether")); - const maxCost = cappedSTOSetupCost; + const cappedSTOSetupCostPOLY = new BN(web3.utils.toWei("80000", "ether")); + const maxCost = cappedSTOSetupCostPOLY; const STOParameters = ["uint256", "uint256", "uint256", "uint256", "uint8[]", "address"]; const STRProxyParameters = ["address", "address", "uint256", "uint256", "address", "address"]; const MRProxyParameters = ["address", "address"]; @@ -149,7 +150,7 @@ contract("Issuance", async (accounts) => { it("POLYMATH: Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: account_polymath }); - + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_polymath }); // Verify the successful generation of the security token @@ -183,8 +184,8 @@ contract("Issuance", async (accounts) => { account_fundsReceiver ]); - await I_PolyToken.getTokens(cappedSTOSetupCost, account_polymath); - await I_PolyToken.transfer(I_SecurityToken.address, cappedSTOSetupCost, { from: account_polymath }); + await I_PolyToken.getTokens(cappedSTOSetupCostPOLY, account_polymath); + await I_PolyToken.transfer(I_SecurityToken.address, cappedSTOSetupCostPOLY, { from: account_polymath }); const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, maxCost, new BN(0), { from: account_polymath }); diff --git a/test/j_manual_approval_transfer_manager.js b/test/j_manual_approval_transfer_manager.js index 26580b093..b46239995 100644 --- a/test/j_manual_approval_transfer_manager.js +++ b/test/j_manual_approval_transfer_manager.js @@ -72,7 +72,7 @@ contract("ManualApprovalTransferManager", accounts => { let approvalTime; // Initial fee for ticker registry and security token registry - const initRegFee = web3.utils.toWei("250"); + const initRegFee = web3.utils.toWei("1000"); const STOParameters = ["uint256", "uint256", "uint256", "uint256", "uint8[]", "address"]; let currentTime; @@ -225,9 +225,9 @@ contract("ManualApprovalTransferManager", accounts => { }); it("Should successfully attach the ManualApprovalTransferManager with the security token", async () => { - await I_PolyToken.getTokens(web3.utils.toWei("500", "ether"), token_owner); + await I_PolyToken.getTokens(web3.utils.toWei("2000", "ether"), token_owner); await catchRevert( - I_SecurityToken.addModule(P_ManualApprovalTransferManagerFactory.address, "0x0", web3.utils.toWei("500", "ether"), 0, { + I_SecurityToken.addModule(P_ManualApprovalTransferManagerFactory.address, "0x0", web3.utils.toWei("2000", "ether"), 0, { from: token_owner }) ); @@ -235,11 +235,11 @@ contract("ManualApprovalTransferManager", accounts => { it("Should successfully attach the General permission manager factory with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("500", "ether"), { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("2000", "ether"), { from: token_owner }); const tx = await I_SecurityToken.addModule( P_ManualApprovalTransferManagerFactory.address, "0x0", - web3.utils.toWei("500", "ether"), + web3.utils.toWei("2000", "ether"), 0, { from: token_owner } ); diff --git a/test/k_module_registry.js b/test/k_module_registry.js index efba2e2f2..a665ab352 100644 --- a/test/k_module_registry.js +++ b/test/k_module_registry.js @@ -80,7 +80,7 @@ contract("ModuleRegistry", async (accounts) => { const one_address = "0x0000000000000000000000000000000000000001"; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); // delagate details const delegateDetails = "I am delegate .."; @@ -253,14 +253,14 @@ contract("ModuleRegistry", async (accounts) => { }); it("Should fail in registering the module-- type = 0", async () => { - I_MockFactory = await MockFactory.new(new BN(0), new BN(0), new BN(0), address_zero, { from: account_polymath }); + I_MockFactory = await MockFactory.new(new BN(0), new BN(0), address_zero, I_PolymathRegistry.address, { from: account_polymath }); catchRevert(I_MRProxied.registerModule(I_MockFactory.address, { from: account_polymath })); }); it("Should fail to register the new module because msg.sender is not the owner of the module", async() => { I_CappedSTOLogic = await CappedSTO.new(address_zero, address_zero, { from: account_polymath }); - I_CappedSTOFactory3 = await CappedSTOFactory.new(new BN(0), new BN(0), new BN(0), I_CappedSTOLogic.address, { from: account_temp }); + I_CappedSTOFactory3 = await CappedSTOFactory.new(new BN(0), new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, { from: account_temp }); catchRevert(I_MRProxied.registerModule(I_CappedSTOFactory3.address, { from: token_owner })); }); @@ -282,7 +282,7 @@ contract("ModuleRegistry", async (accounts) => { }); it("Should successfully verify the module -- false", async () => { - I_CappedSTOFactory1 = await CappedSTOFactory.new(new BN(0), new BN(0), new BN(0), I_CappedSTOLogic.address, { from: account_polymath }); + I_CappedSTOFactory1 = await CappedSTOFactory.new(new BN(0), new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, { from: account_polymath }); await I_MRProxied.registerModule(I_CappedSTOFactory1.address, { from: account_polymath }); let tx = await I_MRProxied.verifyModule(I_CappedSTOFactory1.address, false, { from: account_polymath }); assert.equal(tx.logs[0].args._moduleFactory, I_CappedSTOFactory1.address, "Failed in verifying the module"); @@ -296,8 +296,8 @@ contract("ModuleRegistry", async (accounts) => { describe("Test cases for the useModule function of the module registry", async () => { it("Deploy the securityToken", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500")), account_issuer); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("500")), { from: account_issuer }); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000")), account_issuer); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: account_issuer }); await I_STRProxied.registerTicker(account_issuer, symbol, name, { from: account_issuer }); let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, true, { from: account_issuer }); assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase()); @@ -313,7 +313,7 @@ contract("ModuleRegistry", async (accounts) => { }); it("Should fail to register module because custom modules not allowed", async () => { - I_CappedSTOFactory2 = await CappedSTOFactory.new(0, new BN(0), new BN(0), I_CappedSTOLogic.address, { from: token_owner }); + I_CappedSTOFactory2 = await CappedSTOFactory.new(new BN(0), new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, { from: token_owner }); assert.notEqual(I_CappedSTOFactory2.address.valueOf(), address_zero, "CappedSTOFactory contract was not deployed"); @@ -361,7 +361,7 @@ contract("ModuleRegistry", async (accounts) => { it("Should successfully add verified module", async () => { I_GeneralPermissionManagerLogic = await GeneralPermissionManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: account_polymath }); - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(0, new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, { + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, { from: account_polymath }); await I_MRProxied.registerModule(I_GeneralPermissionManagerFactory.address, { from: account_polymath }); @@ -398,8 +398,8 @@ contract("ModuleRegistry", async (accounts) => { // Generate the new securityToken let newSymbol = "toro"; - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500")), account_issuer); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("500")), { from: account_issuer }); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000")), account_issuer); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: account_issuer }); await I_STRProxied.registerTicker(account_issuer, newSymbol, name, { from: account_issuer }); let tx = await I_STRProxied.generateSecurityToken(name, newSymbol, tokenDetails, true, { from: account_issuer }); assert.equal(tx.logs[2].args._ticker, newSymbol.toUpperCase()); diff --git a/test/l_percentage_transfer_manager.js b/test/l_percentage_transfer_manager.js index b27f34427..428f35b41 100644 --- a/test/l_percentage_transfer_manager.js +++ b/test/l_percentage_transfer_manager.js @@ -63,7 +63,7 @@ contract("PercentageTransferManager", async (accounts) => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); // PercentageTransferManager details const holderPercentage = 70 * 10 ** 16; // Maximum number of token holders @@ -252,9 +252,9 @@ contract("PercentageTransferManager", async (accounts) => { }); it("Should successfully attach the PercentageTransferManager factory with the security token - failed payment", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500", "ether")), token_owner); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000", "ether")), token_owner); await catchRevert( - I_SecurityToken.addModule(P_PercentageTransferManagerFactory.address, bytesSTO, new BN(web3.utils.toWei("500", "ether")), new BN(0), { + I_SecurityToken.addModule(P_PercentageTransferManagerFactory.address, bytesSTO, new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }) ); @@ -262,11 +262,11 @@ contract("PercentageTransferManager", async (accounts) => { it("Should successfully attach the PercentageTransferManager factory with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("500", "ether")), { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("2000", "ether")), { from: token_owner }); const tx = await I_SecurityToken.addModule( P_PercentageTransferManagerFactory.address, bytesSTO, - new BN(web3.utils.toWei("500", "ether")), + new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner } ); diff --git a/test/m_presale_sto.js b/test/m_presale_sto.js index daa982397..86259560c 100644 --- a/test/m_presale_sto.js +++ b/test/m_presale_sto.js @@ -69,7 +69,7 @@ contract("PreSaleSTO", async (accounts) => { const budget = 0; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); let endTime; const address_zero = "0x0000000000000000000000000000000000000000"; const one_address = "0x0000000000000000000000000000000000000001"; diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index d723f4e45..562b4ff16 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -82,7 +82,7 @@ contract("SecurityTokenRegistry", async (accounts) => { const budget = 0; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); const newRegFee = new BN(web3.utils.toWei("300")); const STRProxyParameters = ["address", "address", "uint256", "uint256", "address", "address"]; @@ -528,7 +528,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to generate the SecurityToken because ticker gets expired", async () => { let snap_Id = await takeSnapshot(); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("500")), { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); await increaseTime(duration.days(65)); await catchRevert( @@ -541,7 +541,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should generate the SecurityToken when launch fee is 0", async () => { let snap_Id = await takeSnapshot(); await I_STRProxied.changeSecurityLaunchFee(0, { from: account_polymath }); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("500")), { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); await I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, { from: token_owner }), await revertToSnapshot(snap_Id); @@ -549,8 +549,8 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should get all created security tokens", async() => { let snap_Id = await takeSnapshot(); - await I_PolyToken.getTokens(web3.utils.toWei("500"), account_temp); - await I_PolyToken.approve(I_STRProxied.address, web3.utils.toWei("500"), { from: account_temp }); + await I_PolyToken.getTokens(web3.utils.toWei("2000"), account_temp); + await I_PolyToken.approve(I_STRProxied.address, web3.utils.toWei("2000"), { from: account_temp }); await I_STRProxied.registerTicker(account_temp, "TMP", name, { from: account_temp }); let tx = await I_STRProxied.generateSecurityToken(name, "TMP", tokenDetails, false, { from: account_temp }); @@ -960,7 +960,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should register the ticker with the new fee", async () => { await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), token_owner); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("500")), { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); let tx = await I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }); assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); assert.equal(tx.logs[0].args._ticker, "POLY", `Symbol should be POLY`); diff --git a/test/o_security_token.js b/test/o_security_token.js index d6adbbc99..347e39eef 100644 --- a/test/o_security_token.js +++ b/test/o_security_token.js @@ -84,7 +84,7 @@ contract("SecurityToken", async (accounts) => { const budget = 0; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); // delagate details const delegateDetails = web3.utils.fromAscii("I am delegate .."); diff --git a/test/p_usd_tiered_sto.js b/test/p_usd_tiered_sto.js index 4661fb043..4369e6fff 100644 --- a/test/p_usd_tiered_sto.js +++ b/test/p_usd_tiered_sto.js @@ -406,7 +406,7 @@ contract("USDTieredSTO", async (accounts) => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, config); await catchRevert( - I_SecurityToken.addModule(P_USDTieredSTOFactory.address, bytesSTO, new BN(web3.utils.toWei("500")), new BN(0), { + I_SecurityToken.addModule(P_USDTieredSTOFactory.address, bytesSTO, new BN(web3.utils.toWei("2000")), new BN(0), { from: ISSUER, gasPrice: GAS_PRICE }) @@ -432,8 +432,8 @@ contract("USDTieredSTO", async (accounts) => { ]; let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, config); - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500")), I_SecurityToken.address); - let tx = await I_SecurityToken.addModule(P_USDTieredSTOFactory.address, bytesSTO, new BN(web3.utils.toWei("500")), new BN(0), { + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000")), I_SecurityToken.address); + let tx = await I_SecurityToken.addModule(P_USDTieredSTOFactory.address, bytesSTO, new BN(web3.utils.toWei("2000")), new BN(0), { from: ISSUER, gasPrice: GAS_PRICE }); diff --git a/test/r_concurrent_STO.js b/test/r_concurrent_STO.js index 129116c26..5fa1e9fa7 100644 --- a/test/r_concurrent_STO.js +++ b/test/r_concurrent_STO.js @@ -56,7 +56,7 @@ contract("Concurrent STO", async (accounts) => { let message = "Transaction Should Fail!"; // Initial fees - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); const STOSetupCost = web3.utils.toHex(200 * Math.pow(10, 18)); // Module keys diff --git a/test/u_module_registry_proxy.js b/test/u_module_registry_proxy.js index 624217939..6633d3b69 100644 --- a/test/u_module_registry_proxy.js +++ b/test/u_module_registry_proxy.js @@ -136,7 +136,7 @@ contract("ModuleRegistryProxy", async (accounts) => { { from: account_polymath } ); - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(new BN(0), new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, { + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, { from: account_polymath }); @@ -173,7 +173,7 @@ contract("ModuleRegistryProxy", async (accounts) => { describe("Feed some data in storage", async () => { it("Register and verify the new module", async () => { I_GeneralPermissionManagerLogic = await GeneralPermissionManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: account_polymath }); - I_GeneralPermissionManagerfactory = await GeneralPermissionManagerFactory.new(0, new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, { + I_GeneralPermissionManagerfactory = await GeneralPermissionManagerFactory.new(new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, { from: account_polymath }); diff --git a/test/v_tracked_redemptions.js b/test/v_tracked_redemptions.js index 28ccaded7..891566465 100644 --- a/test/v_tracked_redemptions.js +++ b/test/v_tracked_redemptions.js @@ -135,7 +135,7 @@ contract("TrackedRedemption", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token @@ -157,8 +157,8 @@ contract("TrackedRedemption", async (accounts) => { it("Should successfully attach the paid TrackedRedemption with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500")), I_SecurityToken.address); - const tx = await I_SecurityToken.addModule(P_TrackedRedemptionFactory.address, "0x0", new BN(web3.utils.toWei("500")), new BN(0), { + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000")), I_SecurityToken.address); + const tx = await I_SecurityToken.addModule(P_TrackedRedemptionFactory.address, "0x0", new BN(web3.utils.toWei("2000")), new BN(0), { from: token_owner }); assert.equal(tx.logs[3].args._types[0].toNumber(), burnKey, "TrackedRedemption doesn't get deployed"); diff --git a/test/w_lockup_transfer_manager.js b/test/w_lockup_transfer_manager.js index 0be2bfe04..fdde2132e 100644 --- a/test/w_lockup_transfer_manager.js +++ b/test/w_lockup_transfer_manager.js @@ -246,17 +246,17 @@ contract('LockUpTransferManager', accounts => { }); it("Should unsuccessfully attach the LockUpTransferManager factory with the security token -- failed because Token is not paid", async () => { - await I_PolyToken.getTokens(web3.utils.toWei("500", "ether"), token_owner); + await I_PolyToken.getTokens(web3.utils.toWei("2000", "ether"), token_owner); await catchRevert( - I_SecurityToken.addModule(P_LockUpTransferManagerFactory.address, "0x", new BN(web3.utils.toWei("500", "ether")), 0, { from: token_owner }) + I_SecurityToken.addModule(P_LockUpTransferManagerFactory.address, "0x", new BN(web3.utils.toWei("2000", "ether")), 0, { from: token_owner }) ) }); it("Should successfully attach the LockUpTransferManager factory with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("500", "ether")), {from: token_owner}); + await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("2000", "ether")), {from: token_owner}); console.log((await P_LockUpTransferManagerFactory.getSetupCost.call()).toString()); - const tx = await I_SecurityToken.addModule(P_LockUpTransferManagerFactory.address, "0x", new BN(web3.utils.toWei("500", "ether")), new BN(0), { from: token_owner }); + const tx = await I_SecurityToken.addModule(P_LockUpTransferManagerFactory.address, "0x", new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }); assert.equal(tx.logs[3].args._types[0].toString(), transferManagerKey, "LockUpVolumeRestrictionTMFactory doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[3].args._name) diff --git a/test/z_blacklist_transfer_manager.js b/test/z_blacklist_transfer_manager.js index 54e249a1f..2c4a5cef3 100644 --- a/test/z_blacklist_transfer_manager.js +++ b/test/z_blacklist_transfer_manager.js @@ -67,7 +67,7 @@ contract('BlacklistTransferManager', accounts => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = web3.utils.toWei("250"); + const initRegFee = web3.utils.toWei("1000"); // BlacklistTransferManager details const holderCount = 2; // Maximum number of token holders @@ -171,9 +171,9 @@ contract('BlacklistTransferManager', accounts => { }); it("Should successfully attach the BlacklistTransferManager factory with the security token", async () => { - await I_PolyToken.getTokens(web3.utils.toWei("500", "ether"), token_owner); + await I_PolyToken.getTokens(web3.utils.toWei("2000", "ether"), token_owner); await catchRevert ( - I_SecurityToken.addModule(P_BlacklistTransferManagerFactory.address, bytesSTO, web3.utils.toWei("500", "ether"), 0, { + I_SecurityToken.addModule(P_BlacklistTransferManagerFactory.address, bytesSTO, web3.utils.toWei("2000", "ether"), 0, { from: token_owner }) ); @@ -181,8 +181,8 @@ contract('BlacklistTransferManager', accounts => { it("Should successfully attach the BlacklistTransferManager factory with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("500", "ether"), {from: token_owner}); - const tx = await I_SecurityToken.addModule(P_BlacklistTransferManagerFactory.address, bytesSTO, web3.utils.toWei("500", "ether"), 0, { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("2000", "ether"), {from: token_owner}); + const tx = await I_SecurityToken.addModule(P_BlacklistTransferManagerFactory.address, bytesSTO, web3.utils.toWei("2000", "ether"), 0, { from: token_owner }); assert.equal(tx.logs[3].args._types[0].toString(), transferManagerKey, "BlacklistTransferManager doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[3].args._name) diff --git a/test/z_fuzz_test_adding_removing_modules_ST.js b/test/z_fuzz_test_adding_removing_modules_ST.js index 194287801..fbec6e51b 100644 --- a/test/z_fuzz_test_adding_removing_modules_ST.js +++ b/test/z_fuzz_test_adding_removing_modules_ST.js @@ -98,7 +98,7 @@ contract('GeneralPermissionManager', accounts => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = web3.utils.toWei("250"); + const initRegFee = web3.utils.toWei("1000"); let _details = "details holding for test"; let testRepeat = 20; @@ -210,19 +210,19 @@ contract('GeneralPermissionManager', accounts => { it("Should successfully attach the General permission manager factory with the security token -- failed because Token is not paid", async () => { let errorThrown = false; - await I_PolyToken.getTokens(web3.utils.toWei("500", "ether"), token_owner); + await I_PolyToken.getTokens(web3.utils.toWei("2000", "ether"), token_owner); await catchRevert( - I_SecurityToken.addModule(P_GeneralPermissionManagerFactory.address, "0x0", web3.utils.toWei("500", "ether"), 0, { from: token_owner }) + I_SecurityToken.addModule(P_GeneralPermissionManagerFactory.address, "0x0", web3.utils.toWei("2000", "ether"), 0, { from: token_owner }) ); }); it("Should successfully attach the General permission manager factory with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("500", "ether"), { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("2000", "ether"), { from: token_owner }); const tx = await I_SecurityToken.addModule( P_GeneralPermissionManagerFactory.address, "0x0", - web3.utils.toWei("500", "ether"), + web3.utils.toWei("2000", "ether"), 0, { from: token_owner } ); diff --git a/test/z_fuzzer_volumn_restriction_transfer_manager.js b/test/z_fuzzer_volumn_restriction_transfer_manager.js index 0cf2fc02f..5aac12df8 100644 --- a/test/z_fuzzer_volumn_restriction_transfer_manager.js +++ b/test/z_fuzzer_volumn_restriction_transfer_manager.js @@ -74,7 +74,7 @@ contract('VolumeRestrictionTransferManager', accounts => { let tempArrayGlobal = new Array(); // Initial fee for ticker registry and security token registry - const initRegFee = web3.utils.toWei("250"); + const initRegFee = web3.utils.toWei("1000"); async function print(data, account) { console.log(` diff --git a/test/z_general_permission_manager_fuzzer.js b/test/z_general_permission_manager_fuzzer.js index 7f7933801..9ebb1ea34 100644 --- a/test/z_general_permission_manager_fuzzer.js +++ b/test/z_general_permission_manager_fuzzer.js @@ -204,9 +204,9 @@ contract("GeneralPermissionManager Fuzz", async (accounts) => { it("Should successfully attach the General permission manager factory with the security token -- failed because Token is not paid", async () => { let errorThrown = false; - await I_PolyToken.getTokens(new BN(web3.utils.toWei("500", "ether")), token_owner); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000", "ether")), token_owner); await catchRevert( - I_SecurityToken.addModule(P_GeneralPermissionManagerFactory.address, "0x", new BN(web3.utils.toWei("500", "ether")), new BN(0), { + I_SecurityToken.addModule(P_GeneralPermissionManagerFactory.address, "0x", new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner }) ); @@ -214,11 +214,11 @@ contract("GeneralPermissionManager Fuzz", async (accounts) => { it("Should successfully attach the General permission manager factory with the security token - paid module", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("500", "ether")), { from: token_owner }); + await I_PolyToken.transfer(I_SecurityToken.address, new BN(web3.utils.toWei("2000", "ether")), { from: token_owner }); const tx = await I_SecurityToken.addModule( P_GeneralPermissionManagerFactory.address, "0x", - new BN(web3.utils.toWei("500", "ether")), + new BN(web3.utils.toWei("2000", "ether")), new BN(0), { from: token_owner } ); diff --git a/test/zb_signed_transfer_manager.js b/test/zb_signed_transfer_manager.js index a35baba07..4f276f154 100644 --- a/test/zb_signed_transfer_manager.js +++ b/test/zb_signed_transfer_manager.js @@ -64,7 +64,7 @@ contract("SignedTransferManager", accounts => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = web3.utils.toWei("250"); + const initRegFee = web3.utils.toWei("1000"); let currentTime; From 8bb984068ecc3dcace83b4275d5f5538ff85a419 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Mon, 4 Feb 2019 20:57:58 -0500 Subject: [PATCH 7/9] More fixes --- test/k_module_registry.js | 2 +- test/n_security_token_registry.js | 32 +++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/k_module_registry.js b/test/k_module_registry.js index a665ab352..036949f9a 100644 --- a/test/k_module_registry.js +++ b/test/k_module_registry.js @@ -371,7 +371,7 @@ contract("ModuleRegistry", async (accounts) => { }); it("Should failed in adding the TestSTOFactory module because not compatible with the current protocol version --lower", async () => { - I_TestSTOFactory = await TestSTOFactory.new(new BN(0), new BN(0), new BN(0), address_zero, { from: account_polymath }); + I_TestSTOFactory = await TestSTOFactory.new(new BN(0), new BN(0), address_zero, I_PolymathRegistry.address, { from: account_polymath }); await I_MRProxied.registerModule(I_TestSTOFactory.address, { from: account_polymath }); await I_MRProxied.verifyModule(I_TestSTOFactory.address, true, { from: account_polymath }); // Taking the snapshot the revert the changes from here diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index 562b4ff16..17c85879e 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -82,8 +82,8 @@ contract("SecurityTokenRegistry", async (accounts) => { const budget = 0; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("1000")); - const newRegFee = new BN(web3.utils.toWei("300")); + const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFeePOLY = new BN(web3.utils.toWei("1000")); const STRProxyParameters = ["address", "address", "uint256", "uint256", "address", "address"]; const STOParameters = ["uint256", "uint256", "uint256", "string"]; @@ -324,8 +324,8 @@ contract("SecurityTokenRegistry", async (accounts) => { }); it("Should fail to register ticker if owner is 0x", async () => { - await I_PolyToken.getTokens(initRegFee, account_temp); - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: account_temp }); + await I_PolyToken.getTokens(initRegFeePOLY, account_temp); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); await catchRevert( I_STRProxied.registerTicker(address_zero, symbol, name, { from: account_temp }), @@ -368,8 +368,8 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to register same symbol again", async () => { // Give POLY to token issuer - await I_PolyToken.getTokens(initRegFee, token_owner); - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.getTokens(initRegFeePOLY, token_owner); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); // Call registration function await catchRevert( I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }), @@ -379,7 +379,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should successfully register pre registerd ticker if expiry is reached", async () => { await increaseTime(5184000 + 100); // 60(5184000) days of expiry + 100 sec for buffer - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); let tx = await I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }); assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); @@ -387,7 +387,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to register ticker if registration is paused", async () => { await I_STRProxied.pause({ from: account_polymath }); - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); await catchRevert( I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }), @@ -401,7 +401,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should successfully register ticker if registration is unpaused", async () => { await I_STRProxied.unpause({ from: account_polymath }); - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); let tx = await I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }); assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); assert.equal(tx.logs[0].args._ticker, "AAA", `Symbol should be AAA`); @@ -472,7 +472,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to generate token if registration is paused", async () => { await I_STRProxied.pause({ from: account_polymath }); - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); await catchRevert( I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), @@ -593,14 +593,14 @@ contract("SecurityTokenRegistry", async (accounts) => { }); it("Should register the ticker before the generation of the security token", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); let tx = await I_STRProxied.registerTicker(token_owner, symbol2, name2, { from: token_owner }); assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); assert.equal(tx.logs[0].args._ticker, symbol2, `Symbol should be ${symbol2}`); }); it("Should generate the new security token with version 2", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); let tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, false, { from: token_owner }); @@ -705,7 +705,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should successfully generate custom token", async () => { // Register the new ticker -- Fulfiling the TickerStatus.ON condition await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), account_temp); - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: account_temp }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); console.log(tickersListArray); await I_STRProxied.registerTicker(account_temp, "LOG", "LOGAN", { from: account_temp }); @@ -951,7 +951,7 @@ contract("SecurityTokenRegistry", async (accounts) => { }); it("Should fail to register the ticker with the old fee", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); await catchRevert( I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }), "tx revert -> failed because of ticker registeration fee gets change" @@ -959,7 +959,7 @@ contract("SecurityTokenRegistry", async (accounts) => { }); it("Should register the ticker with the new fee", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), token_owner); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), token_owner); await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); let tx = await I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }); assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); @@ -967,7 +967,7 @@ contract("SecurityTokenRegistry", async (accounts) => { }); it("Should fail to launch the securityToken with the old launch fee", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); await catchRevert( I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }), "tx revert -> failed because of old launch fee" From 7914848221f23aaabffd3ffe025c6880758289e5 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Tue, 5 Feb 2019 19:49:03 -0400 Subject: [PATCH 8/9] Update lots more tests --- test/n_security_token_registry.js | 14 +++++++------- test/o_security_token.js | 20 +++++++++++--------- test/p_usd_tiered_sto.js | 2 +- test/q_usd_tiered_sto_sim.js | 4 ++-- test/r_concurrent_STO.js | 9 +++++---- test/t_security_token_registry_proxy.js | 7 ++++--- test/u_module_registry_proxy.js | 1 - test/v_tracked_redemptions.js | 2 +- test/w_lockup_transfer_manager.js | 2 +- test/x_scheduled_checkpoints.js | 4 ++-- test/y_volume_restriction_tm.js | 2 +- test/z_general_permission_manager_fuzzer.js | 2 +- test/z_vesting_escrow_wallet.js | 4 ++-- test/za_datastore.js | 6 +++--- test/zb_signed_transfer_manager.js | 2 +- 15 files changed, 42 insertions(+), 39 deletions(-) diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index 17c85879e..a7d19c13c 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -975,7 +975,7 @@ contract("SecurityTokenRegistry", async (accounts) => { }); it("Should launch the the securityToken", async () => { - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("500")), { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); let tx = await I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token @@ -1051,8 +1051,8 @@ contract("SecurityTokenRegistry", async (accounts) => { describe(" Test cases of the registerTicker", async () => { it("Should register the ticker 1", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), account_temp); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1000")), { from: account_temp }); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); let tx = await I_STRProxied.registerTicker(account_temp, "TOK1", "0x0", { from: account_temp }); assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); assert.equal(tx.logs[0].args._ticker, "TOK1", `Symbol should be TOK1`); @@ -1060,8 +1060,8 @@ contract("SecurityTokenRegistry", async (accounts) => { }); it("Should register the ticker 2", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), account_temp); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1000")), { from: account_temp }); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); let tx = await I_STRProxied.registerTicker(account_temp, "TOK2", "0x0", { from: account_temp }); assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); assert.equal(tx.logs[0].args._ticker, "TOK2", `Symbol should be TOK2`); @@ -1069,8 +1069,8 @@ contract("SecurityTokenRegistry", async (accounts) => { }); it("Should register the ticker 3", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), account_temp); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1000")), { from: account_temp }); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); let tx = await I_STRProxied.registerTicker(account_temp, "TOK3", "0x0", { from: account_temp }); assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); assert.equal(tx.logs[0].args._ticker, "TOK3", `Symbol should be TOK3`); diff --git a/test/o_security_token.js b/test/o_security_token.js index 347e39eef..680950ccd 100644 --- a/test/o_security_token.js +++ b/test/o_security_token.js @@ -98,7 +98,8 @@ contract("SecurityToken", async (accounts) => { const rate = new BN(web3.utils.toWei("1000")); const fundRaiseType = [0]; const cappedSTOSetupCost = new BN(web3.utils.toWei("20000", "ether")); - const maxCost = cappedSTOSetupCost; + const cappedSTOSetupCostPOLY = new BN(web3.utils.toWei("80000", "ether")); + const maxCost = cappedSTOSetupCostPOLY; const STOParameters = ["uint256", "uint256", "uint256", "uint256", "uint8[]", "address"]; let currentTime; @@ -292,8 +293,8 @@ contract("SecurityToken", async (accounts) => { startTime = await latestTime() + duration.seconds(5000); endTime = startTime + duration.days(30); let bytesSTO = encodeModuleCall(STOParameters, [startTime, endTime, cap, rate, fundRaiseType, account_fundsReceiver]); - await I_PolyToken.getTokens(cappedSTOSetupCost, token_owner); - await I_PolyToken.transfer(I_SecurityToken.address, cappedSTOSetupCost, { from: token_owner }); + await I_PolyToken.getTokens(cappedSTOSetupCostPOLY, token_owner); + await I_PolyToken.transfer(I_SecurityToken.address, cappedSTOSetupCostPOLY, { from: token_owner }); await catchRevert( I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, new BN(web3.utils.toWei("1000", "ether")), new BN(0), { from: token_owner }) @@ -306,8 +307,8 @@ contract("SecurityToken", async (accounts) => { endTime = startTime + duration.days(30); let bytesSTO = encodeModuleCall(STOParameters, [startTime, endTime, cap, rate, fundRaiseType, account_fundsReceiver]); - await I_PolyToken.getTokens(cappedSTOSetupCost, token_owner); - await I_PolyToken.transfer(I_SecurityToken.address, cappedSTOSetupCost, { from: token_owner }); + await I_PolyToken.getTokens(cappedSTOSetupCostPOLY, token_owner); + await I_PolyToken.transfer(I_SecurityToken.address, cappedSTOSetupCostPOLY, { from: token_owner }); console.log("0"); const tx = await I_SecurityToken.addModuleWithLabel(I_CappedSTOFactory.address, bytesSTO, maxCost, new BN(0), web3.utils.fromAscii("stofactory"), { from: token_owner @@ -326,8 +327,8 @@ contract("SecurityToken", async (accounts) => { endTime = startTime + duration.days(30); let bytesSTO = encodeModuleCall(STOParameters, [startTime, endTime, cap, rate, fundRaiseType, account_fundsReceiver]); - await I_PolyToken.getTokens(cappedSTOSetupCost, token_owner); - await I_PolyToken.transfer(I_SecurityToken.address, cappedSTOSetupCost, { from: token_owner }); + await I_PolyToken.getTokens(cappedSTOSetupCostPOLY, token_owner); + await I_PolyToken.transfer(I_SecurityToken.address, cappedSTOSetupCostPOLY, { from: token_owner }); const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, maxCost, new BN(0), { from: token_owner }); @@ -1047,13 +1048,14 @@ contract("SecurityToken", async (accounts) => { it("Should successfully withdraw the poly", async () => { let balanceBefore = await I_PolyToken.balanceOf(token_owner); - await I_SecurityToken.withdrawERC20(I_PolyToken.address, new BN(web3.utils.toWei("20000", "ether")), { from: token_owner }); + let stBalance = await I_PolyToken.balanceOf(I_SecurityToken.address); + await I_SecurityToken.withdrawERC20(I_PolyToken.address, new BN(stBalance), { from: token_owner }); let balanceAfter = await I_PolyToken.balanceOf(token_owner); assert.equal( BN(balanceAfter) .sub(new BN(balanceBefore)) .toString(), - new BN(web3.utils.toWei("20000", "ether").toString()) + stBalance.toString() ); }); diff --git a/test/p_usd_tiered_sto.js b/test/p_usd_tiered_sto.js index 4369e6fff..f70d222ed 100644 --- a/test/p_usd_tiered_sto.js +++ b/test/p_usd_tiered_sto.js @@ -203,7 +203,7 @@ contract("USDTieredSTO", async (accounts) => { e18 = new BN(10).pow(new BN(18)); e16 = new BN(10).pow(new BN(16)); currentTime = new BN(await latestTime()); - REGFEE = new BN(web3.utils.toWei("250")); + REGFEE = new BN(web3.utils.toWei("1000")); USDETH = new BN(500).mul(new BN(10).pow(new BN(18))); // 500 USD/ETH USDPOLY = new BN(25).mul(new BN(10).pow(new BN(16))); // 0.25 USD/POLY POLYMATH = accounts[0]; diff --git a/test/q_usd_tiered_sto_sim.js b/test/q_usd_tiered_sto_sim.js index e4f9db8e1..c0f62f589 100644 --- a/test/q_usd_tiered_sto_sim.js +++ b/test/q_usd_tiered_sto_sim.js @@ -70,7 +70,7 @@ contract("USDTieredSTO Sim", async (accounts) => { const STOKEY = 3; // Initial fee for ticker registry and security token registry - const REGFEE = new BN(web3.utils.toWei("250")); + const REGFEE = new BN(web3.utils.toWei("1000")); const STOSetupCost = 0; // MockOracle USD prices @@ -783,4 +783,4 @@ function assertIsNear(a, b, reason) { } else { assert.isBelow(b.sub(a).toNumber(), 4, reason); } -} \ No newline at end of file +} diff --git a/test/r_concurrent_STO.js b/test/r_concurrent_STO.js index 5fa1e9fa7..513f8c8a7 100644 --- a/test/r_concurrent_STO.js +++ b/test/r_concurrent_STO.js @@ -58,6 +58,7 @@ contract("Concurrent STO", async (accounts) => { // Initial fees const initRegFee = new BN(web3.utils.toWei("1000")); const STOSetupCost = web3.utils.toHex(200 * Math.pow(10, 18)); + const STOSetupCostPOLY = web3.utils.toHex(800 * Math.pow(10, 18)); // Module keys const transferManagerKey = 2; @@ -142,7 +143,7 @@ contract("Concurrent STO", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.getTokens(initRegFee, account_issuer); await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: account_issuer }); - + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_issuer }); assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); @@ -184,7 +185,7 @@ contract("Concurrent STO", async (accounts) => { const rate = new BN(web3.utils.toWei("1000")); const fundRaiseType = [0]; const budget = 0; - const maxCost = STOSetupCost; + const maxCost = STOSetupCostPOLY; const cappedBytesSig = encodeModuleCall(CappedSTOParameters, [ startTime, endTime, @@ -197,8 +198,8 @@ contract("Concurrent STO", async (accounts) => { const presaleBytesSig = encodeModuleCall(PresaleSTOParameters, [endTime]); for (var STOIndex = 0; STOIndex < MAX_MODULES; STOIndex++) { - await I_PolyToken.getTokens(STOSetupCost, account_issuer); - await I_PolyToken.transfer(I_SecurityToken.address, STOSetupCost, { from: account_issuer }); + await I_PolyToken.getTokens(STOSetupCostPOLY, account_issuer); + await I_PolyToken.transfer(I_SecurityToken.address, STOSetupCostPOLY, { from: account_issuer }); switch (STOIndex % 3) { case 0: // Capped STO diff --git a/test/t_security_token_registry_proxy.js b/test/t_security_token_registry_proxy.js index 0854d94e1..d2767dedd 100644 --- a/test/t_security_token_registry_proxy.js +++ b/test/t_security_token_registry_proxy.js @@ -39,6 +39,7 @@ contract("SecurityTokenRegistryProxy", async (accounts) => { // Initial fee for ticker registry and security token registry const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFeePOLY = new BN(web3.utils.toWei("1000")); const version = "1.0.0"; const message = "Transaction Should Fail!"; @@ -147,15 +148,15 @@ contract("SecurityTokenRegistryProxy", async (accounts) => { describe("Feed some data in storage", async () => { it("Register the ticker", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), token_owner); - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.getTokens(new BN(web3.utils.toWei("8000")), token_owner); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); let tx = await I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }); assert.equal(tx.logs[0].args._owner, token_owner, "Owner should be the same as registered with the ticker"); assert.equal(tx.logs[0].args._ticker, symbol, "Same as the symbol registered in the registerTicker function call"); }); it("Should generate the new security token with the same symbol as registered above", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); diff --git a/test/u_module_registry_proxy.js b/test/u_module_registry_proxy.js index 6633d3b69..c4d3c2d98 100644 --- a/test/u_module_registry_proxy.js +++ b/test/u_module_registry_proxy.js @@ -44,7 +44,6 @@ contract("ModuleRegistryProxy", async (accounts) => { let account_polymath_new; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); const version = "1.0.0"; const message = "Transaction Should Fail!"; const address_zero = "0x0000000000000000000000000000000000000000"; diff --git a/test/v_tracked_redemptions.js b/test/v_tracked_redemptions.js index 891566465..a0b3ba36f 100644 --- a/test/v_tracked_redemptions.js +++ b/test/v_tracked_redemptions.js @@ -63,7 +63,7 @@ contract("TrackedRedemption", async (accounts) => { const burnKey = 5; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); let currentTime; const address_zero = "0x0000000000000000000000000000000000000000"; diff --git a/test/w_lockup_transfer_manager.js b/test/w_lockup_transfer_manager.js index fdde2132e..254ae384f 100644 --- a/test/w_lockup_transfer_manager.js +++ b/test/w_lockup_transfer_manager.js @@ -68,7 +68,7 @@ contract('LockUpTransferManager', accounts => { let temp; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); let currentTime; before(async() => { diff --git a/test/x_scheduled_checkpoints.js b/test/x_scheduled_checkpoints.js index aa490f32e..dd23a8f9e 100644 --- a/test/x_scheduled_checkpoints.js +++ b/test/x_scheduled_checkpoints.js @@ -56,7 +56,7 @@ contract("ScheduledCheckpoint", async (accounts) => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); let currentTime; const address_zero = "0x0000000000000000000000000000000000000000"; @@ -122,7 +122,7 @@ contract("ScheduledCheckpoint", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token diff --git a/test/y_volume_restriction_tm.js b/test/y_volume_restriction_tm.js index 0b5456a0d..e855673dd 100644 --- a/test/y_volume_restriction_tm.js +++ b/test/y_volume_restriction_tm.js @@ -74,7 +74,7 @@ contract('VolumeRestrictionTransferManager', accounts => { let tempArrayGlobal = new Array(); // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); const address_zero = "0x0000000000000000000000000000000000000000"; diff --git a/test/z_general_permission_manager_fuzzer.js b/test/z_general_permission_manager_fuzzer.js index 9ebb1ea34..98f2ecbe3 100644 --- a/test/z_general_permission_manager_fuzzer.js +++ b/test/z_general_permission_manager_fuzzer.js @@ -90,7 +90,7 @@ contract("GeneralPermissionManager Fuzz", async (accounts) => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); // CountTransferManager details const holderCount = 2; // Maximum number of token holders diff --git a/test/z_vesting_escrow_wallet.js b/test/z_vesting_escrow_wallet.js index b5aba3441..52252a62c 100644 --- a/test/z_vesting_escrow_wallet.js +++ b/test/z_vesting_escrow_wallet.js @@ -65,7 +65,7 @@ contract('VestingEscrowWallet', accounts => { const stoKey = 3; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); let currentTime; const address_zero = "0x0000000000000000000000000000000000000000"; @@ -123,7 +123,7 @@ contract('VestingEscrowWallet', accounts => { STFactory: ${I_STFactory.address} GeneralTransferManagerFactory: ${I_GeneralTransferManagerFactory.address} GeneralPermissionManagerFactory: ${I_GeneralPermissionManagerFactory.address} - + I_VestingEscrowWalletFactory: ${I_VestingEscrowWalletFactory.address} ----------------------------------------------------------------------------- `); diff --git a/test/za_datastore.js b/test/za_datastore.js index b89646bac..aa3860151 100644 --- a/test/za_datastore.js +++ b/test/za_datastore.js @@ -41,7 +41,7 @@ contract("Data store", async (accounts) => { const bytes32data2 = "0x4400000000000000000000000000000000000000000000000000000000000000"; // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFee = new BN(web3.utils.toWei("1000")); const address_zero = "0x0000000000000000000000000000000000000000"; const address_one = "0x0000000000000000000000000000000000000001"; @@ -422,7 +422,7 @@ contract("Data store", async (accounts) => { }); it("Should not allow unauthorized addresses to delete bytes32 from Array", async () => { - await catchRevert(I_DataStore.deleteBytes32(key, 0, { from: account_polymath })); + await catchRevert(I_DataStore.deleteBytes32(key, 0, { from: account_polymath })); }); it("Should not allow unauthorized addresses to delete address from Array", async () => { @@ -465,4 +465,4 @@ contract("Data store", async (accounts) => { await catchRevert(I_DataStore.insertBoolMulti([key, key2], [true, true], { from: account_polymath })); }); }); -}); \ No newline at end of file +}); diff --git a/test/zb_signed_transfer_manager.js b/test/zb_signed_transfer_manager.js index 4f276f154..88b8a7428 100644 --- a/test/zb_signed_transfer_manager.js +++ b/test/zb_signed_transfer_manager.js @@ -188,7 +188,7 @@ contract("SignedTransferManager", accounts => { it("Should successfully attach the SignedTransferManager with the security token", async () => { - const tx = await I_SecurityToken.addModule(I_SignedTransferManagerFactory.address, new BN(0),new BN(0),new BN(0), { from: token_owner }); + const tx = await I_SecurityToken.addModule(I_SignedTransferManagerFactory.address, "0x0",new BN(0),new BN(0), { from: token_owner }); assert.equal(tx.logs[2].args._types[0].toNumber(), transferManagerKey, "SignedTransferManager doesn't get deployed"); assert.equal( web3.utils.toUtf8(tx.logs[2].args._name), From 08f43d955e74e8bdc83607ab74b1d09c65b91f9d Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Wed, 6 Feb 2019 08:35:51 -0400 Subject: [PATCH 9/9] Update comments --- contracts/SecurityTokenRegistry.sol | 14 +++++++------- contracts/modules/ModuleFactory.sol | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index 7de9c3be8..dfd7eca32 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -165,8 +165,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { * @notice Initializes instance of STR * @param _polymathRegistry is the address of the Polymath Registry * @param _STFactory is the address of the Proxy contract for Security Tokens - * @param _stLaunchFee is the fee in POLY required to launch a token - * @param _tickerRegFee is the fee in POLY required to register a ticker + * @param _stLaunchFee is the fee in USD required to launch a token + * @param _tickerRegFee is the fee in USD required to register a ticker * @param _owner is the owner of the STR, * @param _getterContract Contract address of the contract which consists getter functions. */ @@ -252,7 +252,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { function registerTicker(address _owner, string calldata _ticker, string calldata _tokenName) external whenNotPausedOrOwner { require(_owner != address(0), "Owner should not be 0x"); require(bytes(_ticker).length > 0 && bytes(_ticker).length <= 10, "Ticker length range (0,10]"); - // Attempt to charge the reg fee if it is > 0 POLY + // Attempt to charge the reg fee if it is > 0 USD (uint256 _usdFee, uint256 _polyFee) = _takeFee(TICKERREGFEE); string memory ticker = Util.upper(_ticker); require(_tickerAvailable(ticker), "Ticker is reserved"); @@ -609,8 +609,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { } /** - * @notice Sets the ticker registration fee in POLY tokens. Only Polymath. - * @param _tickerRegFee is the registration fee in POLY tokens (base 18 decimals) + * @notice Sets the ticker registration fee in USD tokens. Only Polymath. + * @param _tickerRegFee is the registration fee in USD tokens (base 18 decimals) */ function changeTickerRegistrationFee(uint256 _tickerRegFee) external onlyOwner { uint256 fee = getUintValue(TICKERREGFEE); @@ -620,8 +620,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { } /** - * @notice Sets the ticker registration fee in POLY tokens. Only Polymath. - * @param _stLaunchFee is the registration fee in POLY tokens (base 18 decimals) + * @notice Sets the ticker registration fee in USD tokens. Only Polymath. + * @param _stLaunchFee is the registration fee in USD tokens (base 18 decimals) */ function changeSecurityLaunchFee(uint256 _stLaunchFee) external onlyOwner { uint256 fee = getUintValue(STLAUNCHFEE); diff --git a/contracts/modules/ModuleFactory.sol b/contracts/modules/ModuleFactory.sol index fb93587c5..bc053e355 100644 --- a/contracts/modules/ModuleFactory.sol +++ b/contracts/modules/ModuleFactory.sol @@ -14,6 +14,7 @@ import "../libraries/DecimalMath.sol"; * @notice Contract is abstract */ contract ModuleFactory is IModuleFactory, Ownable { + // Fee to create underlying module in USD uint256 public setupCost; uint256 public usageCost; address public polymathRegistry; @@ -42,7 +43,7 @@ contract ModuleFactory is IModuleFactory, Ownable { /** * @notice Used to change the fee of the setup cost - * @param _newSetupCost new setup cost + * @param _newSetupCost new setup cost in USD */ function changeSetupCost(uint256 _newSetupCost) public onlyOwner { emit ChangeSetupCost(setupCost, _newSetupCost); @@ -51,7 +52,7 @@ contract ModuleFactory is IModuleFactory, Ownable { /** * @notice Used to change the fee of the usage cost - * @param _newUsageCost new usage cost + * @param _newUsageCost new usage cost in USD */ function changeUsageCost(uint256 _newUsageCost) public onlyOwner { emit ChangeUsageCost(usageCost, _newUsageCost);