Architecture

One Anchor program, mark_perp, holds the exchange, each market, each trader, and each position.

Collateral is a six-decimal mint the exchange can faucet on devnet. Three token accounts — vault, insurance, fees — are program-derived.

The desk, the keeper, and the tests all speak the same integer formulas.

Path of a fill

The trader deposits into the vault. Open refreshes the index, settles funding, quotes the fill, locks margin, and moves open interest.

A later crank writes the cumulative funding index. The payment moves when the position is touched. Close realises price PnL against the insurance fund.

Back to the desk