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"import { Connection, PublicKey } from '@solana/web3.js'
const programId = new PublicKey(MESA_PROGRAM_ID)
const [config] = PublicKey.findProgramAddressSync([Buffer.from('config')], programId)
const account = await new Connection(RPC_URL).getAccountInfo(config)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.
| Parameter | Config field | GET /v1/config | Controls |
|---|---|---|---|
| Batch length | batch_len | batchLengthSeconds | How long each batch takes actions, in seconds |
| Place margin | place_margin | How long before a batch's close place stops accepting actions for it | |
| Open window | open_window | How long after the close actions can be opened. After it, an unopened action can be reclaimed. | |
| Heartbeat | heartbeat | heartbeatSeconds | The length of a heartbeat epoch. A position's deadline is the end of the epoch after the one it was last renewed in. |
| Oracle age | max_oracle_age | The oldest oracle price the program accepts, in seconds | |
| Actions per target | max_actions_per_market | The most actions one market, pool, perp market or vault takes in one batch | |
| Protocol share | protocol_share_bps | fees.protocolShareBps | The protocol's part of each trade and perp fee |
| Fee recipient | fee_recipient | feeRecipient | Where sweep_fees sends the protocol's share |
| Timelock beacon | drand_genesis, drand_period, drand_chain_hash | drand | The drand chain batches and deadlines are sealed to |
| Paused | paused | paused | When 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.
| Parameter | Field | GET /v1/markets | Controls |
|---|---|---|---|
| Pair | base_mint, quote_mint | base, quote | The asset traded and the asset it is priced in |
| Fee | fee_bps | feeBps | Taken from the output of each fill |
| Vault | vault_id | vaultId | The liquidity vault that trades each batch's imbalance |
| Vault reserves | Vault.base_reserve, Vault.quote_reserve | vaultDepth | The curve the clearing price is computed against |
| Last clearing price | last_clearing_price | lastClearingPrice | The price of the most recent batch |
| Paused | paused | status | While 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.
| Parameter | Field | GET /v1/pools | Controls |
|---|---|---|---|
| Asset | mint | asset | What is supplied and borrowed |
| Collateral factor | collateral_factor_bps | collateralFactorBps | The most that can be borrowed against collateral when a borrow is placed |
| Liquidation threshold | liq_threshold_bps | liquidationThresholdBps | The part of collateral value a debt must stay under to renew |
| Liquidation bonus | liq_bonus_bps | liquidationBonusBps | What a liquidator receives above the debt repaid |
| Reserve factor | reserve_factor_bps | reserveFactorBps | The part of interest that goes to the pool's reserves |
| Rate curve | base_rate_bps, slope1_bps, slope2_bps, kink_bps | borrowAprPct, supplyAprPct | The borrow rate at each utilization |
| Accepted collateral | collateral_mints, collateral_oracles | Which 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.
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
collateral · price · collateral_factor ≥ debtand it can renew while
collateral · price · liq_threshold ≥ debt with interestThe 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.
| Parameter | Field | GET /v1/perps | Controls |
|---|---|---|---|
| Base oracle | The market's oracle feed | oracleAddress, oraclePrice | The price every position opens, renews and closes at |
| Collateral | quote_mint | collateral | The asset positions are margined and settled in |
| Maximum leverage | max_leverage | maxLeverage | The most size per unit of collateral when a position is placed |
| Maintenance margin | maint_margin_bps | maintenanceMarginBps | The margin a position must keep to renew |
| Liquidation bonus | liq_bonus_bps | liquidationBonusBps | The part of a liquidated position's collateral the liquidator receives |
| Open fee | open_fee_bps | openFeeBps | Charged on size at the entry price |
| Close fee | close_fee_bps | closeFeeBps | Charged on size at the closing price |
| Funding rate | funding_rate_bps_per_hour | fundingRateHourlyPct | How fast the funding index moves at full imbalance |
| Open interest limit | max_oi | The most open interest per side. An open beyond it is refused. | |
| Open interest | open_interest_long, open_interest_short | openInterestLongBase, openInterestShortBase | The current totals funding is computed from |
Vaults
| Parameter | Field | GET /v1/vaults | Controls |
|---|---|---|---|
| Kind | kind | kind | A spot liquidity vault or the perps vault. The API also lists each lending pool as a vault of kind lending_pool. |
| Reserves | base_reserve, quote_reserve | composition | What the vault holds |
| Total shares | total_shares | totalShares | The supply the share price is computed from |
| Share price | Reserves over total shares | sharePrice | What one share redeems for |
| Protocol fees owed | protocol_fees_base, protocol_fees_quote | The 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.