Market-maker spline live surface#
This document describes the current canonical spline implementation. It is
derived from program/src/instruction.rs, program/src/state/spline.rs,
program/src/logic/spline/, and the spline processors. It intentionally does
not describe the retired per-market registry or region-based ABI.
Model#
Spline liquidity uses a two-account series/seat model (spec/ACCOUNTS.md
§12.1–§12.4) paired with an inline active-seat registry on MarketAccount
(capacity SEAT_REGISTRY_CAPACITY = 16, bounded by
max_active_seats_per_market).
MakerSeriesAccount(1,152 bytes, version 2): reusable maker series and template (bid_levels,ask_levels, default quote program, and subscription policy).Its vault PDA is:text["seesaw", "spline_series", feed_id, duration_seconds.to_le_bytes(), currency_record, maker]text["seesaw", "spline_vault", series]SplineSeatAccount(1,480 bytes, version 2): per-market attached seat holding the installed bounded quote program (ACCOUNTS.md§12.4), parametersP0..P15, hot inputs (mid_bps,skew_bps,half_spread_bps), up to 16 bid and 16 askCurveLevelentries (for preset-0 TABLE programs), EMA state, commitment, inventory, and optional Market Tick window.text["seesaw", "spline_seat", market, maker]
Any maker may attach one seat per compatible market (up to the market's active
seat cap). The maker controls template/program/table installation and authority
rotation; the maker or delegated quote_authority publishes hot-path quotes
(UpdateSeatQuote) and parameters (UpdateSeatParams).
Level endpoints#
end_quantity_lots is an exclusive cumulative quantity endpoint per side.
Level i owns the half-open interval
[previous_end, end_quantity_lots), where previous_end is the prior
level's endpoint (0 for the first level), so it offers exactly
end_quantity_lots - previous_end lots. Endpoints must be nonzero and
strictly increasing; the last endpoint is the side's total capacity.
A side quotes the first level whose endpoint is strictly greater than that side's lifetime consumed-lot counter. When the counter equals an endpoint, that level is exhausted and the next level quotes; when it equals the last endpoint, the side offers no liquidity. One fill that crosses an endpoint is priced per level.
The table below is executable: a unit test in
program/src/logic/spline/snapshot.rs parses it and checks every row
against the matcher. The curve is midpoint 5000 with two ask levels,
(end_quantity_lots, price_offset_bps) = (10, 10) then (25, 20).
| Consumed lots before | Quoting level | Ask price bps | Available lots |
|---|---|---|---|
| 0 | 0 | 5010 | 10 |
| 9 | 0 | 5010 | 1 |
| 10 | 1 | 5020 | 15 |
| 11 | 1 | 5020 | 14 |
| 24 | 1 | 5020 | 1 |
| 25 | none | none | 0 |
From zero consumed lots, a 12-lot buy fills 10 lots at 5010 and 2 lots at
5020, leaving the counter at 12. Bids mirror this below the midpoint
(mid - price_offset_bps).
Account layout#
MakerSeriesAccount is 1,152 bytes (version 2, discriminator MKRSER\0\0) and
SplineSeatAccount is 1,480 bytes (version 2, discriminator SPLSEAT\0).
Their exact layouts and version checks are enforced by compile-time assertions
in program/src/state/spline.rs and program/src/state/spline_seat.rs and
documented in spec/ACCOUNTS.md §12.1–§12.4.
Key seat fields include maker, series, market, quote_authority,
authority_epoch (u64), sequence (u64), program_generation (u64),
mid_price_bps, skew_bps, half_spread_bps, max_quote_age_seconds,
last_update_unix, priority_slot, bid_levels/ask_levels,
consumed_bid_lots/consumed_ask_lots, committed_collateral,
yes_inventory/no_inventory, cumulative rounding state (offsets 824–905),
optional Market Tick window (offsets 912–975), quote-program header/code/params
(offsets 976–1351), cap_bid_lots/cap_ask_lots, and EMA state.
All decoders require exact size, discriminator, version, owner, PDA, bump, and zero reserved bytes.
Canonical instructions#
Recovery validates the complete destination frame before calculating transfers. Both maker YES and NO token accounts must be initialized, unfrozen, and bound to the correct maker and mint, including one-sided and cash-only recovery. A closed or malformed unused destination is not accepted as a placeholder. The owner may recreate a closed account before retrying; a frozen account requires the token freeze authority to restore it. Recovery requires the complete destination frame under the launch contract.
The discriminators and wire sizes are authoritative in
program/src/abi_compaction.rs; spec/IX.md (§1, §44.A, §44.R–§44.S) is the
human-readable contract.
| Instruction | Discriminator | Payload | Purpose |
|---|---|---|---|
InitSplineSeries | 0x2E | 409 bytes | Create a maker series and series vault |
UpdateSeriesTemplate | 0x2F | 702 bytes | Replace series template levels and default quote program |
UpdateSeatQuote | 0x30 | 16 / 62 / 126 | Hot-path pause, quote, or quote + Market Tick window ([signer, seat]) |
AttachSeat | 0x31 | 8 bytes | Attach a seat to a market and commit collateral |
SettleSeat | 0x32 | 0 bytes | Settle resolved/expired seat inventory and return collateral |
RecoverSeat | 0x33 | 0 bytes | Maker-only recovery of unresolved seat inventory |
DepositSeriesVault | 0x34 | 8 bytes | Deposit collateral into series vault |
WithdrawSeriesVault | 0x35 | 8 bytes | Withdraw uncommitted collateral from series vault |
CloseSplineSeries | 0x36 | 0 bytes | Close an empty series with no open seats |
RotateSeatQuoteAuthority | 0x49 | 48 bytes | Rotate delegated quote authority (expected_authority_epoch: u64) |
UpdateSeatTables | 0x5B | 326 bytes | Replace bid/ask tables on an attached TABLE seat |
TopUpSeatCommitment | 0x5C | 8 bytes | Add collateral from series vault to an attached seat |
AttachSeatFromSeries | 0x5D | 0 bytes | Permissionless crank attach from a subscribed series |
UpdateSeriesSubscription | 0x5E | 66 bytes | Configure series auto-attach subscription policy |
TopUpSeriesLamports | 0x5F | 8 bytes | Fund series rent/crank-reimbursement lamports |
FlagSeatBelowFloor | 0x60 | 0 bytes | Flag a seat whose in-band depth is below the floor |
MakeSeatDormant | 0x61 | 0 bytes | Move a flagged seat to dormant and free its registry slot |
CloseSeat | 0x62 | 0 bytes | Close a settled/recovered seat and reclaim rent |
UpdateSeatParams | 0x6E | 154 bytes | Hot-path parameter (P0..P15) and skew/spread update ([signer, seat]) |
UpdateSeatProgram | 0x6F | 360 bytes | Install a new bounded quote program on an attached seat |
UpdateSeatQuote (0x30) has no recorder tail and always takes [signer, seat]:
16 bytes (pause), 62 bytes (quote), or 126 bytes (quote + 64-byte Market Tick
window). UpdateSeatParams (0x6E) is also eventless on [signer, seat].
UpdateSeatProgram (0x6F) emits SeatProgramInstalled (tag 119).
RecoverSeat is the sole canonical, maker-authorized manual recovery
instruction for unresolved native or external seat inventory. It validates
the maker, unresolved state, destination mints, and inventory before each
token CPI and rejects replay. If a later CPI fails, the complete instruction
rolls back atomically.
Attachment and matching#
AttachSeat and AttachSeatFromSeries validate the feed, duration, currency,
market state, series template/program, active-seat cap, and commitment bound
before moving collateral and registering the seat in MarketAccount's inline
active-seat registry (up to 16 seats).
Taking routes (PlaceOrder, SwapWithFreeFunds, PlaceLimitWithFreeFunds)
supply every registered active seat (spline_seat_count == registry.len())
plus optional Market Tick and Pyth PriceUpdateV2 accounts. Book liquidity
and seat liquidity merge deterministically for both YES and NO takers: book
beats seats at equal prices, and equal-price seats fill FIFO by priority_slot
with a deterministic hash tie-breaker. Exact-input IOC (input_mode = 1, #822)
walks the same combined book-and-seat frontier. Post-only batches take no seat
accounts.
The commitment calculation covers aggregate and fragmented per-lot execution
rounding. Inventory, market totals, vault balances, and fees are checked before
token movement. SettleSeat retires each side's inventory once and returns the
terminal payout and unused commitment; CloseSeat reclaims seat rent.
SDK and generated-surface parity#
The TypeScript (@seesaw/core), Rust (seesaw-sdk), Python (sdk-python),
and CLI builders use the same canonical names, payload sizes, PDA seeds,
account order, and recorder-tail grammar. Generated IDL (idl/seesaw.json) is
validated against spec/launch/contract.json and program/src/abi_compaction.rs.
Operational limits and remaining verification#
Before production signoff, release validation must still provide sustained publisher/load measurements, packet and account-size envelopes, restart-safe publisher replay/resynchronization, full cross-client package parity, and a green launch-contract/document-generation gate. Focused Rust/BPF, SDK, IDL, indexer, and spline-core tests are necessary but are not by themselves a production-readiness claim.