Skip to content

Commit 1b126c2

Browse files
committed
Small optimisation
1 parent a2692fc commit 1b126c2

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

contracts/modules/TransferManager/VolumeRestrictionTM.sol

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
112112
*/
113113
function verifyTransfer(address _from, address /*_to */, uint256 _amount, bytes /*_data*/, bool _isTransfer) public returns (Result) {
114114
// If `_from` is present in the exemptionList or it is `0x0` address then it will not follow the vol restriction
115-
if (!paused && _from != address(0) && !exemptList[_from]) {
115+
if (!paused && _from != address(0) && exemptIndex[_from] == 0) {
116116
// Function must only be called by the associated security token if _isTransfer == true
117117
require(msg.sender == securityToken || !_isTransfer);
118118
// Checking the individual restriction if the `_from` comes in the individual category
@@ -137,15 +137,14 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
137137
*/
138138
function changeExemptWalletList(address _wallet, bool _change) public withPerm(ADMIN) {
139139
require(_wallet != address(0));
140-
require(exemptList[_wallet] != _change);
140+
require((exemptIndex[_wallet] == 0) == _change);
141141
if (_change) {
142142
exemptAddresses.push(_wallet);
143143
exemptIndex[_wallet] = exemptAddresses.length;
144-
exemptList[_wallet] = true;
145144
} else {
146-
exemptAddresses[exemptIndex[_wallet] - 1] = exemptAddresses[exemptAddresses.length -1];
147-
exemptIndex[exemptAddresses[exemptIndex[_wallet] -1 ]] = exemptIndex[_wallet];
148-
delete exemptList[_wallet];
145+
exemptAddresses[exemptIndex[_wallet] - 1] = exemptAddresses[exemptAddresses.length - 1];
146+
exemptIndex[exemptAddresses[exemptIndex[_wallet] - 1]] = exemptIndex[_wallet];
147+
delete exemptIndex[_wallet];
149148
exemptAddresses.length --;
150149
}
151150
emit ChangedExemptWalletList(_wallet, _change);
@@ -200,7 +199,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
200199
individualRestriction[_holder].endTime < now,
201200
"Not Allowed"
202201
);
203-
require(_holder != address(0) && !exemptList[_holder], "Invalid address");
202+
require(_holder != address(0) && exemptIndex[_holder] == 0, "Invalid address");
204203
_checkInputParams(_allowedTokens, _startTime, _rollingPeriodInDays, _endTime, _restrictionType, now);
205204

206205
if (individualRestriction[_holder].endTime != 0) {
@@ -1129,15 +1128,15 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
11291128
function getExemptAddress() external view returns(address[]) {
11301129
return exemptAddresses;
11311130
}
1132-
1131+
11331132
/**
11341133
* @notice Provide the restriction details of all the restricted addresses
11351134
* @return address List of the restricted addresses
11361135
* @return uint256 List of the tokens allowed to the restricted addresses corresponds to restricted address
11371136
* @return uint256 List of the start time of the restriction corresponds to restricted address
11381137
* @return uint256 List of the rolling period in days for a restriction corresponds to restricted address.
11391138
* @return uint256 List of the end time of the restriction corresponds to restricted address.
1140-
* @return uint8 List of the type of restriction to validate the value of the `allowedTokens`
1139+
* @return uint8 List of the type of restriction to validate the value of the `allowedTokens`
11411140
* of the restriction corresponds to restricted address
11421141
*/
11431142
function getRestrictedData() external view returns(
@@ -1186,7 +1185,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
11861185
uint256[] memory endTime,
11871186
uint8[] memory typeOfRestriction,
11881187
uint256 index
1189-
)
1188+
)
11901189
internal
11911190
pure
11921191
{

contracts/modules/TransferManager/VolumeRestrictionTMStorage.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ contract VolumeRestrictionTMStorage {
1313

1414
struct VolumeRestriction {
1515
// If typeOfRestriction is `Percentage` then allowedTokens will be in
16-
// the % (w.r.t to totalSupply) with a multiplier of 10**16 . else it
16+
// the % (w.r.t to totalSupply) with a multiplier of 10**16 . else it
1717
// will be fixed amount of tokens
1818
uint256 allowedTokens;
1919
uint256 startTime;
@@ -24,7 +24,7 @@ contract VolumeRestrictionTMStorage {
2424

2525
struct BucketDetails {
2626
uint256 lastTradedDayTime;
27-
uint256 sumOfLastPeriod; // It is the sum of transacted amount within the last rollingPeriodDays
27+
uint256 sumOfLastPeriod; // It is the sum of transacted amount within the last rollingPeriodDays
2828
uint256 daysCovered; // No of days covered till (from the startTime of VolumeRestriction)
2929
uint256 dailyLastTradedDayTime;
3030
}
@@ -44,11 +44,11 @@ contract VolumeRestrictionTMStorage {
4444
// Storing the information related to default restriction
4545
mapping(address => BucketDetails) internal defaultUserToBucket;
4646
// List of wallets that are exempted from all the restrictions applied by the this contract
47-
mapping(address => bool) public exemptList;
47+
/* mapping(address => bool) public exemptList; */
4848
// Restricted data (refernce from the VolumeRestrictionLib library )
4949
VolumeRestrictionLib.RestrictedData holderData;
5050
// Holde exempt index
5151
mapping(address => uint256) exemptIndex;
5252
address[] public exemptAddresses;
53-
54-
}
53+
54+
}

0 commit comments

Comments
 (0)