<!-- canonical: https://0xsimao.com/findings/nftperp-i-orders-paginated-revert-created -->

# getTriggerOrders() should be paginated or it may revert if enough orders are created

Low/Info · Three Sigma · NFT perpetuals · 2nd January, 2024

Finding 3S-NFTPerp-L03 of the Nftperp Exchange security review.

- Report: /reports/nftperp-i
- Source: https://cdn.sanity.io/files/qoqld077/production/c19530de75e234ad15694b4563edb1fc9d2a3fd8.pdf

---

### Description

There is no limit in the amount of triggerOrders, which means that the array may grow too
large and make transactions revert due to the gas usage exceeding the block gas limit when
calling [getTriggerOrders()](https://github.com/nftperp/NFTPerp-V2-Contracts/blob/main/src/ClearingHouse.sol#L753).

### Recommendation

Paginate the getter so users can fetch information safely.

### Status

Acknowledged

---

Related findings:

- [OstiumPairsStorage::getAllPairsMaxLeverage() reverts if enough pairs are created](https://0xsimao.com/findings/ostium-pairs-storage-reverts-created): Ostium
- [OstiumTrading::executeAutomationOrder() and _getLimitOrdersToTrigger() should check isPaused for open limit orders](https://0xsimao.com/findings/ostium-automation-orders-trigger-paused): Ostium
- [In OstiumTradesUpKeep, _getLimitOrdersToTrigger() and _getOpenOrdersToTrigger() return tradesToTrigger with 1 extra length](https://0xsimao.com/findings/ostium-trades-orders-extra-length): Ostium
- [MerkleTreeOperator::getMerklePath() will revert due to OOG after enough elements](https://0xsimao.com/findings/singularity-merkle-path-revert-elements): Singularity
