Severity: Medium
Because MarketConfiguration::update function does not set the priceFeedHeartbeatSeconds value, the priceFeedHeartbeatSeconds cannot be initialized and will always be 0.
The PerpMarket::getIndexPrice function uses the priceFeedHeartbeatSeconds value and the function reverts for most transactions except for transactions which are included after the chainlink price-feed update in the same block.
The PerpMarket::getIndexPrice function is used in all market operations: createMarketOrder, _fillOrder, liquidate and withdrawMargin(if there's a open position). Traders transactions might succeed or fail.
Considering the chances that fillOfflineOrder might be called in the same block as chainlink update are non-negligible, a position might be opened for some traders.
The traders with open position cannot close their position unless the transaction is included in the block with the future chainlink updates for the market resulting in temporary freeze of assets for the traders.
Definition of the MarketConfiguration::update function: MarketConfiguration.sol#L37-L49
The MarketConfiguration::update function does not set the priceFeedHeartbeatSeconds. The value is 0 for all perp markets.
The PerpMarket::getIndexPrice function calls the ChainlinkUtil::getPrice function and passes the priceFeedHeartbeatSeconds of the market.
Snippet of PerpMarket::getIndexPrice calling ChainlinkUtil::getPrice: PerpMarket.sol#L83-L85
The ChainlinkUtil::getPrice function fetches the latestRoundData from the feed and reverts if block.timestamp - updatedAt > priceFeedHeartbeatSeconds.
Snippet of ChainlinkUtil::getPrice function checking the heart beat seconds: ChainlinkUtil.sol#L60-L62
Given priceFeedHeartbeatSeconds is always 0, the getPrice function reverts if block.timestamp != updatedAt. As a result, the getPrice function succeeds if and only if the chainlink feed was updated in the same block.
The Zaros protocol is not usable with the current implementation. Most of the trading operation transactions will fail. If any operation succeeds then it leads to temporary freeze of trader's collateral.
Manual Review
Update MarketConfiguration::update function to initialize priceFeedHeartbeatSeconds value.
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.