add global quota to cp init

This commit is contained in:
tracy
2022-04-21 16:27:46 +08:00
committed by owen05
parent e435578b3f
commit a1a51d9b5a
4 changed files with 34 additions and 4 deletions

View File

@@ -49,11 +49,16 @@ contract FeeRateDIP3Impl is InitializableOwnable {
mapping(address => CPPoolInfo) cpPools;
mapping(address => uint256) public specPoolList;
mapping (address => bool) public isAdminListed;
// ============ Events =============
event AddAdmin(address admin);
event RemoveAdmin(address admin);
// ============ Ownable Functions ============
function addCpPoolInfo(address cpPool, address quoteToken, int globalQuota, address feeAddr, address quotaAddr) external onlyOwner {
function addCpPoolInfo(address cpPool, address quoteToken, int globalQuota, address feeAddr, address quotaAddr) external {
require(isAdminListed[msg.sender], "ACCESS_DENIED");
CPPoolInfo memory cpPoolInfo = CPPoolInfo({
quoteToken: quoteToken,
feeAddr: feeAddr,
@@ -79,6 +84,16 @@ contract FeeRateDIP3Impl is InitializableOwnable {
specPoolList[poolAddr] = mtFeeRate;
}
function addAdminList (address userAddr) external onlyOwner {
isAdminListed[userAddr] = true;
emit AddAdmin(userAddr);
}
function removeAdminList (address userAddr) external onlyOwner {
isAdminListed[userAddr] = false;
emit RemoveAdmin(userAddr);
}
// ============ View Functions ============
function getFeeRate(address pool, address user) external view returns (uint256) {

View File

@@ -15,6 +15,11 @@ import {SafeMath} from "../lib/SafeMath.sol";
import {IERC20} from "../intf/IERC20.sol";
import {DecimalMath} from "../lib/DecimalMath.sol";
interface IFeeRateModel {
function getFeeRate(address trader) external view returns (uint256);
function addCpPoolInfo(address cpPool, address quoteToken, int globalQuota, address feeAddr, address quotaAddr) external;
}
/**
* @title CrowdPoolingFacotry
* @author DODO Breeder
@@ -106,7 +111,8 @@ contract CrowdPoolingFactory is InitializableOwnable {
address[] memory tokens,//0 baseToken 1 quoteToken
uint256[] memory timeLine,
uint256[] memory valueList,
bool[] memory switches
bool[] memory switches,
int globalQuota
) external valueCheck(cpAddress,tokens[0],timeLine,valueList) {
{
address[] memory addressList = new address[](7);
@@ -124,6 +130,8 @@ contract CrowdPoolingFactory is InitializableOwnable {
valueList,
switches
);
IFeeRateModel(_DEFAULT_MT_FEE_RATE_MODEL_).addCpPoolInfo(cpAddress, tokens[1], globalQuota, address(0), address(0));
}
_REGISTRY_[tokens[0]][tokens[1]].push(cpAddress);

View File

@@ -61,7 +61,8 @@ contract DODOCpProxy is ReentrancyGuard {
uint256[] memory timeLine,
uint256[] memory valueList,
bool[] memory switches,
uint256 deadLine
uint256 deadLine,
int globalQuota
) external payable preventReentrant judgeExpired(deadLine) returns (address payable newCrowdPooling) {
address _baseToken = baseToken;
address _quoteToken = quoteToken == _ETH_ADDRESS_ ? _WETH_ : quoteToken;
@@ -89,7 +90,8 @@ contract DODOCpProxy is ReentrancyGuard {
tokens,
timeLine,
valueList,
switches
switches,
globalQuota
);
}

View File

@@ -12,6 +12,7 @@ import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
interface IFeeRateImpl {
function getFeeRate(address pool, address trader) external view returns (uint256);
function addCpPoolInfo(address cpPool, address quoteToken, int globalQuota, address feeAddr, address quotaAddr) external;
}
interface IFeeRateModel {
@@ -30,4 +31,8 @@ contract FeeRateModel is InitializableOwnable {
return 0;
return IFeeRateImpl(feeRateImpl).getFeeRate(msg.sender,trader);
}
function addCpPoolInfo(address cpPool, address quoteToken, int globalQuota, address feeAddr, address quotaAddr) external {
IFeeRateImpl(feeRateImpl).addCpPoolInfo(cpPool, quoteToken, globalQuota, feeAddr, quotaAddr);
}
}