update starter
This commit is contained in:
@@ -38,8 +38,6 @@ contract UpCrowdPoolingFactory is InitializableOwnable {
|
||||
uint256 public _VEST_DURATION_ = 0;
|
||||
uint256 public _CLIFF_RATE_ = 10**18;
|
||||
|
||||
mapping(address => address) liquidityProtectWhitelist;
|
||||
|
||||
// ============ Registry ============
|
||||
|
||||
// base -> quote -> CP address list
|
||||
@@ -50,19 +48,12 @@ contract UpCrowdPoolingFactory is InitializableOwnable {
|
||||
// ============ modifiers ===========
|
||||
|
||||
modifier valueCheck(
|
||||
address creator,
|
||||
address cpAddress,
|
||||
address baseToken,
|
||||
uint256[] memory timeLine,
|
||||
uint256[] memory valueList)
|
||||
{
|
||||
require(timeLine[2] <= _CALM_DURATION_, "CP_FACTORY : PHASE_CALM_DURATION_INVALID");
|
||||
require(timeLine[4] == _VEST_DURATION_, "CP_FACTORY : VEST_DURATION_INVALID");
|
||||
require(valueList[3] == _CLIFF_RATE_, "CP_FACTORY : CLIFF_RATE_INVALID");
|
||||
|
||||
if(liquidityProtectWhitelist[creator] != baseToken) {
|
||||
require(timeLine[3]>= _FREEZE_DURATION_, "CP_FACTORY : FREEZE_DURATION_INVALID");
|
||||
}
|
||||
_;
|
||||
}
|
||||
|
||||
@@ -75,6 +66,8 @@ contract UpCrowdPoolingFactory is InitializableOwnable {
|
||||
address cp
|
||||
);
|
||||
|
||||
event RemoveCP(address cp);
|
||||
|
||||
constructor(
|
||||
address cloneFactory,
|
||||
address cpTemplate,
|
||||
@@ -104,7 +97,7 @@ contract UpCrowdPoolingFactory is InitializableOwnable {
|
||||
uint256[] memory timeLine,
|
||||
uint256[] memory valueList,
|
||||
bool[] memory switches
|
||||
) external valueCheck(creator,cpAddress,tokens[0],timeLine,valueList) {
|
||||
) external valueCheck(timeLine,valueList) {
|
||||
{
|
||||
address[] memory addressList = new address[](7);
|
||||
addressList[0] = creator;
|
||||
@@ -158,10 +151,6 @@ contract UpCrowdPoolingFactory is InitializableOwnable {
|
||||
}
|
||||
|
||||
// ============ Owner Functions ============
|
||||
|
||||
function setLiquidityProtectWhitelist(address creator, address baseToken) external onlyOwner {
|
||||
liquidityProtectWhitelist[creator] = baseToken;
|
||||
}
|
||||
|
||||
function updateCPTemplate(address _newCPTemplate) external onlyOwner {
|
||||
_CP_TEMPLATE_ = _newCPTemplate;
|
||||
@@ -187,4 +176,31 @@ contract UpCrowdPoolingFactory is InitializableOwnable {
|
||||
require(_newCliffRate <= 10**18, "CP_FACTORY : INVALID");
|
||||
_CLIFF_RATE_ = _newCliffRate;
|
||||
}
|
||||
|
||||
function removePoolByAdmin(
|
||||
address creator,
|
||||
address baseToken,
|
||||
address quoteToken,
|
||||
address pool
|
||||
) external onlyOwner {
|
||||
address[] memory registryList = _REGISTRY_[baseToken][quoteToken];
|
||||
for (uint256 i = 0; i < registryList.length; i++) {
|
||||
if (registryList[i] == pool) {
|
||||
registryList[i] = registryList[registryList.length - 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
_REGISTRY_[baseToken][quoteToken] = registryList;
|
||||
_REGISTRY_[baseToken][quoteToken].pop();
|
||||
address[] memory userRegistryList = _USER_REGISTRY_[creator];
|
||||
for (uint256 i = 0; i < userRegistryList.length; i++) {
|
||||
if (userRegistryList[i] == pool) {
|
||||
userRegistryList[i] = userRegistryList[userRegistryList.length - 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
_USER_REGISTRY_[creator] = userRegistryList;
|
||||
_USER_REGISTRY_[creator].pop();
|
||||
emit RemoveCP(pool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ module.exports = {
|
||||
DSP: "0xe2C23cBF03930418BF97e173FE3E950aD29fdb06",
|
||||
DPPAdmin: "0x2FF619B4Cfe36b0F92dD933256B1581a3269a5F4",
|
||||
CP: "0xce1560Ab8F39918F440C5B4b6B2b95A137F84013",
|
||||
CPV2: "0x57871352eeA098E476fD8718eB89e25fDc7bb11e",
|
||||
ERC20MineV3: "0xd5Bbb5497d0503a8d0CB5A9410EcFfF840Fe0012",
|
||||
ERC20: "0x7119D1Ec8235bd0a82289fDb1cCAa4bD4D1e0605",
|
||||
CustomERC20: "0xBcCd9698CF3Be0b37d227406699aEaa3D6C413A1",
|
||||
@@ -33,6 +34,7 @@ module.exports = {
|
||||
DPPFactory: "0x510b49803E356C750f3a93bA5508C0FFD9f71bDD",
|
||||
DSPFactory: "0xa1ab675cB49BA0DC3F39fA4C20E216572A8dD3c8",
|
||||
CrowdPoolingFactory: "0x45CF2EB0DB78ad56450060557BC8D4F386F826cf",
|
||||
CrowdPoolingFactoryV2: "0x79e15fc9B4154d90424b588533AB277D30D573f4",
|
||||
UpCpFactory: "0x9DbbfFE2C5BA6c931C518199C861ff0b6067c2EB",
|
||||
ERC20Factory: "0x48476599281CB7DD46dbE47264C4594d1d2E19A8",
|
||||
ERC20V2Factory: "0x7A22e361cB74E69B5B1C800A3aAbE3E50e84F4F6",
|
||||
@@ -55,6 +57,7 @@ module.exports = {
|
||||
DODOV2Proxy: "0xba001E96AF87bF9d8D0BDA667067A9921FE6d294",
|
||||
DSPProxy: "0x0f6345D1d07C134BB0973AD102F38eA9195F6f78",
|
||||
CpProxy: "0xa2846A259a05b949DE6e3599eE5cFaA818199E9C",
|
||||
CpProxyV2: "0x3d5F3020Aa41b6de1f8e49777F4b708f016Dc65B",
|
||||
DPPProxy: "0x45136c2455Dd2631E31ab884cf167eC618CCf39a",
|
||||
RouteProxy: "0xe2b538a781eB5a115a1359B8f363B9703Fd19dE6",
|
||||
DODOMineV3Proxy: "0xcb15BBb59AC8a4B64A4db9B8d9F66c397d89Bd22",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ module.exports = {
|
||||
deploySwitch: {
|
||||
DEPLOY_V1: false,
|
||||
DEPLOY_V2: false,
|
||||
ERC20V3Factory: true,
|
||||
ERC20V3Factory: false,
|
||||
MOCK_TOKEN: false,
|
||||
MOCK_V2_POOL: false,
|
||||
vDODOToken: false,
|
||||
@@ -65,7 +65,8 @@ module.exports = {
|
||||
MYSTERYBOX_V1: false,
|
||||
Drops_V2: false,
|
||||
MineV3: false,
|
||||
NFT_POOL: false
|
||||
NFT_POOL: false,
|
||||
UserQuota: false
|
||||
},
|
||||
|
||||
networks: {
|
||||
@@ -123,7 +124,6 @@ module.exports = {
|
||||
},
|
||||
network_id: 56,
|
||||
confirmations: 10,
|
||||
gasPrice: 5000000000,
|
||||
timeoutBlocks: 200,
|
||||
gasPrice: 6000000000,
|
||||
skipDryRun: true
|
||||
|
||||
Reference in New Issue
Block a user