@@ -18,9 +18,9 @@ contract ChainlinkOracle is IOracle {
18
18
19
19
/// @notice Vault.
20
20
IERC4626 public immutable VAULT;
21
- /// @notice Vault precision . The number of decimals used to price shares of the vault .
22
- /// @notice Should be chosen such that converting `10 ** VAULT_PRECISION ` to assets has enough precision.
23
- uint256 public immutable VAULT_PRECISION ;
21
+ /// @notice Conversion sample decimals . The decimals of the shares sample used to convert to the underlying asset .
22
+ /// @notice Should be chosen such that converting `10 ** CONVERSION_SAMPLE_DECIMALS ` to assets has enough precision.
23
+ uint256 public immutable CONVERSION_SAMPLE_DECIMALS ;
24
24
/// @notice First base feed.
25
25
AggregatorV3Interface public immutable BASE_FEED_1;
26
26
/// @notice Second base feed.
@@ -39,7 +39,7 @@ contract ChainlinkOracle is IOracle {
39
39
/// @param baseFeed2 Second base feed. Pass address zero if the price = 1.
40
40
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1.
41
41
/// @param quoteFeed2 Second quote feed. Pass address zero if the price = 1.
42
- /// @param vaultPrecision Vault precision . Pass 0 if the oracle does not use a vault.
42
+ /// @param conversionSampleDecimals Conversion sample decimals . Pass 0 if the oracle does not use a vault.
43
43
/// @param baseTokenDecimals Base token decimals.
44
44
/// @param quoteTokenDecimals Quote token decimals.
45
45
constructor (
@@ -48,15 +48,15 @@ contract ChainlinkOracle is IOracle {
48
48
AggregatorV3Interface baseFeed2 ,
49
49
AggregatorV3Interface quoteFeed1 ,
50
50
AggregatorV3Interface quoteFeed2 ,
51
- uint256 vaultPrecision ,
51
+ uint256 conversionSampleDecimals ,
52
52
uint256 baseTokenDecimals ,
53
53
uint256 quoteTokenDecimals
54
54
) {
55
55
// The vault parameter is used for ERC4626 tokens, to price its shares.
56
- // It is used to price `10 ** VAULT_PRECISION ` of the vault shares, so it requires dividing by that number,
57
- // hence the `VAULT_PRECISION ` subtraction in the `SCALE_FACTOR` definition.
56
+ // It is used to price `10 ** CONVERSION_SAMPLE_DECIMALS ` of the vault shares, so it requires dividing
57
+ // by that number, hence the `CONVERSION_SAMPLE_DECIMALS ` subtraction in the `SCALE_FACTOR` definition.
58
58
VAULT = vault;
59
- VAULT_PRECISION = vaultPrecision ;
59
+ CONVERSION_SAMPLE_DECIMALS = conversionSampleDecimals ;
60
60
BASE_FEED_1 = baseFeed1;
61
61
BASE_FEED_2 = baseFeed2;
62
62
QUOTE_FEED_1 = quoteFeed1;
@@ -78,15 +78,16 @@ contract ChainlinkOracle is IOracle {
78
78
SCALE_FACTOR = 10
79
79
** (
80
80
36 + quoteTokenDecimals + quoteFeed1.getDecimals () + quoteFeed2.getDecimals () - baseTokenDecimals
81
- - baseFeed1.getDecimals () - baseFeed2.getDecimals () - vaultPrecision
81
+ - baseFeed1.getDecimals () - baseFeed2.getDecimals () - CONVERSION_SAMPLE_DECIMALS
82
82
);
83
83
}
84
84
85
85
/* PRICE */
86
86
87
87
/// @inheritdoc IOracle
88
88
function price () external view returns (uint256 ) {
89
- return (VAULT.getAssets (10 ** VAULT_PRECISION) * BASE_FEED_1.getPrice () * BASE_FEED_2.getPrice () * SCALE_FACTOR)
89
+ uint256 sample = 10 ** CONVERSION_SAMPLE_DECIMALS;
90
+ return (VAULT.getAssets (sample) * BASE_FEED_1.getPrice () * BASE_FEED_2.getPrice () * SCALE_FACTOR)
90
91
/ (QUOTE_FEED_1.getPrice () * QUOTE_FEED_2.getPrice ());
91
92
}
92
93
}
0 commit comments