89 lines
2.2 KiB
Solidity
89 lines
2.2 KiB
Solidity
/*
|
|
|
|
Copyright 2020 DODO ZOO.
|
|
SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
pragma solidity 0.6.9;
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
|
|
import {SafeMath} from "../../lib/SafeMath.sol";
|
|
import {DecimalMath} from "../../lib/DecimalMath.sol";
|
|
import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
|
|
import {IFeeRateModel} from "../../lib/FeeRateModel.sol";
|
|
import {IERC20} from "../../intf/IERC20.sol";
|
|
import {PMMPricing} from "../../lib/PMMPricing.sol";
|
|
|
|
contract DPPStorage is InitializableOwnable, ReentrancyGuard {
|
|
using SafeMath for uint256;
|
|
|
|
bool public _IS_OPEN_TWAP_ = false;
|
|
|
|
// ============ Core Address ============
|
|
|
|
address public _MAINTAINER_;
|
|
|
|
IERC20 public _BASE_TOKEN_;
|
|
IERC20 public _QUOTE_TOKEN_;
|
|
|
|
uint112 public _BASE_RESERVE_;
|
|
uint112 public _QUOTE_RESERVE_;
|
|
uint32 public _BLOCK_TIMESTAMP_LAST_;
|
|
|
|
uint112 public _BASE_TARGET_;
|
|
uint112 public _QUOTE_TARGET_;
|
|
uint32 public _RState_;
|
|
|
|
uint256 public _BASE_PRICE_CUMULATIVE_LAST_;
|
|
|
|
// ============ Variables for Pricing ============
|
|
|
|
IFeeRateModel public _MT_FEE_RATE_MODEL_;
|
|
|
|
uint64 public _LP_FEE_RATE_;
|
|
uint64 public _K_;
|
|
uint128 public _I_;
|
|
|
|
// ============ Helper Functions ============
|
|
|
|
function getPMMState() public view returns (PMMPricing.PMMState memory state) {
|
|
state.i = _I_;
|
|
state.K = _K_;
|
|
state.B = _BASE_RESERVE_;
|
|
state.Q = _QUOTE_RESERVE_;
|
|
state.B0 = _BASE_TARGET_;
|
|
state.Q0 = _QUOTE_TARGET_;
|
|
state.R = PMMPricing.RState(_RState_);
|
|
PMMPricing.adjustedTarget(state);
|
|
}
|
|
|
|
function getPMMStateForCall()
|
|
external
|
|
view
|
|
returns (
|
|
uint256 i,
|
|
uint256 K,
|
|
uint256 B,
|
|
uint256 Q,
|
|
uint256 B0,
|
|
uint256 Q0,
|
|
uint256 R
|
|
)
|
|
{
|
|
PMMPricing.PMMState memory state = getPMMState();
|
|
i = state.i;
|
|
K = state.K;
|
|
B = state.B;
|
|
Q = state.Q;
|
|
B0 = state.B0;
|
|
Q0 = state.Q0;
|
|
R = uint256(state.R);
|
|
}
|
|
|
|
function getMidPrice() public view returns (uint256 midPrice) {
|
|
return PMMPricing.getMidPrice(getPMMState());
|
|
}
|
|
}
|