fix cp test

This commit is contained in:
mingda
2020-12-18 18:31:45 +08:00
parent 101261803f
commit c24e4b8176
9 changed files with 65 additions and 56 deletions

View File

@@ -31,6 +31,11 @@ contract CPVesting is CPFunding {
_;
}
modifier afterFreeze() {
require(_SETTLED_ && block.timestamp >= _SETTLED_TIME_.add(_FREEZE_DURATION_), "FREEZED");
_;
}
// ============ Bidder Functions ============
function bidderClaim() external afterSettlement {
@@ -43,11 +48,11 @@ contract CPVesting is CPFunding {
// ============ Owner Functions ============
function claimLPToken() external onlyOwner afterSettlement {
function claimLPToken() external onlyOwner afterFreeze {
IERC20(_POOL_).safeTransfer(_OWNER_, getClaimableLPToken());
}
function getClaimableLPToken() public view afterSettlement returns (uint256) {
function getClaimableLPToken() public view afterFreeze returns (uint256) {
uint256 remainingLPToken = DecimalMath.mulFloor(
getRemainingLPRatio(block.timestamp),
_TOTAL_LP_AMOUNT_
@@ -55,8 +60,8 @@ contract CPVesting is CPFunding {
return IERC20(_POOL_).balanceOf(address(this)).sub(remainingLPToken);
}
function getRemainingLPRatio(uint256 timestamp) public view afterSettlement returns (uint256) {
uint256 timePast = timestamp.sub(_SETTLED_TIME_);
function getRemainingLPRatio(uint256 timestamp) public view afterFreeze returns (uint256) {
uint256 timePast = timestamp.sub(_SETTLED_TIME_.add(_FREEZE_DURATION_));
if (timePast < _VESTING_DURATION_) {
uint256 remainingTime = _VESTING_DURATION_.sub(timePast);
return DecimalMath.ONE.sub(_CLIFF_RATE_).mul(remainingTime).div(_VESTING_DURATION_);