Skip to content

Commit

Permalink
Merge pull request #7 from Tropykus/oracleFailureBlocking
Browse files Browse the repository at this point in the history
Add oracle failure blocking
  • Loading branch information
chriss-m240 authored Sep 14, 2021
2 parents a3e6faa + 262ca8b commit bd898dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions contracts/ComptrollerG6.sol
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ contract ComptrollerG6 is
minter;
mintAmount;

if (oracle.getUnderlyingPrice(CToken(cToken)) == 0) {
return uint256(Error.PRICE_ERROR);
}

if (!markets[cToken].isListed) {
return uint256(Error.MARKET_NOT_LISTED);
}
Expand Down Expand Up @@ -361,6 +365,9 @@ contract ComptrollerG6 is
return allowed;
}

if (oracle.getUnderlyingPrice(CToken(cToken)) == 0) {
return uint256(Error.PRICE_ERROR);
}
// Keep the flywheel moving
updateCompSupplyIndex(cToken);
distributeSupplierComp(cToken, redeemer, false);
Expand Down Expand Up @@ -535,6 +542,10 @@ contract ComptrollerG6 is
borrower;
repayAmount;

if (oracle.getUnderlyingPrice(CToken(cToken)) == 0) {
return uint256(Error.PRICE_ERROR);
}

if (!markets[cToken].isListed) {
return uint256(Error.MARKET_NOT_LISTED);
}
Expand Down
13 changes: 13 additions & 0 deletions contracts/mocks/MockPriceProviderMoC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,17 @@ contract MockPriceProviderMoC {
uint256(rbtcPrice)
);
}

/**
* @notice Set a new has state
* @param _has bool value for new has state
*/
function setHasState(bool _has) public {
require(
msg.sender == guardian,
"MockPriceProviderMoC: only guardian may set the address"
);

has = _has;
}
}
1 change: 1 addition & 0 deletions instructions
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ load = async() => {
crbtc = await ethers.getContractAt('CRBTC', cRBTC, dep);
csat = await ethers.getContractAt('CRBTC', cSAT, dep);
priceOracleProxy = await ethers.getContractAt('PriceOracleProxy', PriceOracleProxy, dep);
rbtcOracle = await ethers.getContractAt('MockPriceProviderMoC', RBTCOracle, dep);
whitelist = await ethers.getContractAt('Whitelist', Whitelist, dep);
}

Expand Down

0 comments on commit bd898dc

Please sign in to comment.