02 / Hooks / twap
TWAP
Market-set ceilings for time-sliced execution of vault funds; every slice routes through the hook stack.
01
Behavior
- Caps total and per-slice size, minimum interval (≥ 10 s), maximum duration and per-slice slippage (≤ 20%).
- Slices are ordinary routed trades, so guards and rewards apply to them.
Limitation. Configuration is enforceable today; the strategy vault that schedules slices is not yet deployed.
02
Callbacks
ABI v1 · wire values frozen| # | Callback | Subscribable | Default | Semantics |
|---|---|---|---|---|
| 0 | BeforeBuy | — | Routed buy, before the Pump CPI. Can deny. | |
| 1 | AfterBuy | — | Routed buy, after the Pump CPI. Sees executed amounts; can still fail the transaction. | |
| 2 | BeforeSell | — | Routed sell, before the Pump CPI. Can deny. | |
| 3 | AfterSell | — | Routed sell, after the Pump CPI. | |
| 4 | BeforeSwap | — | Either side, before the Pump CPI. Can deny. | |
| 5 | AfterSwap | — | Either side, after the Pump CPI. | |
| 6 | BeforeLiquidity | reserved | Reserved (wire value 6). | |
| 7 | AfterLiquidity | reserved | Reserved (wire value 7). | |
| 8 | BeforeFeeAction | reserved | Reserved (wire value 8). | |
| 9 | AfterFeeAction | reserved | Reserved (wire value 9). | |
| 10 | OnGraduation | reserved | Reserved (wire value 10). | |
| 11 | OnStrategySignal | reserved | Reserved (wire value 11). |
03
Capabilities
granted at install; enforced by the executor| ■ | READ_MARKET | Read market config, venue reserves and the trade context |
| □ | VETO_ROUTED_SWAP | Deny a routed trade in a before-callback (reverts the transaction) |
| □ | WRITE_HOOK_STATE | Persist its 48-byte slot state on the market |
| □ | WRITE_USER_STATE | Update the trading wallet's per-market state |
| □ | AWARD_POINTS | Credit XP / points in the wallet's per-market ledger |
| □ | TREASURY_SIGNAL | Emit treasury allocation intents for the strategy vault |
| ■ | STRATEGY_EXECUTION | Bound or request vault strategy execution (TWAP, orders) |
| □ | ORACLE_READ | Read an external oracle account (reserved; not granted in V1) |
| □ | EXTERNAL_CPI | Call an external hook program (reserved; no permissionless CPI hooks in V1) |
| □ | EMIT_SIGNAL | Emit or consume signed strategy signals |
04
Config schema
48 bytes · little-endian| Field | Type | Offset | Unit | Preset | Description |
|---|---|---|---|---|---|
| maxTotalQuote | u64 | 0 | lamports | 10 SOL | Max quote per TWAP program |
| maxSliceQuote | u64 | 8 | lamports | 1 SOL | Max quote per slice |
| minIntervalSecs | u32 | 16 | seconds | 60 | Min time between slices |
| maxDurationSecs | u32 | 20 | seconds | 86400 | Max TWAP duration |
| maxSlippageBps | u16 | 24 | bps | 100 | Max slippage per slice |
05
Identity
Module ID
6 (0x0006)
Version
v1
Developer
Pump Hooks
Program
91kRNewiED… (built-in)
Priority range
3000–3999 · default 3100
Markets
bonding-curve · pumpswap
Source
crates/hook-runtime/src/modules/twap.rs
Verification
source in this repository; reproducible-build verification not yet published
Audit
unaudited
06
