Skip to content

Commit 831835c

Browse files
authored
Merge pull request #84 from morpho-org/docs/natspec-issues
Natspec issues
2 parents 93cb98d + 75a5111 commit 831835c

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

src/morpho-chainlink/MorphoChainlinkOracleV2.sol

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,11 @@ contract MorphoChainlinkOracleV2 is IMorphoChainlinkOracleV2 {
5050
/* CONSTRUCTOR */
5151

5252
/// @dev Here is the list of assumptions that guarantees the oracle behaves as expected:
53-
/// - Feeds are either Chainlink-compliant or the address zero.
54-
/// - Feeds have the same behavioral assumptions as Chainlink's.
55-
/// - Feeds are set in the correct order.
53+
/// - The vaults, if set, are ERC4626-compliant.
54+
/// - The feeds, if set, are Chainlink-interface-compliant.
5655
/// - Decimals passed as argument are correct.
57-
/// - The vaults' sample shares quoted as assets and the base feed prices don't overflow when multiplied.
58-
/// - The quote feed prices don't overflow when multiplied.
59-
/// - Vaults are either ERC4626-compliant or the address zero.
60-
/// @dev The base asset is the collateral token and the quote asset is the loan token.
56+
/// - The base vaults's sample shares quoted as assets and the base feed prices don't overflow when multiplied.
57+
/// - The quote vault's sample shares quoted as assets and the quote feed prices don't overflow when multiplied.
6158
/// @param baseVault Base vault. Pass address zero to omit this parameter.
6259
/// @param baseVaultConversionSample The sample amount of base vault shares used to convert to underlying.
6360
/// Pass 1 if the base asset is not a vault. Should be chosen such that converting `baseVaultConversionSample` to
@@ -72,6 +69,7 @@ contract MorphoChainlinkOracleV2 is IMorphoChainlinkOracleV2 {
7269
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1.
7370
/// @param quoteFeed2 Second quote feed. Pass address zero if the price = 1.
7471
/// @param quoteTokenDecimals Quote token decimals.
72+
/// @dev The base asset should be the collateral token and the quote asset the loan token.
7573
constructor(
7674
IERC4626 baseVault,
7775
uint256 baseVaultConversionSample,
@@ -125,7 +123,7 @@ contract MorphoChainlinkOracleV2 is IMorphoChainlinkOracleV2 {
125123
// = 1e36 * (pB1 * 1e(-dB1) * pB2) / (pQ1 * 1e(-dQ1) * pQ2)
126124

127125
// Let fpB1, fpB2, fpQ1, fpQ2 be the feed precision of the respective prices pB1, pB2, pQ1, pQ2.
128-
// Chainlink feeds return pB1 * 1e(fpB1), pB2 * 1e(fpB2), pQ1 * 1e(fpQ1) and pQ2 * 1e(fpQ2).
126+
// Feeds return pB1 * 1e(fpB1), pB2 * 1e(fpB2), pQ1 * 1e(fpQ1) and pQ2 * 1e(fpQ2).
129127

130128
// Based on the implementation of `price()` below, the value of `SCALE_FACTOR` should thus satisfy:
131129
// (pB1 * 1e(fpB1)) * (pB2 * 1e(fpB2)) * SCALE_FACTOR / ((pQ1 * 1e(fpQ1)) * (pQ2 * 1e(fpQ2)))

src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ interface IMorphoChainlinkOracleV2 is IOracle {
2222
/// @notice Returns the quote vault conversion sample.
2323
function QUOTE_VAULT_CONVERSION_SAMPLE() external view returns (uint256);
2424

25-
/// @notice Returns the address of the first Chainlink base feed.
25+
/// @notice Returns the address of the first base feed.
2626
function BASE_FEED_1() external view returns (AggregatorV3Interface);
2727

28-
/// @notice Returns the address of the second Chainlink base feed.
28+
/// @notice Returns the address of the second base feed.
2929
function BASE_FEED_2() external view returns (AggregatorV3Interface);
3030

31-
/// @notice Returns the address of the first Chainlink quote feed.
31+
/// @notice Returns the address of the first quote feed.
3232
function QUOTE_FEED_1() external view returns (AggregatorV3Interface);
3333

34-
/// @notice Returns the address of the second Chainlink quote feed.
34+
/// @notice Returns the address of the second quote feed.
3535
function QUOTE_FEED_2() external view returns (AggregatorV3Interface);
3636

3737
/// @notice Returns the price scale factor, calculated at contract creation.

src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2Factory.sol

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ interface IMorphoChainlinkOracleV2Factory {
1919
function isMorphoChainlinkOracleV2(address target) external view returns (bool);
2020

2121
/// @dev Here is the list of assumptions that guarantees the oracle behaves as expected:
22-
/// - Feeds are either Chainlink-compliant or the address zero.
23-
/// - Feeds have the same behavioral assumptions as Chainlink's.
24-
/// - Feeds are set in the correct order.
22+
/// - The vaults, if set, are ERC4626-compliant.
23+
/// - The feeds, if set, are Chainlink-interface-compliant.
2524
/// - Decimals passed as argument are correct.
26-
/// - The vault's sample shares quoted as assets and the base feed prices don't overflow when multiplied.
27-
/// - The quote feed prices don't overflow when multiplied.
28-
/// - The vault, if set, is ERC4626-compliant.
25+
/// - The base vaults's sample shares quoted as assets and the base feed prices don't overflow when multiplied.
26+
/// - The quote vault's sample shares quoted as assets and the quote feed prices don't overflow when multiplied.
2927
/// @param baseVault Base vault. Pass address zero to omit this parameter.
3028
/// @param baseVaultConversionSample The sample amount of base vault shares used to convert to underlying.
3129
/// Pass 1 if the base asset is not a vault. Should be chosen such that converting `baseVaultConversionSample` to
@@ -40,7 +38,8 @@ interface IMorphoChainlinkOracleV2Factory {
4038
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1.
4139
/// @param quoteFeed2 Second quote feed. Pass address zero if the price = 1.
4240
/// @param quoteTokenDecimals Quote token decimals.
43-
/// @param salt The salt to use for the MetaMorpho vault's CREATE2 address.
41+
/// @param salt The salt to use for the CREATE2.
42+
/// @dev The base asset should be the collateral token and the quote asset the loan token.
4443
function createMorphoChainlinkOracleV2(
4544
IERC4626 baseVault,
4645
uint256 baseVaultConversionSample,

test/MorphoChainlinkOracleV2Test.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ contract MorphoChainlinkOracleV2Test is Test {
9999
}
100100

101101
function testSDaiEthOracle() public {
102-
MorphoChainlinkOracleV2 oracle = new MorphoChainlinkOracleV2(
103-
sDaiVault, 10 ** 18, daiEthFeed, feedZero, 18, vaultZero, 1, feedZero, feedZero, 18
104-
);
102+
MorphoChainlinkOracleV2 oracle =
103+
new MorphoChainlinkOracleV2(sDaiVault, 1e18, daiEthFeed, feedZero, 18, vaultZero, 1, feedZero, feedZero, 18);
105104
(, int256 expectedPrice,,,) = daiEthFeed.latestRoundData();
106105
assertEq(
107106
oracle.price(),
@@ -111,7 +110,7 @@ contract MorphoChainlinkOracleV2Test is Test {
111110

112111
function testSDaiUsdcOracle() public {
113112
MorphoChainlinkOracleV2 oracle = new MorphoChainlinkOracleV2(
114-
sDaiVault, 10 ** 18, daiEthFeed, feedZero, 18, vaultZero, 1, usdcEthFeed, feedZero, 6
113+
sDaiVault, 1e18, daiEthFeed, feedZero, 18, vaultZero, 1, usdcEthFeed, feedZero, 6
115114
);
116115
(, int256 baseAnswer,,,) = daiEthFeed.latestRoundData();
117116
(, int256 quoteAnswer,,,) = usdcEthFeed.latestRoundData();

0 commit comments

Comments
 (0)