fix cp test
This commit is contained in:
@@ -48,39 +48,38 @@ contract CP is CPVesting {
|
||||
0. phase bid starttime
|
||||
1. phase bid duration
|
||||
2. phase calm duration
|
||||
3. vesting duration
|
||||
3. freeze duration
|
||||
4. vesting duration
|
||||
*/
|
||||
|
||||
require(timeLine.length == 4, "LIST_LENGTH_WRONG");
|
||||
require(timeLine.length == 5, "LIST_LENGTH_WRONG");
|
||||
|
||||
_PHASE_BID_STARTTIME_ = timeLine[0];
|
||||
_PHASE_BID_ENDTIME_ = _PHASE_BID_STARTTIME_.add(timeLine[1]);
|
||||
_PHASE_CALM_ENDTIME_ = _PHASE_BID_ENDTIME_.add(timeLine[2]);
|
||||
|
||||
_VESTING_DURATION_ = timeLine[3];
|
||||
_FREEZE_DURATION_ = timeLine[3];
|
||||
_VESTING_DURATION_ = timeLine[4];
|
||||
|
||||
require(block.timestamp <= _PHASE_BID_STARTTIME_, "TIMELINE_WRONG");
|
||||
|
||||
/*
|
||||
Value List
|
||||
0. pool quote cap
|
||||
1. owner quote ratio
|
||||
2. k
|
||||
3. i
|
||||
4. cliff rate
|
||||
1. k
|
||||
2. i
|
||||
3. cliff rate
|
||||
*/
|
||||
|
||||
require(valueList.length == 5, "LIST_LENGTH_WRONG");
|
||||
require(valueList.length == 4, "LIST_LENGTH_WRONG");
|
||||
|
||||
_POOL_QUOTE_CAP_ = valueList[0];
|
||||
_OWNER_QUOTE_RATIO_ = valueList[1];
|
||||
_K_ = valueList[2];
|
||||
_I_ = valueList[3];
|
||||
_CLIFF_RATE_ = valueList[4];
|
||||
_K_ = valueList[1];
|
||||
_I_ = valueList[2];
|
||||
_CLIFF_RATE_ = valueList[3];
|
||||
|
||||
require(_I_ > 0 && _I_ <= 1e36, "I_VALUE_WRONG");
|
||||
require(_K_ <= 1e18, "K_VALUE_WRONG");
|
||||
require(_OWNER_QUOTE_RATIO_ <= 1e18, "OWNER_RATIO_WRONG");
|
||||
require(_CLIFF_RATE_ <= 1e18, "CLIFF_RATE_WRONG");
|
||||
|
||||
_TOTAL_BASE_ = _BASE_TOKEN_.balanceOf(address(this));
|
||||
|
||||
@@ -89,7 +89,7 @@ contract CPFunding is CPStorage {
|
||||
_poolBaseToken = address(_QUOTE_TOKEN_);
|
||||
_poolQuoteToken = address(_BASE_TOKEN_);
|
||||
uint256 ratio = DecimalMath.ONE.sub(DecimalMath.divCeil(baseDepth, poolQuote));
|
||||
_poolI = ratio.mul(ratio).div(avgPrice).div(DecimalMath.ONE2);
|
||||
_poolI = ratio.mul(ratio).div(avgPrice);
|
||||
}
|
||||
_POOL_ = IUnownedDVMFactory(_POOL_FACTORY_).createDODOVendingMachine(
|
||||
address(this),
|
||||
|
||||
@@ -67,6 +67,7 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard {
|
||||
// ============ LP Token Vesting ============
|
||||
|
||||
uint256 public _TOTAL_LP_AMOUNT_;
|
||||
uint256 public _FREEZE_DURATION_;
|
||||
uint256 public _VESTING_DURATION_;
|
||||
uint256 public _CLIFF_RATE_;
|
||||
|
||||
|
||||
@@ -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_);
|
||||
|
||||
Reference in New Issue
Block a user