When computing the price of a stablecoin by using a uniswap v3 twap implementation, it will result in a DoS for most of the time
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/main/protocol/contracts/libraries/Oracle/LibUsdOracle.sol#L155-L159
If we look at the getTokenPriceFromExternal
function we can see there are 3 different scenarios according to the encodeType we pass in:
If the encodeType is equal to bytes1(0x01), it fetches the price of the token using a chainlink price feed.
If the encodeType is equal to bytes1(0x02), it is assumed that a stablecoin is passed (according to the comments) and it fetches the twap from uniswap v3. Afterwards, it fetches the price of USDC/USD from a chainlink price feed. However, to do that it passes a 4-hour timeout that will make the result to be most of the time 0 because the heartbeat of the USDC/USD chainlink price feed is 24 hours, so it will exceed the 4 hour timeout and will understand that the price is stale. In this case, the timeout passed should be the one that is compatible with the 24-hour heartbeat price feeds that is stored in the LibChainlinkOracle
file:
High
Every price of any token that would be configured to be extracted from a uniswap v3 oracle, will not work for 20 hours each day due to the timeout.
Manual review
Change the timeout to be 4 days instead of 4 hours:
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.