BlueprintsSurplus MarketSettlement and Inference

Surplus Market Settlement and Inference

Surplus only works if a bought credit can be redeemed.

The order book can be off-chain. The quote brain can be a sidecar. But the settlement and redemption guarantees have to survive operator mistakes, missing receipts, and issuer default.

Settlement model

The settlement contract clears signed fills atomically:

  1. debit buyer escrow
  2. pay seller
  3. mint or update a collateral-backed credit lot
  4. enforce redemption/default rules
  5. slash or penalize when configured conditions fail

The repo supports three rails in the blueprint manifest:

RailMeaning
router-creditsRouter credit balance path.
shieldedShieldedCredits path.
firmEIP-712 signed orders settled through SurplusSettlement.

The firm rail is the main settlement spine for signed fills.

Attested and proven batches

PathWhat it verifies
settleBatchAttestedA configured attester quorum signs the batch.
settleBatchProvenAn SP1 proof verifies the delegated signature check over the batch commitment.

The SP1 program currently proves the delegated signature check and commits to abi.encode(domainSeparator, fillsHash). Matching logic and account rules remain contract-enforced unless a future state-root rollup extends the proof.

Inference backend

Bonded credit issuance requires an inference backend the operator runs or controls.

Backend shapeUse
Managed vLLMOperator-controlled model service.
OpenAI-compatible APIExternal or internal API with compatible chat-completions surface.
Router fallbackTesting or non-bonded operation only.

If a lot is bonded, router fallback should fail closed. A credit sold as backed capacity must be redeemable against backed capacity.

Market-making loop

The operator can use a market-making sidecar. The sidecar can run a deterministic Avellaneda-Stoikov quoter or an agentic strategy. Both pass through the same risk gate.

The risk gate is the safety boundary:

CheckWhy
quote sizePrevents oversized exposure.
inventoryKeeps the operator from selling beyond capacity.
deviationRejects quotes too far from reference price.
spreadAvoids broken or inverted markets.
drawdownPulls quotes when the session is losing too much.
kill switchStops quoting when hard limits are crossed.

The operator places quotes only after the risk verdict allows them.

What is proven locally

The repo’s release checklist names these proof paths:

ProofCommand
Trader pathbash scripts/settlement-e2e.sh
Developer spend pathbash scripts/spend-e2e.sh
Circuit paritybash scripts/prove-batch.sh execute

Those checks cover atomic fill, receipt redemption, collateral default, attested batch settlement, proven batch path, streaming and buffered spend calls, on-chain billing, and forged voucher refusal.

What is still a deployment decision

DecisionWhy it matters
1-of-1 vs M-of-N booksChanges quorum and peer requirements.
Attester setDecides who can sign settlement batches.
SP1 verifier and vkeyEnables or disables the proven path on that deployment.
Inference backendDetermines whether bonded credits can redeem.
Timelock/Gnosis Safe ownershipControls owner actions such as registering books and rotating attesters.