> ## 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.

# Update Oracle and Curves

## **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.

```typescript theme={null}
// `pool` is a loaded Hadron instance; `authority` is the pool authority (see SDK ▸ Quickstart)
// Updating a midprice of 117.20 SOL/USDC and a base spread of 5 bps

const ix = pool.updateMidpriceAndBaseSpread(authority, {
    // midprice = quote atoms per base atom (USDC 6 decimals, SOL 9 decimals)
    midpriceQ32: toQ32(117.20 * 1e6 / 1e9), // $117.20 SOL/USDC
    spreadFactorQ32: spreadBpsToQ32(5),     // 5 bps base spread
    sequence: 1n,                           // strictly-increasing nonce
});
```

## Building Bid and Ask Curves

**Simple 3 point curve**

Points on Hadron are a function of 3 input values:

* **Volume**: Input volume in atoms
* **Spread**: Distance from the Mid-price
* **Interpolation mode**: Moving between any two points

```typescript theme={null}
// 3 point bid curve with a midprice of 1.00
// Points: Input Amount 0 (base), 1000, 2000 units
// Spread of 10, 20, 50 Bps from Mid
// Interpolating step wise for all 3 points

const ix = pool.setCurve(authority, {
    side: Side.Bid,
    defaultInterpolation: Interpolation.Step,
    points: [
        { amountIn: 0n,    priceFactor: 0.9990 },  // 0-1000: 10bps fee
        { amountIn: 1000n, priceFactor: 0.9980 },  // 1000-5000: 20bps fee
        { amountIn: 5000n, priceFactor: 0.9950 },  // 5000+: 50bps fee
    ],
});
```

### Curve Visualization:

<img src="https://mintcdn.com/hadron/E7MY-jMyfqhTihsy/images/bid-ask.png?fit=max&auto=format&n=E7MY-jMyfqhTihsy&q=85&s=c152ca2b49dc841ea2e69ad1eb95a898" alt="Bid Ask" width="1440" height="1080" data-path="images/bid-ask.png" />
