From 6d61c1cd656d083586d3116698a40be23112034e Mon Sep 17 00:00:00 2001 From: Satyam Agrawal Date: Thu, 13 Jun 2019 19:04:59 +0530 Subject: [PATCH] Synchronise the ISTR with STR (#682) * synchronise the ISTR with STR * fix the interface problem * minor fixes * add some function in interface * add comment in STR * consistency in interfaces of contracts * improve the st interface * remove shadow declaration * add #706 new function declartion in the ISTR * add missing functions in interface --- contracts/FeatureRegistry.sol | 2 - contracts/ModuleRegistry.sol | 23 +- contracts/PolymathRegistry.sol | 5 +- contracts/SecurityTokenRegistry.sol | 11 +- contracts/interfaces/IFeatureRegistry.sol | 11 + contracts/interfaces/IModuleFactory.sol | 24 ++ contracts/interfaces/IModuleRegistry.sol | 47 ++- contracts/interfaces/IPolymathRegistry.sol | 10 + contracts/interfaces/ISTFactory.sol | 42 ++- contracts/interfaces/ISTO.sol | 17 + contracts/interfaces/ISecurityToken.sol | 201 +++++++++--- .../interfaces/ISecurityTokenRegistry.sol | 292 ++++++++++++++++-- contracts/interfaces/IUSDTieredSTOProxy.sol | 22 -- contracts/interfaces/IVoting.sol | 11 +- contracts/modules/STO/STO.sol | 5 - contracts/tokens/STFactory.sol | 1 + contracts/tokens/STGetter.sol | 2 +- 17 files changed, 607 insertions(+), 119 deletions(-) delete mode 100644 contracts/interfaces/IUSDTieredSTOProxy.sol diff --git a/contracts/FeatureRegistry.sol b/contracts/FeatureRegistry.sol index 520e560f8..ea13f0297 100644 --- a/contracts/FeatureRegistry.sol +++ b/contracts/FeatureRegistry.sol @@ -9,8 +9,6 @@ import "./interfaces/IFeatureRegistry.sol"; contract FeatureRegistry is IFeatureRegistry, ReclaimTokens { mapping(bytes32 => bool) public featureStatus; - event ChangeFeatureStatus(string _nameKey, bool _newStatus); - /** * @notice Get the status of a feature * @param _nameKey is the key for the feature status mapping diff --git a/contracts/ModuleRegistry.sol b/contracts/ModuleRegistry.sol index 5c2992aa9..b358763fc 100644 --- a/contracts/ModuleRegistry.sol +++ b/contracts/ModuleRegistry.sol @@ -43,28 +43,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage { bytes32 constant POLYMATHREGISTRY = 0x90eeab7c36075577c7cc5ff366e389fefa8a18289b949bab3529ab4471139d4d; //keccak256("polymathRegistry") bytes32 constant FEATURE_REGISTRY = 0xed9ca06607835ad25ecacbcb97f2bc414d4a51ecf391b5ae42f15991227ab146; //keccak256("featureRegistry") bytes32 constant SECURITY_TOKEN_REGISTRY = 0x12ada4f7ee6c2b7b933330be61fefa007a1f497dc8df1b349b48071a958d7a81; //keccak256("securityTokenRegistry") - - /////////// - // Events - ////////// - - // Emit when network becomes paused - event Pause(address account); - // Emit when network becomes unpaused - event Unpause(address account); - // Emit when Module is used by the SecurityToken - event ModuleUsed(address indexed _moduleFactory, address indexed _securityToken); - // Emit when the Module Factory gets registered on the ModuleRegistry contract - event ModuleRegistered(address indexed _moduleFactory, address indexed _owner); - // Emit when the module gets verified by Polymath - event ModuleVerified(address indexed _moduleFactory); - // Emit when the module gets unverified by Polymath or the factory owner - event ModuleUnverified(address indexed _moduleFactory); - // Emit when a ModuleFactory is removed by Polymath - event ModuleRemoved(address indexed _moduleFactory, address indexed _decisionMaker); - // Emit when ownership gets transferred - event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); - + /////////////// //// Modifiers /////////////// diff --git a/contracts/PolymathRegistry.sol b/contracts/PolymathRegistry.sol index 20b5a8bee..0c0fc9220 100644 --- a/contracts/PolymathRegistry.sol +++ b/contracts/PolymathRegistry.sol @@ -1,15 +1,14 @@ pragma solidity 0.5.8; import "./ReclaimTokens.sol"; +import "./interfaces/IPolymathRegistry.sol"; /** * @title Core functionality for registry upgradability */ -contract PolymathRegistry is ReclaimTokens { +contract PolymathRegistry is ReclaimTokens, IPolymathRegistry { mapping(bytes32 => address) public storedAddresses; - event ChangeAddress(string _nameKey, address indexed _oldAddress, address indexed _newAddress); - /** * @notice Gets the contract address * @param _nameKey is the key for the contract address mapping diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index e4655ea04..751511a79 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -1,10 +1,17 @@ -pragma solidity 0.5.8; +/** + // + IMPORTANT: Developer should update the ISecurityTokenRegistry.sol (Interface) if there is any change in + function signature or addition/removal of the functions from SecurityTokenRegistry & STRGetter contract. + // + + */ + +pragma solidity ^0.5.0; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IOwnable.sol"; import "./interfaces/ISTFactory.sol"; -import "./interfaces/ISecurityTokenRegistry.sol"; import "./interfaces/ISecurityToken.sol"; import "./interfaces/IPolymathRegistry.sol"; import "./interfaces/IOracle.sol"; diff --git a/contracts/interfaces/IFeatureRegistry.sol b/contracts/interfaces/IFeatureRegistry.sol index 6c0392585..ee6c931a8 100644 --- a/contracts/interfaces/IFeatureRegistry.sol +++ b/contracts/interfaces/IFeatureRegistry.sol @@ -4,6 +4,17 @@ pragma solidity 0.5.8; * @title Interface for managing polymath feature switches */ interface IFeatureRegistry { + + event ChangeFeatureStatus(string _nameKey, bool _newStatus); + + /** + * @notice change a feature status + * @dev feature status is set to false by default + * @param _nameKey is the key for the feature status mapping + * @param _newStatus is the new feature status + */ + function setFeatureStatus(string calldata _nameKey, bool _newStatus) external; + /** * @notice Get the status of a feature * @param _nameKey is the key for the feature status mapping diff --git a/contracts/interfaces/IModuleFactory.sol b/contracts/interfaces/IModuleFactory.sol index 7721f04b2..48630a500 100644 --- a/contracts/interfaces/IModuleFactory.sol +++ b/contracts/interfaces/IModuleFactory.sol @@ -91,4 +91,28 @@ interface IModuleFactory { */ function upperSTVersionBounds() external view returns(uint8[] memory upperBounds); + /** + * @notice Updates the tags of the ModuleFactory + * @param _tagsData New list of tags + */ + function changeTags(bytes32[] calldata _tagsData) external; + + /** + * @notice Updates the name of the ModuleFactory + * @param _name New name that will replace the old one. + */ + function changeName(bytes32 _name) external; + + /** + * @notice Updates the description of the ModuleFactory + * @param _description New description that will replace the old one. + */ + function changeDescription(string calldata _description) external; + + /** + * @notice Updates the title of the ModuleFactory + * @param _title New Title that will replace the old one. + */ + function changeTitle(string calldata _title) external; + } diff --git a/contracts/interfaces/IModuleRegistry.sol b/contracts/interfaces/IModuleRegistry.sol index 0efea56aa..a7e6adbd0 100644 --- a/contracts/interfaces/IModuleRegistry.sol +++ b/contracts/interfaces/IModuleRegistry.sol @@ -4,6 +4,29 @@ pragma solidity 0.5.8; * @title Interface for the Polymath Module Registry contract */ interface IModuleRegistry { + + /////////// + // Events + ////////// + + // Emit when network becomes paused + event Pause(address account); + // Emit when network becomes unpaused + event Unpause(address account); + // Emit when Module is used by the SecurityToken + event ModuleUsed(address indexed _moduleFactory, address indexed _securityToken); + // Emit when the Module Factory gets registered on the ModuleRegistry contract + event ModuleRegistered(address indexed _moduleFactory, address indexed _owner); + // Emit when the module gets verified by Polymath + event ModuleVerified(address indexed _moduleFactory); + // Emit when the module gets unverified by Polymath or the factory owner + event ModuleUnverified(address indexed _moduleFactory); + // Emit when a ModuleFactory is removed by Polymath + event ModuleRemoved(address indexed _moduleFactory, address indexed _decisionMaker); + // Emit when ownership gets transferred + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** * @notice Called by a security token to notify the registry it is using a module * @param _moduleFactory is the address of the relevant module factory @@ -78,7 +101,7 @@ interface IModuleRegistry { * @param _moduleType Type of Module * @return address array that contains the list of addresses of module factory contracts. */ - function getAllModulesByType(uint8 _moduleType) external view returns(address[] memory); + function getAllModulesByType(uint8 _moduleType) external view returns(address[] memory factories); /** * @notice Returns the list of addresses of Module Factory of a particular type * @param _moduleType Type of Module @@ -111,4 +134,26 @@ interface IModuleRegistry { */ function isPaused() external view returns(bool paused); + /** + * @notice Reclaims all ERC20Basic compatible tokens + * @param _tokenContract The address of the token contract + */ + function reclaimERC20(address _tokenContract) external; + + /** + * @notice Called by the owner to pause, triggers stopped state + */ + function pause() external; + + /** + * @notice Called by the owner to unpause, returns to normal state + */ + function unpause() external; + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param _newOwner The address to transfer ownership to. + */ + function transferOwnership(address _newOwner) external; + } diff --git a/contracts/interfaces/IPolymathRegistry.sol b/contracts/interfaces/IPolymathRegistry.sol index 23e0f2a8b..24401ada3 100644 --- a/contracts/interfaces/IPolymathRegistry.sol +++ b/contracts/interfaces/IPolymathRegistry.sol @@ -1,6 +1,9 @@ pragma solidity 0.5.8; interface IPolymathRegistry { + + event ChangeAddress(string _nameKey, address indexed _oldAddress, address indexed _newAddress); + /** * @notice Returns the contract address * @param _nameKey is the key for the contract address mapping @@ -8,4 +11,11 @@ interface IPolymathRegistry { */ function getAddress(string calldata _nameKey) external view returns(address registryAddress); + /** + * @notice Changes the contract address + * @param _nameKey is the key for the contract address mapping + * @param _newAddress is the new contract address + */ + function changeAddress(string calldata _nameKey, address _newAddress) external; + } diff --git a/contracts/interfaces/ISTFactory.sol b/contracts/interfaces/ISTFactory.sol index 51e842148..a2b911f9d 100644 --- a/contracts/interfaces/ISTFactory.sol +++ b/contracts/interfaces/ISTFactory.sol @@ -4,6 +4,15 @@ pragma solidity 0.5.8; * @title Interface for security token proxy deployment */ interface ISTFactory { + + event LogicContractSet(string _version, address _logicContract, bytes _upgradeData); + event TokenUpgraded( + address indexed _securityToken, + uint256 indexed _version + ); + event DefaultTransferManagerUpdated(address indexed _oldTransferManagerFactory, address indexed _newTransferManagerFactory); + event DefaultDataStoreUpdated(address indexed _oldDataStoreFactory, address indexed _newDataStoreFactory); + /** * @notice Deploys the token and adds default modules like permission manager and transfer manager. * Future versions of the proxy can attach different modules or pass some other paramters. @@ -25,7 +34,36 @@ interface ISTFactory { bool _divisible, address _treasuryWallet, address _polymathRegistry - ) - external + ) + external returns(address tokenAddress); + + /** + * @notice Used to set a new token logic contract + * @param _version Version of upgraded module + * @param _logicContract Address of deployed module logic contract referenced from proxy + * @param _initializationData Initialization data that used to intialize value in the securityToken + * @param _upgradeData Data to be passed in call to upgradeToAndCall when a token upgrades its module + */ + function setLogicContract(string calldata _version, address _logicContract, bytes calldata _initializationData, bytes calldata _upgradeData) external; + + /** + * @notice Used to upgrade a token + * @param _maxModuleType maximum module type enumeration + */ + function upgradeToken(uint8 _maxModuleType) external; + + /** + * @notice Used to set a new default transfer manager + * @dev Setting this to address(0) means don't deploy a default TM + * @param _transferManagerFactory Address of new default transfer manager factory + */ + function updateDefaultTransferManager(address _transferManagerFactory) external; + + /** + * @notice Used to set a new default data store + * @dev Setting this to address(0) means don't deploy a default data store + * @param _dataStoreFactory Address of new default data store factory + */ + function updateDefaultDataStore(address _dataStoreFactory) external; } diff --git a/contracts/interfaces/ISTO.sol b/contracts/interfaces/ISTO.sol index 8d44df4be..ce46ef456 100644 --- a/contracts/interfaces/ISTO.sol +++ b/contracts/interfaces/ISTO.sol @@ -4,9 +4,26 @@ pragma solidity 0.5.8; * @title Interface to be implemented by all STO modules */ interface ISTO { + + enum FundRaiseType {ETH, POLY, SC} + + // Event + event SetFundRaiseTypes(FundRaiseType[] _fundRaiseTypes); + /** * @notice Returns the total no. of tokens sold */ function getTokensSold() external view returns(uint256 soldTokens); + /** + * @notice Returns funds raised by the STO + */ + function getRaised(FundRaiseType _fundRaiseType) external view returns(uint256 raisedAmount); + + /** + * @notice Pause (overridden function) + * @dev Only securityToken owner restriction applied on the super function + */ + function pause() external; + } diff --git a/contracts/interfaces/ISecurityToken.sol b/contracts/interfaces/ISecurityToken.sol index 026a7663e..67a2dc2f8 100644 --- a/contracts/interfaces/ISecurityToken.sol +++ b/contracts/interfaces/ISecurityToken.sol @@ -5,45 +5,119 @@ pragma solidity 0.5.8; */ interface ISecurityToken { // Standard ERC20 interface + function symbol() external view returns (string memory); + function name() external view returns (string memory); function decimals() external view returns(uint8); function totalSupply() external view returns(uint256); - function balanceOf(address _owner) external view returns(uint256); - function allowance(address _owner, address _spender) external view returns(uint256); - function transfer(address _to, uint256 _value) external returns(bool); - function transferFrom(address _from, address _to, uint256 _value) external returns(bool); - function approve(address _spender, uint256 _value) external returns(bool); - function decreaseApproval(address _spender, uint _subtractedValue) external returns(bool); - function increaseApproval(address _spender, uint _addedValue) external returns(bool); + function balanceOf(address owner) external view returns(uint256); + function allowance(address owner, address spender) external view returns(uint256); + function transfer(address to, uint256 value) external returns(bool); + function transferFrom(address from, address to, uint256 value) external returns(bool); + function approve(address spender, uint256 value) external returns(bool); + function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool); + function increaseAllowance(address spender, uint256 addedValue) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); - function name() external view returns(string memory); + // Emit at the time when module get added + event ModuleAdded( + uint8[] _types, + bytes32 indexed _name, + address indexed _moduleFactory, + address _module, + uint256 _moduleCost, + uint256 _budget, + bytes32 _label, + bool _archived + ); + + // Emit when the token details get updated + event UpdateTokenDetails(string _oldDetails, string _newDetails); + // Emit when the token name get updated + event UpdateTokenName(string _oldName, string _newName); + // Emit when the granularity get changed + event GranularityChanged(uint256 _oldGranularity, uint256 _newGranularity); + // Emit when is permanently frozen by the issuer + event FreezeIssuance(); + // Emit when transfers are frozen or unfrozen + event FreezeTransfers(bool _status); + // Emit when new checkpoint created + event CheckpointCreated(uint256 indexed _checkpointId, uint256 _investorLength); + // Events to log controller actions + event SetController(address indexed _oldController, address indexed _newController); + //Event emit when the global treasury wallet address get changed + event TreasuryWalletChanged(address _oldTreasuryWallet, address _newTreasuryWallet); + event DisableController(); + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + event TokenUpgraded(uint8 _major, uint8 _minor, uint8 _patch); + + // Emit when Module get archived from the securityToken + event ModuleArchived(uint8[] _types, address _module); //Event emitted by the tokenLib. + // Emit when Module get unarchived from the securityToken + event ModuleUnarchived(uint8[] _types, address _module); //Event emitted by the tokenLib. + // Emit when Module get removed from the securityToken + event ModuleRemoved(uint8[] _types, address _module); //Event emitted by the tokenLib. + // Emit when the budget allocated to a module is changed + event ModuleBudgetChanged(uint8[] _moduleTypes, address _module, uint256 _oldBudget, uint256 _budget); //Event emitted by the tokenLib. + + // Transfer Events + event TransferByPartition( + bytes32 indexed _fromPartition, + address _operator, + address indexed _from, + address indexed _to, + uint256 _value, + bytes _data, + bytes _operatorData + ); - /** - * @notice Transfers of securities may fail for a number of reasons. So this function will used to understand the - * cause of failure by getting the byte value. Which will be the ESC that follows the EIP 1066. ESC can be mapped - * with a reson string to understand the failure cause, table of Ethereum status code will always reside off-chain - * @param _to address The address which you want to transfer to - * @param _value uint256 the amount of tokens to be transferred - * @param _data The `bytes _data` allows arbitrary data to be submitted alongside the transfer. - * @return bool It signifies whether the transaction will be executed or not. - * @return byte Ethereum status code (ESC) - * @return bytes32 Application specific reason code - */ - function canTransfer(address _to, uint256 _value, bytes calldata _data) external view returns (bool isExecuted, byte statusCode, bytes32 reasonCode); + // Operator Events + event AuthorizedOperator(address indexed operator, address indexed tokenHolder); + event RevokedOperator(address indexed operator, address indexed tokenHolder); + event AuthorizedOperatorByPartition(bytes32 indexed partition, address indexed operator, address indexed tokenHolder); + event RevokedOperatorByPartition(bytes32 indexed partition, address indexed operator, address indexed tokenHolder); + + // Issuance / Redemption Events + event IssuedByPartition(bytes32 indexed partition, address indexed to, uint256 value, bytes data); + event RedeemedByPartition(bytes32 indexed partition, address indexed operator, address indexed from, uint256 value, bytes data, bytes operatorData); + + // Document Events + event DocumentRemoved(bytes32 indexed _name, string _uri, bytes32 _documentHash); + event DocumentUpdated(bytes32 indexed _name, string _uri, bytes32 _documentHash); + + // Controller Events + event ControllerTransfer( + address _controller, + address indexed _from, + address indexed _to, + uint256 _value, + bytes _data, + bytes _operatorData + ); + + event ControllerRedemption( + address _controller, + address indexed _tokenHolder, + uint256 _value, + bytes _data, + bytes _operatorData + ); + + // Issuance / Redemption Events + event Issued(address indexed _operator, address indexed _to, uint256 _value, bytes _data); + event Redeemed(address indexed _operator, address indexed _from, uint256 _value, bytes _data); /** * @notice Initialization function * @dev Expected to be called atomically with the proxy being created, by the owner of the token * @dev Can only be called once */ - function initialize() external; + function initialize(address _getterDelegate) external; /** * @notice Transfers of securities may fail for a number of reasons. So this function will used to understand the * cause of failure by getting the byte value. Which will be the ESC that follows the EIP 1066. ESC can be mapped * with a reson string to understand the failure cause, table of Ethereum status code will always reside off-chain - * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred * @param _data The `bytes _data` allows arbitrary data to be submitted alongside the transfer. @@ -51,7 +125,7 @@ interface ISecurityToken { * @return byte Ethereum status code (ESC) * @return bytes32 Application specific reason code */ - function canTransferFrom(address _from, address _to, uint256 _value, bytes calldata _data) external view returns (bool isExecuted, byte statusCode, bytes32 reasonCode); + function canTransfer(address _to, uint256 _value, bytes calldata _data) external view returns (bool isExecuted, byte statusCode, bytes32 reasonCode); /** * @notice The standard provides an on-chain function to determine whether a transfer will succeed, @@ -65,7 +139,30 @@ interface ISecurityToken { * @return Application specific reason codes with additional details * @return The partition to which the transferred tokens were allocated for the _to address */ - function canTransferByPartition(address _from, address _to, bytes32 _partition, uint256 _value, bytes calldata _data) external view returns (byte isExecuted, bytes32 statusCode, bytes32 reasonCode); + function canTransferByPartition( + address _from, + address _to, + bytes32 _partition, + uint256 _value, + bytes calldata _data + ) + external + view + returns (byte statusCode, bytes32 reasonCode, bytes32 partition); + + /** + * @notice Transfers of securities may fail for a number of reasons. So this function will used to understand the + * cause of failure by getting the byte value. Which will be the ESC that follows the EIP 1066. ESC can be mapped + * with a reson string to understand the failure cause, table of Ethereum status code will always reside off-chain + * @param _from address The address which you want to send tokens from + * @param _to address The address which you want to transfer to + * @param _value uint256 the amount of tokens to be transferred + * @param _data The `bytes _data` allows arbitrary data to be submitted alongside the transfer. + * @return bool It signifies whether the transaction will be executed or not. + * @return byte Ethereum status code (ESC) + * @return bytes32 Application specific reason code + */ + function canTransferFrom(address _from, address _to, uint256 _value, bytes calldata _data) external view returns (bool isExecuted, byte statusCode, bytes32 reasonCode); /** * @notice Used to attach a new document to the contract, or update the URI or hash of an existing attached document @@ -188,10 +285,6 @@ interface ISecurityToken { bytes calldata _operatorData ) external; - // Issuance / Redemption Events - event Issued(address indexed _operator, address indexed _to, uint256 _value, bytes _data); - event Redeemed(address indexed _operator, address indexed _from, uint256 _value, bytes _data); - /** * @notice Validate permissions with PermissionManager if it exists, If no Permission return false * @dev Note that IModule withPerm will allow ST owner all permissions anyway @@ -259,9 +352,9 @@ interface ISecurityToken { function getCheckpointTimes() external view returns(uint256[] memory checkpointTimes); /** - * @notice Gets length of investors array - * NB - this length may differ from investorCount if the list has not been pruned of zero-balance investors - * @return Length + * @notice returns an array of investors + * NB - this length may differ from investorCount as it contains all investors that ever held tokens + * @return list of addresses */ function getInvestors() external view returns(address[] memory investors); @@ -385,11 +478,12 @@ interface ISecurityToken { function unfreezeTransfers() external; /** - * @notice Ends token minting period permanently + * @notice Permanently freeze issuance of this security token. + * @dev It MUST NOT be possible to increase `totalSuppy` after this function is called. */ - function freezeIssuance() external; + function freezeIssuance(bytes calldata _signature) external; - /** + /** * @notice Attachs a module to the SecurityToken * @dev E.G.: On deployment (through the STR) ST gets a TransferManager module attached to it * @dev to control restrictions on transfers. @@ -481,7 +575,7 @@ interface ISecurityToken { * @notice Used by the issuer to permanently disable controller functionality * @dev enabled via feature switch "disableControllerAllowed" */ - function disableController() external; + function disableController(bytes calldata _signature) external; /** * @notice Used to get the version of the securityToken @@ -624,4 +718,41 @@ interface ISecurityToken { * @notice Returns if transfers are currently frozen or not */ function transfersFrozen() external view returns (bool isFrozen); + + /** + * @dev Allows the current owner to transfer control of the contract to a newOwner. + * @param newOwner The address to transfer ownership to. + */ + function transferOwnership(address newOwner) external; + + /** + * @return true if `msg.sender` is the owner of the contract. + */ + function isOwner() external view returns (bool); + + /** + * @return the address of the owner. + */ + function owner() external view returns (address ownerAddress); + + function controller() external view returns(address controllerAddress); + + function moduleRegistry() external view returns(address moduleRegistryAddress); + + function securityTokenRegistry() external view returns(address securityTokenRegistryAddress); + + function polyToken() external view returns(address polyTokenAddress); + + function tokenFactory() external view returns(address tokenFactoryAddress); + + function getterDelegate() external view returns(address delegate); + + function controllerDisabled() external view returns(bool isDisabled); + + function initialized() external view returns(bool isInitialized); + + function tokenDetails() external view returns(string memory details); + + function updateFromRegistry() external; + } diff --git a/contracts/interfaces/ISecurityTokenRegistry.sol b/contracts/interfaces/ISecurityTokenRegistry.sol index fb3dcf7dd..225b3c13c 100644 --- a/contracts/interfaces/ISecurityTokenRegistry.sol +++ b/contracts/interfaces/ISecurityTokenRegistry.sol @@ -5,6 +5,101 @@ pragma solidity 0.5.8; */ interface ISecurityTokenRegistry { + // Emit when network becomes paused + event Pause(address account); + // Emit when network becomes unpaused + event Unpause(address account); + // Emit when the ticker is removed from the registry + event TickerRemoved(string _ticker, address _removedBy); + // Emit when the token ticker expiry is changed + event ChangeExpiryLimit(uint256 _oldExpiry, uint256 _newExpiry); + // Emit when changeSecurityLaunchFee is called + 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 + event ChangeTickerOwnership(string _ticker, address indexed _oldOwner, address indexed _newOwner); + // Emit at the time of launching a new security token of version 3.0+ + event NewSecurityTokenCreated( + string _ticker, + string _name, + address indexed _securityTokenAddress, + address indexed _owner, + uint256 _addedAt, + address _registrant, + bool _fromAdmin, + uint256 _usdFee, + uint256 _polyFee, + uint256 _protocolVersion + ); + // Emit at the time of launching a new security token v2.0. + // _registrationFee is in poly + event NewSecurityToken( + string _ticker, + string _name, + address indexed _securityTokenAddress, + address indexed _owner, + uint256 _addedAt, + address _registrant, + bool _fromAdmin, + uint256 _registrationFee + ); + // Emit when new ticker get registers + event RegisterTicker( + address indexed _owner, + string _ticker, + uint256 indexed _registrationDate, + uint256 indexed _expiryDate, + bool _fromAdmin, + uint256 _registrationFeePoly, + uint256 _registrationFeeUsd + ); + // Emit after ticker registration + // _registrationFee is in poly + // fee in usd is not being emitted to maintain backwards compatibility + event RegisterTicker( + address indexed _owner, + string _ticker, + string _name, + uint256 indexed _registrationDate, + uint256 indexed _expiryDate, + bool _fromAdmin, + uint256 _registrationFee + ); + // Emit at when issuer refreshes exisiting token + event SecurityTokenRefreshed( + string _ticker, + string _name, + address indexed _securityTokenAddress, + address indexed _owner, + uint256 _addedAt, + address _registrant, + uint256 _protocolVersion + ); + event ProtocolFactorySet(address indexed _STFactory, uint8 _major, uint8 _minor, uint8 _patch); + event LatestVersionSet(uint8 _major, uint8 _minor, uint8 _patch); + event ProtocolFactoryRemoved(address indexed _STFactory, uint8 _major, uint8 _minor, uint8 _patch); + + /** + * @notice Deploys an instance of a new Security Token of version 2.0 and records it to the registry + * @dev this function is for backwards compatibilty with 2.0 dApp. + * @param _name is the name of the token + * @param _ticker is the ticker symbol of the security token + * @param _tokenDetails is the off-chain details of the token + * @param _divisible is whether or not the token is divisible + */ + function generateSecurityToken( + string calldata _name, + string calldata _ticker, + string calldata _tokenDetails, + bool _divisible + ) + external; + /** * @notice Deploys an instance of a new Security Token and records it to the registry * @param _name is the name of the token @@ -16,14 +111,33 @@ interface ISecurityTokenRegistry { * - `_protocolVersion` is the packed value of uin8[3] array (it will be calculated offchain) * - if _protocolVersion == 0 then latest version of securityToken will be generated */ - function generateSecurityToken( + function generateNewSecurityToken( string calldata _name, string calldata _ticker, string calldata _tokenDetails, bool _divisible, address _treasuryWallet, uint256 _protocolVersion - ) external; + ) + external; + + /** + * @notice Deploys an instance of a new Security Token and replaces the old one in the registry + * This can be used to upgrade from version 2.0 of ST to 3.0 or in case something goes wrong with earlier ST + * @dev This function needs to be in STR 3.0. Defined public to avoid stack overflow + * @param _name is the name of the token + * @param _ticker is the ticker symbol of the security token + * @param _tokenDetails is the off-chain details of the token + * @param _divisible is whether or not the token is divisible + */ + function refreshSecurityToken( + string calldata _name, + string calldata _ticker, + string calldata _tokenDetails, + bool _divisible, + address _treasuryWallet + ) + external returns (address securityToken); /** * @notice Adds a new custom Security Token and saves it to the registry. (Token should follow the ISecurityToken interface) @@ -44,6 +158,41 @@ interface ISecurityTokenRegistry { ) external; + /** + * @notice Adds a new custom Security Token and saves it to the registry. (Token should follow the ISecurityToken interface) + * @param _ticker is the ticker symbol of the security token + * @param _owner is the owner of the token + * @param _securityToken is the address of the securityToken + * @param _tokenDetails is the off-chain details of the token + * @param _deployedAt is the timestamp at which the security token is deployed + */ + function modifyExistingSecurityToken( + string calldata _ticker, + address _owner, + address _securityToken, + string calldata _tokenDetails, + uint256 _deployedAt + ) + external; + + /** + * @notice Modifies the ticker details. Only Polymath has the ability to do so. + * @notice Only allowed to modify the tickers which are not yet deployed. + * @param _owner is the owner of the token + * @param _ticker is the token ticker + * @param _registrationDate is the date at which ticker is registered + * @param _expiryDate is the expiry date for the ticker + * @param _status is the token deployment status + */ + function modifyExistingTicker( + address _owner, + string calldata _ticker, + uint256 _registrationDate, + uint256 _expiryDate, + bool _status + ) + external; + /** * @notice Registers the token ticker for its particular owner * @notice once the token ticker is registered to its owner then no other issuer can claim @@ -55,15 +204,13 @@ interface ISecurityTokenRegistry { function registerTicker(address _owner, string calldata _ticker, string calldata _tokenName) external; /** - * @notice Changes the protocol version and the SecurityToken contract - * @notice Used only by Polymath to upgrade the SecurityToken contract and add more functionalities to future versions - * @notice Changing versions does not affect existing tokens. - * @param _STFactoryAddress Address of the proxy. - * @param _major Major version of the proxy. - * @param _minor Minor version of the proxy. - * @param _patch Patch version of the proxy - */ - function setProtocolVersion(address _STFactoryAddress, uint8 _major, uint8 _minor, uint8 _patch) external; + * @notice Registers the token ticker to the selected owner + * @notice Once the token ticker is registered to its owner then no other issuer can claim + * @notice its ownership. If the ticker expires and its issuer hasn't used it, then someone else can take it. + * @param _owner is address of the owner of the token + * @param _ticker is unique token ticker + */ + function registerNewTicker(address _owner, string calldata _ticker) external; /** * @notice Check that Security Token is registered @@ -86,25 +233,36 @@ interface ISecurityTokenRegistry { function getSecurityTokenAddress(string calldata _ticker) external view returns(address tokenAddress); /** - * @notice Get security token data by its address - * @param _securityToken Address of the Scurity token. - * @return string Symbol of the Security Token. - * @return address Address of the issuer of Security Token. - * @return string Details of the Token. - * @return uint256 Timestamp at which Security Token get launched on Polymath platform - * @return version of the securityToken - */ - function getSecurityTokenData(address _securityToken) external view returns(string memory tokenSymbol, address tokenAddress, string memory tokenDetails, uint256 tokenTime, uint8[] memory tokenVersion); + * @notice Returns the security token data by address + * @param _securityToken is the address of the security token. + * @return string is the ticker of the security Token. + * @return address is the issuer of the security Token. + * @return string is the details of the security token. + * @return uint256 is the timestamp at which security Token was deployed. + */ + function getSecurityTokenData(address _securityToken) external view returns ( + string memory tokenSymbol, + address tokenAddress, + string memory tokenDetails, + uint256 tokenTime, + uint8[] memory tokenVersion + ); /** * @notice Get the current STFactory Address */ function getSTFactoryAddress() external view returns(address stFactoryAddress); + /** + * @notice Returns the STFactory Address of a particular version + * @param _protocolVersion Packed protocol version + */ + function getSTFactoryAddressOfVersion(uint256 _protocolVersion) external view returns(address stFactory); + /** * @notice Get Protocol version */ - function getProtocolVersion() external view returns(uint8[] memory protocolVersion); + function getLatestProtocolVersion() external view returns(uint8[] memory protocolVersion); /** * @notice Used to get the ticker list as per the owner @@ -195,17 +353,69 @@ interface ISecurityTokenRegistry { */ function changeFeesAmountAndCurrency(uint256 _tickerRegFee, uint256 _stLaunchFee, bool _isFeeInPoly) external; + /** + * @notice Changes the SecurityToken contract for a particular factory version + * @notice Used only by Polymath to upgrade the SecurityToken contract and add more functionalities to future versions + * @notice Changing versions does not affect existing tokens. + * @param _STFactoryAddress is the address of the proxy. + * @param _major Major version of the proxy. + * @param _minor Minor version of the proxy. + * @param _patch Patch version of the proxy + */ + function setProtocolFactory(address _STFactoryAddress, uint8 _major, uint8 _minor, uint8 _patch) external; + + /** + * @notice Removes a STFactory + * @param _major Major version of the proxy. + * @param _minor Minor version of the proxy. + * @param _patch Patch version of the proxy + */ + function removeProtocolFactory(uint8 _major, uint8 _minor, uint8 _patch) external; + + /** + * @notice Changes the default protocol version + * @notice Used only by Polymath to upgrade the SecurityToken contract and add more functionalities to future versions + * @notice Changing versions does not affect existing tokens. + * @param _major Major version of the proxy. + * @param _minor Minor version of the proxy. + * @param _patch Patch version of the proxy + */ + function setLatestVersion(uint8 _major, uint8 _minor, uint8 _patch) external; + + /** + * @notice Changes the PolyToken address. Only Polymath. + * @param _newAddress is the address of the polytoken. + */ + function updatePolyTokenAddress(address _newAddress) external; + + /** + * @notice Used to update the polyToken contract address + */ + function updateFromRegistry() external; + /** * @notice Gets the security token launch fee * @return Fee amount */ - function getSecurityTokenLaunchFee() external view returns(uint256 fee); + function getSecurityTokenLaunchFee() external returns(uint256 fee); /** * @notice Gets the ticker registration fee * @return Fee amount */ - function getTickerRegistrationFee() external view returns(uint256 fee); + function getTickerRegistrationFee() external returns(uint256 fee); + + /** + * @notice Set the getter contract address + * @param _getterContract Address of the contract + */ + function setGetterRegistry(address _getterContract) external; + + /** + * @notice Returns the usd & poly fee for a particular feetype + * @param _feeType Key corresponding to fee type + */ + function getFees(bytes32 _feeType) external returns (uint256 usdFee, uint256 polyFee); /** * @notice Returns the list of tokens to which the delegate has some access @@ -220,12 +430,48 @@ interface ISecurityTokenRegistry { */ function getExpiryLimit() external view returns(uint256 expiry); + /** + * @notice Gets the status of the ticker + * @param _ticker Ticker whose status need to determine + * @return bool + */ + function getTickerStatus(string calldata _ticker) external view returns(bool status); + + /** + * @notice Gets the fee currency + * @return true = poly, false = usd + */ + function getIsFeeInPoly() external view returns(bool isInPoly); + + /** + * @notice Gets the owner of the ticker + * @param _ticker Ticker whose owner need to determine + * @return address Address of the owner + */ + function getTickerOwner(string calldata _ticker) external view returns(address owner); + /** * @notice Checks whether the registry is paused or not * @return bool */ function isPaused() external view returns(bool paused); + /** + * @notice Called by the owner to pause, triggers stopped state + */ + function pause() external; + + /** + * @notice Called by the owner to unpause, returns to normal state + */ + function unpause() external; + + /** + * @notice Reclaims all ERC20Basic compatible tokens + * @param _tokenContract is the address of the token contract + */ + function reclaimERC20(address _tokenContract) external; + /** * @notice Gets the owner of the contract * @return address owner diff --git a/contracts/interfaces/IUSDTieredSTOProxy.sol b/contracts/interfaces/IUSDTieredSTOProxy.sol deleted file mode 100644 index 08d6e70a0..000000000 --- a/contracts/interfaces/IUSDTieredSTOProxy.sol +++ /dev/null @@ -1,22 +0,0 @@ -pragma solidity 0.5.8; - -/** - * @title Interface for security token proxy deployment - */ -interface IUSDTieredSTOProxy { - /** - * @notice Deploys the STO. - * @param _securityToken Contract address of the securityToken - * @param _factoryAddress Contract address of the factory - * @return address Address of the deployed STO - */ - function deploySTO(address _securityToken, address _factoryAddress) external returns(address STOAddress); - - /** - * @notice Used to get the init function signature - * @param _contractAddress Address of the STO contract - * @return bytes4 - */ - function getInitFunction(address _contractAddress) external returns(bytes4 initFunction); - -} diff --git a/contracts/interfaces/IVoting.sol b/contracts/interfaces/IVoting.sol index 5421dc30b..61a8a158d 100644 --- a/contracts/interfaces/IVoting.sol +++ b/contracts/interfaces/IVoting.sol @@ -46,6 +46,15 @@ interface IVoting { * @return uint256 totalVoters * @return bool isActive */ - function getBallotDetails(uint256 _ballotId) external view returns(uint256 quorum, uint256 totalSupplyAtCheckpoint, uint256 checkpointId, uint256 startTime, uint256 endTime, uint256 totalProposals, uint256 totalVoters, bool isActive); + function getBallotDetails(uint256 _ballotId) external view returns( + uint256 quorum, + uint256 totalSupplyAtCheckpoint, + uint256 checkpointId, + uint256 startTime, + uint256 endTime, + uint256 totalProposals, + uint256 totalVoters, + bool isActive + ); } diff --git a/contracts/modules/STO/STO.sol b/contracts/modules/STO/STO.sol index c1ca2606a..af68cca4c 100644 --- a/contracts/modules/STO/STO.sol +++ b/contracts/modules/STO/STO.sol @@ -12,11 +12,6 @@ import "../../interfaces/ISTO.sol"; contract STO is ISTO, STOStorage, Module { using SafeMath for uint256; - enum FundRaiseType {ETH, POLY, SC} - - // Event - event SetFundRaiseTypes(FundRaiseType[] _fundRaiseTypes); - /** * @notice Returns funds raised by the STO */ diff --git a/contracts/tokens/STFactory.sol b/contracts/tokens/STFactory.sol index 5b78e057c..2f01f7e96 100644 --- a/contracts/tokens/STFactory.sol +++ b/contracts/tokens/STFactory.sol @@ -138,6 +138,7 @@ contract STFactory is ISTFactory, Ownable { * @notice Used to set a new token logic contract * @param _version Version of upgraded module * @param _logicContract Address of deployed module logic contract referenced from proxy + * @param _initializationData Initialization data that used to intialize value in the securityToken * @param _upgradeData Data to be passed in call to upgradeToAndCall when a token upgrades its module */ function setLogicContract(string calldata _version, address _logicContract, bytes calldata _initializationData, bytes calldata _upgradeData) external onlyOwner { diff --git a/contracts/tokens/STGetter.sol b/contracts/tokens/STGetter.sol index f78d99043..efea1793a 100644 --- a/contracts/tokens/STGetter.sol +++ b/contracts/tokens/STGetter.sol @@ -230,7 +230,7 @@ contract STGetter is OZStorage, SecurityTokenStorage { * @notice Return all partitions * @return List of partitions */ - function partitionsOf(address /*_tokenHolder*/) external view returns (bytes32[] memory) { + function partitionsOf(address /*_tokenHolder*/) external pure returns (bytes32[] memory) { bytes32[] memory result = new bytes32[](2); result[0] = UNLOCKED; result[1] = LOCKED;