Contract Relationships
Position Data Structure
Every position is stored onchain as aPosition 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 Config — Config.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
getOpenPositions
Position Queries
PnL and Risk
Write Functions
openPosition
increasePosition
addPositionMargin
imLocked + amountmust not exceednotional- Allowed even when liquidatable (rescue mechanism)
- Allowed in NORMAL, DEGRADED, and REDUCE_ONLY modes
removePositionMargin
- 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)
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)
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 bySettlementEngineasPositionReduced, since reductions are routed through that contract.
Admin Functions
setProtocolAuthorized / setRiskManager
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
Related Pages
Position Lifecycle
Product-level overview of the position lifecycle.
Settlement Engine
Settlement, liquidation, and early termination contract.
Margin Accounts
Collateral management contract.