Appearance
Settlement
Settlement is the process of converting oracle rate index changes into realized P&L on trader positions. It is lazy - funding only settles when a position is touched (via trade, withdrawal, liquidation, or explicit close). This avoids continuous per-position update overhead on Solana.
Oracle Cumulative Index
The oracle maintains a signed cumulative funding integral
This index may increase or decrease depending on the sign of the floating rate. The key property is that the difference between two index snapshots gives the realized floating rate over that period:
Querying the Index
The protocol needs the oracle index at specific timestamps for settlement. There are three cases:
- Current time: If the oracle was just updated, use the on-chain
rate_index_waddirectly - Between updates (extrapolation): For timestamps after the last update but within the staleness window, the index is extrapolated using the last known instantaneous rate
- Historical timestamps: For timestamps in the past (e.g., a position's expiry time), the oracle history Merkle tree provides a proof of the index at that time, and linear interpolation within the proven interval gives the exact value
Funding Settlement
When a position is settled, the protocol computes the funding payment based on the position's notional and the change in the oracle index since the last settlement:
This is a signed calculation:
- Pay-fixed positions (
notional > 0): Profit when the floating rate rises (index increases) - Receive-fixed positions (
notional < 0): Profit when the floating rate falls (index decreases)
The funding delta is added to the position's realized_pnl_wad. After settlement, the position's last_funding_index_wad is updated to the current index value.
Mark-to-Market (MTM)
MTM captures the unrealized value of the difference between a position's entry rate and the current mark rate:
MTM is used for health calculations, margin checks, and liquidation eligibility. It is not realized until the position is closed or modified.
After Expiry
Once a position passes its end time, MTM becomes exactly zero - there is no remaining time-value. Settlement of expired positions uses only the funding accrual up to the expiry timestamp.
Expired Position Settlement
Positions that have passed their end_time enter a special settlement flow:
Funding accrual stops at expiry: The position's funding is settled only up to
end_time, not the current time. Any floating rate movement after expiry does not affect the position.Historical oracle proof: Since the oracle's on-chain state only reflects the latest update, the protocol uses the oracle history Merkle tree to prove what the index was at the position's
end_time. A leaf from the history tree is provided containing the time interval that brackets the expiry, and linear interpolation gives the exact index value.Final settlement: The difference between the interpolated index at
end_timeand the position'slast_funding_index_wadgives the final funding delta. This is added to realized PnL, and the position is closed.
This mechanism ensures that positions are settled at their exact expiry rate regardless of when the close transaction actually executes - whether that's seconds or days after expiry.
Open Interest Fee Settlement
At each settlement, the Open Interest Fee (see Fees) is also computed and deducted from the position's realized PnL. The fee accrues proportionally to the time elapsed since the last settlement, based on the position's absolute notional and the configured annual rate.