Trading Model
Trading Model
Section titled “Trading Model”bitCaster uses a central limit order book (CLOB). Liquidity-provider quotes rest on the book. Public orders take available liquidity within their price limit. Amounts use msat internally. The UI displays sats.
Public market books use primitive outcome routes. A categorical market exposes
A / Not A, B / Not B, and similar books. Clients use the market identifier
{conditionId}-{outcomeName} and select the required token side.
First-release public scope
Section titled “First-release public scope”The public server accepts only public FOK orders. The GUI and CLI submit FOK orders. Each public attempt uses one one-shot capability. FOK uses the book state at admission. It commits the full requested quantity or cancels the complete request. Public FAK, GTC, GTD, continuation, and residual reauthorization are not available.
Public FOK preview
Section titled “Public FOK preview”POST /api/v1/orders/preview previews one FOK order. Send marketId, side,
tokenSide, price, and faceAmountSubunits. Use the selected token’s limit
price. The face amount must be a whole tradable unit for the market denominator.
Do not send proofs, an owner, or a time-in-force field.
NIP-98 authentication is optional. The authenticated subject determines the
subject rate-limit partition and self-match exclusion. The preview is read-only.
It does not reserve funds or liquidity. It does not authorize or submit an order.
Final admission checks the current book again with the user’s price limit.
The opaque previewRevision is display metadata, not authorization.
If the preview cannot fill the order, the browser shows the reason and a Refresh quote action. The result is a snapshot. Refresh checks the current market without submitting an order. The browser labels a pending wallet funds and fee check separately from a pending market preview.
The detail page separates settlement checks from wallet recovery. A saved result can be a partial result. It does not prove that the earlier operation is complete or that its outputs are still spendable. A new trade can proceed when current market checks and wallet funds and fee checks pass, and the user confirms that trade.
The browser hides additional-funding advice while an operation is active, recovery remains pending, or estimates need refresh. Funding does not resolve an incomplete wallet operation. Completion and live market events invalidate estimates. The next response must match the current form and wallet. If an update is missing, use Refresh quote in the trade form or Refresh market beside an empty book. A visible older book does not prove that the next order can fill.
The response reports full-fill availability and one reason: fillable,
insufficient_liquidity, price_limit, request_too_large,
market_unavailable, or temporarily_unavailable. Recommend a separate subsidy
only when subsidyMayHelp is true. Funding and trading require separate consent.
quotePaymentSubunits is the exact quote payment in msat, without fees.
averagePrice and worstPrice describe the selected token. The current
currentLatestTradePrice and projected projectedFinalPrice describe the
primitive outcome route. Prices use priceDenominator. The projected price is
based on the captured preview. For a binary market, currentLatestTradePrice
uses the newest confirmed trade from either route in that same preview.
An opposite-route trade maps to priceDenominator - price.
For a categorical market with more than two outcomes, only the requested
primitive route supplies this price. A trade in another outcome does not
update it. Clients convert primitive-route prices to the selected token’s
price at the display boundary. The projected price is
not a confirmed trade. Execution estimates are null when the full amount
cannot fill. The current price is null when no confirmed trade exists.
Funding does not create a market-price point.
The GUI uses one Buy/Sell form. It previews the requested quantity over the
full valid price range: D - 1 for Buy and 1 for Sell.
The user confirms the quoted trade value and reviews fees separately.
The order keeps that accepted total and the preview’s worst execution price.
The engine checks the complete current FOK plan before accepting fills.
Equal or better execution can proceed. Worse execution refuses the whole order.
Order acceptance keeps the selected outcome. It clears the submitted quantity and comment only if the user has not changed the draft. Newer input remains in the form. A confirmation click or a refused attempt does not clear the comment. The comment accompanies the signed order.
Buy uses maxQuotePaymentSubunits as the maximum trade payment.
Sell uses minQuotePaymentSubunits as the minimum gross trade proceeds.
The applicable bound must be a non-negative integer in msat.
The opposite bound is null. These bounds exclude fees.
They are engine admission constraints, not independent mint-enforced constraints.
CLI clients can also select a narrower per-fill price limit.
POST /api/v1/orders/capacity-preview estimates the maximum quantity at
a selected price limit. Send marketId, side, and tokenSide. Omit price for Auto.
Send an integer price for Custom. Explicit null is invalid.
Auto uses floor(D * 20 / 100) ticks and clamps the limit to 1..D-1.
The result includes all eligible makers, not only the bot.
This API remains available to clients. The browser form does not display a
maximum-capacity number. It checks the entered quantity and explains refusals.
The capacity result excludes wallet balance and fees. It does not reserve
liquidity.
A ready result contains referencePrice, effectiveLimitPrice,
maxFaceAmountSubunits, quotePaymentSubunits, worstPrice,
priceDenominator, and an opaque previewRevision.
Prices describe the selected token, including a selected complement.
Zero capacity has zero face and quote amounts and a null worst price.
When no eligible maker exists, the reference is null. Auto then has a null
limit; Custom retains the supplied limit. A restrictive Custom limit can
also return zero capacity with a known reference price.
market_unavailable and temporarily_unavailable have null facts, not zero
capacity. Both preview endpoints share the same preview rate budgets.
Capacity is limited to one public FOK order. Maker minimums can leave gaps:
not every smaller quantity must fill. Continue to use /orders/preview
for the entered quantity and calculate its fees separately.
The order keeps the accepted trade total and per-fill price limit through balance checks, top-up, preparation, submission, and recovery. It fills the complete quantity within both limits or fills none. These limits do not reserve liquidity or guarantee execution. If the order no longer fits, review a fresh preview and confirm a new attempt. The GUI does not retry the order automatically. Wallet or Nostr setup, or a change of trading identity, also requires a fresh preview and confirmation.
The trade summary shows New probability for the selected outcome. This is the
estimated final execution price. It is not a forecast or the theoretical
post-trade LMSR probability. The current market price stays in the market header.
The summary does not show average, worst, or latest-confirmed token price rows.
The accepted worst per-fill price still protects the submitted order.
For Buy, Payout if you win shows the face value of the conditional shares that
the accepted trade will deliver. Use the registered payout denomination. This
value is not net profit. Redemption fees can apply. Sell shows expected proceeds
and no winning payout for sold shares.
One fee summary has a collapsed, accessible breakdown. It groups fees only when the asset and unit match. Distinct conditional collections stay separate. A cancelled or failed attempt keeps its reviewed preparation fees in a separate labelled breakdown. These amounts do not show which fees were paid. A new draft does not reuse them as current consent. Dismissal, a new attempt, or an identity change clears this display. After reload, the durable recovery notice states that preparation and refund fees can apply even when no trade completes. Zero, pending, unavailable, and changed-fee states remain explicit. Current fee consent is required before confirmation.
The UI displays amounts in sats: 100 msat is 0.1 sats. Buy cash totals add the quote and only fees paid in regular collateral. Sell totals show gross collateral proceeds and net proceeds after the settlement-input fee and preparation costs paid in regular cash. Show conditional-token preparation and consolidation fees separately. Do not add fees in different assets. Unused fee headroom is not a paid fee. If fee amounts, assets, or preparation mode change, obtain fresh consent before the next new wallet step. A Sell can use held conditional tokens and regular cash to prepare the full offered quantity. The cash pays the preparation fee. The wallet needs this cash before the sale. Future sale proceeds cannot pay it. Do not use this preparation path to create missing shares. Price protection does not replace fee consent. Fee consent applies to the order with the reviewed price bound.
Invalid input returns HTTP 400. The raw request limit is 16 KiB. Larger bodies
return 413. Rate or concurrency limits return 429 with Retry-After.
Order authorization
Section titled “Order authorization”A wallet supplies one PAY_TO_UNLOCK capability when it submits a public FOK
order. The engine validates the capability during order admission. It makes no
mint network call during admission. One order request carries the capability.
The engine binds it and accepts the order in one commit, or writes nothing.
The capability covers an authorized range for that one attempt. Public FOK does not rest on the book or leave a residual order. If the complete quantity cannot fill, the engine cancels the complete request. This cancellation does not spend the capability or trigger a refund.
Fills and settlement groups
Section titled “Fills and settlement groups”Each matched quantity creates one fill. fillId identifies that real fill.
The engine can group one or more fills into one atomic settlement group.
groupId identifies the settlement group. The mint receives one multi-party
conversion for the group. The current product supports complementary, mint,
and merge conversion. A merge match pairs a sell with a sell of the
complementary outcome set, and the mint merges the two positions into
collateral. This API version reports a merge match as Complementary, with the
taker’s token side and execution price. A later engine version reports Merge.
Mint confirmation returns exact result entries. Clients retain their submitted operations and confirmed results. They can recover those exact records after a crash. An acknowledged FOK operation stores its operation facts and result. These records survive a server restart. An intentional reuse of the same client order ID with the same operation facts returns the stored result. Changed facts return a conflict. If the result is uncertain, clients reconcile with the durable engine and mint authority.
The browser uses completion notifications to recheck pending wallet recovery. If a recheck is already running, it retains one follow-up request. Work deferred during an active order attempt resumes when the last active attempt finishes. An uncertain result keeps its recovery retry. A notification or elapsed time alone does not make funds spendable. Recovery does not submit a new order.
Participation Score
Section titled “Participation Score”Participation Score protects public order admission. A successful public
one-shot capability binding charges once under settlement-capability-v2. The
tariff is max(1, ceil(v1 / 10)), where v1 = 1 + InputCount + ceil(ManifestCount/16) + ceil(ArtifactByteCount/4096). A charge recorded
earlier under settlement-capability-v1 keeps its v1 amount. Each
authenticated invalid proof or DLEQ validation attempt uses the same tariff.
The tariff is not a per-order, per-fill, or settlement-failure fee. Fills,
cancellation, settlement failure, refund, and recovery do not charge the tariff.
This tariff applies to public client capabilities. The reused-output penalty
below is a separate charge, not a tariff.
The mint refuses a settlement when one of its outputs was already used by
another operation, for example by the same wallet in another browser. When the
engine can prove from the mint’s answers that the output belongs to one order,
it removes that order and any order accepted after it from the settlement, and
it submits the remaining orders once more. If no order remains, or the
remaining orders cannot settle, the whole settlement fails. It charges the owner of the removed
order reused-output-penalty-v1: 100 Score once for that settlement. The
balance can become negative. An order that fails only because it was in the
same settlement pays nothing. The engine never charges its own bot. The
penalty changes Score only. It does not take funds: a removed order follows
the normal refund path after its authorization expires.
The order status of a removed order stays failed, and its settlement group
status stays DefinitivelyRejected.
GET /api/v1/{marketId}/orders/{orderId}/settlement-failure returns the
reason: OwnOutputReused for the charged order and GroupOutputReused for an
order that failed with no penalty. GET /api/v1/participation-score/history
returns the balance and the 50 most recent Score changes, newest first. The
penalty has the kind reused-output-penalty. The CLI reads them with
bitcaster-cli order settlement-failure <market-id> <order-id> and
bitcaster-cli score history.
If Score is insufficient, the daemon submits a payment and waits for its
delivery state to become credited before it prepares the order capability.
Retries use the same delivery identity. Credit can be delayed after the mint
receives the payment. If the bounded wait ends, the payment remains available
for recovery. A pending delivery does not prove that the payment failed.
When at least 200 sats remain spendable after the order’s own funds, a Score top-up buys 20 sats of Score, or the full shortfall if it is larger. Later trades use the remaining Score, so they often need no top-up. Otherwise, and while another order of the same client is prepared, the top-up buys only the shortfall, so a small wallet keeps its funds for trades. Score is non-refundable and cannot be withdrawn.
Trust boundary
Section titled “Trust boundary”The engine receives the exact PAY_TO_UNLOCK proofs that authorize an order.
It sees their secrets and the public blinded-output manifest. It does not
receive the wallet seed, output blinding factors, refund key, or other wallet
proofs.
The engine can use only the authorized selection before expiry. It cannot redirect value outside the manifest or extend the lock. If it withholds settlement, the authorized proofs remain unavailable until refund becomes valid.
The mint performs the conversion. Wallets control their proof material. A
PAY_TO_UNLOCK capability can refund after expiry under the NUT rules.
Comparison with on-chain CTF exchanges
Section titled “Comparison with on-chain CTF exchanges”The names complementary, mint, and merge also appear in on-chain CTF systems. The implementation differs. bitCaster exposes complementary, mint, and merge conversion. It uses one mint conversion for an atomic settlement group. It does not use a peer-to-peer settlement exchange or an on-chain operator transaction.
Waiting for fresh quotes
Section titled “Waiting for fresh quotes”For a single order, the server can briefly retry the same order before returning
order-quotes-refreshing. It preserves the original authorization, consent,
and expiry. This optional wait does not guarantee acceptance or settlement.
It does not change the client’s retry limits below. A disconnect stops further
retries; it does not cancel an order that was already accepted.
For a batch, the server can retry the same batch only when every submitted
item was refused before acceptance because quotes were refreshing. It rechecks
the market and the original authorizations before retrying. All server waits
share the original request budget of at most five seconds and four attempts.
A partial success or another refusal does not trigger a whole-batch retry.
The server does not extend price limits, consent, or expiry. If the quote wait
ends without acceptance, the batch reports authorityUnavailable for the
remaining current items. This does not guarantee a fill.
The GUI and CLI can wait when the engine refuses the order before acceptance
with the exact order-quotes-refreshing problem or with order-book-conflict.
Neither refusal commits anything. The client sends the same serialized request
and signed comment again. It keeps the original capability, price limit, fee
consent and expiry. It does not prepare a replacement order.
Waiting lasts at most 60 seconds from the first submission and 30 attempts. The first delay is one second. Later delays are two seconds. Each request has at most 30 seconds. It also ends no later than the wait deadline and the original authorization expiry. A shorter caller timeout stays in effect. A new attempt starts only while time remains before both limits.
The GUI shows progress and lets you stop waiting. The CLI shows progress on stderr. Press Ctrl-C to stop waiting. Stopping does not release reserved funds or prove that the order was never accepted. The wallet reads the original order and shows it once found. The wallet keeps its existing recovery and expiry process.
A generic service error, timeout, malformed response or uncertain result stops automatic submission. The client reconciles the original operation through the read-only order lookup and never sends the order again. When waiting stops at a limit or by your stop, and every attempt got one of the two refusals, no order exists: the wallet records the refusal and refunds after the authorization expires. If the stop interrupts an attempt in flight, the result is uncertain and the wallet uses the order lookup. Restarting the app does not restart this submission loop.
Reading depth while quotes refresh
Section titled “Reading depth while quotes refresh”GET /api/v1/{marketId}/orderbook can return HTTP 503 with code
order-quotes-refreshing, type /errors/order-quotes-refreshing, and status
503. This response means that current depth is temporarily unavailable.
It does not mean that the book is empty or that the market needs more funding.
The GUI keeps the last received snapshot while a depth read retries. Without a snapshot, it keeps the initial depth display pending. The market page and its subscriptions remain available. Order, fill, and settlement notifications continue. A fresh snapshot replaces the previous display normally.
The browser makes at most five attempts for this exact response, including the first request. It waits two seconds between attempts. Each request has a ten-second deadline. Leaving the page cancels its pending reads. Other errors and timeouts stop the retry. The SDK uses one attempt by default; callers can opt into this bounded policy. A reconnect can start the existing snapshot repair. These reads do not resubmit an order.
A successful response with zero depth remains valid, including for a closed market. A previous snapshot is display data only. Obtain a current order preview and submit through normal order admission before trading.