<!-- canonical: https://0xsimao.com/findings/nftperp-ii-notional-difference-liquidty-revert -->

# Notional difference in AmmRouter:removeLiquidty() may revert in certain cases

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

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

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

---

### Description

[AmmRouter:removeLiquidity()](https://github.com/nftperp/NFTPerp-V2-Contracts/blob/8ea05fc0ecf299ca8374b571486846652c8725f8/src/AMMRouter.sol#L367-L371) subtracts the long notional by the short notional if the size is
bigger than 0 (contrary if size is smaller than 0), which may revert if the short notional is
bigger than the long one.

### Recommendation

Use the distance between the notionals.

### Status

Addressed in [#74bc3c3](https://github.com/nftperp/NFTPerp-V2-Contracts/commit/74bc3c391f95ead71e2a9ce9e26b0badda96419c)

---

Related findings:

- [removeLiquidity() in the amm calculates marginToRemove without updating the margin with the funding payment](https://0xsimao.com/findings/nftperp-i-calculates-margin-updating-payment): Nftperp Exchange
- [Queue MapleWithdrawalManager may revert due to honest removeShares() or manual redeem calls](https://0xsimao.com/findings/maple-finance-ii-queue-withdrawal-shares-redeem): Maple Withdrawal Manager
- [_crossTransfer(...) should revert if users specify routerByDomain[destDomain] as destination](https://0xsimao.com/findings/fuji-finance-transfer-revert-specify-dest): Fuji Finance
