fix DSP stablecoin support

This commit is contained in:
owen05
2021-04-20 16:52:49 +08:00
parent 16b4a51f17
commit 00a5b8ab76

View File

@@ -11,6 +11,7 @@ pragma experimental ABIEncoderV2;
import {IERC20} from "../../intf/IERC20.sol";
import {SafeMath} from "../../lib/SafeMath.sol";
import {DecimalMath} from "../../lib/DecimalMath.sol";
import {PMMPricing} from "../../lib/PMMPricing.sol";
import {SafeERC20} from "../../lib/SafeERC20.sol";
import {DSPStorage} from "./DSPStorage.sol";
@@ -93,6 +94,19 @@ contract DSPVault is DSPStorage {
_sync();
}
function correctRState() public {
if (_RState_ == uint32(PMMPricing.RState.BELOW_ONE) && _BASE_RESERVE_<_BASE_TARGET_) {
_RState_ = uint32(PMMPricing.RState.ONE);
_BASE_TARGET_ = _BASE_RESERVE_;
_QUOTE_TARGET_ = _QUOTE_RESERVE_;
}
if (_RState_ == uint32(PMMPricing.RState.ABOVE_ONE) && _QUOTE_RESERVE_<_QUOTE_TARGET_) {
_RState_ = uint32(PMMPricing.RState.ONE);
_BASE_TARGET_ = _BASE_RESERVE_;
_QUOTE_TARGET_ = _QUOTE_RESERVE_;
}
}
// ============ Asset Out ============
function _transferBaseOut(address to, uint256 amount) internal {