Lines 53 and 54 do not consider decimals, this can lead to very large calculation errors. For example, the decimals of token A is 8 and the decimals of token B is 18, then r0 is almost always 0.
Impact
The computeFairReserves function is used to calculate prices, which can lead to very large price errors.
J4de
medium
BalancePairOracal.sol#computeFairReserves
function does not consider the decimalsSummary
BalancePairOracal.sol#computeFairReserves
function does not consider the decimals.Vulnerability Detail
resA
: the balances of token AresB
: the balances of token BpxA
: the price of token ApxB
: the price of token BwA
: the weight of token AwB
: the weight of token BLines 53 and 54 do not consider decimals, this can lead to very large calculation errors. For example, the decimals of token A is 8 and the decimals of token B is 18, then
r0
is almost always 0.Impact
The
computeFairReserves
function is used to calculate prices, which can lead to very large price errors.Code Snippet
https://github.com/sherlock-audit/2023-04-blueberry/blob/main/blueberry-core/contracts/oracle/BalancerPairOracle.sol#L53-L54
Tool used
Manual Review
Recommendation
It is recommended to consider the decimal places of token and price.