> ## Documentation Index
> Fetch the complete documentation index at: https://docs.joyride.exchange/llms.txt
> Use this file to discover all available pages before exploring further.

# Settlement

> How daily options on Joyride expire and settle, from the settlement price and payoff through the expiry sequence and the records delivered

This page covers the settlement price, the payoff calculation, the sequence of events at the expiry boundary, and the records delivered. Settlement is an on-chain transaction against the margin-vault program, and most of what follows is a consequence of that.

## Contract summary

| Parameter               | Value                                                                                                                             |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Exercise style          | European. Settlement is automatic at expiry.                                                                                      |
| Delivery                | Cash-settled in USDC. No physical delivery of the underlying.                                                                     |
| Expiry                  | Daily at `08:00:00 UTC`                                                                                                           |
| Contract multiplier     | One (1), i.e. one contract represents one unit of the underlying.                                                                 |
| Settlement price source | Time-weighted average price (TWAP) of the underlying index, derived from Pyth oracle prices. One price per underlying per expiry. |
| Settlement fee          | Charged at expiry to ITM holders. See [Settlement fee](#settlement-fee) below.                                                    |

## Settlement price

At the expiry instant, the exchange freezes the current TWAP of the underlying index into a canonical settlement price. The TWAP window opens 30 minutes before expiry (`07:30:00 UTC` for the standard 24-hour round).

Every account on the same underlying and expiry settles against that price. The recorded value is authoritative and replayable.

If no settlement price is available at the boundary, settlement is deferred. There is no fallback price. Trading in the expiring round remains closed, the next round does not open early, and settlement executes once a valid price is available.

## Payoff

Each position settles at intrinsic value against the settlement price `S` and strike `K`:

```text theme={null}
call_intrinsic = max(S − K, 0)
put_intrinsic  = max(K − S, 0)

gross_cashflow = intrinsic × position_quantity   (signed: long +, short −)
net_cashflow   = gross_cashflow − settlement_fee
```

Longs are credited and shorts are debited directly to the account's vault subaccount. There is no separate claims or payout process. An option exactly at the money (`S = K`) settles worthless for both calls and puts. Out-of-the-money positions settle at zero, i.e. the position is still closed and a settlement record is still issued, with a cashflow of zero.

### What counts as one settled unit

Settlement acts on each fill. Every finalized, non-reverted fill at that expiry is valued independently and the results are then netted into one signed balance adjustment per account for the whole expiry, applied on chain to that account's vault subaccount. A strategy (multi-leg) fill settles as its legs, each valued independently and netted per account.

Because a fee is assessed per in-the-money leg, an offsetting pair of fills nets to zero cash but still contains one in-the-money leg. The clamp under [Settlement fee](#settlement-fee) bounds what that leg is charged.

## Settlement fee

The holder of an in-the-money (ITM) position pays a fee at expiry. The writer pays nothing at settlement. Out-of-the-money (OTM) positions pay nothing since intrinsic value is zero.

The fee is the lesser of a rate on index notional and a cap on intrinsic value:

```text theme={null}
fee = min( ppm × settlement_price × quantity, cap_bps × intrinsic × quantity )
```

`ppm` is the rate in parts per million of index notional. `cap_bps` is the cap in basis points of intrinsic value. Both come from your account's fee tier; the standard tier sets the rate to 0.015% of index notional and the cap to 12.5% of intrinsic value. The tier values and their units are set out on [Fees and Limits](/market-makers/fees-and-limits).

The cap keeps a barely-in-the-money position from owing more than it receives. It also covers the out-of-the-money case, since zero intrinsic gives a zero cap and therefore a zero fee.

### What the fee is netted against

An account can hold in-the-money longs and owe on shorts settling together. The fee is clamped against the account's net: an account that nets negative pays no settlement fee, and one whose net is smaller than its assessed total pays only the net.

```text theme={null}
charged = min( sum(assessed fees), max(net_cashflow, 0) )
```

The clamp is applied per expiry. An expiry is planned as a single settlement across every underlying, so the clamp sees the account's whole expiry in one number.

A settlement fee never leaves an account worse off than it stood before the settlement.

### Which rate applies

The rate and the account's tier assignment are frozen when the expiry's settlement price is recorded, and the whole expiry settles against that frozen pair. Settlement can span several transactions over several minutes; without the freeze, two accounts with identical positions could be charged different rates depending on which batch landed first.

A rate change never unwinds fees already collected.

### Where the money lands

The fee is an on-chain transfer into the fee subaccount, carried inside the settlement transaction itself as the entry that makes the batch balance.

## Expiry sequence

Settlement is a transaction against the margin-vault program and waits for its inputs to be final on chain before moving any balance.

1. **A settlement delay elapses** after the expiry instant (default 60 seconds), giving the settlement price and the last on-chain fill finalizations time to land.
2. **Preconditions are checked.** Every fill at that expiry must be finalized on chain (confirmed is not sufficient), and a settlement price must exist for every underlying involved. If either is missing, settlement waits and retries. There is no fallback price, and a fill that could still be reorged away is not settled.
3. **The expiry is planned.** Across every fill at that expiry and every underlying, the planner computes for each account: its net signed balance adjustment, the collateral lock to release, how many written positions close, and any shortfall. Fees are assessed per in-the-money leg and then clamped to the account's expiry net.
4. **Entries are batched.** Entries are ordered deterministically, payers first and then receivers, and chunked into `apply_settlement` batches sized to one Solana transaction. Payers land first so the fee subaccount always holds what the later receiver batches pay out.
5. **Each batch is made self-balancing.** A single entry against the fee subaccount closes the batch so that its balance adjustments sum exactly to its insurance draw. This is the same entry that collects the settlement fees.
6. **Batches are sent in order**, each recorded durably as an intent before it is submitted. A batch is keyed `(expiry, batch_id)` and guarded by an on-chain receipt, so re-submitting one is a no-op rather than a double settlement.
7. **Landed batches are ingested.** The chain watcher reads the per-entry effects and the batch summary back off chain: positions clear, collateral locks release, and fee attribution is marked confirmed.
8. **Anything that did not land is re-planned.** A re-plan excludes accounts a prior batch already settled and never reuses a batch id, so recovery converges on exactly one settlement per account.

## Settlement records

There is no live message stream for settlement. The authoritative record is the `apply_settlement` transaction, which carries, per account, the signed balance adjustment, the lock release, and the position count closed. The exchange mirrors it into its own records as it is ingested; the settled fills are read from `GET /api/query/rfq-fills` and the resulting balance from `GET /api/query/vault-subaccount`.

A fee record is written before it is charged. Fee attribution is recorded when the settlement batch is built, ahead of submission, and carries a confirmation timestamp that stays empty until that exact transaction lands. An unconfirmed row records an intent; the charge exists only once the timestamp is set. Revenue and statement figures must filter on confirmation.

Confirmation is per attempt. A batch that fails to land is re-planned and re-sent, and the replacement can carry a different fee, or none, if the account's tier changed in between. Each attempt keeps its own record and at most one is ever confirmed, because the on-chain receipt allows only one application to take effect. Superseded attempts stay unconfirmed.

The recorded cashflow stays gross, so the payout before fees and the amount taken from it are both recoverable.

## Solvency & loss handling

Joyride does not socialize losses. There is no auto-deleveraging, no clawback of settled profits, and no haircut applied to winning positions to fund another account's shortfall. Winning counterparties are paid full intrinsic value less the settlement fee described above.

The settlement fee is never the cause of a shortfall draw. It is clamped to what the settlement paid the account, so the debit cannot leave the account worse off than it stood before, and loss-absorbing capital never finances fee revenue.
