Olive Docs
Perpetual Futures

Close Perp

You can close any percentage of an active perp position with a market close order. Price-triggered exits are handled through TP/SL orders, not through a separate limit-close order. You can choose to receive either currency of the pool when closing.

Partial and Full Close

A close can consume part of the position or the full remaining position. For a partial close, the closed base quantity, collateral, accrued borrow fees, and close fee are all applied to the closed fraction. The remaining position keeps the unclosed fraction.

For a full close, the position is terminal. The position account is closed, rent is returned to the owner, and any companion TP/SL orderbook closure must preserve the orderbook cleanup rules: the orderbook can only be closed when no TP or SL orders remain, and the position's tp_sl_orderbook pointer is cleared when that closure happens.

PnL

Perp PnL uses the stored base quantity from the position and the oracle spot price. The entry price is the spot oracle price at open:

S0=entry spot priceS_0=\text{entry spot price}

The current close price is:

St=current oracle spot priceS_t=\text{current oracle spot price}

The closed quantity is:

qclosed=qbaseclose fractionq_\text{closed}=q_\text{base}\cdot\text{close fraction}

PnL on the closed fraction is:

PnL={qclosed(StS0),long perp,qclosed(S0St),short perp.\mathrm{PnL}= \begin{cases} q_\text{closed}(S_t-S_0), & \text{long perp},\\ q_\text{closed}(S_0-S_t), & \text{short perp}. \end{cases}

Borrow Fees

Before closing, the position accrues borrow fees through the relevant custody's cumulative borrow-rate index. A long perp accrues against the underlying custody index. A short perp accrues against the USDC custody index.

For a partial close, only the closed portion of accrued borrow fees is charged. The remaining borrow-fee debt stays with the remaining position.

Close Settlement

The close result is computed from the closed collateral, realized PnL, accrued borrow fees on the closed portion, and the voluntary close fee:

settlement=closed collateral+PnLborrow feeclose fee\text{settlement} = \text{closed collateral} +\mathrm{PnL} -\text{borrow fee} -\text{close fee}

The voluntary close fee is:

close fee=0.001closed size\text{close fee}=0.001\cdot\text{closed size}

The fee routes through the protocol fee split: 25% to the company fee bucket and 75% to the pool. Keeper rewards are not paid from the close fee.

If settlement is positive, the owner receives the payout in the selected receive currency. If settlement is zero or negative, there is no positive payout to send.

On this page