Docs · Guides

Read a batch

Read the public record of one batch, on the page and through the API, and check its clearing price against its opened orders.

The batch record is what the chain shows of each batch: its clearing prices, the actions it opened without owners, and the change in each pool's totals. Anyone can read it, with no wallet and no key.

Find a batch

  • Batches lists every batch, newest first, with its close time, each market's clearing price, its volume, the count of opened actions and the change in pool totals.
  • An order, a share or a position in your own account links to the batch it went into.
  • GET /v1/batches pages through them, and GET /v1/batches/{batch} returns one.
bash
curl "https://api.mesa.markets/v1/batches?limit=5"
curl "https://api.mesa.markets/v1/batches/1071"

A batch that is still open

While a batch is taking actions, its record holds three things: the count of sealed actions, the time it closes, and the timelock round it is sealed to. The page shows the count and a countdown.

The actions are on chain only as commitments, and their terms are encrypted to a round that has not been published.

json
{
  "batchNumber": 1072,
  "state": "open",
  "openedAt": "2026-11-22T14:26:44.472Z",
  "closesAt": "2026-11-22T14:27:14.472Z",
  "batchLengthSeconds": 30,
  "drandRound": 34184755,
  "sealedActionCount": 7,
  "serverTime": "2026-11-22T14:26:49.627Z"
}

That is the whole response for an open batch, here from a local network with 30-second batches.

A batch that has closed

The head

On the pageAPI fieldMeaning
ClosedclosesAtWhen the batch stopped taking actions, in UTC
Timelock rounddrandRoundThe drand quicknet round whose signature opened it
Actions openedopenedActionCount, sealedActionCountHow many of the batch's actions were opened. An action left unopened is reclaimed by its owner.
VolumetotalVolumeQuoteMatched volume across the batch's markets
Cleared, SettledclearedAt, settledAtWhen every target had its result, and when every action was paid out

Each market

For each spot market the batch touched, markets[] holds:

FieldMeaning
clearingPriceThe one price every fill in this market got
matchedVolumeBase, matchedVolumeQuoteWhat traded at that price
vaultNetBaseDelta, vaultNetQuoteDeltaWhat the liquidity vault traded: the imbalance the orders left
orders[]Every order the batch opened

And for each order:

FieldMeaning
side, orderTypeBuy or sell, limit or market
amountBaseThe order's size
limitPriceIts limit, or null for a market order
filledBase, filledQuoteWhat it filled
statusfilled, partially_filled or unfilled

An order has no owner field. The record cannot say who placed it, because the chain never held that.

Pools, vaults and perps

SectionFieldsMeaning
Pool totalssuppliedDelta, borrowedDelta, totalSuppliedAfter, totalBorrowedAfter, sharePriceAfterThe batch's supplies, redeems and borrows, netted into one change per pool
Vaults and perpsdepositedDelta, withdrawnDelta, sharePriceAfterDeposits into and withdrawals from each vault
oraclePrice, openInterestLongDelta, openInterestShortDeltaThe oracle price the perp market cleared at, and the change in open interest per side

Each is a total. Ten supplies in a batch appear as one number.

Settlement transactions

settlementSignatures lists the Solana transactions that settled the batch's actions. Each can be opened in an explorer: it shows the Mesa authority spending notes and creating notes, and the amounts moving through Mesa's public vault accounts.

Find your own order in it

Open the batch from batch N on your order. Your order is one of the rows, recognisable to you by its side, amount and limit. Your page marks it nowhere, since the record is the same for every reader. What links the row to you exists only in your account: the order note your keys decrypt.

Check the price yourself

A clearing price follows from two public things: the batch's opened orders and the vault's reserves before the batch. With them, anyone can recompute it.

  1. Take the reserves before the batch

    The vault's reserves after the batch are in its account and in GET /v1/vaults/{vault}. Subtract vaultNetBaseDelta and vaultNetQuoteDelta to get the reserves the batch cleared against, x and y, and k = x · y.

  2. Sum the demand

    For a candidate price, add the base amount of every buy with a limit at or above it and every market buy, and subtract every sell with a limit at or below it and every market sell. Call the result N.

  3. Solve for the price

    Between two neighbouring limits N is constant, and the price is k / (x − N)². The clearing price is the candidate that lands inside the interval it was computed for, or the limit at which demand jumps across the vault's line.

The rule is set out with a worked example in Clearing at one price. The program runs the same computation in clear and accepts no price from its caller.

The opened orders can also be read from the chain without Mesa's API: each settlement emits the order's opened terms with its result, and the batch's totals are in its Batch account, laid out in Program: accounts.

Follow batches as they happen

ts
const apiUrl = 'https://api.mesa.markets'
const events = new EventSource(`${apiUrl}/v1/events`)
events.addEventListener('batch.settled', async (e) => {
  const { data } = JSON.parse(e.data)
  const batch = await fetch(`${apiUrl}/v1/batches/${data.batchNumber}`).then((r) => r.json())
  console.log(batch.markets?.map((m) => [m.pair, m.clearingPrice]))
})

See the batch event stream.