add global quota to cp init
This commit is contained in:
@@ -49,11 +49,16 @@ contract FeeRateDIP3Impl is InitializableOwnable {
|
|||||||
|
|
||||||
mapping(address => CPPoolInfo) cpPools;
|
mapping(address => CPPoolInfo) cpPools;
|
||||||
mapping(address => uint256) public specPoolList;
|
mapping(address => uint256) public specPoolList;
|
||||||
|
mapping (address => bool) public isAdminListed;
|
||||||
|
|
||||||
|
// ============ Events =============
|
||||||
|
event AddAdmin(address admin);
|
||||||
|
event RemoveAdmin(address admin);
|
||||||
|
|
||||||
// ============ Ownable Functions ============
|
// ============ 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({
|
CPPoolInfo memory cpPoolInfo = CPPoolInfo({
|
||||||
quoteToken: quoteToken,
|
quoteToken: quoteToken,
|
||||||
feeAddr: feeAddr,
|
feeAddr: feeAddr,
|
||||||
@@ -79,6 +84,16 @@ contract FeeRateDIP3Impl is InitializableOwnable {
|
|||||||
specPoolList[poolAddr] = mtFeeRate;
|
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 ============
|
// ============ View Functions ============
|
||||||
|
|
||||||
function getFeeRate(address pool, address user) external view returns (uint256) {
|
function getFeeRate(address pool, address user) external view returns (uint256) {
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ import {SafeMath} from "../lib/SafeMath.sol";
|
|||||||
import {IERC20} from "../intf/IERC20.sol";
|
import {IERC20} from "../intf/IERC20.sol";
|
||||||
import {DecimalMath} from "../lib/DecimalMath.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
|
* @title CrowdPoolingFacotry
|
||||||
* @author DODO Breeder
|
* @author DODO Breeder
|
||||||
@@ -106,7 +111,8 @@ contract CrowdPoolingFactory is InitializableOwnable {
|
|||||||
address[] memory tokens,//0 baseToken 1 quoteToken
|
address[] memory tokens,//0 baseToken 1 quoteToken
|
||||||
uint256[] memory timeLine,
|
uint256[] memory timeLine,
|
||||||
uint256[] memory valueList,
|
uint256[] memory valueList,
|
||||||
bool[] memory switches
|
bool[] memory switches,
|
||||||
|
int globalQuota
|
||||||
) external valueCheck(cpAddress,tokens[0],timeLine,valueList) {
|
) external valueCheck(cpAddress,tokens[0],timeLine,valueList) {
|
||||||
{
|
{
|
||||||
address[] memory addressList = new address[](7);
|
address[] memory addressList = new address[](7);
|
||||||
@@ -124,6 +130,8 @@ contract CrowdPoolingFactory is InitializableOwnable {
|
|||||||
valueList,
|
valueList,
|
||||||
switches
|
switches
|
||||||
);
|
);
|
||||||
|
|
||||||
|
IFeeRateModel(_DEFAULT_MT_FEE_RATE_MODEL_).addCpPoolInfo(cpAddress, tokens[1], globalQuota, address(0), address(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
_REGISTRY_[tokens[0]][tokens[1]].push(cpAddress);
|
_REGISTRY_[tokens[0]][tokens[1]].push(cpAddress);
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ contract DODOCpProxy is ReentrancyGuard {
|
|||||||
uint256[] memory timeLine,
|
uint256[] memory timeLine,
|
||||||
uint256[] memory valueList,
|
uint256[] memory valueList,
|
||||||
bool[] memory switches,
|
bool[] memory switches,
|
||||||
uint256 deadLine
|
uint256 deadLine,
|
||||||
|
int globalQuota
|
||||||
) external payable preventReentrant judgeExpired(deadLine) returns (address payable newCrowdPooling) {
|
) external payable preventReentrant judgeExpired(deadLine) returns (address payable newCrowdPooling) {
|
||||||
address _baseToken = baseToken;
|
address _baseToken = baseToken;
|
||||||
address _quoteToken = quoteToken == _ETH_ADDRESS_ ? _WETH_ : quoteToken;
|
address _quoteToken = quoteToken == _ETH_ADDRESS_ ? _WETH_ : quoteToken;
|
||||||
@@ -89,7 +90,8 @@ contract DODOCpProxy is ReentrancyGuard {
|
|||||||
tokens,
|
tokens,
|
||||||
timeLine,
|
timeLine,
|
||||||
valueList,
|
valueList,
|
||||||
switches
|
switches,
|
||||||
|
globalQuota
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
|
|||||||
|
|
||||||
interface IFeeRateImpl {
|
interface IFeeRateImpl {
|
||||||
function getFeeRate(address pool, address trader) external view returns (uint256);
|
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 {
|
interface IFeeRateModel {
|
||||||
@@ -30,4 +31,8 @@ contract FeeRateModel is InitializableOwnable {
|
|||||||
return 0;
|
return 0;
|
||||||
return IFeeRateImpl(feeRateImpl).getFeeRate(msg.sender,trader);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user