Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expiry for investors #92

Merged
merged 4 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ All notable changes to this project will be documented in this file.

* Fixed `capReached()` which was checking fundsRaised agains cap, but the cap is expressed in tokens.
* Constant key variables migrated from the securityToken to ISecurityToken contract.
* Solidity compiler version get changed to 0.4.23 that leads to the addition of reason string in the `require` and `revert` statements.
* Solidity compiler version get changed to 0.4.23 that leads to the addition of reason string in the `require` and `revert` statements.
* zeppelin-solidity package version and name get changed to openzeppelin-solidity v1.9.0.

## Added

* IModule contract takes the polyToken contract address as the constructor argument to wrapping all the factories with the polyToken contract address.
* `takeFee()` new function introduced to extract the POLY token from the factory. It only be called by the owner of the factory.
* Added ability for issuer to provide a signed piece of data to allow investors to whitelist themselves.
* Added ability for issuer to provide a signed piece of data to allow investors to whitelist themselves.
* `_securityTokenAddress` get indexed in the `LogNewSecurityToken` event.
* Now each investor have its `expiryTime` for the KYC. After the expiryTime limit reached, investor will not abe to use transfer related functions.

## Remove

* `investorStatus()` function in securityToken contract has removed.

***

Expand Down
2 changes: 1 addition & 1 deletion contracts/ModuleRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "./interfaces/IModuleRegistry.sol";
import "./interfaces/IModuleFactory.sol";
import "./interfaces/ISecurityToken.sol";
import "./interfaces/ISecurityTokenRegistry.sol";
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";

/**
* @title ModuleRegistry
Expand Down
4 changes: 2 additions & 2 deletions contracts/SecurityTokenRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import "./interfaces/ITickerRegistry.sol";
import "./tokens/SecurityToken.sol";
import "./interfaces/ISTProxy.sol";
import "./interfaces/ISecurityTokenRegistry.sol";
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "./helpers/Util.sol";


contract SecurityTokenRegistry is Ownable, ISecurityTokenRegistry, Util {

event LogNewSecurityToken(string _ticker, address _securityTokenAddress, address _owner);
event LogNewSecurityToken(string _ticker, address indexed _securityTokenAddress, address _owner);

/**
* @dev Constructor used to set the essentials addresses to facilitate
Expand Down
6 changes: 3 additions & 3 deletions contracts/TickerRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pragma solidity ^0.4.23;
only its owner can deploy the token with that symbol.
*/

import "zeppelin-solidity/contracts/math/SafeMath.sol";
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "./interfaces/ITickerRegistry.sol";
import "./helpers/Util.sol";

