add crowdpooling factory and proxy

This commit is contained in:
owen05
2020-12-14 01:22:30 +08:00
parent aa70e54f56
commit f5ceb29843
7 changed files with 248 additions and 6 deletions

View File

@@ -33,6 +33,7 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard, Ownable {
address public immutable _DODO_SELL_HELPER_;
address public immutable _DVM_FACTORY_;
address public immutable _DPP_FACTORY_;
address public immutable _CP_FACTORY_;
mapping (address => bool) public isWhiteListed;
// ============ Events ============
@@ -59,12 +60,14 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard, Ownable {
constructor(
address dvmFactory,
address dppFactory,
address cpFactory,
address payable weth,
address dodoApprove,
address dodoSellHelper
) public {
_DVM_FACTORY_ = dvmFactory;
_DPP_FACTORY_ = dppFactory;
_CP_FACTORY_ = cpFactory;
_WETH_ = weth;
_DODO_APPROVE_ = dodoApprove;
_DODO_SELL_HELPER_ = dodoSellHelper;
@@ -551,6 +554,51 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard, Ownable {
return 0;
}
//============ CrowdPooling Functions (create & bid) ============
function createCrowdPooling(
address baseToken,
address quoteToken,
uint256 baseInAmount,
uint256[] memory timeLine,
uint256[] memory valueList,
uint256 deadLine
) external override judgeExpired(deadLine) returns (address newCrowdPooling) {
address _baseToken = baseToken;
address _quoteToken = quoteToken == _ETH_ADDRESS_ ? _WETH_ : quoteToken;
newCrowdPooling = IDODOV2(_CP_FACTORY_).createCrowdPooling();
_deposit(
msg.sender,
newCrowdPooling,
_baseToken,
baseInAmount,
false
);
IDODOV2(_CP_FACTORY_).initCrowdPooling(
newCrowdPooling,
msg.sender,
_baseToken,
_quoteToken,
timeLine,
valueList
);
}
function bid(
address assetTo,
address cpAddress,
uint256 quoteAmount,
uint8 flag, // 0 - ERC20, 1 - quoteInETH
uint256 deadLine
) external override payable judgeExpired(deadLine) {
_deposit(msg.sender, cpAddress, IDODOV2(cpAddress)._QUOTE_TOKEN_(), quoteAmount, flag == 1);
IDODOV2(cpAddress).bid(assetTo);
}
function addLiquidityToV1(
address to,

View File

@@ -63,4 +63,19 @@ interface IDODOV2 {
uint256 baseOutAmount,
uint256 quoteOutAmount
) external;
//========== CrowdPooling ===========
function createCrowdPooling() external returns (address newCrowdPooling);
function initCrowdPooling(
address cpAddress,
address creator,
address baseToken,
address quoteToken,
uint256[] memory timeLine,
uint256[] memory valueList
) external;
function bid(address to) external;
}

View File

@@ -98,6 +98,23 @@ interface IDODOV2Proxy01 is IDODOV1Proxy01 {
uint256 deadLine
) external payable;
function createCrowdPooling(
address baseToken,
address quoteToken,
uint256 baseInAmount,
uint256[] memory timeLine,
uint256[] memory valueList,
uint256 deadLine
) external returns (address newCrowdPooling);
function bid(
address assetTo,
address cpAddress,
uint256 quoteAmount,
uint8 flag, // 0 - ERC20, 1 - quoteInETH
uint256 deadLine
) external payable;
function addLiquidityToV1(
address to,
address pair,