DPP trade test

This commit is contained in:
mingda
2020-11-26 13:22:22 +08:00
parent 6d8bd3646a
commit 61479dbf04
6 changed files with 223 additions and 17 deletions

View File

@@ -25,7 +25,6 @@ contract DPP is DPPTrader {
address kSource,
address iSource,
address gasPriceSource,
address dodoSmartApprove,
address tradePermissionManager
) external {
initOwner(owner);
@@ -38,7 +37,6 @@ contract DPP is DPPTrader {
_K_ = IExternalValue(kSource);
_GAS_PRICE_LIMIT_ = IExternalValue(gasPriceSource);
_TRADE_PERMISSION_ = IPermissionManager(tradePermissionManager);
_DODO_SMART_APPROVE_ = dodoSmartApprove;
_resetTargetAndReserve();
}

View File

@@ -27,8 +27,6 @@ import {PMMPricing} from "../../lib/PMMPricing.sol";
contract DPPStorage is InitializableOwnable, ReentrancyGuard {
using SafeMath for uint256;
address public _DODO_SMART_APPROVE_;
// ============ Variables for Control ============
IExternalValue public _GAS_PRICE_LIMIT_;
@@ -78,10 +76,6 @@ contract DPPStorage is InitializableOwnable, ReentrancyGuard {
_MAINTAINER_ = newMaintainer;
}
function setOperator(address newOperator) external onlyOwner {
_OPERATOR_ = newOperator;
}
function setGasPriceSource(address newGasPriceLimitSource) external onlyOwner {
_GAS_PRICE_LIMIT_ = IExternalValue(newGasPriceLimitSource);
}

View File

@@ -64,7 +64,7 @@ contract DPPVault is DPPStorage {
}
function reset(
address from,
address assetTo,
uint256 newLpFeeRate,
uint256 newMtFeeRate,
uint256 newI,
@@ -73,8 +73,8 @@ contract DPPVault is DPPStorage {
uint256 quoteOutAmount
) public onlyOwner {
require(newK > 0 && newK <= 10**18, "K OUT OF RANGE!");
if (baseOutAmount > 0) _transferBaseOut(from, baseOutAmount);
if (quoteOutAmount > 0) _transferQuoteOut(from, quoteOutAmount);
_transferBaseOut(assetTo, baseOutAmount);
_transferQuoteOut(assetTo, quoteOutAmount);
_resetTargetAndReserve();
_LP_FEE_RATE_MODEL_.setFeeRate(newLpFeeRate);
_MT_FEE_RATE_MODEL_.setFeeRate(newMtFeeRate);

View File

@@ -213,18 +213,17 @@ library PMMPricing {
// ============ Helper functions ============
// todo 我不确定这个函数是不是能改state的状态
function adjustedTarget(PMMState memory state) internal pure {
if (state.R == RState.BELOW_ONE) {
state.Q0 = DODOMath._SolveQuadraticFunctionForTarget(
state.B,
state.Q,
state.B.sub(state.B0),
state.i,
state.K
);
} else if (state.R == RState.ABOVE_ONE) {
state.B0 = DODOMath._SolveQuadraticFunctionForTarget(
state.Q,
state.B,
state.Q.sub(state.Q0),
DecimalMath.reciprocalFloor(state.i),
state.K