Skip to content

Move contracts to the respective folders #510

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

Merged
merged 8 commits into from
Jan 14, 2019
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
31 changes: 8 additions & 23 deletions contracts/libraries/VolumeRestrictionLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,12 @@ pragma solidity ^0.4.24;
import "./BokkyPooBahsDateTimeLibrary.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../interfaces/ISecurityToken.sol";
import "../storage/VolumeRestrictionTMStorage.sol";

library VolumeRestrictionLib {

using SafeMath for uint256;

enum TypeOfPeriod { MultipleDays, OneDay, Both }

struct RestrictedHolder {
// 1 represent true & 0 for false
uint8 seen;
// Type of period will be enum index of TypeOfPeriod enum
uint8 typeOfPeriod;
// Index of the array where the holder address lives
uint128 index;
}

struct RestrictedData {
mapping(address => RestrictedHolder) restrictedHolders;
address[] restrictedAddresses;
}

function _checkLengthOfArray(
address[] _holders,
uint256[] _allowedTokens,
Expand All @@ -45,14 +30,14 @@ library VolumeRestrictionLib {
);
}

function _deleteHolderFromList(RestrictedData storage data, address _holder, uint8 _typeOfPeriod) public {
function deleteHolderFromList(VolumeRestrictionTMStorage.RestrictedData storage data, address _holder, uint8 _typeOfPeriod) public {
// Deleting the holder if holder's type of Period is `Both` type otherwise
// it will assign the given type `_typeOfPeriod` to the _holder typeOfPeriod
// `_typeOfPeriod` it always be contrary to the removing restriction
// if removing restriction is individual then typeOfPeriod is TypeOfPeriod.OneDay
// in uint8 its value is 1. if removing restriction is daily individual then typeOfPeriod
// is TypeOfPeriod.MultipleDays in uint8 its value is 0.
if (data.restrictedHolders[_holder].typeOfPeriod != uint8(TypeOfPeriod.Both)) {
if (data.restrictedHolders[_holder].typeOfPeriod != uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both)) {
uint128 index = data.restrictedHolders[_holder].index;
uint256 _len = data.restrictedAddresses.length;
if (index != _len) {
Expand All @@ -66,22 +51,22 @@ library VolumeRestrictionLib {
}
}

function _addRestrictionData(RestrictedData storage data, address _holder, uint8 _callFrom, uint256 _endTime) public {
function addRestrictionData(VolumeRestrictionTMStorage.RestrictedData storage data, address _holder, uint8 _callFrom, uint256 _endTime) public {
uint128 index = data.restrictedHolders[_holder].index;
if (data.restrictedHolders[_holder].seen == 0) {
data.restrictedAddresses.push(_holder);
index = uint128(data.restrictedAddresses.length);
}
uint8 _type = _getTypeOfPeriod(data.restrictedHolders[_holder].typeOfPeriod, _callFrom, _endTime);
data.restrictedHolders[_holder] = RestrictedHolder(uint8(1), _type, index);
data.restrictedHolders[_holder] = VolumeRestrictionTMStorage.RestrictedHolder(uint8(1), _type, index);
}

function _getTypeOfPeriod(uint8 _currentTypeOfPeriod, uint8 _callFrom, uint256 _endTime) internal pure returns(uint8) {
if (_currentTypeOfPeriod != _callFrom && _endTime != uint256(0))
return uint8(TypeOfPeriod.Both);
return uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both);
else
return _callFrom;
}


}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "./ITransferManager.sol";
import "../../TransferManager/ITransferManager.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.24;

import "./BlacklistTransferManager.sol";
import "../ModuleFactory.sol";
import "../../libraries/Util.sol";
import "../../ModuleFactory.sol";
import "../../../libraries/Util.sol";

/**
* @title Factory for deploying BlacklistManager module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "./ITransferManager.sol";
import "../../TransferManager/ITransferManager.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

contract LockUpTransferManager is ITransferManager {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../ModuleFactory.sol";
import "../../ModuleFactory.sol";
import "./LockUpTransferManager.sol";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.24;

import "../../Pausable.sol";
import "../Module.sol";
import "../../../Pausable.sol";
import "../../Module.sol";

/**
* @title Interface to be implemented by all Wallet modules
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.24;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./VestingEscrowWalletStorage.sol";
import "../../../storage/VestingEscrowWalletStorage.sol";
import "./IWallet.sol";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.4.24;

import "../../proxy/VestingEscrowWalletProxy.sol";
import "../../interfaces/IBoot.sol";
import "../ModuleFactory.sol";
import "../../libraries/Util.sol";
import "../../../proxy/VestingEscrowWalletProxy.sol";
import "../../../interfaces/IBoot.sol";
import "../../ModuleFactory.sol";
import "../../../libraries/Util.sol";

/**
* @title Factory for deploying VestingEscrowWallet module
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/STO/USDTieredSTO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../../RegistryUpdater.sol";
import "../../libraries/DecimalMath.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ReentrancyGuard.sol";
import "./USDTieredSTOStorage.sol";
import "../../storage/USDTieredSTOStorage.sol";

/**
* @title STO module for standard capped crowdsale
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.24;

import "./ITransferManager.sol";
import "./GeneralTransferManagerStorage.sol";
import "../../storage/GeneralTransferManagerStorage.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
Expand Down
10 changes: 5 additions & 5 deletions contracts/modules/TransferManager/VolumeRestrictionTM.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.4.24;

import "./ITransferManager.sol";
import "./VolumeRestrictionTMStorage.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../../libraries/BokkyPooBahsDateTimeLibrary.sol";
import "../../libraries/VolumeRestrictionLib.sol";

contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {

Expand Down Expand Up @@ -212,7 +212,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
_endTime,
RestrictionType(_restrictionType)
);
VolumeRestrictionLib._addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.MultipleDays), individualRestriction[_holder].endTime);
VolumeRestrictionLib.addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.MultipleDays), individualRestriction[_holder].endTime);
emit AddIndividualRestriction(
_holder,
_allowedTokens,
Expand Down Expand Up @@ -275,7 +275,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
_endTime,
RestrictionType(_restrictionType)
);
VolumeRestrictionLib._addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.OneDay), individualRestriction[_holder].endTime);
VolumeRestrictionLib.addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.OneDay), individualRestriction[_holder].endTime);
emit AddIndividualDailyRestriction(
_holder,
_allowedTokens,
Expand Down Expand Up @@ -447,7 +447,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
require(_holder != address(0));
require(individualRestriction[_holder].endTime != 0);
individualRestriction[_holder] = VolumeRestriction(0, 0, 0, 0, RestrictionType(0));
VolumeRestrictionLib._deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.OneDay));
VolumeRestrictionLib.deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.OneDay));
userToBucket[_holder].lastTradedDayTime = 0;
userToBucket[_holder].sumOfLastPeriod = 0;
userToBucket[_holder].daysCovered = 0;
Expand Down Expand Up @@ -477,7 +477,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
require(_holder != address(0));
require(individualDailyRestriction[_holder].endTime != 0);
individualDailyRestriction[_holder] = VolumeRestriction(0, 0, 0, 0, RestrictionType(0));
VolumeRestrictionLib._deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.MultipleDays));
VolumeRestrictionLib.deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.MultipleDays));
userToBucket[_holder].dailyLastTradedDayTime = 0;
emit IndividualDailyRestrictionRemoved(_holder);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/GeneralTransferManagerProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../modules/TransferManager/GeneralTransferManagerStorage.sol";
import "../storage/GeneralTransferManagerStorage.sol";
import "./OwnedProxy.sol";
import "../Pausable.sol";
import "../modules/ModuleStorage.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/USDTieredSTOProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../modules/STO/USDTieredSTOStorage.sol";
import "../storage/USDTieredSTOStorage.sol";
import "./OwnedProxy.sol";
import "../Pausable.sol";
import "openzeppelin-solidity/contracts/ReentrancyGuard.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/VestingEscrowWalletProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../modules/Wallet/VestingEscrowWalletStorage.sol";
import "../storage/VestingEscrowWalletStorage.sol";
import "./OwnedProxy.sol";
import "../Pausable.sol";
import "../modules/ModuleStorage.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/proxy/VolumeRestrictionTMProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../modules/TransferManager/VolumeRestrictionTMStorage.sol";
import "../storage/VolumeRestrictionTMStorage.sol";
import "./OwnedProxy.sol";
import "../Pausable.sol";
import "../modules/ModuleStorage.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../../interfaces/IERC20.sol";
import "../interfaces/IERC20.sol";

/**
* @title Contract used to store layout for the USDTieredSTO storage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
pragma solidity ^0.4.24;

import "../../libraries/VolumeRestrictionLib.sol";

/**
* @title Storage layout for VolumeRestrictionTM
*/
Expand All @@ -11,6 +9,20 @@ contract VolumeRestrictionTMStorage {

enum TypeOfPeriod { MultipleDays, OneDay, Both }

struct RestrictedHolder {
// 1 represent true & 0 for false
uint8 seen;
// Type of period will be enum index of TypeOfPeriod enum
uint8 typeOfPeriod;
// Index of the array where the holder address lives
uint128 index;
}

struct RestrictedData {
mapping(address => RestrictedHolder) restrictedHolders;
address[] restrictedAddresses;
}

struct VolumeRestriction {
// If typeOfRestriction is `Percentage` then allowedTokens will be in
// the % (w.r.t to totalSupply) with a multiplier of 10**16 . else it
Expand Down Expand Up @@ -43,11 +55,9 @@ contract VolumeRestrictionTMStorage {
mapping(address => BucketDetails) internal userToBucket;
// Storing the information related to default restriction
mapping(address => BucketDetails) internal defaultUserToBucket;
// List of wallets that are exempted from all the restrictions applied by the this contract
/* mapping(address => bool) public exemptList; */
// Restricted data (refernce from the VolumeRestrictionLib library )
VolumeRestrictionLib.RestrictedData holderData;
// Holde exempt index
RestrictedData holderData;
// Hold exempt index
mapping(address => uint256) exemptIndex;
address[] public exemptAddresses;

Expand Down
2 changes: 1 addition & 1 deletion test/y_volume_restriction_tm.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ contract('VolumeRestrictionTransferManager', accounts => {
await I_VolumeRestrictionTM.addIndividualRestrictionMulti(
[account_investor2, account_delegate3, account_investor4],
[web3.utils.toWei("12"), web3.utils.toWei("10"), web3.utils.toWei("15")],
[latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)],
[0, 0, 0],
[3, 4, 5],
[latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)],
[0,0,0],
Expand Down