update DPPOracle

This commit is contained in:
tracy
2022-06-22 14:18:37 +08:00
parent a1453561ae
commit eb631f6255
7 changed files with 157 additions and 14 deletions

View File

@@ -38,9 +38,11 @@ contract DPPTrader is DPPVault {
event RChange(PMMPricing.RState newRState);
modifier isOraclePriceValid() {
bool isFeasible = IOracle(_I_).isFeasible(address(_BASE_TOKEN_));
require(isFeasible, "ORACLE_PRICE_INVALID");
modifier isPriceValid() {
if (_IS_ORACLE_ENABLED) {
bool isFeasible = IOracle(_I_).isFeasible(address(_BASE_TOKEN_));
require(isFeasible, "ORACLE_PRICE_INVALID");
}
_;
}
@@ -49,7 +51,7 @@ contract DPPTrader is DPPVault {
function sellBase(address to)
external
preventReentrant
isOraclePriceValid
isPriceValid
returns (uint256 receiveQuoteAmount)
{
uint256 baseBalance = _BASE_TOKEN_.balanceOf(address(this));
@@ -85,7 +87,7 @@ contract DPPTrader is DPPVault {
function sellQuote(address to)
external
preventReentrant
isOraclePriceValid
isPriceValid
returns (uint256 receiveBaseAmount)
{
uint256 quoteBalance = _QUOTE_TOKEN_.balanceOf(address(this));
@@ -126,7 +128,7 @@ contract DPPTrader is DPPVault {
uint256 quoteAmount,
address _assetTo,
bytes calldata data
) external isOraclePriceValid preventReentrant {
) external isPriceValid preventReentrant {
address assetTo = _assetTo;
_transferBaseOut(assetTo, baseAmount);
_transferQuoteOut(assetTo, quoteAmount);