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.

Hadron pools do not update the midprice automatically based on reserves. As an operator, you are responsible for pushing price updates from your own price engine. This is what makes Hadron a propAMM rather than a passive AMM.

updateMidprice

Update your pool’s midprice. Midprice can be updated when pools are in the RejectSwaps mode.
use hadron_sdk::types::UpdateMidpriceParams;
use hadron_sdk::helpers::math::to_q32;

let ix = pool.update_midprice(&authority, &UpdateMidpriceParams {
    midprice_q32: to_q32(1.05),
    sequence: None,
});
ParamTypeDescription
params.midprice_q32Q32New midprice in Q32 format — use to_q32(price)
params.sequenceOption<u64>Optional sequence number. Updates with a lower sequence than the current on-chain value are rejected, preventing out-of-order application when sending concurrent updates.
Q32 (more precisely Q32.32) is a fixed-point number format where the value is stored as an integer scaled by 2^32.In short: stored = realValue * 2^32The SDK offers a .toQ32() helpers to convert numbers to fixed point numbers

updateMidpriceAndBaseSpread

Atomic update of both midprice and base spread in a single instruction. Prefer this over two separate calls when updating both together.
use hadron_sdk::types::UpdateMidpriceAndBaseSpreadParams;
use hadron_sdk::helpers::math::{to_q32, spread_bps_to_q32};

let ix = pool.update_midprice_and_base_spread(&authority, &UpdateMidpriceAndBaseSpreadParams {
    midprice_q32: to_q32(1.05),
    spread_factor_q32: spread_bps_to_q32(5),
    sequence: None,
});
ParamTypeDescription
params.midprice_q32u64New midprice in Q32 format
params.spread_factor_q32u64New spread factor in Q32 — use spread_bps_to_q32(n) for n bps
params.sequenceOption<u64>Optional sequence number for ordering

updateDeltaStaleness

Delta staleness is a kill-switch. If no oracle update has been received within this many slots, the pool stops quoting.
use hadron_sdk::types::UpdateDeltaStalenessParams;

let ix = pool.update_delta_staleness(&authority, &UpdateDeltaStalenessParams {
    delta_staleness: 150,  // slots — ~60 seconds at 400ms/slot
});
ParamTypeDescription
params.delta_stalenessu64Number of slots without an oracle update before the pool halts quoting. At ~400ms per slot, 150 slots ≈ 60 seconds.
Recommended usage Set delta_staleness to a value slightly above your oracle update frequency. If your crank pushes updates every 10 slots, a staleness of 30–50 slots gives headroom for missed updates without leaving the pool quoting a stale price for too long.