Trading
Open leveraged long or short positions on an event's probability. Margin, mark price, funding, and PnL are computed continuously; settlement is written on-chain.
Collateral & balance
All positions are margined in USDC held in the on-chain CollateralVault. Your balance is split into buckets, mirrored in HotCache for fast reads:
Deposits are direct on-chain transfers to the vault. Withdrawals pass through a delay window — the protocol can reject a withdrawal during that window if your equity would fall below requirements, which is what makes off-chain margining safe.
Margin
perp.com uses cross-style margining per market with two thresholds:
- Initial margin (IM) — required to open or increase a position. Charged up front and held in
locked_for_positions. - Maintenance margin (MM) — the floor your equity must stay above. Cross it and the position becomes liquidatable.
Open-interest-scaled initial margin
The initial margin factor is not flat. It scales with the market's open interest between a per-market lower and upper cap: below the lower cap you pay the base factor; above the upper cap you pay the maximum. The crowdedness of a market raises the cost of adding to it, which damps reflexive blow-offs in thin event markets.
Equity & PnL
Equity is your position margin plus unrealized PnL plus accrued funding. Unrealized PnL is marked against the mark price — the guarded probability — not the last trade, so a single thin print can't trigger or dodge a liquidation.
Mark price
The mark is the smoothed, guarded probability the protocol reads from its oracle. It drives margin, PnL, and liquidation. It is distinct from the trading price set by the order book. The full guard pipeline — deviation clamp, smoothing, staleness, bounds — is documented on the Oracle page.
Funding
Funding is the mechanism that keeps the trading price anchored to the mark. When the book trades persistently above the mark, longs pay shorts; when it trades below, shorts pay longs. It is computed in three stages:
- Per-block premium sample. The engine sweeps a fixed notional through each side of the book to get an impact-bid and impact-ask, takes the impact-mid, and subtracts the index. The result is clamped to a per-market bound.
- Per-minute median. Block samples are reduced to a median each minute, rejecting momentary book gaps.
- Per-period average. Minute medians are averaged across the funding interval to produce the period's funding rate.
The rate is capped so a single period can never push a fully-margined position past maintenance. The cumulative funding index delta is pushed on-chain via applyFundingIndex, and your position accrues funding lazily the next time it's touched — a fill, a liquidation, or settlement.
Market lifecycle
A market moves through an explicit on-chain state machine. Trading behavior changes at each phase:
| Phase | Trading | Notes |
|---|---|---|
Active | Full | Open, close, increase, decrease. Funding and liquidation run. |
Resolving / Settling | Reduce-only | The mark interpolates from its last value toward the resolved value over a window. No new exposure. |
Resolved → Settled | Closed | Residual positions close at the oracle terminal value; balances are released. |
During the settling window the SETTLING Handler interpolates the mark and enforces reduce-only so positions land gently rather than gapping to 0 or 1 at the instant of resolution.
Fees
Taker fills pay a fee; resting maker liquidity is rebated or charged less, encouraging book depth. A share of fees and liquidation residuals seeds the Insurance Fund.