Skip to main content
Prefabs allow operators to save multiple curves in the contract, allowing them to switch between strategies by only updating a single parameter in the instruction. This allows for switching between vastly different (or similar) quoting functions and risk curves in under 40 CUs. Makers can store up to 16 prefabs for each curve (64 total) on Hadron, set at pool initialization (2 by default).

How Prefabs Work:

Concepts:
  • Slot (0 to maxPrefabSlots−1, up to 0–15): Which prefab slot to write to (SetCurve / SetRiskCurve) or to activate (SwitchPriceCurve / SwitchRiskCurve).
  • Side: bid (0) or ask (1). Price and risk curves have one active slot per side
  • Active slot: The slot index currently used for quoting. Swap reads the active curve from prefabs by this index.

Example: Switching between multiple price and risk curves

Store two ask curves in different slots (e.g. slot 0 = tight spread, slot 1 = wide spread). Then switch the active ask curve by sending a single SwitchPriceCurve instruction with side: Side.Ask, slot: 0 or 1.
  • 1. Set an ask curve into slot 0 with (e.g. tight spread)
  • 2. Set a different ask curve into slot 1 (e.g. wide spread)
  • 3. Switch the active ask curve to slot 0 or 1 (one parameter, ~38 CUs)*
    • No curve data is sent in the switch instruction—only sequence, side, and slot. The program updates the active slot index