Skip to content

Commit ef5cb20

Browse files
committed
docs: add description of the contracts
1 parent c8782a6 commit ef5cb20

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

src/chainlink/Oracle2.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import {IOracle} from "morpho-blue/interfaces/IOracle.sol";
55

66
import {AggregatorV3Interface, DataFeedLib} from "./libraries/DataFeedLib.sol";
77

8+
/// @title Oracle2
9+
/// @author Morpho Labs
10+
/// @custom:contact [email protected]
11+
/// @notice Oracle using 2 Chainlink-compliant feeds to compute the price of a collateral token quoted in a borrowable
12+
/// token within a Morpho Blue market.
813
contract Oracle2 is IOracle {
914
using DataFeedLib for AggregatorV3Interface;
1015

src/chainlink/Oracle4.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import {IOracle} from "morpho-blue/interfaces/IOracle.sol";
55

66
import {AggregatorV3Interface, DataFeedLib} from "./libraries/DataFeedLib.sol";
77

8+
/// @title Oracle4
9+
/// @author Morpho Labs
10+
/// @custom:contact [email protected]
11+
/// @notice Oracle using 4 Chainlink-compliant feeds to compute the price of a collateral token quoted in a borrowable
12+
/// token within a Morpho Blue market.
813
contract Oracle4 is IOracle {
914
using DataFeedLib for AggregatorV3Interface;
1015

src/chainlink/libraries/DataFeedLib.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import {AggregatorV3Interface} from "chainlink/contracts/src/v0.8/interfaces/Agg
55

66
import {ErrorsLib} from "./ErrorsLib.sol";
77

8+
/// @title DataFeedLib
9+
/// @author Morpho Labs
10+
/// @custom:contact [email protected]
11+
/// @notice Library exposing functions to interact with a Chainlink-compliant feed.
812
library DataFeedLib {
913
/// @dev Returns the latest price of a `feed`.
1014
/// @dev Performing some security checks and returns the latest price of a feed.

src/chainlink/libraries/ErrorsLib.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity ^0.8.0;
33

4+
/// @title ErrorsLib
5+
/// @author Morpho Labs
6+
/// @custom:contact [email protected]
7+
/// @notice Library exposing error messages.
48
library ErrorsLib {
59
/// @notice Thrown when the answer returned by a Chainlink feed is negative.
610
string constant NEGATIVE_ANSWER = "negative answer";

test/chainlink/Oracle4Test.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ contract OracleTest is Test {
2626
(, int256 quoteAnswer,,,) = usdcUsdFeed.latestRoundData();
2727
assertEq(
2828
oracle.price(),
29-
(uint256(firstBaseAnswer) * uint256(secondBaseAnswer) * 10 ** (36 + 8 + 6 - 8 - 8 - 8)) / uint256(quoteAnswer)
29+
(uint256(firstBaseAnswer) * uint256(secondBaseAnswer) * 10 ** (36 + 8 + 6 - 8 - 8 - 8))
30+
/ uint256(quoteAnswer)
3031
);
3132
}
3233

@@ -37,7 +38,8 @@ contract OracleTest is Test {
3738
(, int256 secondQuoteAnswer,,,) = btcUsdFeed.latestRoundData();
3839
assertEq(
3940
oracle.price(),
40-
(uint256(baseAnswer) * 10 ** (36 + 8 + 8 + 8 - 6 - 8)) / (uint256(firstQuoteAnswer) * uint256(secondQuoteAnswer))
41+
(uint256(baseAnswer) * 10 ** (36 + 8 + 8 + 8 - 6 - 8))
42+
/ (uint256(firstQuoteAnswer) * uint256(secondQuoteAnswer))
4143
);
4244
}
4345

0 commit comments

Comments
 (0)