Skip to content

Core instruction surface

Find actual entrypoints, argument contracts, and the operations each hook observes.

Source: programs/grapl-amm/src/lib.rs. The Pool 6 source increment defines 19 instructions and four Anchor account types. Generate clients from the matching hook ABI 4 / Pool 6 build; this overview is not a substitute for the Anchor account order. See current validation status.

Issuance and market creation

EntrypointArgumentsBehavior
create_tokenCreateTokenArgsIssues an independent classic SPL token; no implicit pool or metadata
initialize_poolInitializePoolArgsCreates a direct CLMM, directory, vaults, and optional hook binding
initialize_curveInitializePoolArgs, CurveConfigurationCreates curve mode and deposits real base inventory
initialize_tick_arrayInitializeTickArrayArgsCreates a canonical fixed or compact tick page
reserve_tick_arraycapacity: u8Funds rent and grows an existing compact page

InitializePoolArgs contains pool_id: u64, sqrt_price_x64: u128, configuration: PoolConfiguration, hook_payload: Vec<u8>, and hook_accounts: Vec<HookAccountAccess>. Curve initialization derives the initial price from the virtual-reserve configuration.

See token factory and bonding curve for their parameter tables and authority decisions.

Positions and fees

EntrypointArgumentsBehavior
open_positionOpenPositionArgsCreates an owner-bound empty position with a valid range
close_positionNoneCloses only when liquidity and both owed fee amounts are zero
modify_liquidityModifyLiquidityArgsAdds/removes signed liquidity and settles principal
collect_position_feesNoneCrystallizes and transfers LP fees without changing liquidity
collect_beneficiary_feesbeneficiary_index: u8Pays the selected beneficiary's accrued A/B debt to that signer
initialize_protocol_treasuryrecipient: PubkeyInitializes the immutable global recipient through the program's upgrade authority
collect_protocol_feesNonePays one pool's protocol A/B debt to the treasury recipient; preserves fractional carry
donateDonateArgsAdds to active LP fee growth without minting liquidity

OpenPositionArgs contains position_id: u64, tick_lower: i32, and tick_upper: i32. Opening is not a deposit.

ModifyLiquidityArgs contains liquidity_delta: i128, limit_a: u64, limit_b: u64, hook_payload, and hook_accounts. Positive deltas add principal subject to maximum deposits; negative deltas withdraw principal subject to minimum outputs. Public liquidity deposits are unavailable while the pool remains in curve mode.

DonateArgs contains amount_a: u64, amount_b: u64, hook_payload, and hook_accounts. At least one amount must be nonzero; LP accrual needs active liquidity.

Swaps and composition

EntrypointArgumentsBehavior
swapSwapArgsExactIn; reports consumed input, net output, and unspent budget
swap_exact_outExactOutArgsExact net output with a maximum gross input
zap_inZapInArgsSwaps a caller-selected amount, then funds the owned CLMM position
zap_outZapOutArgsRemoves principal, then converts the withdrawn side into one asset
graduate_curveGraduateCurveArgsConverts the eligible curve into a full-range CLMM in one atomic instruction
collect_curve_remainderNoneLets the creator collect recorded leftover assets after graduation

SwapArgs contains amount_in: u64, minimum_out: u64, sqrt_price_limit_x64: u128, a_to_b: bool, hook_payload, and hook_accounts. Reaching a CLMM price limit may leave input unspent. Metis rejects incomplete ExactIn quotes.

ExactOutArgs replaces the amount fields with maximum_in: u64 and amount_out: u64; the target is net of a hook output fee. The direction, price limit, payload, and descriptors remain explicit. An incomplete ExactOut fails.

See swap semantics and zaps for user limits and callback order. Graduation uses add-liquidity callbacks, preserves the market identity, and creates a position owned by the stored creator. It is separate from the last curve swap.

Pool configuration

FieldValidation or meaning
mode0: CLMM; 1: virtual-reserve curve through initialize_curve
tick_spacing1..=32768
trade_fee_ppmAt most the immutable max_fee_ppm
max_fee_ppmAt most 990000 ppm, or 99%
lp_share_bps + beneficiary sharesExactly 10000 basis points of the remainder after mandatory protocol retention
beneficiariesFour slots; nonzero recipient iff nonzero share; recipients unique
hook_capabilitiesSupported lifecycle bits/profile and bounded account permissions
max_output_fee_ppm in hook permissionsSeparate output-deduction cap; defaults to zero

These are validation bounds, not recommended economic settings. Share weights use basis points; swap fee rates use parts per million.

The fixed 1,000 bps protocol share is enforced before the configured remainder split and is not a PoolConfiguration opt-out. Per-pool, per-mint carry preserves fractional protocol allocations. Donations and hook output deductions follow separate paths. Read fee accounting.

Remaining accounts

Swap and modify-liquidity use ascending signed tick-page indices first, then hook extras in descriptor order. Each page is validated against the pool and canonical address. Collect-position-fees receives endpoint pages. Other hookable operations receive their corresponding extras.

A zap partitions remaining accounts into its two legs using an explicit count. Supply each leg's pages and hook extras under that leg's descriptors. Neither leg silently inherits the other's permissions.

For all methods, the Anchor Accounts structs define signer, owner, mint, mutability, and PDA constraints. General custom hook deltas, automatic compounding, and position transfer are not part of the instruction surface.