> For the complete documentation index, see [llms.txt](https://polyperp.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polyperp.gitbook.io/docs/trading/settlement-and-resolution.md).

# Settlement & Resolution

Settlement is the final stage of a Polyperp leveraged position, directly triggered by the resolution of the underlying Polymarket event. Each Polyperp market corresponds to a unique Polymarket event, which has a defined outcome (YES = 1, NO = 0). When Polymarket finalizes this outcome, Polyperp automatically settles all open positions on-chain. This design ensures that trading results are always anchored to real-world event probabilities and prevents any divergence between leveraged positions and their underlying reference.

The system continuously monitors Polymarket for event resolution and triggers settlement automatically without requiring any manual intervention. This ensures that traders receive their final account balances immediately after the outcome is finalized.

### Position PnL Calculation

Once the event outcome is known, each trader’s realized profit and loss (PnL) is calculated using three key parameters: position size, trade direction (long or short), and leverage applied. The final reference price is reconciled with the Polymarket outcome to compute the exact PnL.

Profitable positions are credited with USDC directly into the trader’s margin account, while losing positions have their collateral deducted proportionally. The on-chain nature of this calculation ensures full determinism, meaning that every trader, third-party observer, or analytics tool can independently verify the PnL calculation based on recorded trades, leverage, and collateral.

Additionally, the system accounts for partial positions, cross-margin allocations, and any remaining collateral after liquidations, ensuring that PnL distribution is precise and fair.

### Fair and Deterministic Settlement

Polyperp’s settlement mechanism leverages the on-chain mark price, which incorporates the Polymarket reference price and current order book state. This ensures that even during periods of high volatility or rapid market changes near event resolution, settlements remain predictable, fair, and resistant to manipulation.

Unlike off-chain or centralized systems, where delays or intermediaries can introduce errors, Polyperp’s settlement is fully permissionless. Every payout, margin adjustment, and closure of positions is recorded on-chain, allowing complete transparency.

### Post-Settlement Process

After settlement, all resolved positions are automatically closed, freeing collateral for traders to use in new markets. Resolved markets are archived on-chain, ensuring that historical data remains accessible.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://polyperp.gitbook.io/docs/trading/settlement-and-resolution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
