Skip to content
Request an audit

‹ All findings

reqID_pendingAutomationOrder stores the index of the trade, which could point to a different trade since the request was created

Low/InfoOstium·Three Sigma · RWA perpetuals DEX · 19th February, 20243S-OS-L06

Description

reqID_pendingAutomationOrder store the trader, pairIndex and index. index points to the trade in OstiumTradingStorage::openTrades, but the trade itself may have changed since the OstiumPriceUpKeep automation was requested.

A possible scenario is, for example, triggering a take profit, then closing the trade immediately and creating a new trade on index 0 before the first callback was triggered. Note: this is also true for open limit orders, it should also check if the a.orderId matches the corresponding limit order.

The easiest way to fix this is adding a orderId field to OpenLimitOrder which is filled when OstiumTrading::executeAutomationOrder() requests a price.

Recommendation

To avoid this problem, OstiumTradingCallbacks::executeAutomationCloseOrderCallback() and OstiumTradingCallbacks::closeTradeMarketCallback() should validate a.orderId against OstiumTradingStorage::openTradesInfo.tradeId.

Status

Acknowledged