@@ -18,8 +18,9 @@ contract ChainlinkOracle is IOracle {
18
18
19
19
/// @notice Vault.
20
20
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;
23
24
/// @notice First base feed.
24
25
AggregatorV3Interface public immutable BASE_FEED_1;
25
26
/// @notice Second base feed.
@@ -38,8 +39,7 @@ contract ChainlinkOracle is IOracle {
38
39
/// @param baseFeed2 Second base feed. Pass address zero if the price = 1.
39
40
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1.
40
41
/// @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.
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 vaultDecimals ,
51
+ uint256 vaultPrecision ,
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 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.
58
58
VAULT = vault;
59
- VAULT_DECIMALS = vaultDecimals ;
59
+ VAULT_PRECISION = vaultPrecision ;
60
60
BASE_FEED_1 = baseFeed1;
61
61
BASE_FEED_2 = baseFeed2;
62
62
QUOTE_FEED_1 = quoteFeed1;
@@ -78,15 +78,15 @@ 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 () - vaultDecimals
81
+ - baseFeed1.getDecimals () - baseFeed2.getDecimals () - vaultPrecision
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_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)
90
90
/ (QUOTE_FEED_1.getPrice () * QUOTE_FEED_2.getPrice ());
91
91
}
92
92
}
0 commit comments