Q32 Fixed-Point Format
Many curve and oracle params use Q32 (Q32.32) format. This is a fixed-point number where the value is stored as an integer scaled by 2^32.to_q32() for prices and price factors. Use spread_bps_to_q32() for spread values.
updateBaseSpread
Add a flat pool-level fee to all swaps.Creating Price Curves
Write a price curve to a prefab slot. Curves define how price moves relative to the midprice as trade size increases.amount_in: Amount in atoms (smallest token unit based on token decimals). Stored asu64.price_factor_q32: Distance from midprice — useto_q32(factor)where 1.0 = midprice, 0.99 = 1% below.
Returns
Instruction
Interpolation Types
switchPriceCurve
Switch between different price curves in a single instruction. Up to 16 per curve side (set at pool initialization).setRiskCurve
Write a risk curve using percent-of-vault on the x-axis. Risk curves adjust price based on your current inventory position.setRiskCurveAbsolute
Write a risk curve using absolute token amounts on the x-axis instead of percentages.switchRiskCurve
Switch between different risk curves in a single instruction. Up to 16 per curve side (set at pool initialization).submit_curve_updates / apply_curve_updates
Two-step batched curve editing for modifying individual points without rewriting an entire curve. Submit a list of edits, then apply them atomically.Buffer limit If errorCurveUpdatesBufferFull(code 46) is returned, callapply_curve_updatesto flush before submitting more.
.png?fit=max&auto=format&n=pH37fL0GL14scVCH&q=85&s=5749b485c8c5b2386a4cca404e97d6be)