Skip to content
Request an audit

‹ All findings

removeLiquidity() in the amm calculates marginToRemove without updating the margin with the funding payment

MediumNftperp Exchange·Three Sigma · NFT perpetuals · 2nd January, 20243S-NFTPerp-L05

Description

removeLiquidity() removes the margin from the position pro-rata to the removed shares, without considering the previous funding payment.

The impact should be limited to the case when a significant amount of shares is removed and the fundingPayment is applied after the margin removal, which may lead to bad debt and revert.

Recommendation

Add the fundingPayment to the margin and only then calculate marginToRemove.

Status

Addressed in the AMMRouter