Files
dodo-contractV2/contracts/DODOPrivatePool/impl/DPPOracle/DPPOracleAdmin.sol

136 lines
3.4 KiB
Solidity
Raw Normal View History

2021-03-01 21:13:33 +08:00
/*
2021-06-15 16:42:16 +08:00
Copyright 2021 DODO ZOO.
2021-03-01 21:13:33 +08:00
SPDX-License-Identifier: Apache-2.0
*/
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
2021-06-15 16:42:16 +08:00
import {IDPPOracle} from "../../intf/IDPPOracle.sol";
import {IDODOApproveProxy} from "../../../SmartRoute/DODOApproveProxy.sol";
import {InitializableOwnable} from "../../../lib/InitializableOwnable.sol";
2021-03-01 21:13:33 +08:00
/**
2021-06-15 16:42:16 +08:00
* @title DPPOracleAdmin
2021-03-01 21:13:33 +08:00
* @author DODO Breeder
*
2021-06-15 16:42:16 +08:00
* @notice Admin of Oracle DODOPrivatePool
2021-03-01 21:13:33 +08:00
*/
2021-06-15 16:42:16 +08:00
contract DPPOracleAdmin is InitializableOwnable {
2021-03-01 21:13:33 +08:00
address public _DPP_;
address public _OPERATOR_;
address public _DODO_APPROVE_PROXY_;
uint256 public _FREEZE_TIMESTAMP_;
modifier notFreezed() {
require(block.timestamp >= _FREEZE_TIMESTAMP_, "ADMIN_FREEZED");
_;
}
function init(
address owner,
address dpp,
address operator,
address dodoApproveProxy
) external {
initOwner(owner);
_DPP_ = dpp;
_OPERATOR_ = operator;
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
}
function sync() external notFreezed onlyOwner {
2021-06-15 16:42:16 +08:00
IDPPOracle(_DPP_).ratioSync();
2021-03-01 21:13:33 +08:00
}
function setFreezeTimestamp(uint256 timestamp) external notFreezed onlyOwner {
_FREEZE_TIMESTAMP_ = timestamp;
}
function setOperator(address newOperator) external notFreezed onlyOwner {
_OPERATOR_ = newOperator;
}
function retrieve(
address payable to,
address token,
uint256 amount
) external notFreezed onlyOwner {
2021-06-15 16:42:16 +08:00
IDPPOracle(_DPP_).retrieve(to, token, amount);
2021-03-01 21:13:33 +08:00
}
2022-06-27 10:32:27 +08:00
function changeOracle(address newOracle) external onlyOwner notFreezed {
2022-06-22 14:18:37 +08:00
IDPPOracle(_DPP_).changeOracle(newOracle);
}
2022-06-27 10:32:27 +08:00
function enableOracle() external onlyOwner notFreezed {
IDPPOracle(_DPP_).enableOracle();
}
2022-06-27 10:32:27 +08:00
function disableOracle(uint256 newI) external onlyOwner notFreezed {
IDPPOracle(_DPP_).disableOracle(newI);
2022-06-22 14:18:37 +08:00
}
2021-03-01 21:13:33 +08:00
function tuneParameters(
uint256 newLpFeeRate,
2022-06-22 14:18:37 +08:00
uint256 newI,
2021-03-01 21:13:33 +08:00
uint256 newK,
uint256 minBaseReserve,
uint256 minQuoteReserve
2022-06-27 10:32:27 +08:00
) external onlyOwner notFreezed returns (bool) {
2021-03-01 21:13:33 +08:00
return
2021-06-15 16:42:16 +08:00
IDPPOracle(_DPP_).tuneParameters(
2021-03-01 21:13:33 +08:00
newLpFeeRate,
2022-06-22 14:18:37 +08:00
newI,
2021-03-01 21:13:33 +08:00
newK,
minBaseReserve,
minQuoteReserve
);
}
2022-06-22 14:18:37 +08:00
function tunePrice(
uint256 newI,
uint256 minBaseReserve,
uint256 minQuoteReserve
2022-06-27 10:32:27 +08:00
) external onlyOwner notFreezed returns (bool) {
2022-06-22 14:18:37 +08:00
return
IDPPOracle(_DPP_).tunePrice(
newI,
minBaseReserve,
minQuoteReserve
);
}
2021-03-01 21:13:33 +08:00
function reset(
uint256 newLpFeeRate,
2022-06-22 14:18:37 +08:00
uint256 newI,
2021-03-01 21:13:33 +08:00
uint256 newK,
uint256 baseOutAmount,
uint256 quoteOutAmount,
uint256 minBaseReserve,
uint256 minQuoteReserve
2022-06-27 10:32:27 +08:00
) external onlyOwner notFreezed returns (bool) {
2021-03-01 21:13:33 +08:00
return
2021-06-15 16:42:16 +08:00
IDPPOracle(_DPP_).reset(
_OWNER_, //only support asset transfer out to owner
2021-03-01 21:13:33 +08:00
newLpFeeRate,
2022-06-22 14:18:37 +08:00
newI,
2021-03-01 21:13:33 +08:00
newK,
baseOutAmount,
quoteOutAmount,
minBaseReserve,
minQuoteReserve
);
}
// ============ Admin Version Control ============
function version() external pure returns (string memory) {
2022-06-22 14:18:37 +08:00
return "DPPOracle Admin 1.1.0";
2021-03-01 21:13:33 +08:00
}
}