Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oracle): add price bounds #10

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions script/DeployOracles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ struct OracleConfig {
address baseFeed1;
address baseFeed2;
address collateralToken;
uint256 expectedPrice;
address loanToken;
uint256 maxPrice;
uint256 minPrice;
string name;
address quoteFeed1;
address quoteFeed2;
Expand Down Expand Up @@ -67,9 +68,8 @@ contract DeployOracle is ConfiguredScript {
console2.log(" Deployed ChainlinkOracle for market [%s] at: %s", oracleConfig.name, address(oracle));

uint256 price = oracle.price();
uint256 priceRatio = price * 1 ether / oracleConfig.expectedPrice;
require(priceRatio <= 10 ether, string.concat("price too high: ", vm.toString(price)));
require(priceRatio >= 0.1 ether, string.concat("price too low: ", vm.toString(price)));
require(price <= oracleConfig.maxPrice, string.concat("price too high: ", vm.toString(price)));
require(price >= oracleConfig.minPrice, string.concat("price too low: ", vm.toString(price)));
}
}
}
9 changes: 6 additions & 3 deletions script/config/oracles/ethereum.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"quoteFeed1": "0x0000000000000000000000000000000000000000",
"quoteFeed2": "0x0000000000000000000000000000000000000000",
"vaultConversionSample": 1,
"expectedPrice": 1000000000000000000000000000000000000
"minPrice": 100000000000000000000000000000000000,
"maxPrice": 1500000000000000000000000000000000000
MathisGD marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "WETH (cbETH)",
Expand All @@ -19,7 +20,8 @@
"quoteFeed1": "0x0000000000000000000000000000000000000000",
"quoteFeed2": "0x0000000000000000000000000000000000000000",
"vaultConversionSample": 1,
"expectedPrice": 1000000000000000000000000000000000000
"minPrice": 100000000000000000000000000000000000,
"maxPrice": 1500000000000000000000000000000000000
},
{
"name": "USDC (sDAI)",
Expand All @@ -30,6 +32,7 @@
"quoteFeed1": "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6",
"quoteFeed2": "0x0000000000000000000000000000000000000000",
"vaultConversionSample": 1000000000000000000,
"expectedPrice": 1000000000000000000000000
"minPrice": 990000000000000000000000,
"maxPrice": 1500000000000000000000000
}
]