Skip to main content

Initializing a new pool

Hadron::initialize

Builds all the instructions needed to create a new on-chain pool: account allocation + initialization. Returns the instructions, derived pool address, and seed. The allocate instruction(s) must be confirmed before sending the initialize instruction (they can be in separate transactions, or together if they fit).
Returns (Vec<Instruction>, Pubkey, u64) — instructions, pool address, seed
With default parameters the CurvePrefabs account is ~15 KB, so two allocate instructions are returned (Solana’s single-instruction realloc limit is 10 KB). Send the allocates first, then the initialize.

Loading an existing pool

Hadron::from_accounts

Create a Hadron instance from raw account data bytes. This is sync — no RPC calls. You fetch the accounts however you like (RPC, Geyser, etc.) and pass the raw data in.
Returns Result<Hadron, HadronSdkError>
Enable the rpc feature (cargo add hadron-sdk-v2 --features rpc) for a convenience Hadron::load(&rpc_client, &pool_address) method that fetches accounts over RPC.

Reading pool state

get_midprice

Current midprice decoded from the on-chain Q32 oracle value.
Returns f64

get_spread_factor / get_spread_bps

Current spread factor and basis-point equivalent.
Returns f64

get_active_curve_slots

Returns the slot index for each active curve.
Returns ActiveCurveSlots

get_active_curves

Decodes and returns all four active curves from prefab data.
Returns Result<ActiveCurves, HadronSdkError> Each CurveSide contains:

get_curve_slot

Decode a specific curve slot by type and index.
Returns Result<CurveSide, HadronSdkError>

Building instructions

All methods below return an Instruction. They do not send a transaction — add the instruction to a Transaction and submit it yourself.

swap

Build a swap instruction.

deposit

Build a deposit instruction.

withdraw

Build a withdraw instruction.

Curve management

set_curve

Write a price curve to a prefab slot.

set_risk_curve

Write a risk curve using percent-of-vault x-axis.

set_risk_curve_absolute

Write a risk curve using absolute token amounts on the x-axis.

switch_price_curve / switch_risk_curve

Activate a previously written curve slot (hot path — no curve data uploaded).

submit_curve_updates / apply_curve_updates

Two-step batched curve editing. Submit a list of point edits, then apply them.

Oracle management

update_midprice

update_base_spread

update_midprice_and_base_spread

Atomic update of both values in a single instruction.

Admin

nominate_authority / accept_authority

Two-step authority transfer.

set_pool_state

States: Uninitialized, Initialized, Paused, RejectSwaps, Closed (set via close_pool). set_pool_state only accepts Initialized, Paused, or RejectSwaps.

update_delta_staleness

close_pool

Closes the pool and reclaims rent. Requires authority and all vaults to be empty.

Properties

These are available on any Hadron instance: