dodo-start && cpV2 ing
This commit is contained in:
@@ -82,15 +82,17 @@ contract CP is CPVesting {
|
||||
2. i
|
||||
3. lp cliff rate
|
||||
4. base token cliff rate
|
||||
5. lp fee rate
|
||||
*/
|
||||
|
||||
require(valueList.length == 5, "LIST_LENGTH_WRONG");
|
||||
require(valueList.length == 6, "LIST_LENGTH_WRONG");
|
||||
|
||||
_POOL_QUOTE_CAP_ = valueList[0];
|
||||
_K_ = valueList[1];
|
||||
_I_ = valueList[2];
|
||||
_CLIFF_RATE_ = valueList[3];
|
||||
_TOKEN_CLIFF_RATE_ = valueList[4];
|
||||
_POOL_FEE_RATE_ = valueList[5];
|
||||
|
||||
require(_I_ > 0 && _I_ <= 1e36, "I_VALUE_WRONG");
|
||||
require(_K_ <= 1e18, "K_VALUE_WRONG");
|
||||
|
||||
@@ -37,7 +37,7 @@ contract CPFunding is CPStorage {
|
||||
_;
|
||||
}
|
||||
|
||||
function bid(address to) external phaseBid preventReentrant isBidderAllow(to) {
|
||||
function bid(address to) external isForceStop 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 phaseSettlement preventReentrant {
|
||||
function settle() external isForceStop phaseSettlement preventReentrant {
|
||||
_settle();
|
||||
|
||||
(uint256 poolBase, uint256 poolQuote, uint256 poolI, uint256 unUsedBase, uint256 unUsedQuote) = getSettleResult();
|
||||
@@ -92,7 +92,7 @@ contract CPFunding is CPStorage {
|
||||
_POOL_ = IDVMFactory(_POOL_FACTORY_).createDODOVendingMachine(
|
||||
_poolBaseToken,
|
||||
_poolQuoteToken,
|
||||
3e15, // 0.3% lp feeRate
|
||||
_POOL_FEE_RATE_,
|
||||
poolI,
|
||||
DecimalMath.ONE,
|
||||
_IS_OPEN_TWAP_
|
||||
@@ -112,7 +112,7 @@ contract CPFunding is CPStorage {
|
||||
}
|
||||
|
||||
// in case something wrong with base token contract
|
||||
function emergencySettle() external phaseSettlement preventReentrant {
|
||||
function emergencySettle() external isForceStop phaseSettlement preventReentrant {
|
||||
require(block.timestamp >= _PHASE_CALM_ENDTIME_.add(_SETTLEMENT_EXPIRE_), "NOT_EMERGENCY");
|
||||
_settle();
|
||||
_UNUSED_QUOTE_ = _QUOTE_TOKEN_.balanceOf(address(this));
|
||||
|
||||
@@ -25,6 +25,8 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard {
|
||||
bool public _IS_OPEN_TWAP_ = false;
|
||||
bool public _IS_OVERCAP_STOP = false;
|
||||
|
||||
bool public _FORCE_STOP_ = false;
|
||||
|
||||
// ============ Timeline ============
|
||||
|
||||
uint256 public _PHASE_BID_STARTTIME_;
|
||||
@@ -56,6 +58,7 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard {
|
||||
|
||||
address public _POOL_FACTORY_;
|
||||
address public _POOL_;
|
||||
uint256 public _POOL_FEE_RATE_;
|
||||
uint256 public _AVG_SETTLED_PRICE_;
|
||||
|
||||
// ============ Advanced Control ============
|
||||
@@ -82,6 +85,10 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard {
|
||||
mapping(address => uint256) _CLAIMED_BASE_TOKEN_;
|
||||
|
||||
// ============ Modifiers ============
|
||||
modifier isForceStop() {
|
||||
require(!_FORCE_STOP_, "FORCE_STOP");
|
||||
_;
|
||||
}
|
||||
|
||||
modifier phaseBid() {
|
||||
require(
|
||||
@@ -116,4 +123,12 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard {
|
||||
require(_SETTLED_, "NOT_VESTING");
|
||||
_;
|
||||
}
|
||||
|
||||
function forceStop() external onlyOwner {
|
||||
require(block.timestamp < _PHASE_BID_STARTTIME_, "CP_ALREADY_STARTED");
|
||||
_FORCE_STOP_ = true;
|
||||
_TOTAL_BASE_ = 0;
|
||||
uint256 baseAmount = _BASE_TOKEN_.balanceOf(address(this));
|
||||
_BASE_TOKEN_.transfer(_OWNER_, baseAmount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user