<!-- canonical: https://0xsimao.com/findings/ostium-close-redundant-storage-info -->

# OstiumTrading::closeTradeMarket() Makes Redundant Call to OstiumTradingStorage::getOpenTradeInfo()

Low/Info · Three Sigma · RWA perpetuals DEX · 19th February, 2024

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

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

---

### Description

At [L284](https://github.com/0xOstium/smart-contracts-threeSigma/blob/869392c4c9114ad468f6c2ea7e425269faf2fe2b/src/OstiumTrading.sol#L284) in OstiumTrading::closeTradeMarket(), the trade info can be reused from the
previous call to OstiumTradingStorage::getOpenTradeInfo() at [L265](https://github.com/0xOstium/smart-contracts-threeSigma/blob/869392c4c9114ad468f6c2ea7e425269faf2fe2b/src/OstiumTrading.sol#L265) to conserve gas by
avoiding redundant function calls.
The same issue is seen in OstiumTrading::closeTradeMarketTimeout() on [L561](https://github.com/0xOstium/smart-contracts-threeSigma/blob/1b70cffbac621d39e321c159e45c048b703add92/src/OstiumTrading.sol#L561) and [L568](https://github.com/0xOstium/smart-contracts-threeSigma/blob/1b70cffbac621d39e321c159e45c048b703add92/src/OstiumTrading.sol#L568)

### Recommendation

```solidity
emit MarketCloseOrderInitiated( - orderId, storageT.getOpenTradeInfo(sender, pairIndex, index).tradeId,
```

sender, pairIndex + orderId, i.tradeId, sender, pairIndex
);

### Status

Addressed in [#155ab21](https://github.com/0xOstium/smart-contracts-threeSigma/pull/58/commits/155ab2117f01d2c6805b3798ea0ddd3b3ab250a5).

---

Related findings:

- [In ConnextHandler, executeFailedWithUpdatedArgs(...), the whole tx is updated on storage if the try call succeeds](https://0xsimao.com/findings/fuji-finance-whole-storage-try-succeeds): Fuji Finance