Expand Down Expand Up @@ -43,7 +43,7 @@ contract TickerRegistry is ITickerRegistry, Ownable, Util {
// Emit when the token symbol expiry get changed
event LogChangeExpiryLimit(uint256 _oldExpiry, uint256 _newExpiry);

constructor() public {
constructor () public {

}

Expand Down
2 changes: 1 addition & 1 deletion contracts/helpers/PolyToken.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.23;

import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
import "openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol";


contract PolyToken is MintableToken {
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pragma solidity ^0.4.23;

import "./ISecurityToken.sol";
import "./IModuleFactory.sol";
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";

//Simple interface that any module contracts should implement
contract IModule {
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IModuleFactory.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.23;

import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";


//Simple interface that any module contracts should implement
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ISecurityToken.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.23;

import "./IST20.sol";
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";


contract ISecurityToken is IST20, Ownable {
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/STO/CappedSTO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pragma solidity ^0.4.23;

import "./ISTO.sol";
import "../../interfaces/IST20.sol";
import "zeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";


contract CappedSTO is ISTO {
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/STO/ISTO.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.23;

import "../../interfaces/IModule.sol";
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";


contract ISTO is IModule {
Expand Down
41 changes: 29 additions & 12 deletions contracts/modules/TransferManager/GeneralTransferManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contract GeneralTransferManager is ITransferManager {
struct TimeRestriction {
uint256 fromTime;
uint256 toTime;
uint256 expiryTime;
}

// An address can only send / receive tokens once their corresponding uint256 > block.number
Expand All @@ -52,7 +53,8 @@ contract GeneralTransferManager is ITransferManager {
uint256 _dateAdded,
address _addedBy,
uint256 _fromTime,
uint256 _toTime
uint256 _toTime,
uint256 _expiryTime
);

constructor (address _securityToken, address _polyAddress)
Expand Down Expand Up @@ -120,22 +122,25 @@ contract GeneralTransferManager is ITransferManager {
* @param _investor is the address to whitelist
* @param _fromTime is the moment when the sale lockup period ends and the investor can freely sell his tokens
* @param _toTime is the moment when the purchase lockup period ends and the investor can freely purchase tokens from others
* @param _expiryTime is the moment till investors KYC will be validated. After that investor need to do re-KYC
*/
function modifyWhitelist(address _investor, uint256 _fromTime, uint256 _toTime) public withPerm(WHITELIST) {
function modifyWhitelist(address _investor, uint256 _fromTime, uint256 _toTime, uint256 _expiryTime) public withPerm(WHITELIST) {
//Passing a _time == 0 into this function, is equivalent to removing the _investor from the whitelist
whitelist[_investor] = TimeRestriction(_fromTime, _toTime);
emit LogModifyWhitelist(_investor, now, msg.sender, _fromTime, _toTime);
whitelist[_investor] = TimeRestriction(_fromTime, _toTime, _expiryTime);
emit LogModifyWhitelist(_investor, now, msg.sender, _fromTime, _toTime, _expiryTime);
}

function modifyWhitelistMulti(
address[] _investors,
uint256[] _fromTimes,
uint256[] _toTimes
uint256[] _toTimes,
uint256[] _expiryTime
) public withPerm(WHITELIST) {
require(_investors.length == _fromTimes.length, "Mismatched input lengths");
require(_fromTimes.length == _toTimes.length, "Mismatched input lengths");
require(_toTimes.length == _expiryTime.length, "Mismatched input lengths");
for (uint256 i = 0; i < _investors.length; i++) {
modifyWhitelist(_investors[i], _fromTimes[i], _toTimes[i]);
modifyWhitelist(_investors[i], _fromTimes[i], _toTimes[i], _expiryTime[i]);
}
}

Expand All @@ -144,25 +149,36 @@ contract GeneralTransferManager is ITransferManager {
* @param _investor is the address to whitelist
* @param _fromTime is the moment when the sale lockup period ends and the investor can freely sell his tokens
* @param _toTime is the moment when the purchase lockup period ends and the investor can freely purchase tokens from others
* @param _expiryTime is the moment till investors KYC will be validated. After that investor need to do re-KYC
* @param _validFrom is the time that this signature is valid from
* @param _validTo is the time that this signature is valid until
* @param _v issuer signature
* @param _r issuer signature
* @param _s issuer signature
*/
function modifyWhitelistSigned(address _investor, uint256 _fromTime, uint256 _toTime, uint256 _validFrom, uint256 _validTo, uint8 _v, bytes32 _r, bytes32 _s) public {
function modifyWhitelistSigned(
address _investor,
uint256 _fromTime,
uint256 _toTime,
uint256 _expiryTime,
uint256 _validFrom,
uint256 _validTo,
uint8 _v,
bytes32 _r,
bytes32 _s
) public {
require(_validFrom <= now, "ValidFrom is too early");
require(_validTo >= now, "ValidTo is too late");
bytes32 hash = keccak256(this, _investor, _fromTime, _toTime, _validFrom, _validTo);
bytes32 hash = keccak256(this, _investor, _fromTime, _toTime, _expiryTime, _validFrom, _validTo);
checkSig(hash, _v, _r, _s);
//Passing a _time == 0 into this function, is equivalent to removing the _investor from the whitelist
whitelist[_investor] = TimeRestriction(_fromTime, _toTime);
emit LogModifyWhitelist(_investor, now, msg.sender, _fromTime, _toTime);
whitelist[_investor] = TimeRestriction(_fromTime, _toTime, _expiryTime);
emit LogModifyWhitelist(_investor, now, msg.sender, _fromTime, _toTime, _expiryTime);
}

function checkSig(bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s) internal view {
//Check that the signature is valid
//sig should be signing - _investor, _fromTime & _toTime and be signed by the issuer address
//sig should be signing - _investor, _fromTime, _toTime & _expiryTime and be signed by the issuer address
address signer = ecrecover(keccak256("\x19Ethereum Signed Message:\n32", _hash), _v, _r, _s);
require(signer == ISecurityToken(securityToken).owner() || signer == signingAddress, "Incorrect signer");
}
Expand All @@ -175,6 +191,7 @@ contract GeneralTransferManager is ITransferManager {
}

function onWhitelist(address _investor) internal view returns(bool) {
return ((whitelist[_investor].fromTime != 0) || (whitelist[_investor].toTime != 0));
return (((whitelist[_investor].fromTime != 0) || (whitelist[_investor].toTime != 0)) &&
(whitelist[_investor].expiryTime >= now));
}
}
11 changes: 3 additions & 8 deletions contracts/tokens/SecurityToken.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.23;

import "zeppelin-solidity/contracts/token/ERC20/StandardToken.sol";
import "zeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol";
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol";
import "openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "../interfaces/ISecurityToken.sol";
import "../interfaces/IModule.sol";
import "../interfaces/IModuleFactory.sol";
Expand Down Expand Up @@ -249,11 +249,6 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 {
return true;
}

//TODO: Implement this function
function investorStatus(address /* _investor */) public pure returns (uint8 _status) {
return 0;
}

// Permissions this to a Permission module, which has a key of 1
// If no Permission return false - note that IModule withPerm will allow ST owner all permissions anyway
// this allows individual modules to override this logic if needed (to not allow ST owner all permissions)
Expand Down
29 changes: 5 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"truffle-contract": "^3.0.4",
"truffle-hdwallet-provider-privkey": "^0.1.0",
"web3": "^1.0.0-beta.33",
"zeppelin-solidity": "^1.8.0"
"openzeppelin-solidity": "^1.9.0"
},
"devDependencies": {
"eslint": "^4.19.1",
Expand Down
3 changes: 3 additions & 0 deletions test/Issuance.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract('Issuance', accounts => {
// investor Details
let fromTime = latestTime();
let toTime = latestTime() + duration.days(15);
let expiryTime = toTime + duration.days(100);

// Contract Instance Declaration
let I_GeneralPermissionManagerFactory;
Expand Down Expand Up @@ -303,6 +304,7 @@ contract('Issuance', accounts => {
account_investor1,
fromTime + duration.days(70),
toTime + duration.days(90),
expiryTime + duration.days(50),
{
from: account_polymath,
gas: 500000
Expand Down Expand Up @@ -383,6 +385,7 @@ contract('Issuance', accounts => {
account_investor2,
fromTime,
toTime,
expiryTime,
{
from: account_delegate,
gas: 500000
Expand Down
6 changes: 6 additions & 0 deletions test/capped_sto.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ contract('CappedSTO', accounts => {
// investor Details
let fromTime = latestTime();
let toTime = latestTime() + duration.days(15);
let expiryTime = toTime + duration.days(100);
let P_fromTime = fromTime + duration.days(1);
let P_toTime = P_fromTime + duration.days(50);
let P_expiryTime = toTime + duration.days(100);

// Contract Instance Declaration
let I_GeneralPermissionManagerFactory;
Expand Down Expand Up @@ -397,6 +399,7 @@ contract('CappedSTO', accounts => {
account_investor1,
fromTime,
toTime,
expiryTime,
{
from: account_issuer,
gas: 500000
Expand Down Expand Up @@ -453,6 +456,7 @@ contract('CappedSTO', accounts => {
account_investor2,
fromTime,
toTime + duration.days(20),
expiryTime,
{
from: account_issuer,
gas: 500000
Expand Down Expand Up @@ -641,6 +645,7 @@ contract('CappedSTO', accounts => {
account_investor1,
P_fromTime,
P_toTime,
P_expiryTime,
{
from: account_issuer,
gas: 500000
Expand Down Expand Up @@ -701,6 +706,7 @@ contract('CappedSTO', accounts => {
account_investor2,
P_fromTime,
P_toTime + duration.days(20),
P_expiryTime,
{
from: account_issuer,
gas: 500000
Expand Down
Loading