Skip to main content
These examples use the SDK methods exported by @meteora-ag/zap-sdk. The SDK returns unsigned Transaction objects; sign and submit them with your wallet adapter, backend signer, or test keypair.

Create A Client

Submit Zap-In Transactions In Order

Zap-in builders return multiple transactions because swaps, ledger writes, zap instructions, and cleanup are deliberately separated.
If a DLMM zap-in creates a new position, sign the zap transaction with the generated position keypair as well as the user.

DAMM v2 Direct Zap In

Use this path when the input token is one of the DAMM v2 pool tokens. dammV2Quote and jupiterQuote are used to choose the swap route for balancing; pass null for a route you do not want to consider.
The source repository includes richer DAMM v2 examples that prepare both DAMM v2 and Jupiter quotes. The published package root exports the generic Jupiter helpers; use DAMM v2 SDK quote helpers directly when you want to compare both routes.

DLMM Direct Zap In

Use this path when the input token is token X or token Y of the DLMM pair.
The generated position keypair must sign the transaction that includes zapInTransaction because the Zap program calls DLMM initialize_position2.

Zap Out Through Jupiter

Use zap out when another instruction first creates a balance increase in the user’s input token account, for example after a claim or remove-liquidity action.
zapOutThroughJupiter reads the user’s input token balance before the zap-out instruction is built. Build the zap-out transaction after you know which token account receives the upstream balance increase.

DLMM Position Rebalance

rebalanceDlmmPosition builds a full rebalance sequence for an existing DLMM position: remove liquidity through DLMM helpers, optionally swap the withdrawn tokens, write ledger balances, zap back in, and clean up.