<!-- canonical: https://0xsimao.com/findings/nftperp-ii-match-certain-tick-checking -->

# _match() always checks the trigger of the first order of a certain tick, instead of checking i order

Medium · Three Sigma · NFT perpetuals · 29th January, 2024

Finding 3S-NFTPerp-L02 of the Nftperp Matching Engine security review.

- Report: /reports/nftperp-ii
- Source: https://cdn.sanity.io/files/qoqld077/production/87f617e82d5468500e950a669f30607376b37c32.pdf

---

### Description

[PositionManager:_match()](https://github.com/nftperp/NFTPerp-V2-Contracts/blob/8ea05fc0ecf299ca8374b571486846652c8725f8/src/clearinghouse-libs/PositionManager.sol#L398) looks for all the orders for their trigger values as some order
may have been filled/deleted. However, currently it only checks the first order instead of the
i one, which could cause problems down the line.

### Status

Addressed in [#b471f71](https://github.com/nftperp/NFTPerp-V2-Contracts/commit/b471f7126ffd7f3438202eb9add092d85de9af05)

---

Related findings:

- [OstiumTrading::executeAutomationOrder() and _getLimitOrdersToTrigger() should check isPaused for open limit orders](https://0xsimao.com/findings/ostium-automation-orders-trigger-paused): Ostium
- [OstiumTrading::closeTradeMarket() and OstiumTrading::topUpCollateral() are missing pending trigger checks](https://0xsimao.com/findings/ostium-close-trade-top-collateral): Ostium
- [OstiumTradingCallbacks::executeAutomationOpenOrderCallback() opens limit orders at market price instead of the limit price](https://0xsimao.com/findings/ostium-callbacks-callback-opens-price): Ostium
