chapters· API reference
27 · Reference

API reference

Every function, struct, event and error on the hook, with who may call what.

The complete external surface of IGlueHook — every function with who may call it, the structs, the events and the errors. The interface source is IGlueHook.sol.

Launch & pot configuration

launchPool(key, sqrtPriceX96, main, recipient, tickLower, tickUpper, liquidity, owner, config) payable → (amount0, amount1)
anyone, on a pool that does not exist yet

The whole launch in one transaction: initializes the pool (the caller becomes the pot admin), declares the roles and creates the seeded LP program — same validation, events and funding rules as the standalone entries. (0,0) ticks = full range; ERC20 sides settle from the caller's allowance, a native side (if the pool has one) via msg.value with excess refunded.

initPot(key, main, recipient)
the pool's initializer, once

Declares the roles; the key's other currency becomes secondary automatically. Until this runs the hook is passive on the pool. A native main rejects burn intent (address(0) recipient).

setRecipient(poolId, recipient)
the pot admin

Moves the delivery target. address(0) = burn (ERC20 main only); anything else is a literal target.

donate(key, amount) payable → credited
anyone

Funds the pot in its SECONDARY currency. Native: amount == msg.value. ERC20: approve first; the credit is the measured balance delta (fee-on-transfer safe). Irreversible.

flushDirect(poolId) → delivered
anyone

Retries a delivery the pot's live recipient refused; pays the pot's current recipient. Reverts if nothing is parked, the pot moved to burn intent, or the recipient refuses again (the park stays intact).

LP program — liquidity

addLiquidity(key, tickLower, tickUpper, liquidity, owner) payable → (amount0, amount1)
the pot admin, once per pool

Creates the program with everything off: zero shares, recipients defaulting to the owner, auto-harvest disarmed. The owner must be live here (the defaults point at it). Tick range fixed forever; (0,0) = full range.

addLiquidityAdvanced(key, tickLower, tickUpper, liquidity, owner, config) payable → (amount0, amount1)
the pot admin, once per pool

Creates the program with full rules at creation. owner == address(0) ships it surrendered at birth: frozen rules, locked liquidity, public harvest.

addProgramLiquidity(key, liquidity) payable → (amount0, amount1)
the program owner

Grows the position. Harvests pending fees first, then settles pure principal from the caller.

removeProgramLiquidity(key, liquidity, to) → (amount0, amount1)
the program owner

Shrinks the position; principal goes to to. Harvests first. A live owner can always withdraw; an ownerless program is locked forever.

LP program — rules & harvest

setProgramConfig(poolId, config)
the program operator

Replaces the split rules — the LP fee shares AND the buyback split; validated like the advanced entry. Shapes future harvests and buybacks only — the standing carry keeps retrying under the new rules.

setProgramOperator(poolId, newOperator)
the program operator

Moves the settings role. address(0) freezes the rules forever without touching the owner's property. No way back.

transferProgramOwnership(poolId, newOwner)
the program owner

Moves the property; the operator role does not travel with it. address(0) locks the liquidity forever and forces the manual harvest public.

harvest(key) → (mainFees, secondaryFees)
the owner — or anyone when publicHarvest

Collects the program's fees and runs the split with the caller's full gas — the same path the auto-harvest runs. The natural entry for heavy tokens.

claim(asset) → amount
any owed recipient

Pulls everything booked to the caller in asset after refused pushes. Full-gas, reverting delivery.

Views

potOf(poolId) → Pot programOf(poolId) → Program quotePump(key, userAmountIn) → (spend, minOut) quoteShield(key, amountSpecified) → (absorbed, paid) parkedOf(asset) → amount // refused deliveries, all pools parkedDirectOf(poolId) → amount // refused deliveries, this pool heldOf(asset) → amount // held-forever ledger (custody = burn) owedOf(to, asset) → amount // refused harvest legs, claimable obligationOf(asset) → amount // everything the hook owes in `asset`

