Skip to content

Commit fac8a4a

Browse files
authored
Merge pull request #246 from PolymathNetwork/corl_changes
Corl Change & MATM update
2 parents 028a95b + 807de45 commit fac8a4a

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

contracts/modules/STO/USDTieredSTO.sol

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ contract USDTieredSTO is ISTO, ReentrancyGuard {
8282
// List of accredited investors
8383
mapping (address => bool) public accredited;
8484

85-
// Limit in USD for non-accredited investors multiplied by 10**18
85+
// Default limit in USD for non-accredited investors multiplied by 10**18
8686
uint256 public nonAccreditedLimitUSD;
8787

88+
// Overrides for default limit in USD for non-accredited investors multiplied by 10**18
89+
mapping (address => uint256) public nonAccreditedLimitUSDOverride;
90+
8891
// Minimum investable amount in USD
8992
uint256 public minimumInvestmentUSD;
9093

@@ -102,6 +105,8 @@ contract USDTieredSTO is ISTO, ReentrancyGuard {
102105
////////////
103106

104107
event SetAllowBeneficialInvestments(bool _allowed);
108+
event SetNonAccreditedLimit(address _investor, uint256 _limit);
109+
event SetAccredited(address _investor, bool _accredited);
105110
event TokenPurchase(address indexed _purchaser, address indexed _beneficiary, uint256 _tokens, uint256 _usdAmount, uint256 _tierPrice, uint8 _tier);
106111
event FundsReceivedETH(address indexed _purchaser, address indexed _beneficiary, uint256 _usdAmount, uint256 _receivedValue, uint256 _spentValue, uint256 _rate);
107112
event FundsReceivedPOLY(address indexed _purchaser, address indexed _beneficiary, uint256 _usdAmount, uint256 _receivedValue, uint256 _spentValue, uint256 _rate);
@@ -331,6 +336,22 @@ contract USDTieredSTO is ISTO, ReentrancyGuard {
331336
require(_investors.length == _accredited.length);
332337
for (uint256 i = 0; i < _investors.length; i++) {
333338
accredited[_investors[i]] = _accredited[i];
339+
emit SetAccredited(_investors[i], _accredited[i]);
340+
}
341+
}
342+
343+
/**
344+
* @notice Modify the list of overrides for non-accredited limits in USD
345+
* @param _investors Array of investor addresses to modify
346+
* @param _nonAccreditedLimit Array of uints specifying non-accredited limits
347+
*/
348+
function changeNonAccreditedLimit(address[] _investors, uint256[] _nonAccreditedLimit) public onlyOwner {
349+
//nonAccreditedLimitUSDOverride
350+
require(_investors.length == _nonAccreditedLimit.length);
351+
for (uint256 i = 0; i < _investors.length; i++) {
352+
require(_nonAccreditedLimit[i] > 0, "Limit cannot be 0");
353+
nonAccreditedLimitUSDOverride[_investors[i]] = _nonAccreditedLimit[i];
354+
emit SetNonAccreditedLimit(_investors[i], _nonAccreditedLimit[i]);
334355
}
335356
}
336357

@@ -409,9 +430,10 @@ contract USDTieredSTO is ISTO, ReentrancyGuard {
409430

410431
// Check for non-accredited cap
411432
if (!accredited[_beneficiary]) {
412-
require(investorInvestedUSD[_beneficiary] < nonAccreditedLimitUSD, "Non-accredited investor has already reached nonAccreditedLimitUSD");
413-
if (investedUSD.add(investorInvestedUSD[_beneficiary]) > nonAccreditedLimitUSD)
414-
investedUSD = nonAccreditedLimitUSD.sub(investorInvestedUSD[_beneficiary]);
433+
uint256 investorLimitUSD = (nonAccreditedLimitUSDOverride[_beneficiary] == 0) ? nonAccreditedLimitUSD : nonAccreditedLimitUSDOverride[_beneficiary];
434+
require(investorInvestedUSD[_beneficiary] < investorLimitUSD, "Non-accredited investor has already reached nonAccreditedLimitUSD");
435+
if (investedUSD.add(investorInvestedUSD[_beneficiary]) > investorLimitUSD)
436+
investedUSD = investorLimitUSD.sub(investorInvestedUSD[_beneficiary]);
415437
}
416438

417439
uint256 spentUSD;

contracts/modules/TransferManager/ManualApprovalTransferManager.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ contract ManualApprovalTransferManager is ITransferManager {
122122
* @param _expiryTime is the time until which the transfer is allowed
123123
*/
124124
function addManualApproval(address _from, address _to, uint256 _allowance, uint256 _expiryTime) public withPerm(TRANSFER_APPROVAL) {
125-
//Passing a _expiryTime == 0 into this function, is equivalent to removing the manual approval.
126125
require(_from != address(0), "Invalid from address");
127126
require(_to != address(0), "Invalid to address");
128127
require(_expiryTime > now, "Invalid expiry time");
128+
require(manualApprovals[_from][_to].allowance == 0, "Approval already exists");
129129
manualApprovals[_from][_to] = ManualApproval(_allowance, _expiryTime);
130130
emit LogAddManualApproval(_from, _to, _allowance, _expiryTime, msg.sender);
131131
}
@@ -137,10 +137,10 @@ contract ManualApprovalTransferManager is ITransferManager {
137137
* @param _expiryTime is the time until which the transfer is blocked
138138
*/
139139
function addManualBlocking(address _from, address _to, uint256 _expiryTime) public withPerm(TRANSFER_APPROVAL) {
140-
//Passing a _expiryTime == 0 into this function, is equivalent to removing the manual blocking.
141140
require(_from != address(0), "Invalid from address");
142141
require(_to != address(0), "Invalid to address");
143142
require(_expiryTime > now, "Invalid expiry time");
143+
require(manualApprovals[_from][_to].expiryTime == 0, "Blocking already exists");
144144
manualBlockings[_from][_to] = ManualBlocking(_expiryTime);
145145
emit LogAddManualBlocking(_from, _to, _expiryTime, msg.sender);
146146
}

test/q_usd_tiered_sto.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,11 +1563,19 @@ contract('USDTieredSTO', accounts => {
15631563
assert.equal((await I_USDTieredSTO_Array[stoId].investorInvestedPOLY.call(ACCREDITED1)).toNumber(), init_investorInvestedPOLY.add(investment_POLY).toNumber(), "investorInvestedPOLY not changed as expected");
15641564
});
15651565

1566+
it("should successfully modify NONACCREDITED cap for NONACCREDITED1", async() => {
1567+
let stoId = 0;
1568+
let tierId = 0;
1569+
console.log("Current investment: " + (await I_USDTieredSTO_Array[stoId].investorInvestedUSD.call(NONACCREDITED1)).toNumber());
1570+
await I_USDTieredSTO_Array[stoId].changeNonAccreditedLimit([NONACCREDITED1], [_nonAccreditedLimitUSD[stoId].div(2)], {from: ISSUER});
1571+
console.log("Current limit: " + (await I_USDTieredSTO_Array[stoId].nonAccreditedLimitUSDOverride(NONACCREDITED1)).toNumber());
1572+
});
1573+
15661574
it("should successfully buy a partial amount and refund balance when reaching NONACCREDITED cap", async() => {
15671575
let stoId = 0;
15681576
let tierId = 0;
15691577

1570-
let investment_USD = _nonAccreditedLimitUSD[stoId];
1578+
let investment_USD = (await I_USDTieredSTO_Array[stoId].nonAccreditedLimitUSDOverride(NONACCREDITED1));//_nonAccreditedLimitUSD[stoId];
15711579
let investment_Token = await convert(stoId, tierId, false, "USD", "TOKEN", investment_USD);
15721580
let investment_ETH = await convert(stoId, tierId, false, "USD", "ETH", investment_USD);
15731581
let investment_POLY = await convert(stoId, tierId, false, "USD", "POLY", investment_USD);
@@ -1577,6 +1585,8 @@ contract('USDTieredSTO', accounts => {
15771585
let refund_ETH = await convert(stoId, tierId, false, "USD", "ETH", refund_USD);
15781586
let refund_POLY = await convert(stoId, tierId, false, "USD", "POLY", refund_USD);
15791587

1588+
console.log("Expected refund in tokens: " + refund_Token.toNumber());
1589+
15801590
let snap = await takeSnapshot();
15811591

15821592
let init_TokenSupply = await I_SecurityToken.totalSupply();

0 commit comments

Comments
 (0)