diff --git a/contracts/modules/TransferManager/VolumeDumpingRestrictionTM.sol b/contracts/modules/TransferManager/VolumeDumpingRestrictionTM.sol new file mode 100644 index 000000000..54dd0fadf --- /dev/null +++ b/contracts/modules/TransferManager/VolumeDumpingRestrictionTM.sol @@ -0,0 +1,465 @@ +pragma solidity ^0.4.24; + +import "./ITransferManager.sol"; +import "openzeppelin-solidity/contracts/math/SafeMath.sol"; + +/** + * @title Transfer Manager module for restricting volume dumping within a time period for an account + */ + +contract VolumeDumpingRestrictionTM is ITransferManager { + + using SafeMath for uint256; + + bytes32 public constant VOLUME_RESTRICTION = "VOLUME_DUMPING_RESTRICTION"; + + // permission definition + bytes32 public constant ADMIN = "ADMIN"; + + //per volume restriction rule + struct VolumeRestriction { + uint256 percentAllowed; + uint256 startTime; + uint256 endTime; + uint256 rollingPeriod; + } + + // used to store modify rolling period logs + mapping(address => mapping(bool => uint256)) modifyRollingPeriod; + + // Maps user address to a volumerestriction rule + mapping(address => VolumeRestriction) internal volumeRestriction; + + // Maps user address to a rollingPeriod then periodId & amount transferred so far in that periodId + // using the rolling period helps prevent collision of period id in cases where its changed + mapping(address => mapping(uint256 => mapping(uint256 => uint256))) internal volumeTally; + + // map user address to a list of rolling period & periodIds + mapping(address => mapping(uint256 => uint256[])) internal volumePeriodIds; + + // map user address to a list of rolling periods + mapping(address => uint256[]) internal rollingPeriods; + + event ModifyVolumeDumping ( + address indexed restrictedAddress, + uint256 percentAllowed, + uint256 startTime, + uint256 endTime, + uint256 rollingPeriod + ); + + event AddNewVolumeDumping ( + address indexed restrictedAddress, + uint256 percentAllowed, + uint256 startTime, + uint256 endTime, + uint256 rollingPeriod + ); + + event RemoveVolumeDumping ( + address indexed restrictedAddress, + uint256 percentAllowed, + uint256 startTime, + uint256 endTime, + uint256 rollingPeriod + + ); + + /** + * @notice Constructor + * @param _securityToken Address of the security token + * @param _polyAddress Address of the polytoken + */ + constructor (address _securityToken, address _polyAddress) + public + Module(_securityToken, _polyAddress) + { + } + + /** @notice Used to verify the transfer transaction and prevent locked up tokens from being transferred + * @param _from Address of the sender + * @param _amount The amount of tokens to transfer + */ + function verifyTransfer(address _from, address /*_to */, uint256 _amount, bytes /* _data */, bool _isTransfer) public returns(Result) { + + // function must only be called by the associated security token if _isTransfer == true + require(_isTransfer == false || msg.sender == securityToken, "Sender is not owner"); + + if (!paused && _from != address(0) && _amount != 0 ) { + VolumeRestriction memory userDumpingRestriction = volumeRestriction[_from]; + + if (now < userDumpingRestriction.startTime || now > userDumpingRestriction.endTime){ + return Result.NA; + } + + uint256 periodId = now.sub(userDumpingRestriction.startTime).div(userDumpingRestriction.rollingPeriod); + uint256 rollingPeriod = userDumpingRestriction.rollingPeriod; + + // // the remainig transferable amount + uint256 allowedRemainingAmount = _currentAllowedAmount(_from, periodId); + + if (_amount <= allowedRemainingAmount){ + + // readonly transaction shouldn't modify state + if(!_isTransfer) { + return Result.VALID; + } + + volumeTally[_from][rollingPeriod][periodId] = volumeTally[_from][rollingPeriod][periodId].add(_amount); + return Result.VALID; + } + return Result.INVALID; + } + return Result.NA; + } + + /** + * @notice lets the admin create a volume dumping restriction for a give address. + * @param _userAddress Address of the user to apply the volume dumping restriction + * @param _percentAllowed Percent of tokens balance allowed to transfer within a rolling period + * @param _startTime When the dumping restriction, 0 means now in seconds + * @param _endTime When the dumping restriction ends in seconds + * @param _rollingPeriod Ttime period in seconds + */ + function addDumpingRestriction( + address _userAddress, + uint256 _percentAllowed, + uint256 _startTime, + uint256 _endTime, + uint256 _rollingPeriod ) public withPerm(ADMIN) { + + // if a startTime of 0 is passed in, then start now. + if(_startTime == 0) { + _startTime = now; + } + + _checkVolumeDumpingParams(_userAddress, _percentAllowed, _startTime, _endTime, _rollingPeriod, false); + + // deny if restriction already exists + require(volumeRestriction[_userAddress].percentAllowed == 0, "volume dumping restriction already exists"); + + // add the volume dumping restriction + volumeRestriction[_userAddress] = VolumeRestriction(_percentAllowed, _startTime, _endTime, _rollingPeriod); + + // push the rolling period + rollingPeriods[_userAddress].push(_rollingPeriod); + + emit AddNewVolumeDumping( + _userAddress, + _percentAllowed, + _startTime, + _endTime, + _rollingPeriod + ); + } + + /** + * @notice lets the admin create multiple volume dumping restriction for a multiple addresses. + * @param _userAddresses Address of the user to apply the volume dumping restriction + * @param _percentsAllowed Percent of tokens balance allowed to transfer within a rolling period + * @param _startTimes When the dumping restriction, 0 means now in seconds + * @param _endTimes When the dumping restriction ends in seconds + * @param _rollingPeriods Time period in seconds + */ + function addDumpingRestrictionMulti( + address[] _userAddresses, + uint256[] _percentsAllowed, + uint256[] _startTimes, + uint256[] _endTimes, + uint256[] _rollingPeriods) public withPerm(ADMIN) { + require( + _userAddresses.length == _percentsAllowed.length && + _userAddresses.length == _rollingPeriods.length && + _userAddresses.length == _startTimes.length && + _userAddresses.length == _endTimes.length, + "Input array length mis-match" + ); + + for (uint256 i = 0; i < _userAddresses.length; i++) { + addDumpingRestriction(_userAddresses[i], _percentsAllowed[i], _startTimes[i], _endTimes[i], _rollingPeriods[i]); + } + } + + /** + * @notice lets the admin remove a volume dumping restriction. + * @param _userAddress User address to remove the volume dumping restriction + */ + function removeRestriction(address _userAddress) public withPerm(ADMIN) { + VolumeRestriction memory toRemove = volumeRestriction[_userAddress]; + + // check if entry is in the past + // not allowed to delete past entries + require(toRemove.endTime > now, "Cannot remove past restrictions"); + + uint256 rollingPeriodLength = rollingPeriods[_userAddress].length; + + // delete all the volume tally period ids for the user address + //loop throught the rolling periods + for(uint256 j = 0; j < rollingPeriodLength; j++){ + + uint rollingPeriod = rollingPeriods[_userAddress][j]; + + // length of the period ids + uint256 length = volumePeriodIds[_userAddress][rollingPeriod].length; + + for( uint256 i = 0; i < length; i++ ){ + uint256 periodId = volumePeriodIds[_userAddress][rollingPeriod][i]; + delete volumeTally[_userAddress][rollingPeriod][periodId]; + } + volumePeriodIds[_userAddress][rollingPeriod].length = 0; + } + + // remove voluem restriction + delete volumeRestriction[_userAddress]; + + emit RemoveVolumeDumping( + _userAddress, + toRemove.percentAllowed, + toRemove.startTime, + toRemove.endTime, + toRemove.rollingPeriod + ); + } + + /** + * @notice lets the admin remove multiple volume dumping restriction. + * @param _userAddresses List of User addresses to remove the volume dumping restriction + */ + function removeRestrictionMulti(address[] _userAddresses) public withPerm(ADMIN) { + // ensure the the array length is > 0 + require(_userAddresses.length > 0, "Invalid array length"); + + for (uint256 i = 0; i < _userAddresses.length; i++) { + removeRestriction(_userAddresses[i]); + } + } + + + /** + * @notice moves spent amount in active periodId to new periodId & deletees + * all previous ids to prevent collision + * @param _oldUserDumpingRestriction old dumping restriction details + * @param _newUserDumpingRestriction new dumping restriction details + * @param _userAddress user address + */ + function movePeriodAmounts( + VolumeRestriction _oldUserDumpingRestriction, + VolumeRestriction _newUserDumpingRestriction, + address _userAddress ) internal { + + uint256 currentTime = now; + + uint256 currentPeriodId = currentTime.sub(_oldUserDumpingRestriction.startTime).div(_oldUserDumpingRestriction.rollingPeriod); + uint256 newPeriodId = currentTime.sub(_newUserDumpingRestriction.startTime).div(_newUserDumpingRestriction.rollingPeriod); + + // Already spent amount for the current active + // period id + uint256 currentPeriodAmount = volumeTally[_userAddress][_oldUserDumpingRestriction.rollingPeriod][currentPeriodId]; + + // set the volume tally of the + // new period id to the already spent + // amount of the old acitve period id + volumeTally[_userAddress][_newUserDumpingRestriction.rollingPeriod][newPeriodId] = currentPeriodAmount; + + // push the new period id + volumePeriodIds[_userAddress][_newUserDumpingRestriction.rollingPeriod].push(newPeriodId); + } + + /** + * @notice lets the admin modify volume dumping restriction for an addresses. + * @param _userAddress Address of the user to apply the volume dumping restriction + * @param _percentAllowed Percent of tokens balance allowed to transfer within a rolling period + * @param _startTime When the dumping restriction, 0 means now in seconds + * @param _endTime When the dumping restriction ends in seconds + * @param _rollingPeriod is the time period in seconds + */ + function modifyVolumeDumpingRestriction( + address _userAddress, + uint256 _percentAllowed, + uint256 _startTime, + uint256 _endTime, + uint256 _rollingPeriod + ) public withPerm(ADMIN) { + + if (_startTime == 0) { + _startTime = now; + } + + _checkVolumeDumpingParams(_userAddress, _percentAllowed, _startTime, _endTime, _rollingPeriod, true); + + // don't allow modifying entries that have ended + require(volumeRestriction[_userAddress].endTime > now, "Cannot modify past restrictions"); + + VolumeRestriction memory newVolumeRestriction = VolumeRestriction(_percentAllowed, _startTime, _endTime, _rollingPeriod); + + // allow modifying the start time + // only if the restriction period has not started + if( now > volumeRestriction[_userAddress].startTime ){ + + require(volumeRestriction[_userAddress].startTime == _startTime, "Cannot modify start time of already started restriction"); + + // check if the rolling period is changed + // since its used in calculating the period id + if( volumeRestriction[_userAddress].rollingPeriod != _rollingPeriod ) { + // add modified rolling period + rollingPeriods[_userAddress].push(_rollingPeriod); + // move the already spent amount in + // previous acitve rolling period periodId to new + // rolling period periodId + movePeriodAmounts( + volumeRestriction[_userAddress], + newVolumeRestriction, + _userAddress + ); + } + + } else { + require(_startTime >= now, "Invalid start time"); + } + + volumeRestriction[_userAddress] = newVolumeRestriction; + + emit ModifyVolumeDumping( + _userAddress, + _percentAllowed, + _startTime, + _endTime, + _rollingPeriod + ); + } + + /** + * @notice lets the admin modify multiple volume dumping restriction for an addresses. + * @param _userAddresses Address of the user to apply the volume dumping restriction + * @param _percentsAllowed Percent of tokens balance allowed to transfer within a rolling period + * @param _startTimes When the dumping restriction, 0 means now in seconds + * @param _endTimes When the dumping restriction ends in seconds + * @param _rollingPeriods is the time period in seconds + */ + function modifyVolumeDumpingRestrictionMulti( + address[] _userAddresses, + uint256[] _percentsAllowed, + uint256[] _startTimes, + uint256[] _endTimes, + uint256[] _rollingPeriods + ) public withPerm(ADMIN) { + + require( + _userAddresses.length == _percentsAllowed.length && + _userAddresses.length == _rollingPeriods.length && + _userAddresses.length == _startTimes.length && + _userAddresses.length == _endTimes.length, + "Input array length mis-match" + ); + + for (uint256 i = 0; i < _userAddresses.length; i++) { + modifyVolumeDumpingRestriction(_userAddresses[i], _percentsAllowed[i], _startTimes[i], _endTimes[i], _rollingPeriods[i]); + } + } + + /** + * @notice Get volume dumping restriction rules for a user address + * @param _userAddress User Address to get the rule + */ + function getVolumeDumpingRestrictions(address _userAddress) public view returns ( + uint256 _percentAllowed , uint256 _startTime, uint256 _endTime, uint256 _rollingPeriod + ) { + VolumeRestriction storage userRestriction = volumeRestriction[_userAddress]; + return ( + userRestriction.percentAllowed, + userRestriction.startTime, + userRestriction.endTime, + userRestriction.rollingPeriod + ); + } + + /** + * @notice Get the remaining allowed amount for a user in a period + * @param _userAddress User Address to get the rule + */ + function getAllowedAmount(address _userAddress, uint256 _periodId) public view returns (uint256) { + VolumeRestriction storage userDumpingRestriction = volumeRestriction[_userAddress]; + + uint256 percentAllowed = userDumpingRestriction.percentAllowed; + + uint256 currentUserBalance = ISecurityToken(securityToken).balanceOf(_userAddress); + + uint256 alreadyWithdrawn = volumeTally[_userAddress][userDumpingRestriction.rollingPeriod][_periodId]; + uint256 totalAmountAllowedForPeriod = currentUserBalance.add(alreadyWithdrawn).mul(percentAllowed).div(100 * uint256(10)**16); + uint256 allowedAmount = totalAmountAllowedForPeriod.sub(alreadyWithdrawn); + + return allowedAmount; + } + + /** + * @notice This function returns the signature of configure function + */ + function getInitFunction() public pure returns (bytes4) { + return bytes4(0); + } + + + /** + * @notice Return the permissions flag that are associated with Volume Restriction transfer manager + */ + function getPermissions() public view returns(bytes32[]) { + bytes32[] memory allPermissions = new bytes32[](1); + allPermissions[0] = VOLUME_RESTRICTION; + return allPermissions; + } + + /** + * @notice Takes a userAddress as input, and returns a uint that represents the number of tokens allowed to be withdrawn right now + * @param _userAddress User Address to get the rule + * @param _periodId Time period identifier + */ + function _currentAllowedAmount(address _userAddress, uint256 _periodId) internal returns (uint256) { + VolumeRestriction storage userDumpingRestriction = volumeRestriction[_userAddress]; + + // get already withdrawn amount in period + uint256 alreadyWithdrawn = volumeTally[_userAddress][userDumpingRestriction.rollingPeriod][_periodId]; + + // if the already with drawn is 0 + // means its essentially a new period + if(alreadyWithdrawn == 0){ + volumePeriodIds[_userAddress][userDumpingRestriction.rollingPeriod].push(_periodId); + } + + uint256 currentUserBalance = ISecurityToken(securityToken).balanceOf(_userAddress); + // add already withdrawn amount for this period + // to be able to get the correct value + + uint256 percentAllowed = userDumpingRestriction.percentAllowed; + + // totalAmountAllowedForPeriod = currentbalance * 20/100 + uint256 totalAmountAllowedForPeriod = currentUserBalance.add(alreadyWithdrawn).mul(percentAllowed).div(100 * uint256(10)**16); + + uint256 allowedAmount = totalAmountAllowedForPeriod.sub(alreadyWithdrawn); + return allowedAmount; + } + + /** + * @notice Parameter checking function for creating a volume restriction. This function will cause an exception if any of the parameters are bad. + * @param _userAddress Address of the user to apply the volume dumping restriction + * @param _percentAllowed Percent of tokens balance allowed to transfer within a rolling period + * @param _startTime When the dumping restriction, 0 means now in seconds + * @param _endTime When the dumping restriction ends in seconds + * @param _rollingPeriod Ttime period in seconds + */ + function _checkVolumeDumpingParams( + address _userAddress, + uint256 _percentAllowed, + uint256 _startTime, + uint256 _endTime, + uint256 _rollingPeriod, + bool modify + ) internal view { + require(address(0) != _userAddress, "Invalid user address"); + require(_percentAllowed > 0 && _percentAllowed <= 100 * uint256(10)**16, "Invalid percent input"); + require(_endTime > _startTime, "Invalid endtime"); + require(_rollingPeriod > 0 && _rollingPeriod < _endTime, "Invalid rolling period"); + if(modify == false){ + require(_startTime >= now, "Invalid start time"); + } + } +} diff --git a/contracts/modules/TransferManager/VolumeDumpingRestrictionTMFactory.sol b/contracts/modules/TransferManager/VolumeDumpingRestrictionTMFactory.sol new file mode 100644 index 000000000..c8700062c --- /dev/null +++ b/contracts/modules/TransferManager/VolumeDumpingRestrictionTMFactory.sol @@ -0,0 +1,103 @@ +pragma solidity ^0.4.24; + +import "./VolumeDumpingRestrictionTM.sol"; +import "../ModuleFactory.sol"; + +/** + * @title Factory for deploying VolumeRestrictionManager module + */ +contract VolumeDumpingRestrictionTMFactory is ModuleFactory { + + /** + * @notice Constructor + * @param _polyAddress Address of the polytoken + */ + constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public + ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) + { + version = "1.0.0"; + name = "VolumeDumpingTransferManager"; + title = "Volume Dumping Transfer Manager"; + description = "Manage the volume of tokens dumpable by an owner"; + compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); + compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); + } + + /** + * @notice used to launch the Module with the help of factory + * @return address Contract address of the Module + */ + function deploy(bytes /* _data */) external returns(address) { + if (setupCost > 0) + require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + address volumeDumpingRestrictionTransferManager = new VolumeDumpingRestrictionTM(msg.sender, address(polyToken)); + emit GenerateModuleFromFactory(address(volumeDumpingRestrictionTransferManager), getName(), address(this), msg.sender, now); + return address(volumeDumpingRestrictionTransferManager); + } + + /** + * @notice Type of the Module factory + * @return uint8 + */ + function getTypes() external view returns(uint8[]) { + uint8[] memory res = new uint8[](1); + res[0] = 2; + return res; + } + + + /** + * @notice Get the name of the Module + */ + function getName() public view returns(bytes32) { + return name; + } + + /** + * @notice Get the description of the Module + */ + function getDescription() public view returns(string) { + return description; + } + + + /** + * @notice Get the title of the Module + */ + function getTitle() public view returns(string) { + return title; + } + + /** + * @notice Get the Instructions that helped to used the module + */ + function getInstructions() public view returns(string) { + return "Allows an issuer to restrict the total number of tokens dumpable withing a rolling period"; + } + + /** + * @notice Get the setup cost of the module + */ + function getSetupCost() external view returns (uint256) { + return setupCost; + } + + /** + * @notice Get the version of the Module + */ + function getVersion() external view returns(string) { + return version; + } + + /** + * @notice Get the tags related to the module factory + */ + function getTags() public view returns(bytes32[]) { + bytes32[] memory availableTags = new bytes32[](2); + availableTags[0] = "VolumeDumping"; + availableTags[1] = "Transfer Restriction"; + return availableTags; + } + + +} diff --git a/test/helpers/createInstances.js b/test/helpers/createInstances.js index 2021d350e..0c4412fa9 100644 --- a/test/helpers/createInstances.js +++ b/test/helpers/createInstances.js @@ -24,6 +24,7 @@ const GeneralTransferManagerFactory = artifacts.require("./GeneralTransferManage const GeneralPermissionManagerFactory = artifacts.require("./GeneralPermissionManagerFactory.sol"); const CountTransferManagerFactory = artifacts.require("./CountTransferManagerFactory.sol"); const VolumeRestrictionTransferManagerFactory = artifacts.require("./LockupVolumeRestrictionTMFactory"); +const VolumeDumpingRestrictionTransferManager = artifacts.require('./VolumeDumpingRestrictionTMFactory'); const PreSaleSTOFactory = artifacts.require("./PreSaleSTOFactory.sol"); const PolyToken = artifacts.require("./PolyToken.sol"); const PolyTokenFaucet = artifacts.require("./PolyTokenFaucet.sol"); @@ -44,6 +45,7 @@ let I_MockWrongTypeBurnFactory; let I_SingleTradeVolumeRestrictionManagerFactory; let I_ManualApprovalTransferManagerFactory; let I_VolumeRestrictionTransferManagerFactory; +let I_VolumeDumpingRestrictionTransferManagerFactory; let I_PercentageTransferManagerFactory; let I_EtherDividendCheckpointFactory; let I_CountTransferManagerFactory; @@ -255,6 +257,18 @@ export async function deployLockupVolumeRTMAndVerified(accountPolymath, MRProxyI return new Array(I_VolumeRestrictionTransferManagerFactory); } +export async function deployVolumeDumpingRTMAndVerified(accountPolymath, MRProxyInstance, polyToken, setupCost) { + I_VolumeDumpingRestrictionTransferManagerFactory = await VolumeDumpingRestrictionTransferManager.new(polyToken, setupCost, 0, 0, { from: accountPolymath }); + assert.notEqual( + I_VolumeDumpingRestrictionTransferManagerFactory.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "VolumeRestrictionTransferManagerFactory contract was not deployed" + ); + + await registerAndVerifyByMR(I_VolumeDumpingRestrictionTransferManagerFactory.address, accountPolymath, MRProxyInstance); + return new Array(I_VolumeDumpingRestrictionTransferManagerFactory); +} + export async function deploySingleTradeVolumeRMAndVerified(accountPolymath, MRProxyInstance, polyToken, setupCost) { I_SingleTradeVolumeRestrictionManagerFactory = await SingleTradeVolumeRestrictionManagerFactory.new(polyToken, setupCost, 0, 0, { from: accountPolymath }); assert.notEqual( diff --git a/test/y_volume_dumping_restriction_transfer_manager.js b/test/y_volume_dumping_restriction_transfer_manager.js new file mode 100644 index 000000000..b79c7eca3 --- /dev/null +++ b/test/y_volume_dumping_restriction_transfer_manager.js @@ -0,0 +1,644 @@ +import latestTime from './helpers/latestTime'; +import { duration, ensureException, promisifyLogWatch, latestBlock } from './helpers/utils'; +import takeSnapshot, { increaseTime, revertToSnapshot } from './helpers/time'; +import { setUpPolymathNetwork, deployVolumeDumpingRTMAndVerified } from "./helpers/createInstances"; +import { catchRevert } from "./helpers/exceptions"; + +import {signData} from './helpers/signData'; +import { pk } from './helpers/testprivateKey'; +import { encodeProxyCall, encodeModuleCall } from './helpers/encodeCall'; + +const SecurityToken = artifacts.require('./SecurityToken.sol'); +const GeneralTransferManager = artifacts.require('./GeneralTransferManager'); +const VolumeRestrictionTransferManager = artifacts.require('./VolumeDumpingRestrictionTM'); + +const Web3 = require('web3'); +const BigNumber = require('bignumber.js'); +const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) // Hardcoded development port + +contract('VolumeDumpingRestrictionTransferManager', accounts => { + + // Accounts Variable declaration + let account_polymath; + let account_issuer; + let token_owner; + let token_owner_pk; + let account_investor1; + let account_investor2; + let account_investor3; + let account_investor4; + let account_investor5; + + // investor Details + let fromTime = latestTime(); + let toTime = latestTime(); + let expiryTime = toTime + duration.days(15); + + let message = "Transaction Should Fail!"; + + // Contract Instance Declaration + let I_GeneralPermissionManagerFactory; + // let P_PercentageTransferManagerFactory; + let P_VolumeRestrictionTransferManagerFactory; + let I_SecurityTokenRegistryProxy; + // let P_PercentageTransferManager; + let P_VolumeRestrictionTransferManager; + let I_GeneralTransferManagerFactory; + // let I_PercentageTransferManagerFactory; + let I_VolumeRestrictionTransferManagerFactory; + let I_GeneralPermissionManager; + // let I_PercentageTransferManager; + let I_VolumeRestrictionTransferManager; + let I_GeneralTransferManager; + let I_ModuleRegistry; + let I_FeatureRegistry; + let I_SecurityTokenRegistry; + let I_STRProxied; + let I_MRProxied; + let I_STFactory; + let I_SecurityToken; + let I_PolyToken; + let I_PolymathRegistry; + let I_ModuleRegistryProxy + + // SecurityToken Details + const name = "Team"; + const symbol = "sap"; + const tokenDetails = "This is equity type of issuance"; + const decimals = 18; + const contact = "team@polymath.network"; + + // Module key + const delegateManagerKey = 1; + const transferManagerKey = 2; + const stoKey = 3; + + // Initial fee for ticker registry and security token registry + const initRegFee = web3.utils.toWei("250"); + + // Dummy STO details + const startTime = latestTime() + duration.seconds(5000); // Start time will be 5000 seconds more than the latest time + const endTime = startTime + duration.days(80); // Add 80 days more + const cap = web3.utils.toWei('10', 'ether'); + const someString = "A string which is not used"; + const STOParameters = ['uint256', 'uint256', 'uint256', 'string']; + const STRProxyParameters = ['address', 'address', 'uint256', 'uint256', 'address', 'address']; + const MRProxyParameters = ['address', 'address']; + + let bytesSTO = encodeModuleCall(STOParameters, [latestTime() + duration.seconds(1000), latestTime() + duration.days(40), cap, someString]); + + before(async() => { + // Accounts setup + account_polymath = accounts[0]; + account_issuer = accounts[1]; + + token_owner = account_issuer; + + account_investor1 = accounts[7]; + account_investor2 = accounts[8]; + account_investor3 = accounts[9]; + account_investor4 = accounts[3] + + let instances = await setUpPolymathNetwork(account_polymath, token_owner); + + [ + I_PolymathRegistry, + I_PolyToken, + I_FeatureRegistry, + I_ModuleRegistry, + I_ModuleRegistryProxy, + I_MRProxied, + I_GeneralTransferManagerFactory, + I_STFactory, + I_SecurityTokenRegistry, + I_SecurityTokenRegistryProxy, + I_STRProxied + ] = instances; + + // STEP 4(c): Deploy the VolumeRestrictionTransferManager + [I_VolumeRestrictionTransferManagerFactory] = await deployVolumeDumpingRTMAndVerified(account_polymath, I_MRProxied, I_PolyToken.address, 0); + // STEP 4(d): Deploy the VolumeRestrictionTransferManager + [P_VolumeRestrictionTransferManagerFactory] = await deployVolumeDumpingRTMAndVerified(account_polymath, I_MRProxied, I_PolyToken.address, web3.utils.toWei("500")); + + // Printing all the contract addresses + console.log(` + --------------------- Polymath Network Smart Contracts: --------------------- + PolymathRegistry: ${I_PolymathRegistry.address} + SecurityTokenRegistryProxy: ${I_SecurityTokenRegistryProxy.address} + SecurityTokenRegistry: ${I_SecurityTokenRegistry.address} + ModuleRegistry: ${I_ModuleRegistry.address} + ModuleRegistryProxy: ${I_ModuleRegistryProxy.address} + FeatureRegistry: ${I_FeatureRegistry.address} + + STFactory: ${I_STFactory.address} + GeneralTransferManagerFactory: ${I_GeneralTransferManagerFactory.address} + VolumeDumpingRestrictionTransferManagerFactory: ${I_VolumeRestrictionTransferManagerFactory.address} + ----------------------------------------------------------------------------- + `); + }); + + describe("Generate the SecurityToken", async() => { + + it("Should register the ticker before the generation of the security token", async () => { + await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from : token_owner }); + assert.equal(tx.logs[0].args._owner, token_owner); + assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase()); + }); + + it("Should generate the new security token with the same symbol as registered above", async () => { + await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); + let _blockNo = latestBlock(); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + + // Verify the successful generation of the security token + assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + + I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + + const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({from: _blockNo}), 1); + + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._types[0].toNumber(), 2); + assert.equal( + web3.utils.toAscii(log.args._name) + .replace(/\u0000/g, ''), + "GeneralTransferManager" + ); + }); + + it("Should intialize the auto attached modules", async () => { + let moduleData = (await I_SecurityToken.getModulesByType(2))[0]; + I_GeneralTransferManager = GeneralTransferManager.at(moduleData); + }); + + }); + + describe("Buy tokens using on-chain whitelist and test dumping them and attempting to transfer", async() => { + + it("Should Buy the tokens", async() => { + // Add the Investor in to the whitelist + + let tx = await I_GeneralTransferManager.modifyWhitelist( + account_investor1, + latestTime(), + latestTime(), + latestTime() + duration.days(1000), + true, + { + from: account_issuer, + gas: 6000000 + }); + + assert.equal(tx.logs[0].args._investor.toLowerCase(), account_investor1.toLowerCase(), "Failed in adding the investor in whitelist"); + + // Jump time + await increaseTime(5000); + + // Mint some tokens + await I_SecurityToken.mint(account_investor1, web3.utils.toWei('1', 'ether'), { from: token_owner }); + + assert.equal( + (await I_SecurityToken.balanceOf(account_investor1)).toNumber(), + web3.utils.toWei('1', 'ether') + ); + }); + + it("Should Buy some more tokens", async() => { + // Add the Investor in to the whitelist + + let tx = await I_GeneralTransferManager.modifyWhitelist( + account_investor2, + latestTime(), + latestTime(), + latestTime() + duration.days(1000), + true, + { + from: account_issuer, + gas: 6000000 + }); + + assert.equal(tx.logs[0].args._investor.toLowerCase(), account_investor2.toLowerCase(), "Failed in adding the investor in whitelist"); + + // Mint some tokens + await I_SecurityToken.mint(account_investor2, web3.utils.toWei('10', 'ether'), { from: token_owner }); + + assert.equal( + (await I_SecurityToken.balanceOf(account_investor2)).toNumber(), + web3.utils.toWei('10', 'ether') + ); + }); + + it("Should unsuccessfully attach the VolumeRestrictionTransferManager factory with the security token", async () => { + let errorThrown = false; + await I_PolyToken.getTokens(web3.utils.toWei("500", "ether"), token_owner); + await catchRevert( + I_SecurityToken.addModule(P_VolumeRestrictionTransferManagerFactory.address, 0, web3.utils.toWei("500", "ether"), 0, { from: token_owner }) + ) + }); + + it("Should successfully attach the VolumeRestrictionTransferManager factory with the security token", async () => { + let snapId = await takeSnapshot(); + await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("500", "ether"), {from: token_owner}); + const tx = await I_SecurityToken.addModule(P_VolumeRestrictionTransferManagerFactory.address, 0, web3.utils.toWei("500", "ether"), 0, { from: token_owner }); + assert.equal(tx.logs[3].args._types[0].toNumber(), transferManagerKey, "VolumeRestrictionTransferManagerFactory doesn't get deployed"); + assert.equal( + web3.utils.toAscii(tx.logs[3].args._name) + .replace(/\u0000/g, ''), + "VolumeDumpingTransferManager", + "VolumeDumpingTransferManagerFactory module was not added" + ); + P_VolumeRestrictionTransferManager = VolumeRestrictionTransferManager.at(tx.logs[3].args._module); + await revertToSnapshot(snapId); + }); + + it("Should successfully attach the VolumeRestrictionTransferManager with the security token", async () => { + const tx = await I_SecurityToken.addModule(I_VolumeRestrictionTransferManagerFactory.address, 0, 0, 0, { from: token_owner }); + assert.equal(tx.logs[2].args._types[0].toNumber(), transferManagerKey, "VolumeRestrictionTransferManager doesn't get deployed"); + assert.equal( + web3.utils.toAscii(tx.logs[2].args._name) + .replace(/\u0000/g, ''), + "VolumeDumpingTransferManager", + "VolumeDumpingTransferManagerFactory module was not added" + ); + I_VolumeRestrictionTransferManager = VolumeRestrictionTransferManager.at(tx.logs[2].args._module); + }); + + it("Should pause the tranfers at transferManager level", async() => { + let tx = await I_VolumeRestrictionTransferManager.pause({from: token_owner}); + }); + + it("Should still be able to transfer between existing token holders up to limit", async() => { + // Add the Investor in to the whitelist + // Mint some tokens + await I_SecurityToken.transfer(account_investor1, web3.utils.toWei('1', 'ether'), { from: account_investor2 }); + + assert.equal( + (await I_SecurityToken.balanceOf(account_investor1)).toNumber(), + web3.utils.toWei('2', 'ether') + ); + }); + + it("Should unpause the tranfers at transferManager level", async() => { + await I_VolumeRestrictionTransferManager.unpause({from: token_owner}); + }) + + let percent = 10 * Math.pow(10, 16) + let startTime = 0 + let endTime = latestTime() + duration.years(2); + let endTimeFn = (n=1) => latestTime() + duration.years(n); + let rollingPeriod = 1000 + + it("Should prevent creation of a dump restriction where rolling period is zero", async() => { + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, percent, startTime, endTime, 0, { from: token_owner }) + ); + }) + + it("Should prevent creation of a dump restriction where end time is zero", async() => { + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, percent, startTime, 0, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should prevent creation of a dump restriction where user address is empty", async() => { + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(null, percent, startTime, endTime, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should prevent creation of a dump restriction where percent is zero", async() => { + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, 0, startTime, endTime, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should prevent creation of a dump restriction where percent is greater than 100", async() => { + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, (120 * Math.pow(10, 16)), startTime, endTime, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should prevent creation of a dump restriction where the endtime is less than startime", async() => { + let endTimeNegative = (await web3.eth.getBlock('latest')).timestamp - 10000 + + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, percent, startTime, endTimeNegative, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should prevent creation of a dump restriction where the starttime is in the past", async() => { + let startTimeNegative = (await web3.eth.getBlock('latest')).timestamp - 10000 + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, percent, startTimeNegative, endTime, rollingPeriod, { from: token_owner }) + + ) + }) + + it("Should prevent creation of a dump restriction where the rolling period is greater than endtime", async() => { + let rollingPeriod = endTime + 10 + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, percent, startTime, endTime, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should create a dumping restriction", async() => { + const tx = await I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, percent, 0, endTime, rollingPeriod, { from: token_owner }); + const logs = tx.logs[0] + startTime = (await web3.eth.getBlock('latest')).timestamp + // check the add new dumping restriction event emitted + assert.equal("AddNewVolumeDumping", logs['event'], "Invalid percent"); + assert.equal(endTime, logs['args']['endTime'], "Invalid end time"); + assert.equal(startTime, logs['args']['startTime'], "Invalid start time"); + assert.equal(rollingPeriod, logs['args']['rollingPeriod'], "Invalid rolling period"); + }) + + it("Should prevent adding another dumping restriction for an address", async() => { + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor2, percent, 0, endTime, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should verify transfer of multiple break up of tokens up to limit in a dumping restriction period", async() => { + // a readonly transaction + const result = await I_VolumeRestrictionTransferManager.verifyTransfer.call(account_investor2, 0, web3.utils.toWei('0.9', 'ether'), "", false); + // enum Result {INVALID, NA, VALID, FORCE_VALID} and we want VALID so it should be 2 + assert.equal(result.toString(), '2') + }) + + it("Should not verify transfer of multiple break up of tokens more than the limit in a dumping restriction period", async() => { + // a readonly transaction + const result = await I_VolumeRestrictionTransferManager.verifyTransfer.call(account_investor2, 0, web3.utils.toWei('1', 'ether'), "", false); + // enum Result {INVALID, NA, VALID, FORCE_VALID} and we want VALID so it should be 2 + assert.equal(result.toString(), '0') + }) + + it("Should allow transfer of multiple break up of tokens up to limit in a dumping restriction period", async() => { + /** + * Allows transfers up to 0.9 ether + * where user balance is 9 ether + */ + await I_SecurityToken.changeGranularity(Math.pow(10, 15), {from: token_owner }); + + await I_SecurityToken.transfer(account_investor1, web3.utils.toWei('0.2', 'ether'), { from: account_investor2 }); + await I_SecurityToken.transfer(account_investor1, web3.utils.toWei('0.3', 'ether'), { from: account_investor2 }); + await I_SecurityToken.transfer(account_investor1, web3.utils.toWei('0.4', 'ether'), { from: account_investor2 }); + }) + + + + it("Should get volume restriction details", async() => { + const result = await I_VolumeRestrictionTransferManager.getVolumeDumpingRestrictions(account_investor2, { from: token_owner }) + assert.equal(percent, result[0].toNumber(), "Failed to modify the percent"); + assert.equal(endTime, result[2].toNumber(), "Failed to modify end time"); + assert.equal(rollingPeriod, result[3].toNumber(), "Failed to modify rolling period"); + }) + + it("Should modify volume dumping restriction", async() => { + let percent = 20 + let endTime = latestTime() + duration.seconds(30); + let rollingPeriod = 30 + + let t = (await web3.eth.getBlock('latest')).timestamp + + await I_VolumeRestrictionTransferManager.modifyVolumeDumpingRestriction(account_investor2, percent, startTime, endTime, rollingPeriod, { from: token_owner }); + + const result = await I_VolumeRestrictionTransferManager.getVolumeDumpingRestrictions(account_investor2, { from: token_owner }); + + assert.equal(percent, result[0].toNumber(), "Failed to modify the percent"); + assert.equal(endTime, result[2].toNumber(), "Failed to modify end time"); + assert.equal(rollingPeriod, result[3].toNumber(), "Failed to modify rolling period"); + }) + + it("Should prevent exceeding transfer of tokens in dumping restriction period", async () => { + let balance = (await I_SecurityToken.balanceOf(account_investor1)).toString() + await catchRevert( + I_SecurityToken.transfer(account_investor1, balance, { from: account_investor2 }) + ) + }) + + it("Should be possible to remove a dumping restriction", async() => { + const tx = await I_VolumeRestrictionTransferManager.removeRestriction(account_investor2, { from: token_owner }); + const log = tx.logs[0] + assert.equal(log['event'], "RemoveVolumeDumping", "Failed to remove volume dumping restriction"); + + const result = await I_VolumeRestrictionTransferManager.getVolumeDumpingRestrictions(account_investor2, { from: token_owner }); + + assert.equal(0, result[0].toNumber(), "Failed to remove the dumping restriction"); + assert.equal(0, result[1].toNumber(), "Failed to remove the dumping restriction"); + }); + + it("Should prevent modifying of a dump restriction start time when alredy started", async() => { + let percent = 20 + let startTime = 0 + let endTime = latestTime() + duration.years(5); + let rollingPeriod = 30 + + // increase evm time to 30 seconds + await increaseTime(30) + await catchRevert( + I_VolumeRestrictionTransferManager.modifyVolumeDumpingRestriction(account_investor2, percent, startTime, endTime, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should prevent modifying of a dump restriction where end time is in past", async() => { + let percent = 20 + let startTime = 0 + let endTime = latestTime() + duration.years(5); + let rollingPeriod = 30 + + // increase evm time to 30 seconds + await increaseTime(30) + await catchRevert( + I_VolumeRestrictionTransferManager.modifyVolumeDumpingRestriction(account_investor2, percent, startTime, endTime, rollingPeriod, { from: token_owner }) + ) + }) + + it("Should prevent removing of a dump restriction where end time is in past", async() => { + await catchRevert( + I_VolumeRestrictionTransferManager.removeRestriction(account_investor2, { from: token_owner }) + ) + }) + + it("Should allow the transfer of all tokens in a dumping restriction if the end time has exceeded", async() => { + let balance = (await I_SecurityToken.balanceOf(account_investor2)).toString() + let endTime = latestTime() + duration.seconds(2); + + // transfering the remaning balance + const result = await I_SecurityToken.transfer(account_investor1, balance, { from: account_investor2 }); + assert.equal(result.logs[0].event, "Transfer", message); + assert.equal(result.logs[0].args['from'], account_investor2, message); + assert.equal(result.logs[0].args['to'], account_investor1, message); + }) + + let evmStartTimes = [] + + it("Should be possible to create multiple volume dumping restrictions at once", async() => { + const accounts = [account_investor3, account_investor4] + const percents = [ 10, 20 ] + const startTimes = [0, 0] + const endTimes = [endTimeFn(1), endTimeFn(2)] + const rollingPeriods = [10, 10] + // evmStartTimes = (await web3.eth.getBlock('latest')).timestamp + + let result = await I_VolumeRestrictionTransferManager.addDumpingRestrictionMulti(accounts, percents, startTimes, endTimes, rollingPeriods, { from: token_owner }); + + for (let account in accounts) { + result = await I_VolumeRestrictionTransferManager.getVolumeDumpingRestrictions(accounts[account], { from: token_owner }); + // get the start times + evmStartTimes[account] = result[1].toNumber() + assert.equal(percents[account], result[0].toNumber(), "Failed to create the percent"); + assert.equal(endTimes[account], result[2].toNumber(), "Failed to create end time"); + assert.equal(rollingPeriods[account], result[3].toNumber(), "Failed to create rolling period"); + } + }) + + it("Should revert if the parameters are bad when modifying multiple volume dumping restrictions", async() => { + const accounts = [account_investor3, account_investor4] + const percents = [10] + const startTimes = [(await web3.eth.getBlock('latest')).timestamp + 10, 0] + const endTimes = [endTimeFn(1), endTimeFn(2)] + const rollingPeriods = [30] + + await catchRevert( + I_VolumeRestrictionTransferManager.modifyVolumeDumpingRestrictionMulti(accounts, percents, startTimes, endTimes, rollingPeriods, { from: token_owner }) + ) + }) + + it("Should be possible to modify multiple volume dumping restrictions at once", async() => { + const accounts = [account_investor3, account_investor4] + const percents = [ 20, 30 ] + + const endTimes = [endTimeFn(1), endTimeFn(2)] + const rollingPeriods = [20, 20] + + let result = await I_VolumeRestrictionTransferManager.modifyVolumeDumpingRestrictionMulti(accounts, percents, evmStartTimes, endTimes, rollingPeriods, { from: token_owner }); + + for (let account in accounts) { + result = await I_VolumeRestrictionTransferManager.getVolumeDumpingRestrictions(accounts[account], { from: token_owner }); + + assert.equal(percents[account], result[0].toNumber(), "Failed to modify the percent"); + assert.equal(endTimes[account], result[2].toNumber(), "Failed to modify end time"); + assert.equal(rollingPeriods[account], result[3].toNumber(), "Failed to modify rolling period"); + } + }) + + it("Should revert if the parameters are bad when removing multiple volume dumping restrictions", async() => { + await catchRevert( + I_VolumeRestrictionTransferManager.removeRestrictionMulti([], { from: token_owner }) + ) + }) + + it("Should be possible to remove multiple volume dumping restrictions at once", async() => { + const accounts = [account_investor3, account_investor4] + + let result = await I_VolumeRestrictionTransferManager.removeRestrictionMulti(accounts, { from: token_owner }); + + for (let account in accounts) { + result = await I_VolumeRestrictionTransferManager.getVolumeDumpingRestrictions(accounts[account], { from: token_owner }); + + assert.equal(0, result[0].toNumber(), "Failed to remove the percent"); + assert.equal(0, result[2].toNumber(), "Failed to remove end time"); + assert.equal(0, result[3].toNumber(), "Failed to remove rolling period"); + } + }) + + it("Should be possible to create and modify volume dumping already active restrictions", async() => { + /** + * This test checks for the roll over of the active period Id already spent + * amount to a new periodId + */ + // create restriction + let endTime = latestTime() + duration.years(2); + let percent = 10 * Math.pow(10, 16) + + let rollingPeriod = 20; + + let currentTime = (await web3.eth.getBlock('latest')).timestamp; + await I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor1, percent, 0, endTime, rollingPeriod, { from: token_owner }); + await I_VolumeRestrictionTransferManager.getAllowedAmount.call(account_investor1, 0, {from: account_investor1}); + await I_SecurityToken.changeGranularity(Math.pow(10, 15), {from: token_owner}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei('0.1', 'ether'), { from: account_investor1 }); + + let priorRemainingAmount = await I_VolumeRestrictionTransferManager.getAllowedAmount.call(account_investor1, 0, {from: account_investor1}); + increaseTime(10) + + await I_VolumeRestrictionTransferManager.modifyVolumeDumpingRestriction(account_investor1, percent, currentTime, endTime, 30, { from: token_owner }) + + let newRemainingAmount = await I_VolumeRestrictionTransferManager.getAllowedAmount.call(account_investor1, 0, {from: account_investor1}); + + await I_VolumeRestrictionTransferManager.removeRestriction(account_investor1, { from: token_owner }) + + assert.equal(priorRemainingAmount.toNumber(), newRemainingAmount.toNumber(), "Failed to roll over the active period id amount to new period id") + }) + + it("Should modify start time of a not started volume dumping restriction", async() => { + let endTime = latestTime() + duration.years(3); + let percent = 10 * Math.pow(10, 16) + let startTime = latestTime() + duration.years(2); + let newStartTime = latestTime() + duration.years(1); + + let rollingPeriod = 20; + + await I_VolumeRestrictionTransferManager.addDumpingRestriction(account_investor1, percent, startTime, endTime, rollingPeriod, { from: token_owner }); + await I_VolumeRestrictionTransferManager.modifyVolumeDumpingRestriction(account_investor1, percent, newStartTime, endTime, rollingPeriod, { from: token_owner }) + await I_VolumeRestrictionTransferManager.removeRestriction(account_investor1, { from: token_owner }) + }) + + it("Should revert if the parameters are bad when creating multiple volume dumping restrictions", async() => { + const accounts = [account_investor3, account_investor4] + const percents = [ 10 ] + const startTimes = [(await web3.eth.getBlock('latest')).timestamp + 10, 0] + const endTimes = [endTimeFn(1), endTimeFn(2)] + const rollingPeriods = [30] + + await catchRevert( + I_VolumeRestrictionTransferManager.addDumpingRestrictionMulti( + accounts, + percents, + startTimes, + endTimes, + rollingPeriods, + { from: token_owner }) + ) + }) + + it("Should get configuration function signature", async() => { + let sig = await I_VolumeRestrictionTransferManager.getInitFunction.call(); + assert.equal(web3.utils.hexToNumber(sig), 0); + }); + + it("Should get the permission", async() => { + let perm = await I_VolumeRestrictionTransferManager.getPermissions.call(); + assert.equal(perm.length, 1); + }); + + }); + + describe("VolumeDumping Restriction Transfer Manager Factory test cases", async() => { + + it("Should get the exact details of the factory", async() => { + assert.equal(await I_VolumeRestrictionTransferManagerFactory.setupCost.call(), 0); + assert.equal((await I_VolumeRestrictionTransferManagerFactory.getTypes.call())[0], 2); + assert.equal(web3.utils.toAscii(await I_VolumeRestrictionTransferManagerFactory.getName.call()) + .replace(/\u0000/g, ''), + "VolumeDumpingTransferManager", + "Wrong Module added"); + assert.equal(await I_VolumeRestrictionTransferManagerFactory.getDescription.call(), + "Manage the volume of tokens dumpable by an owner", + "Wrong Module added"); + assert.equal(await I_VolumeRestrictionTransferManagerFactory.getTitle.call(), + "Volume Dumping Transfer Manager", + "Wrong Module added"); + assert.equal(await I_VolumeRestrictionTransferManagerFactory.getInstructions.call(), + "Allows an issuer to restrict the total number of tokens dumpable withing a rolling period", + "Wrong Module added"); + }); + + it("Should get the tags of the factory", async() => { + let tags = await I_VolumeRestrictionTransferManagerFactory.getTags.call(); + assert.equal(web3.utils.toAscii(tags[0]).replace(/\u0000/g, ''), "VolumeDumping"); + }); + }); + +});