Docs · Reference

Markets, pools and their parameters

Every parameter that governs a spot market, a lending pool, a perp market, a vault and the protocol as a whole, what it controls, and where to read its current value.

Every parameter on this page is a field of a public Solana account and is also returned by the API. The first table of each section gives both names, so a value can be read from either. Byte layouts are in Program: accounts.

Reading the current values

curl "https://api.mesa.markets/v1/config"
curl "https://api.mesa.markets/v1/markets"
curl "https://api.mesa.markets/v1/pools"
curl "https://api.mesa.markets/v1/perps"
curl "https://api.mesa.markets/v1/vaults"

The app shows the same values where they apply: a market's fee on /trade, a pool's rates and collateral factor on /lend, a perp market's funding and open interest on /perps.

Protocol

One Config account holds what every market shares.

ParameterConfig fieldGET /v1/configControls
Batch lengthbatch_lenbatchLengthSecondsHow long each batch takes actions, in seconds
Place marginplace_marginHow long before a batch's close place stops accepting actions for it
Open windowopen_windowHow long after the close actions can be opened. After it, an unopened action can be reclaimed.
HeartbeatheartbeatheartbeatSecondsThe length of a heartbeat epoch. A position's deadline is the end of the epoch after the one it was last renewed in.
Oracle agemax_oracle_ageThe oldest oracle price the program accepts, in seconds
Actions per targetmax_actions_per_marketThe most actions one market, pool, perp market or vault takes in one batch
Protocol shareprotocol_share_bpsfees.protocolShareBpsThe protocol's part of each trade and perp fee
Fee recipientfee_recipientfeeRecipientWhere sweep_fees sends the protocol's share
Timelock beacondrand_genesis, drand_period, drand_chain_hashdrandThe drand chain batches and deadlines are sealed to
PausedpausedpausedWhen set, the program refuses deposits into Mesa and new exposure: an order, a supply, a borrow, a perp open or a vault deposits. Withdrawals, redeems, renewals, repayments, closes, liquidations and reclaims keep working, and every batch already placed finishes.

How batch times, rounds and deadlines are computed from these is in Batch time and Heartbeat deadlines.

Spot markets

One Market account per pair, with one liquidity Vault.

ParameterFieldGET /v1/marketsControls
Pairbase_mint, quote_mintbase, quoteThe asset traded and the asset it is priced in
Feefee_bpsfeeBpsTaken from the output of each fill
Vaultvault_idvaultIdThe liquidity vault that trades each batch's imbalance
Vault reservesVault.base_reserve, Vault.quote_reservevaultDepthThe curve the clearing price is computed against
Last clearing pricelast_clearing_pricelastClearingPriceThe price of the most recent batch
PausedpausedstatusWhile set, orders for the market open as Invalid and are reclaimed. Set per market by the admin.

A market has no tick size, lot size or order minimum of its own. An order's limit is a price in quote atoms per base atom scaled by 10^12, and its amount is in atoms.

Lending pools

One Pool account per asset.

ParameterFieldGET /v1/poolsControls
AssetmintassetWhat is supplied and borrowed
Collateral factorcollateral_factor_bpscollateralFactorBpsThe most that can be borrowed against collateral when a borrow is placed
Liquidation thresholdliq_threshold_bpsliquidationThresholdBpsThe part of collateral value a debt must stay under to renew
Liquidation bonusliq_bonus_bpsliquidationBonusBpsWhat a liquidator receives above the debt repaid
Reserve factorreserve_factor_bpsreserveFactorBpsThe part of interest that goes to the pool's reserves
Rate curvebase_rate_bps, slope1_bps, slope2_bps, kink_bpsborrowAprPct, supplyAprPctThe borrow rate at each utilization
Accepted collateralcollateral_mints, collateral_oraclesWhich assets a borrow from this pool can post, each with its oracle

The rate curve

The borrow rate is a function of utilization, the share of the pool that is lent out.

text
utilization ≤ kink:  rate = base + slope1 · utilization / kink
utilization > kink:  rate = base + slope1 + slope2 · (utilization − kink) / (1 − kink)

Suppliers earn the borrow rate times utilization, less the reserve factor. GET /v1/pools/{asset}/history returns both rates, the totals and the share price per batch.

Collateral factor and liquidation threshold

A borrow is accepted when

text
collateral · price · collateral_factor  ≥  debt

and it can renew while

text
collateral · price · liq_threshold  ≥  debt with interest

The threshold is the higher of the two, so a borrow placed at the collateral factor has room for the price to move before it can no longer renew. See Sealed positions and renewal and Liquidation.

Perp markets

One PerpMarket account per market, trading against the perps Vault.

ParameterFieldGET /v1/perpsControls
Base oracleThe market's oracle feedoracleAddress, oraclePriceThe price every position opens, renews and closes at
Collateralquote_mintcollateralThe asset positions are margined and settled in
Maximum leveragemax_leveragemaxLeverageThe most size per unit of collateral when a position is placed
Maintenance marginmaint_margin_bpsmaintenanceMarginBpsThe margin a position must keep to renew
Liquidation bonusliq_bonus_bpsliquidationBonusBpsThe part of a liquidated position's collateral the liquidator receives
Open feeopen_fee_bpsopenFeeBpsCharged on size at the entry price
Close feeclose_fee_bpscloseFeeBpsCharged on size at the closing price
Funding ratefunding_rate_bps_per_hourfundingRateHourlyPctHow fast the funding index moves at full imbalance
Open interest limitmax_oiThe most open interest per side. An open beyond it is refused.
Open interestopen_interest_long, open_interest_shortopenInterestLongBase, openInterestShortBaseThe current totals funding is computed from

Vaults

ParameterFieldGET /v1/vaultsControls
KindkindkindA spot liquidity vault or the perps vault. The API also lists each lending pool as a vault of kind lending_pool.
Reservesbase_reserve, quote_reservecompositionWhat the vault holds
Total sharestotal_sharestotalSharesThe supply the share price is computed from
Share priceReserves over total sharessharePriceWhat one share redeems for
Protocol fees owedprotocol_fees_base, protocol_fees_quoteThe protocol's share, held until sweep_fees

Oracles

Lending and perps read Pyth price accounts. The program accepts a price account only if it is owned by the Pyth receiver program named in Config, is fully verified, carries the feed the pool or market names, and was published within max_oracle_age. The accepted layout is in Oracle accounts.

Fee rates

The current rates and where each fee goes are in Fees and MESA.