Skip to content

Commit e6175d5

Browse files
committed
style: rename vault decimals
1 parent 0fcd315 commit e6175d5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/ChainlinkOracle.sol

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ contract ChainlinkOracle is IOracle {
1818

1919
/// @notice Vault.
2020
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;
2424
/// @notice First base feed.
2525
AggregatorV3Interface public immutable BASE_FEED_1;
2626
/// @notice Second base feed.
@@ -39,7 +39,7 @@ contract ChainlinkOracle is IOracle {
3939
/// @param baseFeed2 Second base feed. Pass address zero if the price = 1.
4040
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1.
4141
/// @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.
4343
/// @param baseTokenDecimals Base token decimals.
4444
/// @param quoteTokenDecimals Quote token decimals.
4545
constructor(
@@ -48,15 +48,15 @@ contract ChainlinkOracle is IOracle {
4848
AggregatorV3Interface baseFeed2,
4949
AggregatorV3Interface quoteFeed1,
5050
AggregatorV3Interface quoteFeed2,
51-
uint256 vaultPrecision,
51+
uint256 conversionSampleDecimals,
5252
uint256 baseTokenDecimals,
5353
uint256 quoteTokenDecimals
5454
) {
5555
// 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.
5858
VAULT = vault;
59-
VAULT_PRECISION = vaultPrecision;
59+
CONVERSION_SAMPLE_DECIMALS = conversionSampleDecimals;
6060
BASE_FEED_1 = baseFeed1;
6161
BASE_FEED_2 = baseFeed2;
6262
QUOTE_FEED_1 = quoteFeed1;
@@ -78,15 +78,16 @@ contract ChainlinkOracle is IOracle {
7878
SCALE_FACTOR = 10
7979
** (
8080
36 + quoteTokenDecimals + quoteFeed1.getDecimals() + quoteFeed2.getDecimals() - baseTokenDecimals
81-
- baseFeed1.getDecimals() - baseFeed2.getDecimals() - vaultPrecision
81+
- baseFeed1.getDecimals() - baseFeed2.getDecimals() - CONVERSION_SAMPLE_DECIMALS
8282
);
8383
}
8484

8585
/* PRICE */
8686

8787
/// @inheritdoc IOracle
8888
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)
9091
/ (QUOTE_FEED_1.getPrice() * QUOTE_FEED_2.getPrice());
9192
}
9293
}

0 commit comments

Comments
 (0)