When the Chainlink price feed has invalidFetchData
or priceDeviation
it will call the Uniswap WETH-USDC pool observe()
function as a backup, but in its conversion to Ether, it has significant precision loss.
The /
division operator is used instead of .div()
from PRBMathHelper
, which leads to roundings to zero which diverts the stored price from the real price.
First, uncomment the console import.
Then, add this after line 85 of contracts/libraries/LibOracle.sol:
You can run this numbers with:
FOUNDRY_PROFILE=fork forge test --mt testFork_MultiAsset -vv
Ranging from 0.04% at current market price, which would be magnified to 0.4% if Eth price dropped by an order of magnitude.
At current market price -> (1_902_501_929_000_000_000_000 / 1_902_000_000_000_000_000_000) * 100 = 0.026%
At 90% below market price -> (190_260_455_000_000_000_000 / 190_200_000_000_000_000_000) * 100 = 0.032%
Percentages similar to AMM slippage, which would be unattractive in an Orderbook like Ditto is since one of its promises is being slippage free.
Manual review and Chisel
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.