From 2f1d5eae4a6dab1ad652bd20e8d21514013a4f65 Mon Sep 17 00:00:00 2001 From: owen05 Date: Mon, 13 Dec 2021 10:34:27 +0800 Subject: [PATCH] update cpV2 --- contracts/CrowdPooling/impl/CP.sol | 2 ++ contracts/CrowdPooling/impl/CPFunding.sol | 6 +++--- contracts/CrowdPooling/impl/CPStorage.sol | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contracts/CrowdPooling/impl/CP.sol b/contracts/CrowdPooling/impl/CP.sol index bdcbdb8..13f8216 100644 --- a/contracts/CrowdPooling/impl/CP.sol +++ b/contracts/CrowdPooling/impl/CP.sol @@ -103,6 +103,8 @@ contract CP is CPVesting { _TOTAL_BASE_ = _BASE_TOKEN_.balanceOf(address(this)); + require(switches.length == 2, "SWITCHES_LENGTH_WRONG"); + _IS_OVERCAP_STOP = switches[0]; _IS_OPEN_TWAP_ = switches[1]; diff --git a/contracts/CrowdPooling/impl/CPFunding.sol b/contracts/CrowdPooling/impl/CPFunding.sol index e5596eb..f5cbddf 100644 --- a/contracts/CrowdPooling/impl/CPFunding.sol +++ b/contracts/CrowdPooling/impl/CPFunding.sol @@ -37,7 +37,7 @@ contract CPFunding is CPStorage { _; } - function bid(address to) external isForceStop phaseBid preventReentrant isBidderAllow(to) { + function bid(address to) external isNotForceStop phaseBid preventReentrant isBidderAllow(to) { uint256 input = _getQuoteInput(); uint256 mtFee = DecimalMath.mulFloor(input, _MT_FEE_RATE_MODEL_.getFeeRate(to)); _transferQuoteOut(_MAINTAINER_, mtFee); @@ -71,7 +71,7 @@ contract CPFunding is CPStorage { // ============ SETTLEMENT ============ - function settle() external isForceStop phaseSettlement preventReentrant { + function settle() external isNotForceStop phaseSettlement preventReentrant { _settle(); (uint256 poolBase, uint256 poolQuote, uint256 poolI, uint256 unUsedBase, uint256 unUsedQuote) = getSettleResult(); @@ -112,7 +112,7 @@ contract CPFunding is CPStorage { } // in case something wrong with base token contract - function emergencySettle() external isForceStop phaseSettlement preventReentrant { + function emergencySettle() external isNotForceStop phaseSettlement preventReentrant { require(block.timestamp >= _PHASE_CALM_ENDTIME_.add(_SETTLEMENT_EXPIRE_), "NOT_EMERGENCY"); _settle(); _UNUSED_QUOTE_ = _QUOTE_TOKEN_.balanceOf(address(this)); diff --git a/contracts/CrowdPooling/impl/CPStorage.sol b/contracts/CrowdPooling/impl/CPStorage.sol index ff646e1..e781ce2 100644 --- a/contracts/CrowdPooling/impl/CPStorage.sol +++ b/contracts/CrowdPooling/impl/CPStorage.sol @@ -85,7 +85,7 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard { mapping(address => uint256) _CLAIMED_BASE_TOKEN_; // ============ Modifiers ============ - modifier isForceStop() { + modifier isNotForceStop() { require(!_FORCE_STOP_, "FORCE_STOP"); _; }