第二遍走查 snapshot
This commit is contained in:
@@ -27,20 +27,17 @@ import {PMMPricing} from "../../lib/PMMPricing.sol";
|
||||
contract DPPStorage is InitializableOwnable, ReentrancyGuard {
|
||||
using SafeMath for uint256;
|
||||
|
||||
// ============ Variables for Control ============
|
||||
|
||||
IExternalValue public _GAS_PRICE_LIMIT_;
|
||||
|
||||
// ============ Advanced Controls ============
|
||||
|
||||
bool public _BUYING_CLOSE_;
|
||||
bool public _SELLING_CLOSE_;
|
||||
|
||||
IPermissionManager public _TRADE_PERMISSION_;
|
||||
IExternalValue public _GAS_PRICE_LIMIT_;
|
||||
|
||||
// ============ Core Address ============
|
||||
|
||||
address public _MAINTAINER_; // collect maintainer fee
|
||||
address public _MAINTAINER_;
|
||||
|
||||
IERC20 public _BASE_TOKEN_;
|
||||
IERC20 public _QUOTE_TOKEN_;
|
||||
@@ -58,41 +55,72 @@ contract DPPStorage is InitializableOwnable, ReentrancyGuard {
|
||||
IExternalValue public _K_;
|
||||
IExternalValue public _I_;
|
||||
|
||||
// ============ Events ============
|
||||
|
||||
event SetLpFeeRateModel(address indexed oldAddr, address indexed newAddr);
|
||||
|
||||
event SetMtFeeRateModel(address indexed oldAddr, address indexed newAddr);
|
||||
|
||||
event SetTradePermissionManager(address indexed oldAddr, address indexed newAddr);
|
||||
|
||||
event SetMaintainer(address indexed oldAddr, address indexed newAddr);
|
||||
|
||||
event SetGasPriceSource(address indexed oldAddr, address indexed newAddr);
|
||||
|
||||
event SetISource(address indexed oldAddr, address indexed newAddr);
|
||||
|
||||
event SetKSource(address indexed oldAddr, address indexed newAddr);
|
||||
|
||||
event SetBuy(bool allow);
|
||||
|
||||
event SetSell(bool allow);
|
||||
|
||||
// ============ Setting Functions ============
|
||||
|
||||
function setLpFeeRateModel(address newLpFeeRateModel) external onlyOwner {
|
||||
emit SetLpFeeRateModel(address(_LP_FEE_RATE_MODEL_), newLpFeeRateModel);
|
||||
_LP_FEE_RATE_MODEL_ = IFeeRateModel(newLpFeeRateModel);
|
||||
}
|
||||
|
||||
function setMtFeeRateModel(address newMtFeeRateModel) external onlyOwner {
|
||||
emit SetMtFeeRateModel(address(_MT_FEE_RATE_MODEL_), newMtFeeRateModel);
|
||||
_MT_FEE_RATE_MODEL_ = IFeeRateModel(newMtFeeRateModel);
|
||||
}
|
||||
|
||||
function setTradePermissionManager(address newTradePermissionManager) external onlyOwner {
|
||||
emit SetTradePermissionManager(address(_TRADE_PERMISSION_), newTradePermissionManager);
|
||||
_TRADE_PERMISSION_ = IPermissionManager(newTradePermissionManager);
|
||||
}
|
||||
|
||||
function setMaintainer(address newMaintainer) external onlyOwner {
|
||||
emit SetMaintainer(address(_MAINTAINER_), newMaintainer);
|
||||
_MAINTAINER_ = newMaintainer;
|
||||
}
|
||||
|
||||
function setGasPriceSource(address newGasPriceLimitSource) external onlyOwner {
|
||||
emit SetGasPriceSource(address(_GAS_PRICE_LIMIT_), newGasPriceLimitSource);
|
||||
_GAS_PRICE_LIMIT_ = IExternalValue(newGasPriceLimitSource);
|
||||
}
|
||||
|
||||
function setISource(address newISource) external onlyOwner {
|
||||
emit SetISource(address(_I_), newISource);
|
||||
_I_ = IExternalValue(newISource);
|
||||
_checkIK();
|
||||
}
|
||||
|
||||
function setKSource(address newKSource) external onlyOwner {
|
||||
emit SetKSource(address(_K_), newKSource);
|
||||
_K_ = IExternalValue(newKSource);
|
||||
_checkIK();
|
||||
}
|
||||
|
||||
function setBuy(bool open) external onlyOwner {
|
||||
emit SetBuy(open);
|
||||
_BUYING_CLOSE_ = !open;
|
||||
}
|
||||
|
||||
function setSell(bool open) external onlyOwner {
|
||||
emit SetSell(open);
|
||||
_SELLING_CLOSE_ = !open;
|
||||
}
|
||||
|
||||
@@ -102,14 +130,4 @@ contract DPPStorage is InitializableOwnable, ReentrancyGuard {
|
||||
require(k > 0 && k <= 1e18, "K_OUT_OF_RANGE");
|
||||
require(i > 0 && i <= 1e36, "I_OUT_OF_RANGE");
|
||||
}
|
||||
|
||||
// ============ View Functions ============
|
||||
|
||||
function getLpFeeRate(address trader) external view returns (uint256 feeRate) {
|
||||
return _LP_FEE_RATE_MODEL_.getFeeRate(trader);
|
||||
}
|
||||
|
||||
function getMtFeeRate(address trader) external view returns (uint256 feeRate) {
|
||||
return _MT_FEE_RATE_MODEL_.getFeeRate(trader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,6 @@ contract DPPVault is DPPStorage {
|
||||
|
||||
// ============ Get Input ============
|
||||
|
||||
function getInput() public view returns (uint256 baseInput, uint256 quoteInput) {
|
||||
return (
|
||||
_BASE_TOKEN_.balanceOf(address(this)).sub(_BASE_RESERVE_),
|
||||
_QUOTE_TOKEN_.balanceOf(address(this)).sub(_QUOTE_RESERVE_)
|
||||
);
|
||||
}
|
||||
|
||||
function getBaseInput() public view returns (uint256 input) {
|
||||
return _BASE_TOKEN_.balanceOf(address(this)).sub(_BASE_RESERVE_);
|
||||
}
|
||||
@@ -38,11 +31,6 @@ contract DPPVault is DPPStorage {
|
||||
return _QUOTE_TOKEN_.balanceOf(address(this)).sub(_QUOTE_RESERVE_);
|
||||
}
|
||||
|
||||
// ============ Vault Related
|
||||
function getVaultReserve() public view returns (uint256 baseReserve, uint256 quoteReserve) {
|
||||
return (_BASE_RESERVE_, _QUOTE_RESERVE_);
|
||||
}
|
||||
|
||||
// ============ Set States ============
|
||||
|
||||
function setTarget(uint256 baseTarget, uint256 quoteTarget) public preventReentrant onlyOwner {
|
||||
@@ -90,7 +78,7 @@ contract DPPVault is DPPStorage {
|
||||
}
|
||||
}
|
||||
|
||||
// ============ Assets Transfer ============
|
||||
// ============ Asset Out ============
|
||||
|
||||
function _transferBaseOut(address to, uint256 amount) internal {
|
||||
if (amount > 0) {
|
||||
|
||||
Reference in New Issue
Block a user