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.

Call refetch_states first to ensure all decoded values on the instance reflect the latest on-chain data before reading or building instructions.

refetch_states (rpc feature)

Re-fetches all on-chain accounts (config, oracle, curve metadata, prefabs) and updates the instance in-place.
// Requires the `rpc` feature
pool.refetch_states(&rpc_client).await?;
If you are managing account data yourself (Geyser, websocket), reconstruct the pool with Hadron::from_accounts using the latest data instead.

getMidprice

Current midprice decoded from the on-chain Q32 oracle value.
let mid = pool.get_midprice(); // e.g. 1.0023
Returns f64

getSpreadFactor / getSpreadBps

Current base spread decoded from the on-chain Q32 oracle value. A factor of 0.9995 means 5 bps of spread.
let factor = pool.get_spread_factor(); // e.g. 0.9995
let bps    = pool.get_spread_bps();    // e.g. 5.0
Returns f64

getActiveCurveSlots

Returns the slot index for each currently active curve.
let slots = pool.get_active_curve_slots();
// ActiveCurveSlots { price_bid: 0, price_ask: 0, risk_bid: 0, risk_ask: 0 }
Returns ActiveCurveSlots

getActiveCurves

Decodes and returns all four active curves from the appropriate prefab data.
let curves = pool.get_active_curves()?;
// curves.price_bid.points, curves.price_ask.points, etc.
Returns Result<ActiveCurves, HadronSdkError> Each CurveSide contains:
FieldTypeDescription
num_pointsu8Number of curve points
default_interpolationInterpolationDefault interpolation mode
x_modeCurveXModeNative (token atoms) or Alternate
risk_modeRiskModeVirtual or Integrated
pointsVec<DecodedCurvePoint>The decoded curve point array

getCurveSlot

Decode a specific curve slot by type and index.
use hadron_sdk::types::CurveType;

let curve = pool.get_curve_slot(CurveType::PriceBid, 1)?;
Returns Result<CurveSide, HadronSdkError>
ParamTypeDescription
curve_typeCurveTypeOne of PriceBid, PriceAsk, RiskBid, RiskAsk
slotu8Slot index