Positions are closed either by deleting the Superfluid stream to the Market’s SuperApp yourself or by updating an existing stream to decrease the flow rate.
Positions are liquidated internally by the Market if the Superfluid stream is liquidated (deleted by Superfluid sentinel) due to insufficient balance in the stream sender’s wallet.
The positions aren’t explicitly marked as LIQUIDATED in storage; they are simply accounted for using _lastFlowDeleteTimestamp.
When a user queries for a position using positions(positionId), if the position is still OPEN but the stream was deleted at some point after opening, the position is considered liquidated and the postion state is returend as CLOSED.
When a user tries to delete their own stream, onFlowDeleted and the Market checks to make sure that if the msgSender is the same as the stream sender, then it checks if userData contains a valid positionId owned by the msgSender. If so, it treats this as a user-initiated close. If not, the callback reverts.This does poses a risk of accidentally jailing SuperTokens. Read the risks section for more details.