Submitted by IllIllI
While users are incentivized to call the heartbeat, the incentive may be removed later, or it may be more profitable to use old prices, so users may not call the heartbeat during unfavorable prices, leading to the TWAP price being incorrect, and users getting the wrong price for their assets.
A similar case of an incomplete TWAP algorithm was found to be of Medium risk.
A TWAP is a Time-Weighted average price, but the algorithm below does not take into account the time between observations:
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/modules/PRICE.sol#L134-L144
While the Heart policy enforces an upper bound on how frequently updates are added to the average, there is no guarantee that users call beat() in a timely manner:
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Heart.sol#L92-L94
The incentive may be set to too low an amount:
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Heart.sol#L140-L147
Or users may find it more profitable to skip a particular update, or front-run an unfavorable update, with a transaction that trades assets at the old price
Always call an internal version of beat() that doesnt revert, in functions that swap user assets. The code should also track the timestamps of when each beat() is called, and include the amount of time that has passed since the last beat, in the TWAP calculation
Oighty (Olympus) disagreed with severity and commented:
0xean (judge) commented:
Oighty (Olympus) commented:
