Skip to content

Commit c77b350

Browse files
committed
fix: error message
1 parent 437f44e commit c77b350

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/ChainlinkOracle.sol

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

66
import {AggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/ChainlinkDataFeedLib.sol";
77
import {IERC4626, VaultLib} from "./libraries/VaultLib.sol";
8+
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
89

910
/// @title ChainlinkOracle
1011
/// @author Morpho Labs
@@ -56,7 +57,7 @@ contract ChainlinkOracle is IOracle {
5657
// It is used to price `VAULT_CONVERSION_SAMPLE` of the vault shares, so it requires dividing by that number,
5758
// hence the division by `VAULT_CONVERSION_SAMPLE` in the `SCALE_FACTOR` definition.
5859
// Verify that vault = 0 => vaultConversionSample = 1.
59-
require(address(vault) != address(0) || vaultConversionSample == 1);
60+
require(address(vault) != address(0) || vaultConversionSample == 1, ErrorsLib.VAULT_CONVERSION_SAMPLE_IS_NOT_ONE);
6061
VAULT = vault;
6162
VAULT_CONVERSION_SAMPLE = vaultConversionSample;
6263
BASE_FEED_1 = baseFeed1;

src/libraries/ErrorsLib.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ pragma solidity ^0.8.0;
88
library ErrorsLib {
99
/// @notice Thrown when the answer returned by a Chainlink feed is negative.
1010
string constant NEGATIVE_ANSWER = "negative answer";
11+
12+
/// @notice Thrown when the vault conversion sample is not 1 while vault = 0.
13+
string constant VAULT_CONVERSION_SAMPLE_IS_NOT_ONE = "vault conversion sample is not one";
1114
}

test/ChainlinkOracleTest.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ contract ChainlinkOracleTest is Test {
134134

135135
function testConstructorVaultZeroNonOneSample(uint256 vaultConversionSample) public {
136136
vm.assume(vaultConversionSample != 1);
137-
vm.expectRevert();
137+
vm.expectRevert(bytes(ErrorsLib.VAULT_CONVERSION_SAMPLE_IS_NOT_ONE));
138138
new ChainlinkOracle(vaultZero, daiEthFeed, feedZero, usdcEthFeed, feedZero, vaultConversionSample, 18, 6);
139139
}
140140
}

0 commit comments

Comments
 (0)