Trade and liquidity

Instructions for swapping and providing two-sided liquidity.

Updated Nov 3, 2026

Swaps execute on the ordinary liquidity tranche; liquidity instructions mint and burn srLP against the live reserve less unpaid interest, which stays with the holders who earned it. The previews return typed data for simulation and emit no accounting events. See Trade, Two-sided liquidity and The curve and fees.

swap

Exchange an exact amount of one market asset for the other along the live curve.

Pays the base fee plus any divergence, volatility and launch surcharges, capped together at half the fee basis. When either hLP vault has supply or residual exposure the transaction must carry the five reconciliation accounts; the SDK swap builders prepend them.

Caller
Any trader
In the app
Trade
Discriminator
f8c69e91e17587c8

Arguments

args: SwapArgs

FieldTypeNotes
exact_asset_inu64Input amount in raw atoms, before any input token transfer fee.
min_asset_outu64Minimum output after fees; the instruction fails below it.

Accounts

AccountFlagsResolutionNotes
marketwritablePDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash]
futarchy_authorityPDA ["futarchy_authority"]
traderwritable · signer
asset_in_mint
asset_out_mint
reserve_in_vaultwritable
reserve_out_vaultwritable
trader_asset_in_accountwritable
trader_asset_out_accountwritable
instructions_sysvarSysvar1n…1111during the configured launch rate-limit window.
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb
event_authorityPDA ["__event_authority"]
program

preview_swap

Read-only: quote a swap exactly as swap would execute it, returning output, fee components and the price after.

Simulate it and decode the return data with the SDK's previewSwap; nothing is persisted and no accounting event is emitted.

Caller
Any client, by simulation
Discriminator
624ac573879abc46

Arguments

args: PreviewSwapArgs

FieldTypeNotes
exact_asset_inu64

Accounts

AccountFlagsResolutionNotes
marketPDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash]
futarchy_authorityPDA ["futarchy_authority"]
asset_in_mint
asset_out_mint

add_liquidity

Deposit both assets at the current live-reserve ratio and mint srLP.

The first deposit in a market permanently locks a minimum amount of liquidity. Published yield is checkpointed before the eligible balance changes.

Caller
Any liquidity provider
In the app
Market page · Add liquidity
Discriminator
b59d59438fb63448

Arguments

args: AddLiquidityArgs

FieldTypeNotes
base_deposit_amountu64Base atoms to deposit.
quote_deposit_amountu64Quote atoms to deposit; the smaller ratio wins.
min_srlp_amountu64Minimum srLP to receive.

Accounts

AccountFlagsResolutionNotes
marketwritable
futarchy_authorityPDA ["futarchy_authority"]
ownerwritable · signer
base_mint
quote_mint
srlp_mintwritable
base_reserve_vaultwritable
quote_reserve_vaultwritable
owner_base_accountwritable
owner_quote_accountwritable
owner_srlp_accountwritable
base_yield_accountwritableany liquidity mutation.
quote_yield_accountwritableany liquidity mutation.
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb
system_program11111111…1111
event_authorityPDA ["__event_authority"]
program

remove_liquidity

Burn srLP for its proportional share of both sides at the live basis.

Must pass the cash, market-health and slippage checks; only cash can leave the vault. There is no withdrawal fee.

Caller
The srLP holder
In the app
Market page · Withdraw
Discriminator
5055d14818ceb16c

Arguments

args: RemoveLiquidityArgs

FieldTypeNotes
srlp_amountu64srLP to burn.
min_base_amount_outu64Slippage bound on the base side.
min_quote_amount_outu64Slippage bound on the quote side.

Accounts

AccountFlagsResolutionNotes
marketwritable
futarchy_authorityPDA ["futarchy_authority"]
ownerwritable · signer
base_mint
quote_mint
srlp_mintwritable
base_reserve_vaultwritable
quote_reserve_vaultwritable
owner_base_accountwritable
owner_quote_accountwritable
owner_srlp_accountwritable
base_yield_accountwritable
quote_yield_accountwritable
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb
event_authorityPDA ["__event_authority"]
program

preview_add_liquidity

Read-only: the srLP a deposit would mint and the exact amounts it would take.

Caller
Any client, by simulation
Discriminator
6d6e33e1113af3ff

Arguments

args: PreviewAddLiquidityArgs

FieldTypeNotes
base_deposit_amountu64
quote_deposit_amountu64

Accounts

AccountFlagsResolutionNotes
marketwritablePDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash]
base_mint
quote_mint

open_liquidity_gates

Lift a market's launch liquidity gate by making the qualifying initial deposit.

Takes the same arguments as add_liquidity. Used by the initial liquidity authority during a gated launch.

Caller
The initial liquidity authority
Discriminator
54536e2db904bade

Arguments

args: AddLiquidityArgs

FieldTypeNotes
base_deposit_amountu64
quote_deposit_amountu64
min_srlp_amountu64

Accounts

AccountFlagsResolutionNotes
marketwritable
futarchy_authorityPDA ["futarchy_authority"]
ownerwritable · signer
base_mint
quote_mint
srlp_mintwritable
base_reserve_vaultwritable
quote_reserve_vaultwritable
owner_base_accountwritable
owner_quote_accountwritable
owner_srlp_accountwritable
base_yield_accountwritableany liquidity mutation.
quote_yield_accountwritableany liquidity mutation.
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb
system_program11111111…1111
event_authorityPDA ["__event_authority"]
program

preview_market

Read-only: the market with lazy interest accrued, spot and EMA prices, utilization, rates and hLP vault state.

The SDK's previewMarket decodes it. Because a fetched Market account is the state at its last checkpoint, this is the read to use for live numbers.

Caller
Any client, by simulation
Discriminator
3ce7af111cdd2aec

Arguments

None.

Accounts

AccountFlagsResolutionNotes
marketwritablePDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash]