L-1: Unnecessary precision loss in `_adjustForOracleRates()` due to intermediate WAD truncation
Summary:
_adjustForOracleRates() computes _price.wmul(_baseOracleRate).wdiv(_quoteOracleRate), which introduces an avoidable rounding step.
Description:
The expression _price.wmul(_baseOracleRate).wdiv(_quoteOracleRate) expands to:
((_price * _baseOracleRate / WAD) * WAD) / _quoteOracleRate
The intermediate division by WAD in wmul() truncates before the subsequent multiplication in wdiv(). This can be simplified to _price * _baseOracleRate / _quoteOracleRate, which avoids the intermediate truncation and preserves more precision. Since all three values are in WAD scale, the single division by _quoteOracleRate (1e18-denominated) produces the correct WAD-scaled result.
Impact:
Low.
Recommendation:
Replace the chained wmul/wdiv with a single multiplication and division:
return _price * _baseOracleRate / _quoteOracleRate;
Developer Response:
Acknowledged. This is the same pattern used throughout the codebase.