diff --git a/contracts/STRGetter.sol b/contracts/STRGetter.sol index 850820696..5a5d39163 100644 --- a/contracts/STRGetter.sol +++ b/contracts/STRGetter.sol @@ -14,6 +14,7 @@ contract STRGetter is EternalStorage { bytes32 constant STLAUNCHFEE = 0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2; bytes32 constant TICKERREGFEE = 0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2; bytes32 constant EXPIRYLIMIT = 0x604268e9a73dfd777dcecb8a614493dd65c638bad2f5e7d709d378bd2fb0baee; + bytes32 constant IS_FEE_IN_POLY = 0x7152e5426955da44af11ecd67fec5e2a3ba747be974678842afa9394b9a075b6; //keccak256("IS_FEE_IN_POLY") /** * @notice Returns the list of tickers owned by the selected address @@ -242,6 +243,14 @@ contract STRGetter is EternalStorage { return getUintValue(TICKERREGFEE); } + /** + * @notice Gets the fee currency + * @return true = poly, false = usd + */ + function getIsFeeInPoly() public view returns(bool) { + return getBoolValue(IS_FEE_IN_POLY); + } + /** * @notice Gets the expiry limit * @return Expiry limit diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index 8e350a00f..7f2250ee0 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -75,6 +75,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { bytes32 constant OWNER = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0; bytes32 constant POLYMATHREGISTRY = 0x90eeab7c36075577c7cc5ff366e389fefa8a18289b949bab3529ab4471139d4d; bytes32 constant STRGETTER = 0x982f24b3bd80807ec3cb227ba152e15c07d66855fa8ae6ca536e689205c0e2e9; + bytes32 constant IS_FEE_IN_POLY = 0x7152e5426955da44af11ecd67fec5e2a3ba747be974678842afa9394b9a075b6; //keccak256("IS_FEE_IN_POLY") string constant POLY_ORACLE = "StablePolyUsdOracle"; @@ -90,6 +91,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { event ChangeSecurityLaunchFee(uint256 _oldFee, uint256 _newFee); // Emit when changeTickerRegistrationFee is called event ChangeTickerRegistrationFee(uint256 _oldFee, uint256 _newFee); + // Emit when Fee currency is changed + event ChangeFeeCurrency(bool _isFeeInPoly); // Emit when ownership gets transferred event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); // Emit when ownership of the ticker gets changed @@ -224,12 +227,18 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { * @notice Returns the usd & poly fee for a particular feetype * @param _feeType Key corresponding to fee type */ - function getFees(bytes32 _feeType) public returns (uint256, uint256) { + function getFees(bytes32 _feeType) public returns (uint256 usdFee, uint256 polyFee) { + bool isFeesInPoly = getBoolValue(IS_FEE_IN_POLY); + uint256 rawFee = getUintValue(_feeType); address polymathRegistry = getAddressValue(POLYMATHREGISTRY); uint256 polyRate = IOracle(IPolymathRegistry(polymathRegistry).getAddress(POLY_ORACLE)).getPrice(); - uint256 usdFee = getUintValue(_feeType); - uint256 polyFee = DecimalMath.div(usdFee, polyRate); - return (usdFee, polyFee); + if (!isFeesInPoly) { //Fee is in USD and not poly + usdFee = rawFee; + polyFee = DecimalMath.div(rawFee, polyRate); + } else { + usdFee = DecimalMath.mul(rawFee, polyRate); + polyFee = rawFee; + } } /** @@ -653,8 +662,12 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { function changeTickerRegistrationFee(uint256 _tickerRegFee) external onlyOwner { uint256 fee = getUintValue(TICKERREGFEE); require(fee != _tickerRegFee, "Bad fee"); - emit ChangeTickerRegistrationFee(fee, _tickerRegFee); - set(TICKERREGFEE, _tickerRegFee); + _changeTickerRegistrationFee(fee, _tickerRegFee); + } + + function _changeTickerRegistrationFee(uint256 _oldFee, uint256 _newFee) internal { + emit ChangeTickerRegistrationFee(_oldFee, _newFee); + set(TICKERREGFEE, _newFee); } /** @@ -664,8 +677,29 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { function changeSecurityLaunchFee(uint256 _stLaunchFee) external onlyOwner { uint256 fee = getUintValue(STLAUNCHFEE); require(fee != _stLaunchFee, "Bad fee"); - emit ChangeSecurityLaunchFee(fee, _stLaunchFee); - set(STLAUNCHFEE, _stLaunchFee); + _changeSecurityLaunchFee(fee, _stLaunchFee); + } + + function _changeSecurityLaunchFee(uint256 _oldFee, uint256 _newFee) internal { + emit ChangeSecurityLaunchFee(_oldFee, _newFee); + set(STLAUNCHFEE, _newFee); + } + + /** + * @notice Sets the ticker registration and ST launch fee amount and currency + * @param _tickerRegFee is the ticker registration fee (base 18 decimals) + * @param _stLaunchFee is the st generation fee (base 18 decimals) + * @param _isFeeInPoly defines if the fee is in poly or usd + */ + function changeFeesAmountAndCurrency(uint256 _tickerRegFee, uint256 _stLaunchFee, bool _isFeeInPoly) external onlyOwner { + uint256 tickerFee = getUintValue(TICKERREGFEE); + uint256 stFee = getUintValue(STLAUNCHFEE); + bool isOldFeesInPoly = getBoolValue(IS_FEE_IN_POLY); + require(isOldFeesInPoly != _isFeeInPoly, "Currency unchanged"); + _changeTickerRegistrationFee(tickerFee, _tickerRegFee); + _changeSecurityLaunchFee(stFee, _stLaunchFee); + emit ChangeFeeCurrency(_isFeeInPoly); + set(IS_FEE_IN_POLY, _isFeeInPoly); } /** diff --git a/contracts/interfaces/IModuleFactory.sol b/contracts/interfaces/IModuleFactory.sol index 3e78824fa..040ad8b30 100644 --- a/contracts/interfaces/IModuleFactory.sol +++ b/contracts/interfaces/IModuleFactory.sol @@ -5,6 +5,7 @@ pragma solidity ^0.5.0; */ interface IModuleFactory { event ChangeSetupCost(uint256 _oldSetupCost, uint256 _newSetupCost); + event ChangeCostType(bool _isOldCostInPoly, bool _isNewCostInPoly); event ChangeUsageCost(uint256 _oldUsageCost, uint256 _newUsageCost); event GenerateModuleFromFactory( address _module, @@ -71,6 +72,14 @@ interface IModuleFactory { */ function changeUsageCost(uint256 _newUsageCost) external; + /** + * @notice Used to change the currency and amount of usage and setup cost + * @param _setupCost new setup cost + * @param _usageCost new usage cost + * @param _isCostInPoly new usage cost currency. USD or POLY + */ + function changeCostsAndType(uint256 _setupCost, uint256 _usageCost, bool _isCostInPoly) external; + /** * @notice Function use to change the lower and upper bound of the compatible version st * @param _boundType Type of bound diff --git a/contracts/interfaces/ISecurityTokenRegistry.sol b/contracts/interfaces/ISecurityTokenRegistry.sol index 8d4738fec..3f8acf8ed 100644 --- a/contracts/interfaces/ISecurityTokenRegistry.sol +++ b/contracts/interfaces/ISecurityTokenRegistry.sol @@ -175,18 +175,26 @@ interface ISecurityTokenRegistry { */ function changeExpiryLimit(uint256 _newExpiry) external; - /** - * @notice Sets the ticker registration fee in POLY tokens - * @param _tickerRegFee 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; /** - * @notice Sets the ticker registration fee in POLY tokens - * @param _stLaunchFee 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; + /** + * @notice Sets the ticker registration and ST launch fee amount and currency + * @param _tickerRegFee is the ticker registration fee (base 18 decimals) + * @param _stLaunchFee is the st generation fee (base 18 decimals) + * @param _isFeeInPoly defines if the fee is in poly or usd + */ + function changeFeesAmountAndCurrency(uint256 _tickerRegFee, uint256 _stLaunchFee, bool _isFeeInPoly) external; + /** * @notice Gets the security token launch fee * @return Fee amount diff --git a/contracts/mocks/Dummy/DummySTOFactory.sol b/contracts/mocks/Dummy/DummySTOFactory.sol index b1e03270e..640d0a7d7 100644 --- a/contracts/mocks/Dummy/DummySTOFactory.sol +++ b/contracts/mocks/Dummy/DummySTOFactory.sol @@ -16,15 +16,17 @@ contract DummySTOFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "DummySTO"; title = "Dummy STO"; diff --git a/contracts/mocks/MockBurnFactory.sol b/contracts/mocks/MockBurnFactory.sol index 7fa512d73..cc86e52e2 100644 --- a/contracts/mocks/MockBurnFactory.sol +++ b/contracts/mocks/MockBurnFactory.sol @@ -18,10 +18,11 @@ contract MockBurnFactory is TrackedRedemptionFactory { constructor( uint256 _setupCost, uint256 _usageCost, - address _polymathRegistry + address _polymathRegistry, + bool _isFeeInPoly ) public - TrackedRedemptionFactory(_setupCost, _usageCost, _polymathRegistry) + TrackedRedemptionFactory(_setupCost, _usageCost, _polymathRegistry, _isFeeInPoly) { } diff --git a/contracts/mocks/MockFactory.sol b/contracts/mocks/MockFactory.sol index d86983cb5..3c97c7734 100644 --- a/contracts/mocks/MockFactory.sol +++ b/contracts/mocks/MockFactory.sol @@ -20,10 +20,11 @@ contract MockFactory is DummySTOFactory { uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isFeeInPoly ) public - DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry) + DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry, _isFeeInPoly) { } diff --git a/contracts/mocks/MockWrongTypeFactory.sol b/contracts/mocks/MockWrongTypeFactory.sol index 775cf8ebe..4694e15d7 100644 --- a/contracts/mocks/MockWrongTypeFactory.sol +++ b/contracts/mocks/MockWrongTypeFactory.sol @@ -18,10 +18,11 @@ contract MockWrongTypeFactory is MockBurnFactory { constructor( uint256 _setupCost, uint256 _usageCost, - address _polymathRegistry + address _polymathRegistry, + bool _isFeeInPoly ) public - MockBurnFactory(_setupCost, _usageCost, _polymathRegistry) + MockBurnFactory(_setupCost, _usageCost, _polymathRegistry, _isFeeInPoly) { } diff --git a/contracts/mocks/TestSTOFactory.sol b/contracts/mocks/TestSTOFactory.sol index ab3030c86..0f90bb183 100644 --- a/contracts/mocks/TestSTOFactory.sol +++ b/contracts/mocks/TestSTOFactory.sol @@ -14,10 +14,11 @@ contract TestSTOFactory is DummySTOFactory { uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isFeeInPoly ) public - DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry) + DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry, _isFeeInPoly) { name = "TestSTO"; title = "Test STO"; diff --git a/contracts/modules/Checkpoint/ERC20/ERC20DividendCheckpointFactory.sol b/contracts/modules/Checkpoint/ERC20/ERC20DividendCheckpointFactory.sol index b63bd8f92..30b88f1b9 100644 --- a/contracts/modules/Checkpoint/ERC20/ERC20DividendCheckpointFactory.sol +++ b/contracts/modules/Checkpoint/ERC20/ERC20DividendCheckpointFactory.sol @@ -16,15 +16,17 @@ contract ERC20DividendCheckpointFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "ERC20DividendCheckpoint"; title = "ERC20 Dividend Checkpoint"; diff --git a/contracts/modules/Checkpoint/Ether/EtherDividendCheckpointFactory.sol b/contracts/modules/Checkpoint/Ether/EtherDividendCheckpointFactory.sol index 9ddd00e40..7cd20074e 100644 --- a/contracts/modules/Checkpoint/Ether/EtherDividendCheckpointFactory.sol +++ b/contracts/modules/Checkpoint/Ether/EtherDividendCheckpointFactory.sol @@ -16,15 +16,17 @@ contract EtherDividendCheckpointFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "EtherDividendCheckpoint"; title = "Ether Dividend Checkpoint"; diff --git a/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol b/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol index a42873754..db7da70ef 100644 --- a/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol +++ b/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol @@ -12,14 +12,15 @@ contract TrackedRedemptionFactory is ModuleFactory { * @param _setupCost Setup cost of module * @param _usageCost Usage cost of module * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ constructor( uint256 _setupCost, uint256 _usageCost, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) - public - ModuleFactory(_setupCost, _usageCost, _polymathRegistry) + public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly) { initialVersion = "3.0.0"; name = "TrackedRedemption"; diff --git a/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol b/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol index 4ca75f2f2..99ddf7b8e 100644 --- a/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol +++ b/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol @@ -12,14 +12,15 @@ contract ScheduledCheckpointFactory is ModuleFactory { * @param _setupCost Setup cost of the module * @param _usageCost Usage cost of the module * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ constructor( uint256 _setupCost, uint256 _usageCost, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) - public - ModuleFactory(_setupCost, _usageCost, _polymathRegistry) + public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly) { initialVersion = "3.0.0"; name = "ScheduledCheckpoint"; diff --git a/contracts/modules/Experimental/TransferManager/BlacklistTransferManagerFactory.sol b/contracts/modules/Experimental/TransferManager/BlacklistTransferManagerFactory.sol index 4e0ff5183..4aae8b4cc 100644 --- a/contracts/modules/Experimental/TransferManager/BlacklistTransferManagerFactory.sol +++ b/contracts/modules/Experimental/TransferManager/BlacklistTransferManagerFactory.sol @@ -14,9 +14,15 @@ contract BlacklistTransferManagerFactory is ModuleFactory { * @param _setupCost Setup cost of the module * @param _usageCost Usage cost of the module * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor (uint256 _setupCost, uint256 _usageCost, address _polymathRegistry) public - ModuleFactory(_setupCost, _usageCost, _polymathRegistry) + constructor( + uint256 _setupCost, + uint256 _usageCost, + address _polymathRegistry, + bool _isCostInPoly + ) + public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly) { initialVersion = "3.0.0"; name = "BlacklistTransferManager"; diff --git a/contracts/modules/Experimental/TransferManager/KYCTransferManagerFactory.sol b/contracts/modules/Experimental/TransferManager/KYCTransferManagerFactory.sol index 67dcb3039..a0c0912cb 100644 --- a/contracts/modules/Experimental/TransferManager/KYCTransferManagerFactory.sol +++ b/contracts/modules/Experimental/TransferManager/KYCTransferManagerFactory.sol @@ -9,8 +9,13 @@ contract KYCTransferManagerFactory is ModuleFactory { /** * @notice Constructor */ - constructor (uint256 _setupCost, uint256 _usageCost, address _polymathRegistry) public - ModuleFactory(_setupCost, _usageCost, _polymathRegistry) + constructor( + uint256 _setupCost, + uint256 _usageCost, + address _polymathRegistry, + bool _isCostInPoly + ) + public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly) { initialVersion = "3.0.0"; name = "KYCTransferManager"; diff --git a/contracts/modules/Experimental/TransferManager/LTM/LockUpTransferManagerFactory.sol b/contracts/modules/Experimental/TransferManager/LTM/LockUpTransferManagerFactory.sol index 18c6cea54..ddeb53b4a 100644 --- a/contracts/modules/Experimental/TransferManager/LTM/LockUpTransferManagerFactory.sol +++ b/contracts/modules/Experimental/TransferManager/LTM/LockUpTransferManagerFactory.sol @@ -14,15 +14,17 @@ contract LockUpTransferManagerFactory is UpgradableModuleFactory { * @param _setupCost Setup cost of the module * @param _usageCost Usage cost of the module * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ constructor( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "LockUpTransferManager"; title = "LockUp Transfer Manager"; diff --git a/contracts/modules/Experimental/TransferManager/SignedTransferManagerFactory.sol b/contracts/modules/Experimental/TransferManager/SignedTransferManagerFactory.sol index 1f6c1ce0b..74826a9d9 100644 --- a/contracts/modules/Experimental/TransferManager/SignedTransferManagerFactory.sol +++ b/contracts/modules/Experimental/TransferManager/SignedTransferManagerFactory.sol @@ -11,8 +11,13 @@ contract SignedTransferManagerFactory is ModuleFactory { /** * @notice Constructor */ - constructor (uint256 _setupCost, uint256 _usageCost, address _polymathRegistry) public - ModuleFactory(_setupCost, _usageCost, _polymathRegistry) + constructor( + uint256 _setupCost, + uint256 _usageCost, + address _polymathRegistry, + bool _isCostInPoly + ) + public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly) { initialVersion = "3.0.0"; name = "SignedTransferManager"; diff --git a/contracts/modules/Experimental/Wallet/VestingEscrowWalletFactory.sol b/contracts/modules/Experimental/Wallet/VestingEscrowWalletFactory.sol index cebea9b16..d755e151a 100644 --- a/contracts/modules/Experimental/Wallet/VestingEscrowWalletFactory.sol +++ b/contracts/modules/Experimental/Wallet/VestingEscrowWalletFactory.sol @@ -13,8 +13,15 @@ contract VestingEscrowWalletFactory is UpgradableModuleFactory { /** * @notice Constructor */ - constructor (uint256 _setupCost, uint256 _usageCost, address _logicContract, address _polymathRegistry) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + constructor ( + uint256 _setupCost, + uint256 _usageCost, + address _logicContract, + address _polymathRegistry, + bool _isCostInPoly + ) + public + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "VestingEscrowWallet"; title = "Vesting Escrow Wallet"; diff --git a/contracts/modules/ModuleFactory.sol b/contracts/modules/ModuleFactory.sol index df9fff5f5..676d9773f 100644 --- a/contracts/modules/ModuleFactory.sol +++ b/contracts/modules/ModuleFactory.sol @@ -26,8 +26,9 @@ contract ModuleFactory is IModuleFactory, Ownable { uint8[] typesData; bytes32[] tagsData; - uint256 public usageCost; // Denominated in USD - uint256 public setupCost; // Denominated in USD + bool public isCostInPoly; + uint256 public usageCost; + uint256 public setupCost; string constant POLY_ORACLE = "StablePolyUsdOracle"; @@ -41,10 +42,11 @@ contract ModuleFactory is IModuleFactory, Ownable { /** * @notice Constructor */ - constructor(uint256 _setupCost, uint256 _usageCost, address _polymathRegistry) public { + constructor(uint256 _setupCost, uint256 _usageCost, address _polymathRegistry, bool _isCostInPoly) public { setupCost = _setupCost; usageCost = _usageCost; polymathRegistry = _polymathRegistry; + isCostInPoly = _isCostInPoly; } /** @@ -70,7 +72,7 @@ contract ModuleFactory is IModuleFactory, Ownable { /** * @notice Used to change the fee of the setup cost - * @param _setupCost new setup cost in USD + * @param _setupCost new setup cost */ function changeSetupCost(uint256 _setupCost) public onlyOwner { emit ChangeSetupCost(setupCost, _setupCost); @@ -79,13 +81,28 @@ contract ModuleFactory is IModuleFactory, Ownable { /** * @notice Used to change the fee of the usage cost - * @param _usageCost new usage cost in USD + * @param _usageCost new usage cost */ function changeUsageCost(uint256 _usageCost) public onlyOwner { emit ChangeUsageCost(usageCost, _usageCost); usageCost = _usageCost; } + /** + * @notice Used to change the currency and amount of usage and setup cost + * @param _setupCost new setup cost + * @param _usageCost new usage cost + * @param _isCostInPoly new usage cost currency. USD or POLY + */ + function changeCostsAndType(uint256 _setupCost, uint256 _usageCost, bool _isCostInPoly) public onlyOwner { + emit ChangeSetupCost(setupCost, _setupCost); + emit ChangeUsageCost(usageCost, _usageCost); + emit ChangeCostType(isCostInPoly, _isCostInPoly); + setupCost = _setupCost; + usageCost = _usageCost; + isCostInPoly = _isCostInPoly; + } + /** * @notice Updates the title of the ModuleFactory * @param _title New Title that will replace the old one. @@ -167,6 +184,8 @@ contract ModuleFactory is IModuleFactory, Ownable { * @notice Get the setup cost of the module */ function setupCostInPoly() public returns (uint256) { + if (isCostInPoly) + return setupCost; uint256 polyRate = IOracle(IPolymathRegistry(polymathRegistry).getAddress(POLY_ORACLE)).getPrice(); return DecimalMath.div(setupCost, polyRate); } @@ -175,6 +194,8 @@ contract ModuleFactory is IModuleFactory, Ownable { * @notice Get the setup cost of the module */ function usageCostInPoly() public returns (uint256) { + if (isCostInPoly) + return usageCost; uint256 polyRate = IOracle(IPolymathRegistry(polymathRegistry).getAddress(POLY_ORACLE)).getPrice(); return DecimalMath.div(usageCost, polyRate); } diff --git a/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol b/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol index d86b39404..6a95b2473 100644 --- a/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol +++ b/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol @@ -14,15 +14,17 @@ contract GeneralPermissionManagerFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "GeneralPermissionManager"; title = "General Permission Manager"; @@ -47,5 +49,5 @@ contract GeneralPermissionManagerFactory is UpgradableModuleFactory { _initializeModule(permissionManager, _data); return permissionManager; } - + } diff --git a/contracts/modules/STO/Capped/CappedSTOFactory.sol b/contracts/modules/STO/Capped/CappedSTOFactory.sol index a423bf281..a724c60d3 100644 --- a/contracts/modules/STO/Capped/CappedSTOFactory.sol +++ b/contracts/modules/STO/Capped/CappedSTOFactory.sol @@ -16,15 +16,17 @@ contract CappedSTOFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "CappedSTO"; title = "Capped STO"; diff --git a/contracts/modules/STO/PreSale/PreSaleSTOFactory.sol b/contracts/modules/STO/PreSale/PreSaleSTOFactory.sol index 15574fb88..cee2e5409 100644 --- a/contracts/modules/STO/PreSale/PreSaleSTOFactory.sol +++ b/contracts/modules/STO/PreSale/PreSaleSTOFactory.sol @@ -16,15 +16,17 @@ contract PreSaleSTOFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "PreSaleSTO"; title = "PreSale STO"; diff --git a/contracts/modules/STO/USDTiered/USDTieredSTOFactory.sol b/contracts/modules/STO/USDTiered/USDTieredSTOFactory.sol index 6841d80d0..f0810a677 100644 --- a/contracts/modules/STO/USDTiered/USDTieredSTOFactory.sol +++ b/contracts/modules/STO/USDTiered/USDTieredSTOFactory.sol @@ -16,15 +16,17 @@ contract USDTieredSTOFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "USDTieredSTO"; title = "USD Tiered STO"; diff --git a/contracts/modules/TransferManager/CTM/CountTransferManagerFactory.sol b/contracts/modules/TransferManager/CTM/CountTransferManagerFactory.sol index 06e22a030..397aca56a 100644 --- a/contracts/modules/TransferManager/CTM/CountTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/CTM/CountTransferManagerFactory.sol @@ -14,14 +14,17 @@ contract CountTransferManagerFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) - public UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + public + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "CountTransferManager"; title = "Count Transfer Manager"; diff --git a/contracts/modules/TransferManager/GTM/GeneralTransferManagerFactory.sol b/contracts/modules/TransferManager/GTM/GeneralTransferManagerFactory.sol index 72f11094a..3d4e15b85 100644 --- a/contracts/modules/TransferManager/GTM/GeneralTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/GTM/GeneralTransferManagerFactory.sol @@ -14,15 +14,17 @@ contract GeneralTransferManagerFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "GeneralTransferManager"; title = "General Transfer Manager"; diff --git a/contracts/modules/TransferManager/MATM/ManualApprovalTransferManagerFactory.sol b/contracts/modules/TransferManager/MATM/ManualApprovalTransferManagerFactory.sol index 008eca449..0d671a388 100644 --- a/contracts/modules/TransferManager/MATM/ManualApprovalTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/MATM/ManualApprovalTransferManagerFactory.sol @@ -14,15 +14,17 @@ contract ManualApprovalTransferManagerFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "ManualApprovalTransferManager"; title = "Manual Approval Transfer Manager"; diff --git a/contracts/modules/TransferManager/PTM/PercentageTransferManagerFactory.sol b/contracts/modules/TransferManager/PTM/PercentageTransferManagerFactory.sol index 2d3623879..b9c782b09 100644 --- a/contracts/modules/TransferManager/PTM/PercentageTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/PTM/PercentageTransferManagerFactory.sol @@ -16,15 +16,17 @@ contract PercentageTransferManagerFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor( + constructor ( uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "PercentageTransferManager"; title = "Percentage Transfer Manager"; diff --git a/contracts/modules/TransferManager/VRTM/VolumeRestrictionTMFactory.sol b/contracts/modules/TransferManager/VRTM/VolumeRestrictionTMFactory.sol index ba3aea2e4..a9f3c3939 100644 --- a/contracts/modules/TransferManager/VRTM/VolumeRestrictionTMFactory.sol +++ b/contracts/modules/TransferManager/VRTM/VolumeRestrictionTMFactory.sol @@ -14,9 +14,17 @@ contract VolumeRestrictionTMFactory is UpgradableModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ - constructor (uint256 _setupCost, uint256 _usageCost, address _logicContract, address _polymathRegistry) public - UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry) + constructor ( + uint256 _setupCost, + uint256 _usageCost, + address _logicContract, + address _polymathRegistry, + bool _isCostInPoly + ) + public + UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly) { name = "VolumeRestrictionTM"; title = "Volume Restriction Transfer Manager"; diff --git a/contracts/modules/UpgradableModuleFactory.sol b/contracts/modules/UpgradableModuleFactory.sol index ce5e090ce..01dab6430 100644 --- a/contracts/modules/UpgradableModuleFactory.sol +++ b/contracts/modules/UpgradableModuleFactory.sol @@ -42,15 +42,17 @@ contract UpgradableModuleFactory is ModuleFactory { * @param _usageCost Usage cost of the module * @param _logicContract Contract address that contains the logic related to `description` * @param _polymathRegistry Address of the Polymath registry + * @param _isCostInPoly true = cost in Poly, false = USD */ constructor( string memory _version, uint256 _setupCost, uint256 _usageCost, address _logicContract, - address _polymathRegistry + address _polymathRegistry, + bool _isCostInPoly ) - public ModuleFactory(_setupCost, _usageCost, _polymathRegistry) + public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly) { require(_logicContract != address(0), "Invalid address"); logicContracts[latestUpgrade].logicContract = _logicContract; diff --git a/contracts/oracles/PolyOracle.sol b/contracts/oracles/PolyOracle.sol index a029a11ce..7345e5395 100644 --- a/contracts/oracles/PolyOracle.sol +++ b/contracts/oracles/PolyOracle.sol @@ -16,6 +16,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable { uint256 public oraclizeTimeTolerance = 5 minutes; uint256 public staleTime = 6 hours; + // POLYUSD poly units = 1 * 10^18 USD units (1 USD) uint256 private POLYUSD; uint256 public latestUpdate; uint256 public latestScheduledUpdate; diff --git a/test/b_capped_sto.js b/test/b_capped_sto.js index 89837e96f..061c002c8 100644 --- a/test/b_capped_sto.js +++ b/test/b_capped_sto.js @@ -844,6 +844,23 @@ contract("CappedSTO", async (accounts) => { }); }); + describe("Pricing Test cases for Module Factory", async () => { + it("Should return correct price when price is in poly", async () => { + let newFactory = await CappedSTOFactory.new( + new BN(1000), + new BN(1000), + I_CappedSTO_Array_POLY[0].address, + I_PolymathRegistry.address, + true, + { from: account_polymath } + ); + assert.equal((await newFactory.setupCostInPoly.call()).toString(), (new BN(1000)).toString()); + assert.equal((await newFactory.usageCostInPoly.call()).toString(), (new BN(1000)).toString()); + assert.equal((await newFactory.setupCost()).toString(), (new BN(1000)).toString()); + assert.equal((await newFactory.usageCost()).toString(), (new BN(1000)).toString()); + }); + }); + describe("Check that we can reclaim ETH and ERC20 tokens from an STO", async () => { //xxx it("should attach a dummy STO", async () => { diff --git a/test/d_count_transfer_manager.js b/test/d_count_transfer_manager.js index 98245fd82..f293668d7 100644 --- a/test/d_count_transfer_manager.js +++ b/test/d_count_transfer_manager.js @@ -553,6 +553,25 @@ contract("CountTransferManager", async (accounts) => { assert.equal((await I_CountTransferManagerFactory.setupCost.call()).toString(), new BN(web3.utils.toWei("800")).toString()); }); + it("Should successfully change the cost type -- fail beacuse of bad owner", async () => { + await catchRevert( + I_CountTransferManagerFactory.changeCostsAndType(new BN(web3.utils.toWei("100")), new BN(web3.utils.toWei("500")), true, { from: account_investor3 }) + ); + }); + + it("Should successfully change the cost type", async () => { + let snapId = await takeSnapshot(); + let tx = await I_CountTransferManagerFactory.changeCostsAndType(new BN(web3.utils.toWei("100")), new BN(web3.utils.toWei("500")), true, { from: account_polymath }); + assert.equal(tx.logs[0].args[1].toString(), new BN(web3.utils.toWei("100")).toString(), "wrong setup fee in event"); + assert.equal(tx.logs[1].args[1].toString(), new BN(web3.utils.toWei("500")).toString(), "wrong usage fee in event"); + assert.equal(tx.logs[2].args[1], true, "wrong fee type in event"); + assert.equal((await I_CountTransferManagerFactory.setupCost.call()).toString(), new BN(web3.utils.toWei("100")).toString()); + assert.equal((await I_CountTransferManagerFactory.usageCost.call()).toString(), new BN(web3.utils.toWei("500")).toString()); + assert.equal((await I_CountTransferManagerFactory.setupCost.call()).toString(), (await I_CountTransferManagerFactory.setupCostInPoly.call()).toString()); + assert.equal((await I_CountTransferManagerFactory.usageCost.call()).toString(), (await I_CountTransferManagerFactory.usageCostInPoly.call()).toString()); + await revertToSnapshot(snapId); + }); + it("Should successfully change the usage fee -- fail beacuse of bad owner", async () => { await catchRevert( I_CountTransferManagerFactory.changeUsageCost(new BN(web3.utils.toWei("500")), { from: account_investor3 }) diff --git a/test/h_general_transfer_manager.js b/test/h_general_transfer_manager.js index 29f34fd55..b12a1d5a4 100644 --- a/test/h_general_transfer_manager.js +++ b/test/h_general_transfer_manager.js @@ -1036,7 +1036,7 @@ contract("GeneralTransferManager", async (accounts) => { let balanceBefore = await I_PolyToken.balanceOf(account_polymath); await I_GeneralTransferManager.takeUsageFee({ from: account_delegate }); let balanceAfter = await I_PolyToken.balanceOf(account_polymath); - assert.equal(balanceBefore.add(new BN(web3.utils.toWei("4", "ether"))).toString(), balanceAfter.toString(), "Fee is transferred"); + assert.equal(balanceBefore.add(new BN(web3.utils.toWei("1", "ether"))).toString(), balanceAfter.toString(), "Fee is transferred"); }); it("should allow authorized people to modify transfer requirements", async () => { diff --git a/test/helpers/createInstances.js b/test/helpers/createInstances.js index bb695b224..6bf6de1a0 100644 --- a/test/helpers/createInstances.js +++ b/test/helpers/createInstances.js @@ -223,7 +223,7 @@ async function deployGTMLogic(account_polymath) { } async function deployGTM(account_polymath) { - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, { + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, true, { from: account_polymath }); @@ -308,8 +308,8 @@ 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), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, { +export async function deployGTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(setupCost, new BN(0), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); @@ -324,10 +324,10 @@ export async function deployGTMAndVerifyed(accountPolymath, MRProxyInstance, set return Promise.all(new Array(I_GeneralTransferManagerFactory)); } -export async function deployVRTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployVRTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_VolumeRestrictionTMLogic = await VolumeRestrictionTM.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_VolumeRestrictionTMFactory = await VolumeRestrictionTMFactory.new(setupCost, new BN(0), I_VolumeRestrictionTMLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_VolumeRestrictionTMFactory = await VolumeRestrictionTMFactory.new(setupCost, new BN(0), I_VolumeRestrictionTMLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_VolumeRestrictionTMFactory.address.valueOf(), @@ -340,9 +340,9 @@ export async function deployVRTMAndVerifyed(accountPolymath, MRProxyInstance, se return new Array(I_VolumeRestrictionTMFactory); } -export async function deployCountTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployCountTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_CountTransferManagerLogic = await CountTransferManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_CountTransferManagerFactory = await CountTransferManagerFactory.new(setupCost, new BN(0), I_CountTransferManagerLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_CountTransferManagerFactory = await CountTransferManagerFactory.new(setupCost, new BN(0), I_CountTransferManagerLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_CountTransferManagerFactory.address.valueOf(), @@ -354,9 +354,9 @@ export async function deployCountTMAndVerifyed(accountPolymath, MRProxyInstance, return Promise.all(new Array(I_CountTransferManagerFactory)); } -export async function deployManualApprovalTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployManualApprovalTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_ManualApprovalTransferManagerLogic = await ManualApprovalTransferManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_ManualApprovalTransferManagerFactory = await ManualApprovalTransferManagerFactory.new(setupCost, new BN(0), ManualApprovalTransferManager.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_ManualApprovalTransferManagerFactory = await ManualApprovalTransferManagerFactory.new(setupCost, new BN(0), ManualApprovalTransferManager.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_ManualApprovalTransferManagerFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -367,9 +367,9 @@ export async function deployManualApprovalTMAndVerifyed(accountPolymath, MRProxy return Promise.all(new Array(I_ManualApprovalTransferManagerFactory)); } -export async function deployPercentageTMAndVerified(accountPolymath, MRProxyInstance, setupCost) { +export async function deployPercentageTMAndVerified(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_PercentageTransferManagerLogic = await PercentageTransferManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_PercentageTransferManagerFactory = await PercentageTransferManagerFactory.new(setupCost, new BN(0), I_PercentageTransferManagerLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_PercentageTransferManagerFactory = await PercentageTransferManagerFactory.new(setupCost, new BN(0), I_PercentageTransferManagerLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_PercentageTransferManagerFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -380,9 +380,9 @@ export async function deployPercentageTMAndVerified(accountPolymath, MRProxyInst return Promise.all(new Array(I_PercentageTransferManagerFactory)); } -export async function deployBlacklistTMAndVerified(accountPolymath, MRProxyInstance, setupCost) { +export async function deployBlacklistTMAndVerified(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { - I_BlacklistTransferManagerFactory = await BlacklistTransferManagerFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); + I_BlacklistTransferManagerFactory = await BlacklistTransferManagerFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_BlacklistTransferManagerFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -393,9 +393,9 @@ export async function deployBlacklistTMAndVerified(accountPolymath, MRProxyInsta return new Array(I_BlacklistTransferManagerFactory); } -export async function deployLockUpTMAndVerified(accountPolymath, MRProxyInstance, setupCost) { +export async function deployLockUpTMAndVerified(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_LockUpTransferManagerLogic = await LockUpTransferManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_LockUpTransferManagerFactory = await LockUpTransferManagerFactory.new(setupCost, new BN(0), I_LockUpTransferManagerLogic.address, I_PolymathRegistry.address, { + I_LockUpTransferManagerFactory = await LockUpTransferManagerFactory.new(setupCost, new BN(0), I_LockUpTransferManagerLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( @@ -408,8 +408,8 @@ export async function deployLockUpTMAndVerified(accountPolymath, MRProxyInstance return Promise.all(new Array(I_LockUpTransferManagerFactory)); } -export async function deployScheduleCheckpointAndVerified(accountPolymath, MRProxyInstance, setupCost) { - I_ScheduledCheckpointFactory = await ScheduledCheckpointFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); +export async function deployScheduleCheckpointAndVerified(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { + I_ScheduledCheckpointFactory = await ScheduledCheckpointFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_ScheduledCheckpointFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -422,9 +422,9 @@ export async function deployScheduleCheckpointAndVerified(accountPolymath, MRPro /// Deploy the Permission Manager -export async function deployGPMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployGPMAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_GeneralPermissionManagerLogic = await GeneralPermissionManager.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(setupCost, new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(setupCost, new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -439,9 +439,9 @@ export async function deployGPMAndVerifyed(accountPolymath, MRProxyInstance, set /// Deploy the STO Modules -export async function deployDummySTOAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployDummySTOAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_DummySTOLogic = await DummySTO.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_DummySTOFactory = await DummySTOFactory.new(setupCost, new BN(0), I_DummySTOLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_DummySTOFactory = await DummySTOFactory.new(setupCost, new BN(0), I_DummySTOLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_DummySTOFactory.address.valueOf(), @@ -452,9 +452,9 @@ export async function deployDummySTOAndVerifyed(accountPolymath, MRProxyInstance return Promise.all(new Array(I_DummySTOFactory)); } -export async function deployCappedSTOAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployCappedSTOAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_CappedSTOLogic = await CappedSTO.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_CappedSTOFactory = await CappedSTOFactory.new(setupCost, new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_CappedSTOFactory = await CappedSTOFactory.new(setupCost, new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_CappedSTOFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -465,9 +465,9 @@ export async function deployCappedSTOAndVerifyed(accountPolymath, MRProxyInstanc return Promise.all(new Array(I_CappedSTOFactory)); } -export async function deployPresaleSTOAndVerified(accountPolymath, MRProxyInstance, setupCost) { +export async function deployPresaleSTOAndVerified(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_PreSaleSTOLogic = await PreSaleSTO.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_PreSaleSTOFactory = await PreSaleSTOFactory.new(setupCost, new BN(0), I_PreSaleSTOLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_PreSaleSTOFactory = await PreSaleSTOFactory.new(setupCost, new BN(0), I_PreSaleSTOLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_PreSaleSTOFactory.address.valueOf(), @@ -479,14 +479,14 @@ export async function deployPresaleSTOAndVerified(accountPolymath, MRProxyInstan return Promise.all(new Array(I_PreSaleSTOFactory)); } -export async function deployUSDTieredSTOAndVerified(accountPolymath, MRProxyInstance, setupCost) { +export async function deployUSDTieredSTOAndVerified(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_USDTieredSTOLogic = await USDTieredSTO.new( "0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath } ); - I_USDTieredSTOFactory = await USDTieredSTOFactory.new(setupCost, new BN(0), I_USDTieredSTOLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_USDTieredSTOFactory = await USDTieredSTOFactory.new(setupCost, new BN(0), I_USDTieredSTOLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_USDTieredSTOFactory.address.valueOf(), @@ -500,13 +500,13 @@ export async function deployUSDTieredSTOAndVerified(accountPolymath, MRProxyInst /// Deploy the Dividend Modules -export async function deployERC20DividendAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployERC20DividendAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_ERC20DividendCheckpointLogic = await ERC20DividendCheckpoint.new( "0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath } ); - I_ERC20DividendCheckpointFactory = await ERC20DividendCheckpointFactory.new(setupCost, new BN(0), I_ERC20DividendCheckpointLogic.address, I_PolymathRegistry.address, { + I_ERC20DividendCheckpointFactory = await ERC20DividendCheckpointFactory.new(setupCost, new BN(0), I_ERC20DividendCheckpointLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); @@ -519,13 +519,13 @@ export async function deployERC20DividendAndVerifyed(accountPolymath, MRProxyIns return Promise.all(new Array(I_ERC20DividendCheckpointFactory)); } -export async function deployEtherDividendAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployEtherDividendAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_EtherDividendCheckpointLogic = await EtherDividendCheckpoint.new( "0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath } ); - I_EtherDividendCheckpointFactory = await EtherDividendCheckpointFactory.new(setupCost, new BN(0), I_EtherDividendCheckpointLogic.address, I_PolymathRegistry.address, { + I_EtherDividendCheckpointFactory = await EtherDividendCheckpointFactory.new(setupCost, new BN(0), I_EtherDividendCheckpointLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); @@ -541,8 +541,8 @@ 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), I_PolymathRegistry.address, { from: accountPolymath }); +export async function deployRedemptionAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { + I_TrackedRedemptionFactory = await TrackedRedemptionFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_TrackedRedemptionFactory.address.valueOf(), @@ -554,9 +554,9 @@ export async function deployRedemptionAndVerifyed(accountPolymath, MRProxyInstan return Promise.all(new Array(I_TrackedRedemptionFactory)); } -export async function deployVestingEscrowWalletAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { +export async function deployVestingEscrowWalletAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { I_VestingEscrowWalletLogic = await VestingEscrowWallet.new("0x0000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000", { from: accountPolymath }); - I_VestingEscrowWalletFactory = await VestingEscrowWalletFactory.new(setupCost, new BN(0), I_VestingEscrowWalletLogic.address, I_PolymathRegistry.address, { from: accountPolymath }); + I_VestingEscrowWalletFactory = await VestingEscrowWalletFactory.new(setupCost, new BN(0), I_VestingEscrowWalletLogic.address, I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_VestingEscrowWalletFactory.address.valueOf(), @@ -568,8 +568,8 @@ export async function deployVestingEscrowWalletAndVerifyed(accountPolymath, MRPr return new Array(I_VestingEscrowWalletFactory); } -export async function deployMockRedemptionAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { - I_MockBurnFactory = await MockBurnFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); +export async function deployMockRedemptionAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { + I_MockBurnFactory = await MockBurnFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_MockBurnFactory.address.valueOf(), @@ -581,8 +581,8 @@ export async function deployMockRedemptionAndVerifyed(accountPolymath, MRProxyIn return Promise.all(new Array(I_MockBurnFactory)); } -export async function deployMockWrongTypeRedemptionAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { - I_MockWrongTypeBurnFactory = await MockWrongTypeFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); +export async function deployMockWrongTypeRedemptionAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { + I_MockWrongTypeBurnFactory = await MockWrongTypeFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_MockWrongTypeBurnFactory.address.valueOf(), @@ -594,8 +594,8 @@ export async function deployMockWrongTypeRedemptionAndVerifyed(accountPolymath, return Promise.all(new Array(I_MockWrongTypeBurnFactory)); } -export async function deploySignedTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost) { - I_SignedTransferManagerFactory = await SignedTransferManagerFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, { from: accountPolymath }); +export async function deploySignedTMAndVerifyed(accountPolymath, MRProxyInstance, setupCost, feeInPoly = false) { + I_SignedTransferManagerFactory = await SignedTransferManagerFactory.new(setupCost, new BN(0), I_PolymathRegistry.address, feeInPoly, { from: accountPolymath }); assert.notEqual( I_SignedTransferManagerFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", diff --git a/test/k_module_registry.js b/test/k_module_registry.js index e55658ea4..ab6d280d9 100644 --- a/test/k_module_registry.js +++ b/test/k_module_registry.js @@ -258,15 +258,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), one_address, I_PolymathRegistry.address, { from: account_polymath }); + I_MockFactory = await MockFactory.new(new BN(0), new BN(0), one_address, I_PolymathRegistry.address, true, { 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), I_CappedSTOLogic.address, I_PolymathRegistry.address, { from: account_temp }); - console.log("I_CappedSTOFactory3: " + I_CappedSTOFactory3.address); + I_CappedSTOFactory3 = await CappedSTOFactory.new(new BN(0), new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, true, { from: account_temp }); catchRevert(I_MRProxied.registerModule(I_CappedSTOFactory3.address, { from: token_owner })); }); @@ -289,7 +288,7 @@ contract("ModuleRegistry", async (accounts) => { }); it("Should successfully verify the module -- false", async () => { - I_CappedSTOFactory1 = await CappedSTOFactory.new(new BN(0), new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, { from: account_polymath }); + I_CappedSTOFactory1 = await CappedSTOFactory.new(new BN(0), new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, true, { from: account_polymath }); await I_MRProxied.registerModule(I_CappedSTOFactory1.address, { from: account_polymath }); let tx = await I_MRProxied.unverifyModule(I_CappedSTOFactory1.address, { from: account_polymath }); assert.equal(tx.logs[0].args._moduleFactory, I_CappedSTOFactory1.address, "Failed in verifying the module"); @@ -323,7 +322,7 @@ contract("ModuleRegistry", async (accounts) => { }); it("Should fail to register module because custom modules not allowed", async () => { - I_CappedSTOFactory2 = await CappedSTOFactory.new(new BN(0), new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, { from: token_owner }); + I_CappedSTOFactory2 = await CappedSTOFactory.new(new BN(0), new BN(0), I_CappedSTOLogic.address, I_PolymathRegistry.address, true, { from: token_owner }); assert.notEqual(I_CappedSTOFactory2.address.valueOf(), address_zero, "CappedSTOFactory contract was not deployed"); @@ -371,7 +370,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(new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, { + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, true, { from: account_polymath }); await I_MRProxied.registerModule(I_GeneralPermissionManagerFactory.address, { from: account_polymath }); @@ -382,7 +381,7 @@ contract("ModuleRegistry", async (accounts) => { it("Should failed in adding the TestSTOFactory module because not compatible with the current protocol version --lower", async () => { let I_TestSTOFactoryLogic = await DummySTO.new(address_zero, address_zero); - I_TestSTOFactory = await TestSTOFactory.new(new BN(0), new BN(0), I_TestSTOFactoryLogic.address, I_PolymathRegistry.address, { from: account_polymath }); + I_TestSTOFactory = await TestSTOFactory.new(new BN(0), new BN(0), I_TestSTOFactoryLogic.address, I_PolymathRegistry.address, true, { from: account_polymath }); await I_MRProxied.registerModule(I_TestSTOFactory.address, { from: account_polymath }); await I_MRProxied.verifyModule(I_TestSTOFactory.address, { 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 50b573364..40bb6910c 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -338,7 +338,7 @@ contract("SecurityTokenRegistry", async (accounts) => { let currentRate = await I_POLYOracle.getPrice.call(); console.log("Current Rate: " + currentRate); let feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - let feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + let feesToken = await I_STRProxied.getFees.call("0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2"); assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); assert.equal(feesToken[0].toString(), origPriceUSD.toString()); @@ -346,7 +346,7 @@ contract("SecurityTokenRegistry", async (accounts) => { await I_POLYOracle.changePrice(new BN(27).mul(new BN(10).pow(new BN(16)))); await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesToken = await I_STRProxied.getFees.call("0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2"); // No change as difference is less than 10% assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); @@ -355,7 +355,7 @@ contract("SecurityTokenRegistry", async (accounts) => { await I_POLYOracle.changePrice(new BN(20).mul(new BN(10).pow(new BN(16)))); await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesToken = await I_STRProxied.getFees.call("0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2"); let newPricePOLY = new BN(web3.utils.toWei("1250")); assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); @@ -364,7 +364,7 @@ contract("SecurityTokenRegistry", async (accounts) => { await I_POLYOracle.changePrice(new BN(21).mul(new BN(10).pow(new BN(16)))); await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesToken = await I_STRProxied.getFees.call("0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2"); // No change as difference is less than 10% assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); @@ -373,7 +373,7 @@ contract("SecurityTokenRegistry", async (accounts) => { await I_StablePOLYOracle.changeEvictPercentage(new BN(10).pow(new BN(16))); await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesToken = await I_STRProxied.getFees.call("0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2"); // Change as eviction percentage updated // newPricePOLY = new BN(web3.utils.toWei("1250")); //1190.476190476190476190 = 250/0.21 @@ -588,8 +588,9 @@ 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("2000")), { from: token_owner }); - let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); + await I_STRProxied.changeTickerRegistrationFee(0, { from: account_polymath }); + //await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); + await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); await I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, treasury_wallet, 0, { from: token_owner }), await revertToSnapshot(snap_Id); }); @@ -932,14 +933,14 @@ contract("SecurityTokenRegistry", async (accounts) => { }); describe("Test cases for the transferTickerOwnership()", async () => { - it("Should able to transfer the ticker ownership -- failed because token is not deployed having the same ticker", async () => { + it("Should be able to transfer the ticker ownership -- failed because token is not deployed having the same ticker", async () => { await catchRevert( I_STRProxied.transferTickerOwnership(account_issuer, "ETH", { from: account_temp }), "tx revert -> failed because token is not deployed having the same ticker" ); }); - it("Should able to transfer the ticker ownership -- failed because new owner is 0x", async () => { + it("Should be able to transfer the ticker ownership -- failed because new owner is 0x", async () => { await I_SecurityToken002.transferOwnership(account_temp, { from: token_owner }); await catchRevert( I_STRProxied.transferTickerOwnership(address_zero, symbol2, { from: token_owner }), @@ -947,14 +948,14 @@ contract("SecurityTokenRegistry", async (accounts) => { ); }); - it("Should able to transfer the ticker ownership -- failed because ticker is of zero length", async () => { + it("Should be able to transfer the ticker ownership -- failed because ticker is of zero length", async () => { await catchRevert( I_STRProxied.transferTickerOwnership(account_temp, "", { from: token_owner }), "tx revert -> failed because ticker is of zero length" ); }); - it("Should able to transfer the ticker ownership", async () => { + it("Should be able to transfer the ticker ownership", async () => { let tx = await I_STRProxied.transferTickerOwnership(account_temp, symbol2, { from: token_owner, gas: 5000000 }); assert.equal(tx.logs[0].args._newOwner, account_temp); let symbolDetails = await I_Getter.getTickerDetails.call(symbol2); @@ -964,21 +965,21 @@ contract("SecurityTokenRegistry", async (accounts) => { }); describe("Test case for the changeSecurityLaunchFee()", async () => { - it("Should able to change the STLaunchFee-- failed because of bad owner", async () => { + it("Should be able to change the STLaunchFee-- failed because of bad owner", async () => { await catchRevert( I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_temp }), "tx revert -> failed because of bad owner" ); }); - it("Should able to change the STLaunchFee-- failed because of putting the same fee", async () => { + it("Should be able to change the STLaunchFee-- failed because of putting the same fee", async () => { await catchRevert( I_STRProxied.changeSecurityLaunchFee(initRegFee, { from: account_polymath }), "tx revert -> failed because of putting the same fee" ); }); - it("Should able to change the STLaunchFee", async () => { + it("Should be able to change the STLaunchFee", async () => { let tx = await I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_polymath }); assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("500")).toString()); let stLaunchFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("stLaunchFee")); @@ -987,21 +988,21 @@ contract("SecurityTokenRegistry", async (accounts) => { }); describe("Test cases for the changeExpiryLimit()", async () => { - it("Should able to change the ExpiryLimit-- failed because of bad owner", async () => { + it("Should be able to change the ExpiryLimit-- failed because of bad owner", async () => { await catchRevert( I_STRProxied.changeExpiryLimit(duration.days(15), { from: account_temp }), "tx revert -> failed because of bad owner" ); }); - it("Should able to change the ExpiryLimit-- failed because expirylimit is less than 1 day", async () => { + it("Should be able to change the ExpiryLimit-- failed because expirylimit is less than 1 day", async () => { await catchRevert( I_STRProxied.changeExpiryLimit(duration.minutes(50), { from: account_polymath }), "tx revert -> failed because expirylimit is less than 1 day" ); }); - it("Should able to change the ExpiryLimit", async () => { + it("Should be able to change the ExpiryLimit", async () => { let tx = await I_STRProxied.changeExpiryLimit(duration.days(20), { from: account_polymath }); assert.equal(tx.logs[0].args._newExpiry, duration.days(20)); let expiry = await I_STRProxied.getUintValue(web3.utils.soliditySha3("expiryLimit")); @@ -1010,21 +1011,55 @@ contract("SecurityTokenRegistry", async (accounts) => { }); describe("Test cases for the changeTickerRegistrationFee()", async () => { - it("Should able to change the TickerRegFee-- failed because of bad owner", async () => { + it("Should be able to change the fee currency-- failed because of bad owner", async () => { + await catchRevert( + I_STRProxied.changeFeesAmountAndCurrency(new BN(web3.utils.toWei("500")), new BN(web3.utils.toWei("100")), false, { from: account_temp }), + "tx revert -> failed because of bad owner" + ); + }); + + it("Should be able to change the fee currency-- failed because of putting the same currency", async () => { + await catchRevert( + I_STRProxied.changeFeesAmountAndCurrency(new BN(web3.utils.toWei("500")), new BN(web3.utils.toWei("100")), false, { from: account_polymath }), + "tx revert -> failed because of putting the same fee" + ); + }); + + it("Should be able to change the fee currency", async () => { + let snapId = await takeSnapshot(); + let tx = await I_STRProxied.changeFeesAmountAndCurrency(new BN(web3.utils.toWei("500")), new BN(web3.utils.toWei("100")), true, { from: account_polymath }); + assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("500")).toString(), "wrong ticker fee in event"); + assert.equal(tx.logs[1].args._newFee.toString(), new BN(web3.utils.toWei("100")).toString(), "wrong st fee in event"); + assert.equal(tx.logs[2].args._isFeeInPoly, true, "wrong fee type"); + assert.equal(await I_Getter.getIsFeeInPoly(), true, "is fee in poly not set"); + let tickerRegFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("tickerRegFee")); + assert.equal(tickerRegFee.toString(), new BN(web3.utils.toWei("500")).toString(), "wrong fee"); + let tickerRegFeePoly = (await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"))[1]; + assert.equal(tickerRegFeePoly.toString(), tickerRegFee.toString()); + let stFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("stLaunchFee")); + assert.equal(stFee.toString(), new BN(web3.utils.toWei("100")).toString(), "wrong fee"); + let stFeePoly = (await I_STRProxied.getFees.call("0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2"))[1]; + assert.equal(stFeePoly.toString(), stFee.toString()); + await revertToSnapshot(snapId); + }); + }); + + describe("Test cases for the changeTickerRegistrationFee()", async () => { + it("Should be able to change the TickerRegFee-- failed because of bad owner", async () => { await catchRevert( I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("500")), { from: account_temp }), "tx revert -> failed because of bad owner" ); }); - it("Should able to change the TickerRegFee-- failed because of putting the same fee", async () => { + it("Should be able to change the TickerRegFee-- failed because of putting the same fee", async () => { await catchRevert( I_STRProxied.changeTickerRegistrationFee(initRegFee, { from: account_polymath }), "tx revert -> failed because of putting the same fee" ); }); - it("Should able to change the TickerRegFee", async () => { + it("Should be able to change the TickerRegFee", async () => { let tx = await I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("400")), { from: account_polymath }); assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("400")).toString()); let tickerRegFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("tickerRegFee")); diff --git a/test/u_module_registry_proxy.js b/test/u_module_registry_proxy.js index d70b19acb..e3447bf27 100644 --- a/test/u_module_registry_proxy.js +++ b/test/u_module_registry_proxy.js @@ -146,7 +146,7 @@ contract("ModuleRegistryProxy", async (accounts) => { { from: account_polymath } ); - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, { + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(new BN(0), new BN(0), I_GeneralTransferManagerLogic.address, I_PolymathRegistry.address, true, { from: account_polymath }); @@ -195,7 +195,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(new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, { + I_GeneralPermissionManagerfactory = await GeneralPermissionManagerFactory.new(new BN(0), new BN(0), I_GeneralPermissionManagerLogic.address, I_PolymathRegistry.address, true, { from: account_polymath });