<!-- canonical: https://0xsimao.com/findings/ostium-price-perform-correctly-reverts -->

# OstiumPriceUpKeep::performUpKeep() does not correctly handle possible reverts

Medium · Three Sigma · RWA perpetuals DEX · 19th February, 2024

Finding 3S-OS-M08 of the Ostium security review.

- Protocol: https://www.ostium.com/
- Report: /reports/ostium
- Source: https://cdn.sanity.io/files/qoqld077/production/a95b9c69e0f65d1d6b0e649f0d62a362358ca8ce.pdf

---

### Description

OstiumPriceUpKeep::performUpKeep() should unregister pending market orders or
disable triggers and pending limit orders if the execution fails. However, it is not dealing with
all the revert scenarios, for example:
1. Not enough value to [pay](https://github.com/0xOstium/smart-contracts-threeSigma/blob/audit-feedback/src/OstiumPriceUpKeep.sol#L126) for the verifier.
2. [Invalid prices](https://github.com/0xOstium/smart-contracts-threeSigma/blob/audit-feedback/src/OstiumPriceUpKeep.sol#L147-L152).

### Recommendation

If performUpKeep() reverts due to one of these reasons, the protocol should be protected
and make users pay for it.
If it does not have enough value to pay for the verifier or the prices are invalid, the
corresponding user should still pay the oracle fees. Additionally, before calling
[OstiumPriceUpKeep::getPrice()](https://github.com/0xOstium/smart-contracts-threeSigma/blob/audit-feedback/src/OstiumPriceUpKeep.sol#L66), a check should be in place to ensure the contract will have
enough eth to pay for [performUpkeep()](https://github.com/0xOstium/smart-contracts-threeSigma/blob/audit-feedback/src/OstiumPriceUpKeep.sol#L103).
Instead of reverting, it should also unregister the orders and the triggers to allow faster
replayability.

### Status

Acknowledged

---

Related findings:

- [_getPriceToTick() reverts if the price is smaller than 1e10, which may happen in _search() as it assumes the final tick as going entirely to the amm](https://0xsimao.com/findings/nftperp-i-price-reverts-happen-entirely): Nftperp Exchange
