Skip to content

Commit 3d88fd5

Browse files
committed
docs: minor improvements
1 parent ca38c55 commit 3d88fd5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/chainlink/OracleTwoFeeds.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ contract OracleTwoFeeds is IOracle {
3131
) {
3232
BASE_FEED = baseFeed;
3333
QUOTE_FEED = quoteFeed;
34-
// We note pB the base price, and pQ the quote price (price of 1e(decimals) asset).
35-
// We want to return 1e36 * (pB/1e(bDecimals) / (pQ/1e(qDecimals)).
36-
// 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-
// 1e(qFeedPrecision))
34+
// Let pB be the base price, and pQ the quote price (price of 1e(decimals) asset).
35+
// Chainlink feeds return pB * bFeedPrecision and pQ * qFeedPrecision.
36+
// `price()` should return 1e36 * (pB/1e(bDecimals) / (pQ/1e(qDecimals)).
37+
// Yet `price()` returns pB * 1e(bFeedPrecision) * SCALE_FACTOR / (pQ * 1e(qFeedPrecision))
38+
// So 1e36 * (pB/1e(bDecimals) / (pQ/1e(qDecimals) = pB*1e(bFeedPrecision) * SCALE_FACTOR /
39+
// (pQ*1e(qFeedPrecision))
3940
// So SCALE_FACTOR = 1e36 / 1e(bDecimals) * 1e(qDecimals) * 1e(qFeedPrecision) / 1e(bFeedPrecision)
40-
// So SCALE_FACTOR = 1e(36 + qDecimals + qFeedPrecision - bDecimals - bFeedPrecision)
41+
// = 1e(36 + qDecimals + qFeedPrecision - bDecimals - bFeedPrecision)
4142
SCALE_FACTOR =
4243
10 ** (36 + quoteTokenDecimals + quoteFeed.getDecimals() - baseFeed.getDecimals() - baseTokenDecimals);
4344
}

0 commit comments

Comments
 (0)