On Synthetix, positions, margin, and settlement flows are tracked by the protocol. The UI typically surfaces convenience metrics like average entry price, unrealized PnL, and realized/closed PnL by deriving them from the position state and fills.
Perps
What counts as opening vs closing
A trade is opening when it increases the absolute position size in the same direction (adding to a long or adding to a short). A trade is closing when it reduces an existing position (partially or fully). If a trade crosses through zero, it’s effectively a close + an open in the opposite direction.
Entry price (average entry)
Opening / add-to-position: average entry is updated as a size-weighted average of the existing entry price and the new fill price:
Closing / reduce: the entry price for the remaining position stays the same.
Flip (close then open opposite): the portion that opens a new position gets a new entry price based on the fill(s) that created it.
Unrealized PnL
Unrealized PnL is typically computed from the current mark price versus entry price, multiplied by signed position size:
Realized / Closed PnL
For any closing portion of a trade, realized PnL is the portion closed times the difference between the fill price and entry (sign-aware):
“Closed PnL” shown in the UI is realizedPnL not including and deductions (funding,fees etc)



