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

Add safety comments #25

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions src/libraries/ChainlinkDataFeedLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import {ErrorsLib} from "./ErrorsLib.sol";
library ChainlinkDataFeedLib {
/// @dev Performs safety checks and returns the latest price of a `feed`.
/// @dev When `feed` is the address zero, returns 1.
/// @dev Notes on safety checks:
/// - A stale period is not checked since the heartbeat of a Chainlink feed is an offchain parameter that can
/// change any time and checking the price deviation onchain is not possible. It was not recommended by the Chailink
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved
/// team either.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved
/// - The price is not checked to be in the min/max bounds since the check is already performed by Chainlink most of
/// the time. Adding
/// a safety margin would be arbitrary as well since the contract is immutable.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved
/// - No fallback is used. In case the oracle reverts, Morpho Blue users can still exit their positions but
/// can't be liquidated.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved
function getPrice(AggregatorV3Interface feed) internal view returns (uint256) {
if (address(feed) == address(0)) return 1;

Expand Down