Skip to main content
PositionManager handles the full position lifecycle: open, increase, reduce, and margin adjustments. It is the primary entry point for traders interacting with the protocol.

Contract Relationships

Position Data Structure

Every position is stored onchain as a Position struct (see Types Reference for full definition):
There is no Tenor enum. Maturities are stored as raw uint32 tenorSeconds values from the dynamic registry on ConfigConfig.getEnabledTenors() enumerates them.
The imLocked field is the only mutable economic field on an open position. It changes when the trader adds or removes margin. All snapshot* fields are immutable after position creation.

Read Functions

getPosition

Returns the full Position struct for a given ID.

getOpenPositions

Returns all open position IDs for an account.

Position Queries

PnL and Risk

Write Functions

openPosition

Opens a new position. Only allowed in NORMAL mode. Validation checks (in order):

increasePosition

Increases an existing position’s notional. Only allowed in NORMAL mode. Preconditions: Owner only, OPEN status, not matured, not liquidatable. The increase uses a weighted average entry strike:
Additional margin is calculated proportionally:

addPositionMargin

Increases locked margin. Owner only, position must be OPEN and not matured.
  • imLocked + amount must not exceed notional
  • Allowed even when liquidatable (rescue mechanism)
  • Allowed in NORMAL, DEGRADED, and REDUCE_ONLY modes

removePositionMargin

Decreases locked margin. Owner only, position must be OPEN and not matured.
  • Not allowed when liquidatable (reverts PositionLiquidatable)
  • Remaining margin must be >= minIM (using snapshotted IM bps)
  • Post-removal equity must stay above the MM threshold
  • Requires a forward price read (with oracle fee)

closePosition (protocol-only)

Finalizes a position with a close price and computed PnL. Restricted to addresses authorized via setProtocolAuthorized — in practice this is SettlementEngine. Trader-facing close paths (early termination, settlement, liquidation) all go through SettlementEngine, which then calls back into this function.

reducePositionNotional (protocol-only)

Reduces an open position’s notional. Restricted to protocol-authorized callers (SettlementEngine). The trader-facing entry point is SettlementEngine.reducePosition(...), which validates ownership and settles realized PnL on the reduced portion before invoking this.

Snapshotted Parameters

Six configuration parameters are captured at open and remain immutable:

Events

Reduction events are emitted by SettlementEngine as PositionReduced, since reductions are routed through that contract.

Admin Functions

setProtocolAuthorized / setRiskManager

Owner-only. setProtocolAuthorized toggles which contracts may call closePosition / reducePositionNotional (in practice, SettlementEngine). setRiskManager re-points the risk module — pass address(0) to skip cap checks (intended only for emergency unwind, never production).

sweep

Owner-only. Sweeps an arbitrary ERC-20 balance held by the contract.

Position Lifecycle

Product-level overview of the position lifecycle.

Settlement Engine

Settlement, liquidation, and early termination contract.

Margin Accounts

Collateral management contract.