Skip to main content
Technical reference for the Stableswapper swap instruction. For setup and examples, see Quickstart or Examples.

Swap Instruction

Program ID: 9vDwZVJXw5nxymWmUcgmNpemDH5EBcJwLNhtsznrgJDH (Key Addresses)

Parameters

ParameterTypeDescription
amount_inu64Amount of input token (in token’s native decimals)
min_amount_outu64Minimum acceptable output (slippage protection)

Required Accounts

AccountTypeDescription
poolRead-onlyLiquidity pool PDA (seed: "liquidity_pool")
inVaultRead-onlyVault PDA for input token
outVaultRead-onlyVault PDA for output token
inVaultTokenAccountWritableToken account holding input token reserves
outVaultTokenAccountWritableToken account holding output token reserves
userFromTokenAccountWritableUser’s token account for input token
toTokenAccountWritableDestination token account for output token
feeRecipientTokenAccountWritableFee recipient’s token account for input token
feeRecipientRead-onlyFee recipient authority (validated against pool)
fromMintRead-onlyMint of the input token
toMintRead-onlyMint of the output token
userSigner, WritableUser wallet signing the transaction
whitelistRead-onlyAddress whitelist PDA (seed: "address_whitelist")
tokenProgramRead-onlySPL Token Program
associatedTokenProgramRead-onlyAssociated Token Program
systemProgramRead-onlySystem Program

Transaction Structure

A Solana transaction contains one or more instructions. Each instruction specifies:
  • Program ID — the on-chain program to execute
  • Accounts — all accounts the instruction reads from or writes to
  • Instruction Data — the encoded parameters for the instruction
Account types:
  • Signer: Must sign the transaction
  • Writable: Will be modified by the instruction
  • Read-only: Only read from, not modified