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

# Oracle Management

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.

```rust theme={null}
use hadron_sdk_v2::types::UpdateMidpriceParams;
use hadron_sdk_v2::helpers::math::to_q32;

let ix = pool.update_midprice(&authority, &UpdateMidpriceParams {
    midprice_q32: to_q32(1.05),
    sequence: None,
});
```

| **Param**             | **Type**      | **Description**                                                                                                                                                            |
| --------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params.midprice_q32` | `Q32`         | New midprice in Q32 format — use `to_q32(price)`                                                                                                                           |
| `params.sequence`     | `Option<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. |

<Tip>
  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^32**

  The SDK offers a **.toQ32()** helpers to convert numbers to fixed point numbers
</Tip>

## updateMidpriceAndBaseSpread

Atomic update of both midprice and base spread in a single instruction. Prefer this over two separate calls when updating both together.

```rust theme={null}
use hadron_sdk_v2::types::UpdateMidpriceAndBaseSpreadParams;
use hadron_sdk_v2::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,
});
```

| **Param**                  | **Type**      | **Description**                                                 |
| -------------------------- | ------------- | --------------------------------------------------------------- |
| `params.midprice_q32`      | `u64`         | New midprice in Q32 format                                      |
| `params.spread_factor_q32` | `u64`         | New spread factor in Q32 — use `spread_bps_to_q32(n)` for n bps |
| `params.sequence`          | `Option<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.

```rust theme={null}
use hadron_sdk_v2::types::UpdateDeltaStalenessParams;

let ix = pool.update_delta_staleness(&authority, &UpdateDeltaStalenessParams {
    delta_staleness: 150,  // slots — ~60 seconds at 400ms/slot
});
```

| **Param**                | **Type** | **Description**                                                                                                      |
| ------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `params.delta_staleness` | `u8`     | Number 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.
