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 aHadron 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>
Reading pool state
get_midprice
Current midprice decoded from the on-chain Q32 oracle value.f64
get_spread_factor / get_spread_bps
Current spread factor and basis-point equivalent.f64
get_active_curve_slots
Returns the slot index for each active curve.ActiveCurveSlots
get_active_curves
Decodes and returns all four active curves from prefab data.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 anInstruction. 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
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 anyHadron instance:
.png?fit=max&auto=format&n=pH37fL0GL14scVCH&q=85&s=5749b485c8c5b2386a4cca404e97d6be)