Olive Docs

TP/SL Orders

Take-profit and stop-loss orders are Olive's price-triggered exit orders. They are the supported limit-style close mechanism for options, perpetual futures, and expiry futures. The contract does not create separate limit-close order accounts for these products.

Orderbook

Each TP/SL orderbook is bound to one owner, one position, one pool, and one product type:

  • 0 for perpetual futures
  • 1 for options
  • 2 for expiry futures

The owner initializes the orderbook and pays the orderbook rent. The orderbook stores fixed slots for take-profit orders and stop-loss orders.

Coverage

Each TP/SL order stores a percentage of the parent position. Percentages are scaled on-chain, and 100% means the full remaining position.

Take-profit coverage and stop-loss coverage are tracked separately:

  • Total take-profit coverage cannot exceed 100%.
  • Total stop-loss coverage cannot exceed 100%.
  • Updating an order re-checks the total coverage.
  • Removing an order reduces the relevant total coverage.

This means a position can have 100% take-profit coverage and 100% stop-loss coverage at the same time, but it cannot have more than 100% coverage on either side.

How percentages apply

Each order's percentage is applied to the position's remaining size at the moment that order triggers — not to the position's original size. The 100% cap on total coverage is a limit on what you can schedule; it is not a guarantee that stacked orders fully exit the position.

Because each order acts on whatever is left when it fires, stacked percentages compound rather than add. For example, a 30% take-profit followed by a 70% take-profit closes 30% of the position, then 70% of the remaining 70% (which is 49% of the original), leaving about 21% still open. This is intended: each order closes a fraction of the current remainder.

To fully exit a position with a single trigger, use one order at 100%.

Managing Orders

The owner can add, update, remove, or clear TP/SL orders while the parent position is active. Removing a TP/SL order does not close the parent position.

If all active TP/SL orders are removed, the orderbook is closed and its rent is refunded to the owner.

Execution

TP/SL execution is keeper-driven. When the current oracle-derived price satisfies a trigger, a keeper submits the execute instruction. The contract validates the trigger condition on-chain before closing any amount.

Execution uses the product's voluntary close economics:

  • Options close against the current Black-Scholes premium.
  • Perpetual futures close against current oracle PnL and accrued borrow fees.
  • Expiry futures close against current futures PnL.

If a TP/SL execution consumes the final active order, the orderbook is closed and its rent is paid to the keeper that executed it. If execution fully closes the parent position, the position account can also be closed by the same execution path.

Trigger Prices

TP/SL trigger-price meaning depends on product type:

  • Perpetual futures use the spot price.
  • Expiry futures use the theoretical future price.
  • Options use the current option premium, not the underlying spot price.

For long perpetual and futures positions, take profit triggers when price moves up to or above the target and stop loss triggers when price moves down to or below the target. For short perpetual and futures positions, the direction is reversed.

On this page