<!-- canonical: https://0xsimao.com/findings/nftperp-ii-reverse-calculates-exchanged-quote -->

# PositionManager:_reversePosition() calculates the notional to reverse but could just use the exchangedQuote

Low/Info · Three Sigma · NFT perpetuals · 29th January, 2024

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

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

---

### Description

[PositionManager:_reversePosition()](https://github.com/nftperp/NFTPerp-V2-Contracts/blob/8ea05fc0ecf299ca8374b571486846652c8725f8/src/clearinghouse-libs/PositionManager.sol#L1027) reduces the notional by the amount required to close
the previous position, fetching the value using the [getters](https://github.com/nftperp/NFTPerp-V2-Contracts/blob/8ea05fc0ecf299ca8374b571486846652c8725f8/src/clearinghouse-libs/PositionManager.sol#L1021-L1025) before. However, it could use
closeResponse.exchangedQuote() instead, which does the same calculations.

### Status

Addressed in [#669b569](https://github.com/nftperp/NFTPerp-V2-Contracts/commit/669b5698fd0c86bc71bc70efec2a633b283c01cb)

---

Related findings:

- [Bug in _reversePosition() might lead to future exploits](https://0xsimao.com/findings/nftperp-i-bug-reverse-future-exploits): Nftperp Exchange
- [_getPositionNotional() crops the size of the position to the available reserves, which may lead to unexpected profits/losses](https://0xsimao.com/findings/nftperp-i-notional-crops-unexpected-profits): Nftperp Exchange
