Skip to content
Request an audit

‹ All findings

ClearingHouseLiq::_assertLiquidationAmount() may increase basis points due to negative quoteBalance.amount + insurance

Crit/HighVertex·by the Three Sigma team·Hybrid orderbook DEX·3rd April 20243S-Vertex-C01

Description

If the position is a spread, it may be liquidated as one up to the minimum absolute value of the spot and perp positions. If the spot is short, the liquidatee + insurace need to have enough quote to buy back the spot position.

This check is performed in

solidity
ClearingHouseLiq::_assertLiquidationAmount(): ...

basisAmount = MathHelper.max( -((quoteBalance.amount + insurance).div( liquidationPrice ) + 1), basisAmount

solidity
);
...

Note that quoteBalance.amount + insurance may be negative, which would mean that abs(basisAmount) could be increased, leading to incorrect states.

Recommendation

Add if (quoteBalance.amount + insurance <= 0) basisAmount = 0 or similar.

Status

Addressed in #38bbe76.