Merge branch 'feature/V2' of github.com:DODOEX/contractV2 into feature/V2
This commit is contained in:
@@ -11,8 +11,11 @@ pragma experimental ABIEncoderV2;
|
||||
import {Ownable} from "../lib/Ownable.sol";
|
||||
import {ICloneFactory} from "../lib/CloneFactory.sol";
|
||||
import {ICP} from "../CrowdPooling/intf/ICP.sol";
|
||||
import {SafeMath} from "../lib/SafeMath.sol";
|
||||
import {IERC20} from "../intf/IERC20.sol";
|
||||
|
||||
contract CrowdPoolingFactory {
|
||||
contract CrowdPoolingFactory is Ownable {
|
||||
using SafeMath for uint256;
|
||||
// ============ Templates ============
|
||||
|
||||
address public immutable _CLONE_FACTORY_;
|
||||
@@ -25,6 +28,8 @@ contract CrowdPoolingFactory {
|
||||
address public immutable _DEFAULT_PERMISSION_MANAGER_;
|
||||
address public immutable _DEFAULT_GAS_PRICE_SOURCE_;
|
||||
|
||||
uint256 public _X_;
|
||||
uint256 public _Y_;
|
||||
// ============ Registry ============
|
||||
|
||||
// base -> quote -> CP address list
|
||||
@@ -32,6 +37,24 @@ contract CrowdPoolingFactory {
|
||||
// creator -> CP address list
|
||||
mapping(address => address[]) public _USER_REGISTRY_;
|
||||
|
||||
// ============ modifiers ===========
|
||||
modifier valueCheck(
|
||||
address cpAddress,
|
||||
address baseToken,
|
||||
uint256[] memory timeLine,
|
||||
uint256[] memory valueList)
|
||||
{
|
||||
require(timeLine[2] == 0,"phase calm duration should be 0");
|
||||
require(timeLine[4] == 0,"vesting duration should be 0");
|
||||
require(valueList[1] == 0,"k should be 0");
|
||||
require(valueList[3] == 1,"cliff rate should be 1");
|
||||
|
||||
uint256 baseTokenBalance = IERC20(baseToken).balanceOf(cpAddress);
|
||||
require(valueList[0].mul(100) <= baseTokenBalance.mul(_X_),"pool quote cap should not be greater than _X_% ");
|
||||
require(timeLine[3]>= _Y_,"freeze duration should not be less than _Y_");
|
||||
_;
|
||||
}
|
||||
|
||||
// ============ Events ============
|
||||
|
||||
event NewCP(
|
||||
@@ -61,6 +84,8 @@ contract CrowdPoolingFactory {
|
||||
_DEFAULT_MT_FEE_RATE_MODEL_ = defaultMtFeeRateModel;
|
||||
_DEFAULT_PERMISSION_MANAGER_ = defaultPermissionManager;
|
||||
_DEFAULT_GAS_PRICE_SOURCE_ = defaultGasPriceSource;
|
||||
_X_ = 50;
|
||||
_Y_ = 30 days;
|
||||
}
|
||||
|
||||
function createCrowdPooling() external returns (address newCrowdPooling) {
|
||||
@@ -74,7 +99,7 @@ contract CrowdPoolingFactory {
|
||||
address quoteToken,
|
||||
uint256[] memory timeLine,
|
||||
uint256[] memory valueList
|
||||
) external {
|
||||
) external valueCheck(cpAddress,baseToken,timeLine,valueList) {
|
||||
{
|
||||
address[] memory addressList = new address[](7);
|
||||
addressList[0] = creator;
|
||||
@@ -84,7 +109,7 @@ contract CrowdPoolingFactory {
|
||||
addressList[4] = _DEFAULT_PERMISSION_MANAGER_;
|
||||
addressList[5] = _DEFAULT_MT_FEE_RATE_MODEL_;
|
||||
addressList[6] = _UNOWNED_DVM_FACTORY_;
|
||||
|
||||
|
||||
ICP(cpAddress).init(
|
||||
addressList,
|
||||
timeLine,
|
||||
@@ -123,4 +148,11 @@ contract CrowdPoolingFactory {
|
||||
{
|
||||
return _USER_REGISTRY_[user];
|
||||
}
|
||||
|
||||
// ============ Owner Functions ============
|
||||
function setXY(uint256 x,uint256 y) public onlyOwner {
|
||||
require(x>0&&x<=100,"between 0,100");
|
||||
_X_=x;
|
||||
_Y_=y;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"ethjs": "^0.4.0",
|
||||
"lodash": "^4.17.20",
|
||||
"mocha": "^7.2.0",
|
||||
"solc": "0.6.9",
|
||||
"solc": "^0.6.9",
|
||||
"truffle-hdwallet-provider": "^1.0.17",
|
||||
"ts-node": "^8.10.2",
|
||||
"typescript": "^3.9.5",
|
||||
|
||||
Reference in New Issue
Block a user