Structs

Pot
address admin; // the pool's initializer address main; // the defended currency address secondary; // the buyback currency — the pot's only asset address recipient; // 0x0 = burn bool configured; // liveness flag (main may legally be 0x0 = native) uint256 balance; // pot inventory, in secondary
ProgramConfig — the operator-editable half
uint64 buybackShareWad; // secondary gross → the pot uint64 burnShareWad; // main gross → the burn cascade uint64 compoundShareWad; // both sides' gross → the LP budget uint64 potCompoundShareWad; // buyback split: pot output → the carry uint64 potBurnShareWad; // buyback split: pot output → the cascade bool publicHarvest; address secondaryRecipient; // gross − compound − buyback address mainRecipient; // gross − compound − burn uint256 minMain; // auto-harvest trigger; max = disarmed uint256 minSecondary;
Program — the full record (programOf)
uint128 liquidity; int24 tickLower; int24 tickUpper; bool exists; bool publicHarvest; uint64 buybackShareWad; uint64 burnShareWad; uint64 compoundShareWad; uint64 potCompoundShareWad; uint64 potBurnShareWad; // the buyback split address owner; // 0x0 = locked forever address operator; // 0x0 = rules frozen forever address secondaryRecipient; address mainRecipient; uint256 minMain; uint256 minSecondary; uint256 carryMain; uint256 carrySecondary; // compound budget waiting to fit

Events

PotOpened(poolId, admin) PotInitialized(poolId, main, secondary, recipient) RecipientSet(poolId, recipient) Donated(poolId, donor, amount) Pumped(poolId, spent, bought) Shielded(poolId, absorbed, paid) Delivered(poolId, to, amount, mode) FlushedDirect(poolId, to, amount) ProgramCreated(poolId, owner, tickLower, tickUpper) ProgramConfigured(poolId, config) ProgramOwnershipTransferred(poolId, newOwner) ProgramOperatorSet(poolId, newOperator) ProgramLiquidityAdded(poolId, liquidity, amount0Used, amount1Used) ProgramLiquidityRemoved(poolId, liquidity, amount0, amount1, to) Harvested(poolId, mainFees, secondaryFees, burned, fueled) Compounded(poolId, liquidity, amount0Used, amount1Used) Paid(to, asset, amount) Owed(to, asset, amount) Claimed(to, asset, amount)

Errors

errormeaning
NotAllowed()the caller may not perform this action
Reentrancy()a reentrant call was blocked
PotNotReady()initPot has not run yet
PotAlreadyReady()the pot or the program already exists — both are one-shot
BadRoles()main is not one of the pool's currencies, or the recipient is unusable
BadDonation()attached value doesn't match the declared donation
QuoteMismatch()a quote and its execution disagreed; the operation was abandoned
BadConfig()share sums above 100%, burn share on a native main, a payable leg without a live recipient, or a malformed liquidity request

FAQ

Which functions mutate and which are free views?+

Mutating: launchPool, initPot, addLiquidity(+Advanced), addProgramLiquidity, removeLiquidity, harvest, donate, claim, flushDirect and the setters. Views: potOf, programOf, quotePump, quoteShield, owedOf, parkedOf, heldOf, obligationOf and friends.

Who may call what?+

Trading paths and donations: anyone. harvest: owner (public after surrender). Liquidity: owner. setProgramConfig: operator. setRecipient: pot admin. claim: the booked recipient. flushDirect: anyone.

What units do the shares use?+

WAD — 1e18 = 100%. All amounts elsewhere are raw token units in each token's own decimals; nothing is normalized behind your back.

What are the main custom errors?+

BadConfig for write-time validation, PotAlreadyReady for a second program attempt, plus auth errors on the role-gated calls. Trade-path failures never surface as reverts to the swapper.

Where is the exact struct layout?+

This page lists ProgramConfig and Program field by field; the verified source on any explorer and the repository's interface file are the canonical machine-readable versions.