Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.hadron.fi/llms.txt

Use this file to discover all available pages before exploring further.

Build a swap instruction.
use hadron_sdk::types::SwapParams;

let ix = pool.swap(&user, &SwapParams {
    is_x: true,            // true = sell X for Y, false = sell Y for X
    amount_in: 1_000_000,  // in atoms
    min_out: 950_000,      // minimum acceptable output — set this to protect against slippage
    fee_recipient,
    expiration: None,
});
ParamTypeDescription
user&PubkeyThe user’s wallet
params.is_xboolDirection: true = X→Y, false = Y→X
params.amount_inu64Input amount in token atoms
params.min_outu64Minimum output amount. The transaction fails with SlippageExceeded (error 8) if the pool cannot fill at this level or better. Set to 0 only in tests.
params.fee_recipientPubkeyAddress that receives the operator’s fee portion of the spread
params.expirationOption<i64>Optional slot deadline — transaction fails with Expired (error 38) after this slot
Multi-pool routing Hadron does not currently support native matching across multiple propAMMs for the same asset. For multi-pool routing, use one of the supported aggregators or contact the Hadron team.