Protocol widely assumes price from oracle adapters has 1e6 precission which is explicitly defined in Natspec. However LibUniswapOracle has arbitrary precision depending on Quote token decimals.
For example let's have a look on LibUsdOracle.getUsdPrice()
which is used to fetch price in Fertilizer. getUsdPrice()
-> getTokenPriceFromExternal()
-> LibUniswapOracle.getTwap()
As you can see returned value does not have 1e6 precission if LibUniswapOracle.getTwap()
doesn't return so.
OracleLibrary.sol by definition returns how much of token2
is required to buy oneToken
amount of token1
. As you can see getTwap()
doesn't adjust decimals of returned answer.
Tokens in Fertilizer are incorrectly priced when quote token is different than 6 decimals.
Manual Review
Normalize price in LibUniswapOracle by Qoute's decimals to have 1e6 precision. Also update logic in LibWstethEthOracle because it correctly handles 1e18 precision currently.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.