add dvm && dpp admin control

This commit is contained in:
owen05
2020-11-24 17:25:10 +08:00
parent 5e6db3e4b6
commit 8a4da4b525
17 changed files with 253 additions and 41 deletions

View File

@@ -17,6 +17,10 @@ import {DVMFunding} from "./DVMFunding.sol";
import {DVMVault} from "./DVMVault.sol";
contract DVM is DVMTrader, DVMFunding {
constructor() public {
_FACTORY_ = msg.sender;
}
function init(
address owner,
address maintainer,
@@ -29,7 +33,9 @@ contract DVM is DVMTrader, DVMFunding {
uint256 i,
uint256 k
) external {
require(msg.sender == _FACTORY_, 'INIT FORBIDDEN');
initOwner(owner);
_ADMIN_ = owner;
_BASE_TOKEN_ = IERC20(baseTokenAddress);
_QUOTE_TOKEN_ = IERC20(quoteTokenAddress);
_LP_FEE_RATE_MODEL_ = IFeeRateModel(lpFeeRateModel);

View File

@@ -0,0 +1,50 @@
/*
Copyright 2020 DODO ZOO.
SPDX-License-Identifier: Apache-2.0
*/
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
import {IDVM} from "../intf/IDVM.sol";
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
contract DVMAdmin is InitializableOwnable {
address public dvm;
function init(address owner, address _dvm) external {
initOwner(owner);
dvm = _dvm;
}
function setLpFeeRateModel(address newLpFeeRateModel) external onlyOwner {
IDVM(dvm).setLpFeeRateModel(newLpFeeRateModel);
}
function setMtFeeRateModel(address newMtFeeRateModel) external onlyOwner {
IDVM(dvm).setMtFeeRateModel(newMtFeeRateModel);
}
function setTradePermissionManager(address newTradePermissionManager) external onlyOwner {
IDVM(dvm).setTradePermissionManager(newTradePermissionManager);
}
function setMaintainer(address newMaintainer) external onlyOwner {
IDVM(dvm).setMaintainer(newMaintainer);
}
function setGasPriceSource(address newGasPriceLimitSource) external onlyOwner {
IDVM(dvm).setGasPriceSource(newGasPriceLimitSource);
}
function setBuy(bool open) external onlyOwner {
IDVM(dvm).setBuy(open);
}
function setSell(bool open) external onlyOwner {
IDVM(dvm).setSell(open);
}
}

View File

@@ -21,6 +21,9 @@ import {IERC20} from "../../intf/IERC20.sol";
contract DVMStorage is InitializableOwnable, ReentrancyGuard {
using SafeMath for uint256;
address public _FACTORY_;
address public _ADMIN_;
// ============ Variables for Control ============
IExternalValue public _GAS_PRICE_LIMIT_;

View File

@@ -33,4 +33,21 @@ interface IDVM {
function sellQuote(address to) external returns (uint256);
function buyShares(address to) external returns (uint256);
//=========== admin ==========
function setLpFeeRateModel(address newLpFeeRateModel) external;
function setMtFeeRateModel(address newMtFeeRateModel) external;
function setTradePermissionManager(address newTradePermissionManager) external;
function setMaintainer(address newMaintainer) external;
function setGasPriceSource(address newGasPriceLimitSource) external;
function setBuy(bool open) external;
function setSell(bool open) external;
//==============================
}

View File

@@ -0,0 +1,13 @@
/*
Copyright 2020 DODO ZOO.
SPDX-License-Identifier: Apache-2.0
*/
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
interface IDVMAdmin {
function init(address owner, address _dvm) external;
}