Skip to content

Commit c8782a6

Browse files
committed
docs: add/update/fix comments
1 parent 0564ee9 commit c8782a6

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/chainlink/Oracle2.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ import {AggregatorV3Interface, DataFeedLib} from "./libraries/DataFeedLib.sol";
88
contract Oracle2 is IOracle {
99
using DataFeedLib for AggregatorV3Interface;
1010

11-
/* CONSTANT */
11+
/* IMMUTABLES */
1212

1313
/// @notice Base feed.
1414
AggregatorV3Interface public immutable BASE_FEED;
1515
/// @notice Quote feed.
1616
AggregatorV3Interface public immutable QUOTE_FEED;
17-
/// @notice Price scale factor, computed at contract creation.
17+
/// @notice Price scale factor.
1818
uint256 public immutable SCALE_FACTOR;
1919

2020
/* CONSTRUCTOR */
2121

22+
/// @dev Initializes the contract.
2223
/// @param baseFeed Base feed. Pass address zero if the price = 1.
2324
/// @param quoteFeed Quote feed. Pass address zero if the price = 1.
2425
/// @param baseTokenDecimals Base token decimals.
@@ -34,7 +35,7 @@ contract Oracle2 is IOracle {
3435
// We note pB the base price, and pQ the quote price (price of 1e(decimals) asset).
3536
// We want to return 1e36 * (pB/1e(bDecimals) / (pQ/1e(qDecimals)).
3637
// Chainlink returns pB * bFeedPrecision and pQ * qFeedPrecision.
37-
// So we have 1e36 * (pB/1e(bDecimals) / (pQ/1e(qDecimals) = pB * 1e(bFeedPrecision) * SCALE_FACTOR / (pQ *
38+
// So we have 1e36 * (pB/1e(bDecimals) / (pQ/1e(qDecimals)) = pB * 1e(bFeedPrecision) * SCALE_FACTOR / (pQ *
3839
// 1e(qFeedPrecision))
3940
// So SCALE_FACTOR = 1e36 / 1e(bDecimals) * 1e(qDecimals) * 1e(qFeedPrecision) / 1e(bFeedPrecision)
4041
// So SCALE_FACTOR = 1e(36 + qDecimals + qFeedPrecision - bDecimals - bFeedPrecision)

src/chainlink/Oracle4.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {AggregatorV3Interface, DataFeedLib} from "./libraries/DataFeedLib.sol";
88
contract Oracle4 is IOracle {
99
using DataFeedLib for AggregatorV3Interface;
1010

11-
/* CONSTANT */
11+
/* IMMUTABLES */
1212

1313
/// @notice First base feed.
1414
AggregatorV3Interface public immutable FIRST_BASE_FEED;
@@ -18,11 +18,12 @@ contract Oracle4 is IOracle {
1818
AggregatorV3Interface public immutable FIRST_QUOTE_FEED;
1919
/// @notice Second quote feed.
2020
AggregatorV3Interface public immutable SECOND_QUOTE_FEED;
21-
/// @notice Price scale factor, computed at contract creation.
21+
/// @notice Price scale factor.
2222
uint256 public immutable SCALE_FACTOR;
2323

2424
/* CONSTRUCTOR */
2525

26+
/// @dev Initializes the contract.
2627
/// @param firstBaseFeed First base feed. Pass address zero if the price = 1.
2728
/// @param secondBaseFeed Second base feed. Pass address zero if the price = 1.
2829
/// @param firstQuoteFeed Quote feed. Pass address zero if the price = 1.

src/chainlink/libraries/DataFeedLib.sol

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

4-
import {ErrorsLib} from "./ErrorsLib.sol";
54
import {AggregatorV3Interface} from "chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
65

6+
import {ErrorsLib} from "./ErrorsLib.sol";
7+
78
library DataFeedLib {
9+
/// @dev Returns the latest price of a `feed`.
810
/// @dev Performing some security checks and returns the latest price of a feed.
911
/// @dev When `feed` is the address zero, returns 1.
1012
function getPrice(AggregatorV3Interface feed) internal view returns (uint256) {

src/chainlink/libraries/ErrorsLib.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
pragma solidity ^0.8.0;
33

44
library ErrorsLib {
5+
/// @notice Thrown when the answer returned by a Chainlink feed is negative.
56
string constant NEGATIVE_ANSWER = "negative answer";
67
}

0 commit comments

Comments
 (0)