diff --git a/contracts/schemes/ContinuousLockingToken4Reputation.sol b/contracts/schemes/ContinuousLockingToken4Reputation.sol index 6a9fe193..855aed4d 100644 --- a/contracts/schemes/ContinuousLockingToken4Reputation.sol +++ b/contracts/schemes/ContinuousLockingToken4Reputation.sol @@ -101,7 +101,7 @@ contract ContinuousLocking4Reputation is Agreement { require(_batchTime > 15, "batchTime should be > 15"); require(_maxLockingBatches <= MAX_LOCKING_BATCHES_HARDCAP, "maxLockingBatches should be <= MAX_LOCKING_BATCHES_HARDCAP"); - require(_redeemEnableTime >= _startTime+_batchTime, + require(_redeemEnableTime >= _startTime.add(_batchTime), "_redeemEnableTime >= _startTime+_batchTime"); require(_batchesIndexCap <= BATCHES_INDEX_HARDCAP, "_batchesIndexCap > BATCHES_INDEX_HARDCAP"); token = _token; @@ -129,10 +129,11 @@ contract ContinuousLocking4Reputation is Agreement { // solhint-disable-next-line not-rely-on-time require(now > redeemEnableTime, "now > redeemEnableTime"); Lock storage locker = lockers[_beneficiary][_lockingId]; + require(locker.lockingTime != 0, "_lockingId does not exist"); uint256 batchIndexToRedeemFrom = (locker.lockingTime - startTime) / batchTime; // solhint-disable-next-line not-rely-on-time uint256 currentBatch = (now - startTime) / batchTime; - uint256 lastBatchIndexToRedeem = currentBatch.min(batchIndexToRedeemFrom + locker.period); + uint256 lastBatchIndexToRedeem = currentBatch.min(batchIndexToRedeemFrom.add(locker.period)); for (batchIndexToRedeemFrom; batchIndexToRedeemFrom < lastBatchIndexToRedeem; batchIndexToRedeemFrom++) { Batch storage locking = batches[batchIndexToRedeemFrom]; uint256 score = locking.scores[_lockingId]; @@ -172,7 +173,7 @@ contract ContinuousLocking4Reputation is Agreement { require(now >= startTime, "locking is not enabled yet (it starts at startTime)"); require(_period <= maxLockingBatches, "_period exceed the maximum allowed"); require(_period > 0, "_period must be > 0"); - require((_batchIndexToLockIn + _period) <= batchesIndexCap, + require((_batchIndexToLockIn.add(_period)) <= batchesIndexCap, "_batchIndexToLockIn + _period exceed max allowed batches"); lockCounter = lockCounter.add(1); lockingId = lockCounter; @@ -191,7 +192,7 @@ contract ContinuousLocking4Reputation is Agreement { //fill in the next batches scores. for (uint256 p = 0; p < _period; p++) { Batch storage batch = batches[batchIndexToLockIn + p]; - uint256 score = (_period - p) * _amount; + uint256 score = (_period - p).mul(_amount); batch.totalScore = batch.totalScore.add(score); batch.scores[lockingId] = score; } @@ -218,11 +219,11 @@ contract ContinuousLocking4Reputation is Agreement { require(locker.lockingTime != 0, "_lockingId does not exist"); // remainBatchs is the number of future batches that are part of the currently active lock uint256 remainBatches = - ((locker.lockingTime + (locker.period*batchTime) - startTime)/batchTime).sub(_batchIndexToLockIn); - uint256 batchesCountFromCurrent = remainBatches + _extendPeriod; + ((locker.lockingTime.add(locker.period*batchTime).sub(startTime))/batchTime).sub(_batchIndexToLockIn); + uint256 batchesCountFromCurrent = remainBatches.add(_extendPeriod); require(batchesCountFromCurrent <= maxLockingBatches, "locking period exceeds the maximum allowed"); require(_extendPeriod > 0, "_extendPeriod must be > 0"); - require((_batchIndexToLockIn + batchesCountFromCurrent) <= batchesIndexCap, + require((_batchIndexToLockIn.add(batchesCountFromCurrent)) <= batchesIndexCap, "_extendPeriod exceed max allowed batches"); // solhint-disable-next-line not-rely-on-time uint256 batchIndexToLockIn = (now - startTime) / batchTime; @@ -230,11 +231,11 @@ contract ContinuousLocking4Reputation is Agreement { //fill in the next batch scores. for (uint256 p = 0; p < batchesCountFromCurrent; p++) { Batch storage batch = batches[batchIndexToLockIn + p]; - uint256 score = (batchesCountFromCurrent - p) * locker.amount; + uint256 score = (batchesCountFromCurrent - p).mul(locker.amount); batch.totalScore = batch.totalScore.add(score).sub(batch.scores[_lockingId]); batch.scores[_lockingId] = score; } - locker.period = locker.period + _extendPeriod; + locker.period = locker.period.add(_extendPeriod); emit ExtendLocking(msg.sender, _lockingId, _extendPeriod); } @@ -250,7 +251,7 @@ contract ContinuousLocking4Reputation is Agreement { amount = locker.amount; locker.amount = 0; // solhint-disable-next-line not-rely-on-time - require(block.timestamp > locker.lockingTime + (locker.period*batchTime), + require(block.timestamp > locker.lockingTime.add(locker.period*batchTime), "locking period is still active"); totalLockedLeft = totalLockedLeft.sub(amount); address(token).safeTransfer(_beneficiary, amount); diff --git a/package-lock.json b/package-lock.json index 2c46a974..803620a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.27", + "version": "0.0.1-rc.28", "lockfileVersion": 1, "requires": true, "dependencies": { "@babel/cli": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.6.0.tgz", - "integrity": "sha512-1CTDyGUjQqW3Mz4gfKZ04KGOckyyaNmKneAMlABPS+ZyuxWv3FrVEVz7Ag08kNIztVx8VaJ8YgvYLSNlMKAT5Q==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.6.2.tgz", + "integrity": "sha512-JDZ+T/br9pPfT2lmAMJypJDTTTHM9ePD/ED10TRjRzJVdEVy+JB3iRlhzYmTt5YkNgHvxWGlUVnLtdv6ruiDrQ==", "dev": true, "requires": { "chokidar": "^2.1.8", @@ -32,16 +32,15 @@ } }, "@babel/generator": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.0.tgz", - "integrity": "sha512-Ms8Mo7YBdMMn1BYuNtKuP/z0TgEIhbcyB8HVR6PPNYp4P61lMsABiS4A3VG1qznjXVCf3r+fVHhm4efTYVsySA==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.2.tgz", + "integrity": "sha512-j8iHaIW4gGPnViaIHI7e9t/Hl8qLjERI6DcV9kEpAIDJsAOrcnXqRS7t+QbhL76pwbtqP+QCQLL0z1CyVmtjjQ==", "dev": true, "requires": { "@babel/types": "^7.6.0", "jsesc": "^2.5.1", "lodash": "^4.17.13", - "source-map": "^0.5.0", - "trim-right": "^1.0.1" + "source-map": "^0.5.0" } }, "@babel/helper-function-name": { @@ -85,9 +84,9 @@ } }, "@babel/parser": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.0.tgz", - "integrity": "sha512-+o2q111WEx4srBs7L9eJmcwi655eD8sXniLqMB93TBK9GrNzGrxDWSjiqz2hLU0Ha8MTXFIP0yd9fNdP+m43ZQ==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.2.tgz", + "integrity": "sha512-mdFqWrSPCmikBoaBYMuBulzTIKuXVPtEISFbRRVNwMWpCms/hmE2kRq0bblUHaNRKrjRlmVbx1sDHmjmRgD2Xg==", "dev": true }, "@babel/template": { @@ -102,16 +101,16 @@ } }, "@babel/traverse": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.0.tgz", - "integrity": "sha512-93t52SaOBgml/xY74lsmt7xOR4ufYvhb5c5qiM6lu4J/dWGMAfAh6eKw4PjLes6DI6nQgearoxnFJk60YchpvQ==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.2.tgz", + "integrity": "sha512-8fRE76xNwNttVEF2TwxJDGBLWthUkHWSldmfuBzVRmEDWOtu4XdINTgN7TDWzuLg4bbeIMLvfMFD9we5YcWkRQ==", "dev": true, "requires": { "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.6.0", + "@babel/generator": "^7.6.2", "@babel/helper-function-name": "^7.1.0", "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.6.0", + "@babel/parser": "^7.6.2", "@babel/types": "^7.6.0", "debug": "^4.1.0", "globals": "^11.1.0", @@ -1575,9 +1574,9 @@ "dev": true }, "colors": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", - "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", + "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", "dev": true }, "combined-stream": { @@ -5647,9 +5646,9 @@ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" }, "react-is": { - "version": "16.9.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz", - "integrity": "sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==", + "version": "16.10.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.0.tgz", + "integrity": "sha512-WRki2sBb7MTpYp7FtDEmSeGKX2vamYyq3rc9o7fKUG+/DHVyJu69NnvJsiSwwhh2Tt8XN40MQHkDBEXwyfxncQ==", "dev": true }, "read": { @@ -6209,9 +6208,9 @@ } }, "solhint": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/solhint/-/solhint-2.2.0.tgz", - "integrity": "sha512-KNi9qGu17XNV75q9eFftrWIpDVHbejyZ5vaDuNQwet0e9+k8Xw0BdckyVUjYRfFQXAQA3nBTafxUVUtkM4cfIA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/solhint/-/solhint-2.3.0.tgz", + "integrity": "sha512-2yiELLp+MsDtuOTrjc14lgsYmlMchp++SicvqCBu01VXsi9Mk2uynhyN3nBfbGzYq1YfmOEBpUqJfFYXVAR/Ig==", "dev": true, "requires": { "ajv": "^6.6.1", @@ -6226,7 +6225,7 @@ "js-yaml": "^3.12.0", "lodash": "^4.17.11", "prettier": "^1.14.3", - "semver": "^6.0.0" + "semver": "^6.3.0" }, "dependencies": { "commander": { diff --git a/package.json b/package.json index fb4c2063..6c0b7a7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.27", + "version": "0.0.1-rc.28", "description": "A platform for building DAOs", "files": [ "contracts/",