Skip to main content
Defining mid-price: Defining and updating mid-price on Hadron has three variables
  • Input: Mid-price is defined in quote atoms per base atom
  • Sequence: Sequence is a nonce sent by the operator to prevent stale quotes from block builders re-ordering transactions. Instructions with a sequence strictly less than the current sequence will be fail.
  • Base spread (optional): Operators can initialize an optional base spread with the mid-price update.
//Updating a midprice of 117.20 and base spread of 5bps

const ix = buildUpdateMidpriceInstruction(
    HADRON_PROGRAM_ID,
    authority.publicKey,
    midpriceOraclePda,
    1n,                                  // sequence = 1
    uiPriceToMidpriceQ32(117.20, 9, 6)   // $117.20 SOL/USDC
    bpsToBaseSpreadQ32(5)                // 5 Bps base spread
);
Curve Visualization: Bid Ask