update starter
This commit is contained in:
@@ -32,7 +32,7 @@ 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");
|
||||
require(_QUOTE_TOKEN_.balanceOf(address(this)) <= _POOL_QUOTE_CAP_, "ALREADY_OVER_CAP");
|
||||
}
|
||||
_;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,20 @@ contract CPVesting is CPFunding {
|
||||
|
||||
// ============ Bidder Functions ============
|
||||
|
||||
function claimQuoteToken(address to,bytes calldata data) external afterSettlement {
|
||||
require(!_CLAIMED_QUOTE_[msg.sender], "ALREADY_CLAIMED_FUND");
|
||||
function bidderClaim(address to, bytes calldata data) external {
|
||||
if(_SETTLED_) {
|
||||
_claimQuoteToken(to, data);
|
||||
}
|
||||
|
||||
if(_SETTLED_ && block.timestamp >= _SETTLED_TIME_.add(_TOKEN_CLAIM_DURATION_)) {
|
||||
_claimBaseToken(to);
|
||||
}
|
||||
}
|
||||
|
||||
function _claimQuoteToken(address to,bytes calldata data) internal {
|
||||
// require(!_CLAIMED_QUOTE_[msg.sender], "ALREADY_CLAIMED_FUND");
|
||||
if(_CLAIMED_QUOTE_[msg.sender]) return;
|
||||
|
||||
_CLAIMED_QUOTE_[msg.sender] = true;
|
||||
|
||||
uint256 quoteAmount = _UNUSED_QUOTE_.mul(_SHARES_[msg.sender]).div(_TOTAL_SHARES_);
|
||||
@@ -68,10 +80,9 @@ contract CPVesting is CPFunding {
|
||||
emit ClaimQuoteToken(msg.sender, quoteAmount);
|
||||
}
|
||||
|
||||
|
||||
function claimBaseToken() external afterClaimFreeze {
|
||||
function _claimBaseToken(address to) internal {
|
||||
uint256 claimableBaseAmount = getClaimableBaseToken(msg.sender);
|
||||
_transferBaseOut(msg.sender, claimableBaseAmount);
|
||||
_transferBaseOut(to, claimableBaseAmount);
|
||||
_CLAIMED_BASE_TOKEN_[msg.sender] = _CLAIMED_BASE_TOKEN_[msg.sender].add(claimableBaseAmount);
|
||||
emit ClaimBaseToken(msg.sender, claimableBaseAmount);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ contract FairFunding is Vesting {
|
||||
uint256 public _LOWER_LIMIT_PRICE_;
|
||||
uint256 public _UPPER_LIMIT_PRICE_;
|
||||
|
||||
bool public _IS_OVERCAP_STOP = false;
|
||||
|
||||
receive() external payable {
|
||||
require(_INITIALIZED_ == false, "WE_NOT_SAVE_ETH_AFTER_INIT");
|
||||
}
|
||||
@@ -39,7 +41,8 @@ contract FairFunding is Vesting {
|
||||
function init(
|
||||
address[] calldata addressList,
|
||||
uint256[] calldata timeLine,
|
||||
uint256[] calldata valueList
|
||||
uint256[] calldata valueList,
|
||||
bool isOverCapStop
|
||||
) external {
|
||||
/*
|
||||
Address List
|
||||
@@ -118,6 +121,8 @@ contract FairFunding is Vesting {
|
||||
require(_FUNDS_CLIFF_RATE_ <= 1e18, "FUND_CLIFF_RATE_WRONG");
|
||||
require(_LP_CLIFF_RATE_ <= 1e18, "LP_CLIFF_RATE_WRONG");
|
||||
|
||||
_IS_OVERCAP_STOP = isOverCapStop;
|
||||
|
||||
_TOTAL_TOKEN_AMOUNT_ = IERC20(_TOKEN_ADDRESS_).balanceOf(address(this));
|
||||
|
||||
require(_TOTAL_TOKEN_AMOUNT_ > 0, "NO_TOKEN_TRANSFERED");
|
||||
@@ -184,8 +189,15 @@ contract FairFunding is Vesting {
|
||||
|
||||
function depositFunds(address to) external preventReentrant isForceStop returns(uint256 inputFund) {
|
||||
require(isDepositOpen(), "DEPOSIT_NOT_OPEN");
|
||||
|
||||
uint256 currentFundBalance = IERC20(_FUNDS_ADDRESS_).balanceOf(address(this));
|
||||
|
||||
if(_IS_OVERCAP_STOP) {
|
||||
require(currentFundBalance <= DecimalMath.mulFloor(_TOTAL_TOKEN_AMOUNT_, _UPPER_LIMIT_PRICE_), "ALREADY_OVER_CAP");
|
||||
}
|
||||
|
||||
// input fund check
|
||||
inputFund = IERC20(_FUNDS_ADDRESS_).balanceOf(address(this)).sub(_FUNDS_RESERVE_);
|
||||
inputFund = currentFundBalance.sub(_FUNDS_RESERVE_);
|
||||
_FUNDS_RESERVE_ = _FUNDS_RESERVE_.add(inputFund);
|
||||
|
||||
if (_QUOTA_ != address(0)) {
|
||||
@@ -217,8 +229,12 @@ contract FairFunding is Vesting {
|
||||
require(isSettled(), "NOT_SETTLED");
|
||||
uint256 totalAllocation = getUserTokenAllocation(msg.sender);
|
||||
_claimToken(to, totalAllocation);
|
||||
}
|
||||
|
||||
if(!_FUNDS_CLAIMED_[msg.sender]) {
|
||||
_FUNDS_CLAIMED_[msg.sender] = true;
|
||||
IERC20(_FUNDS_ADDRESS_).safeTransfer(to, getUserFundsUnused(msg.sender));
|
||||
}
|
||||
}
|
||||
|
||||
// ============ Ownable Functions ============
|
||||
|
||||
|
||||
@@ -9,12 +9,21 @@ pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
interface IDODOStarter {
|
||||
//Instant mode
|
||||
function init(
|
||||
address[] calldata addressList,
|
||||
uint256[] calldata timeLine,
|
||||
uint256[] calldata valueList
|
||||
) external;
|
||||
|
||||
//Fair mode
|
||||
function init(
|
||||
address[] calldata addressList,
|
||||
uint256[] calldata timeLine,
|
||||
uint256[] calldata valueList,
|
||||
bool isOverCapStop
|
||||
) external;
|
||||
|
||||
function _FUNDS_ADDRESS_() external view returns (address);
|
||||
|
||||
function depositFunds(address to) external returns (uint256);
|
||||
|
||||
@@ -78,7 +78,8 @@ contract DODOStarterFactory is InitializableOwnable {
|
||||
address[] memory addressList,
|
||||
uint256[] memory timeLine,
|
||||
uint256[] memory valueList,
|
||||
uint256 sellTokenAmount
|
||||
uint256 sellTokenAmount,
|
||||
bool isOverCapStop
|
||||
) external payable permissionCheck(addressList[0],addressList[1]) returns(address newFairFundPool){
|
||||
newFairFundPool = ICloneFactory(_CLONE_FACTORY_).clone(_FAIR_FUND_TEMPLATE_);
|
||||
|
||||
@@ -89,7 +90,8 @@ contract DODOStarterFactory is InitializableOwnable {
|
||||
IDODOStarter(newFairFundPool).init(
|
||||
addressList,
|
||||
timeLine,
|
||||
valueList
|
||||
valueList,
|
||||
isOverCapStop
|
||||
);
|
||||
|
||||
_FAIR_REGISTRY_[addressList[1]][addressList[2]].push(newFairFundPool);
|
||||
|
||||
@@ -29,7 +29,6 @@ contract DODOCpProxy is ReentrancyGuard {
|
||||
address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||
address public immutable _WETH_;
|
||||
address public immutable _DODO_APPROVE_PROXY_;
|
||||
// address public immutable _UPCP_FACTORY_;
|
||||
address public immutable _CP_FACTORY_;
|
||||
|
||||
// ============ Modifiers ============
|
||||
@@ -46,56 +45,13 @@ contract DODOCpProxy is ReentrancyGuard {
|
||||
constructor(
|
||||
address payable weth,
|
||||
address cpFactory,
|
||||
// address upCpFactory,
|
||||
address dodoApproveProxy
|
||||
) public {
|
||||
_WETH_ = weth;
|
||||
_CP_FACTORY_ = cpFactory;
|
||||
// _UPCP_FACTORY_ = upCpFactory;
|
||||
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
|
||||
}
|
||||
|
||||
//============ UpCrowdPooling Functions (create) ============
|
||||
|
||||
// function createUpCrowdPooling(
|
||||
// address baseToken,
|
||||
// address quoteToken,
|
||||
// uint256 baseInAmount,
|
||||
// uint256[] memory timeLine,
|
||||
// uint256[] memory valueList,
|
||||
// bool[] memory switches,
|
||||
// uint256 deadLine
|
||||
// ) external payable preventReentrant judgeExpired(deadLine) returns (address payable newUpCrowdPooling) {
|
||||
// address _baseToken = baseToken;
|
||||
// address _quoteToken = quoteToken == _ETH_ADDRESS_ ? _WETH_ : quoteToken;
|
||||
|
||||
// newUpCrowdPooling = IDODOV2(_UPCP_FACTORY_).createCrowdPooling();
|
||||
|
||||
// _deposit(
|
||||
// msg.sender,
|
||||
// newUpCrowdPooling,
|
||||
// _baseToken,
|
||||
// baseInAmount,
|
||||
// false
|
||||
// );
|
||||
|
||||
// (bool success, ) = newUpCrowdPooling.call{value: msg.value}("");
|
||||
// require(success, "DODOCpProxy: Transfer failed");
|
||||
|
||||
// address[] memory tokens = new address[](2);
|
||||
// tokens[0] = _baseToken;
|
||||
// tokens[1] = _quoteToken;
|
||||
|
||||
// IDODOV2(_UPCP_FACTORY_).initCrowdPooling(
|
||||
// newUpCrowdPooling,
|
||||
// msg.sender,
|
||||
// tokens,
|
||||
// timeLine,
|
||||
// valueList,
|
||||
// switches
|
||||
// );
|
||||
// }
|
||||
|
||||
//============ CrowdPooling Functions (create) ============
|
||||
|
||||
function createCrowdPooling(
|
||||
@@ -158,6 +114,7 @@ contract DODOCpProxy is ReentrancyGuard {
|
||||
) internal {
|
||||
if (isETH) {
|
||||
if (amount > 0) {
|
||||
require(msg.value == amount, "ETH_VALUE_WRONG");
|
||||
IWETH(_WETH_).deposit{value: amount}();
|
||||
if (to != address(this)) SafeERC20.safeTransfer(IERC20(_WETH_), to, amount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user