kimia-perp) is an on-chain orderbook-based derivatives
exchange. It supports long and short positions on SOL-PERP (V1) with USDC as the single
collateral type.
What makes it distinct
- On-chain FIFO orderbook, up to 32 bids and 32 asks per market, matched in price-then-time priority. Up to 4 fills per transaction to stay inside compute limits.
- Single-position-per-market (V1), one user account holds one directional position per market; switching direction requires closing first.
- Reserved margin for resting orders, margin locks at placement, not fill, preventing order-book spam from over-leveraging the account.
- Permissionless funding + liquidation, any keeper can crank.
- Pyth Hermes Pull Oracles, prices are posted and consumed in the same tx.
Precision
| Quantity | Decimals | Precision |
|---|---|---|
| Base (SOL) | 9 | 1_000_000_000 |
| Quote / collateral (USDC) | 6 | 1_000_000 |
| Price | 6 | 1_000_000 |
| Funding rate | 9 | 1_000_000_000 |
| Margin ratio / BPS | 4 | 10_000 |
Position math
A position has a signedbase_amount (positive = long, negative = short) and a
quote_entry accumulator.
For a long at entry with mark :
pnl = base·M - base·E = base·(M-E) ✓
For a short at entry with mark :
pnl = -base·M + base·E = base·(E-M) ✓
Margin model
| Check | Formula | When |
|---|---|---|
| Initial margin | notional × initialMarginRatio / 10_000 | Opening / increasing a position |
| Maintenance margin | notional × maintenanceMarginRatio / 10_000 | Every mark / oracle update |
| Health | freeCollateral + unrealizedPnL - maintReq | On liquidation check |
| Liquidation trigger | health ≤ 0 |
Mark price
Mark price is derived from the last trade, clamped to the oracle within ±10%. This prevents a single manipulated fill from cascading through liquidations.What a trade touches
Oracle post (prepended instruction)
Off-chain you fetch a signed update from Hermes and post it via
@pythnetwork/pyth-solana-receiver. This creates a PriceUpdateV2 account
usable for one tx.Reserve margin + match
place_order locks notional × initialMargin out of free collateral and then
walks the book up to 4 fills, emitting OrderFilled events and adjusting both
sides’ positions.Fees
| Fee | Default | Sink |
|---|---|---|
| Taker | 10 bps | fee_vault |
| Maker | 5 bps | fee_vault |
| Liquidation | 500 bps of notional closed | split 50/50 between liquidator and insurance |
Read next
Funding rate
The Drift-style dynamic funding formula Kimia uses.
Oracles
How Pyth Hermes Pull Oracles are validated.
kimia-perp reference
Full list of instructions, accounts, and error codes.
Trade a perpetual
End-to-end walkthrough.

