add new features on cp

This commit is contained in:
owen05
2021-11-09 21:05:54 +08:00
parent 549d8f1e5e
commit d295533e88
10 changed files with 75 additions and 43 deletions

View File

@@ -29,7 +29,7 @@ contract CP is CPVesting {
address[] calldata addressList,
uint256[] calldata timeLine,
uint256[] calldata valueList,
bool isOpenTWAP
bool[] calldata switches //0 isOverCapStop 1 isOpenTWAP
) external {
/*
Address List
@@ -59,9 +59,10 @@ contract CP is CPVesting {
2. phase calm duration
3. freeze duration
4. vesting duration
5. claim lock duration
*/
require(timeLine.length == 5, "LIST_LENGTH_WRONG");
require(timeLine.length == 6, "LIST_LENGTH_WRONG");
_PHASE_BID_STARTTIME_ = timeLine[0];
_PHASE_BID_ENDTIME_ = _PHASE_BID_STARTTIME_.add(timeLine[1]);
@@ -69,7 +70,7 @@ contract CP is CPVesting {
_FREEZE_DURATION_ = timeLine[3];
_VESTING_DURATION_ = timeLine[4];
_CLAIM_LOCK_DURATION_ = timeLine[5];
require(block.timestamp <= _PHASE_BID_STARTTIME_, "TIMELINE_WRONG");
/*
@@ -93,7 +94,8 @@ contract CP is CPVesting {
_TOTAL_BASE_ = _BASE_TOKEN_.balanceOf(address(this));
_IS_OPEN_TWAP_ = isOpenTWAP;
_IS_OVERCAP_STOP = switches[0];
_IS_OPEN_TWAP_ = switches[1];
require(address(this).balance == _SETTEL_FUND_, "SETTLE_FUND_NOT_MATCH");
}
@@ -101,6 +103,6 @@ contract CP is CPVesting {
// ============ Version Control ============
function version() virtual external pure returns (string memory) {
return "CP 1.0.0";
return "CP 1.0.1";
}
}

View File

@@ -31,6 +31,9 @@ contract CPFunding is CPStorage {
modifier isBidderAllow(address bidder) {
require(_BIDDER_PERMISSION_.isAllowed(bidder), "BIDDER_NOT_ALLOWED");
if(_IS_OVERCAP_STOP) {
require(_QUOTE_TOKEN_.balanceOf(address(this)) < _POOL_QUOTE_CAP_, "ALREADY_OVER_CAP");
}
_;
}

View File

@@ -23,6 +23,7 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard {
uint256 internal constant _SETTLEMENT_EXPIRE_ = 86400 * 7;
uint256 internal constant _SETTEL_FUND_ = 200 finney;
bool public _IS_OPEN_TWAP_ = false;
bool public _IS_OVERCAP_STOP = false;
// ============ Timeline ============
@@ -68,12 +69,13 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard {
uint256 public _K_;
uint256 public _I_;
// ============ LP Token Vesting ============
// ============ LP Token Vesting && Claim Params ============
uint256 public _TOTAL_LP_AMOUNT_;
uint256 public _FREEZE_DURATION_;
uint256 public _VESTING_DURATION_;
uint256 public _CLIFF_RATE_;
uint256 public _CLAIM_LOCK_DURATION_;
// ============ Modifiers ============

View File

@@ -40,6 +40,11 @@ contract CPVesting is CPFunding {
_;
}
modifier afterClaimLockDuration() {
require(_SETTLED_ && block.timestamp >= _SETTLED_TIME_.add(_CLAIM_LOCK_DURATION_), "CLAIM_LOCKED");
_;
}
modifier afterFreeze() {
require(_SETTLED_ && block.timestamp >= _SETTLED_TIME_.add(_FREEZE_DURATION_), "FREEZED");
_;
@@ -47,7 +52,7 @@ contract CPVesting is CPFunding {
// ============ Bidder Functions ============
function bidderClaim(address to,bytes calldata data) external afterSettlement {
function bidderClaim(address to,bytes calldata data) external afterClaimLockDuration {
require(!_CLAIMED_[msg.sender], "ALREADY_CLAIMED");
_CLAIMED_[msg.sender] = true;

View File

@@ -13,7 +13,7 @@ interface ICP {
address[] calldata addressList,
uint256[] calldata timeLine,
uint256[] calldata valueList,
bool isOpenTWAP
bool[] calldata switches
) external;
function bid(address to) external;