Skip to content

Commit bc39f3f

Browse files
committed
refactor: rename vault precision
1 parent 3617143 commit bc39f3f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/ChainlinkOracle.sol

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

1919
/// @notice Vault.
2020
IERC4626 public immutable VAULT;
21-
/// @notice Vault decimals.
22-
uint256 public immutable VAULT_DECIMALS;
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;
2324
/// @notice First base feed.
2425
AggregatorV3Interface public immutable BASE_FEED_1;
2526
/// @notice Second base feed.
@@ -38,8 +39,7 @@ contract ChainlinkOracle is IOracle {
3839
/// @param baseFeed2 Second base feed. Pass address zero if the price = 1.
3940
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1.
4041
/// @param quoteFeed2 Second quote feed. Pass address zero if the price = 1.
41-
/// @param vaultDecimals Vault decimals, where the vault is an ERC4626 seen as an ERC20. Pass 0 if the oracle does
42-
/// not use a vault.
42+
/// @param vaultPrecision Vault precision. 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 vaultDecimals,
51+
uint256 vaultPrecision,
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 a full unit of the vault shares, so it requires dividing by that number, hence the
57-
// `VAULT_DECIMALS` subtraction in the following `SCALE_FACTOR` definition.
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.
5858
VAULT = vault;
59-
VAULT_DECIMALS = vaultDecimals;
59+
VAULT_PRECISION = vaultPrecision;
6060
BASE_FEED_1 = baseFeed1;
6161
BASE_FEED_2 = baseFeed2;
6262
QUOTE_FEED_1 = quoteFeed1;
@@ -78,15 +78,15 @@ contract ChainlinkOracle is IOracle {
7878
SCALE_FACTOR = 10
7979
** (
8080
36 + quoteTokenDecimals + quoteFeed1.getDecimals() + quoteFeed2.getDecimals() - baseTokenDecimals
81-
- baseFeed1.getDecimals() - baseFeed2.getDecimals() - vaultDecimals
81+
- baseFeed1.getDecimals() - baseFeed2.getDecimals() - vaultPrecision
8282
);
8383
}
8484

8585
/* PRICE */
8686

8787
/// @inheritdoc IOracle
8888
function price() external view returns (uint256) {
89-
return (VAULT.getAssets(10 ** VAULT_DECIMALS) * BASE_FEED_1.getPrice() * BASE_FEED_2.getPrice() * SCALE_FACTOR)
89+
return (VAULT.getAssets(10 ** VAULT_PRECISION) * BASE_FEED_1.getPrice() * BASE_FEED_2.getPrice() * SCALE_FACTOR)
9090
/ (QUOTE_FEED_1.getPrice() * QUOTE_FEED_2.getPrice());
9191
}
9292
}

0 commit comments

Comments
 (0)