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.
All Hadron Pools have price and risk curves which help maker encode their trading strategy into the on-chain PDA for the operator’s propAMM.
A operator deploys a pool by describing a quoting function:
The operator picks the midprice, picks how price changes with trade size, picks how price shifts with their inventory. Hadron is the engine that runs that function on chain.
Hadron Quoting Pipeline
updateBaseSpread
Add a flat pool level fee to all swaps. This is added to any additional spread initialised later in the curve setup by default.
pool.updateBaseSpread(authority, { spreadFactorQ32: newSpreadQ32 });
| Param | Type | Description |
|---|
params.spreadFactorQ32 | bigint | Spread discount factor in Q32 (e.g. toQ32(0.9995) = 5 bps) |
params.sequence? | bigint | Optional sequence number |
Creating Price Curves
Write a price curve to a prefab slot.
- Curves comprise of three key ideas
AmountIn: Stored in atoms(lowest unit of the token based on the token decimal) of the amount inputed by the taker. Stored internally as Bigint
PriceFactor : Distance from the midprice in BPS
const ix = pool.setCurve(authority, {
side: Side.Bid,
defaultInterpolation: Interpolation.Linear,
points: [
//Midprice is initialized as 1. AmountIn is based on the decimals for the input amount
{ amountIn: 100_000n, priceFactor: 0.99 }, // For an input of
{ amountIn: 500_000n, priceFactor: 0.95 },
], slot: 0,
});
| Param | Type | Description |
|---|
authority | PublicKey | Pool authority |
params.side | Side | Bid or Ask |
params.defaultInterpolation | Interpolation | Step, Linear, MarginalStep, Hyperbolic, Quadratic, Cubic |
params.points | SetCurvePointInput[] | Array of { amountIn, priceFactor, interpolation?, params? } |
params.slot? | number | Target prefab slot (default: 0) |
params.xMode? | CurveXMode | X-axis mode |
switchPriceCurve
Switch between different price curves in a single instruction. Upto 10 per curve side, set at pool initialization.
pool.switchPriceCurve(authority, { side: Side.Bid, slot: 1 });
//slot number set presets
| Param | Type | Description |
|---|
authority | PublicKey | Pool authority |
params.side | Side | Bid or Ask |
params.slot | number | Slot to activate |
Hadron protocol fees are added at the pool level to all pools and need to be factored into pools to remain competitive. For the latest fee rates go to https://docs.hadron.fi/fees
setRiskCurve
Write a risk curve using percent-of-vault x-axis.
pool.setRiskCurve(authority, {
side: Side.Bid,
defaultInterpolation: Interpolation.Linear,
points: [
{ pctBase: 0.25, priceFactor: 0.995 },
{ pctBase: 0.75, priceFactor: 1.005 },
],
});
| Param | Type | Description |
|---|
authority | PublicKey | Pool authority |
params.side | Side | Bid or Ask |
params.defaultInterpolation | Interpolation | Interpolation mode |
params.points | SetRiskCurvePointInput[] | { pctBase: 0.0–1.0, priceFactor, ... } |
params.slot? | number | Target prefab slot |
params.riskMode? | RiskMode | Virtual or Integrated |
setRiskCurveAbsolute
Write a risk curve using absolute token amounts on the x-axis.
pool.setRiskCurveAbsolute(authority, {
side: Side.Ask,
defaultInterpolation: Interpolation.Step,
points: [
{ vaultBalance: 1_000_000_000n, priceFactor: 1.002 },
{ vaultBalance: 2_000_000_000n, priceFactor: 1.006 },
],
});
| Param | Type | Description |
|---|
authority | PublicKey | Pool authority |
params.side | Side | Bid or Ask |
params.defaultInterpolation | Interpolation | Interpolation mode |
params.points | SetRiskCurveAbsolutePointInput[] | { vaultBalance, priceFactor, ... } |
params.slot? | number | Target prefab slot |
params.riskMode? | RiskMode | Virtual or Integrated |
switchRiskCurve
Switch between different risk curves in a single instruction. Upto 10 per curve side, set at pool initialization.
pool.switchRiskCurve(authority, { side: Side.Ask, slot: 2 });
//slot number set presets
| Param | Type | Description |
|---|
authority | PublicKey | Pool authority |
params.side | Side | Bid or Ask |
params.slot | number | Slot to activate |