Skip to content

Build your first integration

Go from a pool configuration to a quoted trade and a verified result.

For a concrete source-SDK example, start with the RPC and wallet quickstart. This page explains the integration decisions around that flow.

grapl combines concentrated liquidity with optional pool hooks. A useful first integration reads one pool, explains its behavior, and constructs one bounded swap. The same primitives support direct trading, routed swaps, and applications with custom market rules.

1. Choose the market

A direct pool opens at a configured price and uses funded CLMM positions. A bonding curve begins with virtual-reserve pricing backed by real inventory, then graduates into a CLMM. Both paths can attach a hook; a pool without one is valid.

Read market creation before creating a pool, or AMM math to understand how an existing pool quotes a trade.

2. Read the pool's contract

Resolve the pool under the program ID supplied by your deployment configuration. Check its version, ordered reserve mints, token programs, current mode, price, liquidity, fees, and optional hook. Derive accounts using the account reference.

Use a matching Pool 6 / hook ABI 4 interface for the current source increment. Pool 5 accounts require an explicit migration strategy; there is no automatic runtime conversion. These docs do not publish a program-address registry; a source identifier alone is not deployment discovery.

A hooked pool also needs its declared policy accounts. Inspect enabled callbacks and account permissions before deciding which operations your application supports.

3. Express the user's limits

User intentModeProtect with
Spend a chosen amountExactInMinimum net output and price limit
Receive a chosen amountExactOutMaximum input and price limit

Parse decimal strings into integer token atoms using the mint's decimals. Keep amounts in integer types throughout quoting and instruction construction. Client amounts explains parsing; swap modes explains partial fills and net output.

4. Quote a complete snapshot

Load the pool, required tick pages, and hook state from a coherent snapshot. For a hook, reproduce its time, fee, eligibility, and account requirements. If a required policy evaluator or identity context is unavailable, reject the quote.

The Metis adapter accepts injected hook evaluators and shares the core traversal. A successful quote is a price estimate against that snapshot; execution validates current state again.

5. Construct and authorize the operation

Use the instruction reference and matching IDL for account order. Supply canonical tick pages followed by the declared hook extras. Bind source and destination token accounts to the intended authority and mints.

The transaction signer authorizes the operation. A callback's actor may be a router PDA, so it is not always the wallet shown by your application. Read wallet context before supporting routed or sponsored flows.

6. Show the settled result

Confirm transaction success before presenting a completed trade. Reconcile actual input, net output, fees, and relevant hook effects. A rejected after callback rolls back the operation's state changes; transaction fees can still be charged.

Continue with integration validation, liquidity positions, or your first hook.