Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.meteora.ag/llms.txt

Use this file to discover all available pages before exploring further.

Zap has a fixed compatibility surface in the on-chain program. Use this page to check whether a user flow maps to one of Zap’s supported instructions.

Instruction Surface

InstructionPurposeMain constraint
initialize_ledger_accountCreate the user ledger PDA.owner and payer sign.
set_ledger_balanceWrite token A/B or token X/Y amount into the ledger.Ledger owner signs.
update_ledger_balance_after_swapRecord a post-swap balance delta, capped by max_transfer_amount.Ledger owner signs.
close_ledger_accountClose the ledger and send rent to rent_receiver.Ledger owner and rent receiver sign.
zap_in_damm_v2Add DAMM v2 liquidity, optionally swap surplus through DAMM v2, then add again.Existing DAMM v2 position; owner signs.
zap_in_dlmm_for_uninitialized_positionInitialize a new DLMM position and add liquidity through rebalance_liquidity.Position account must be empty and sign.
zap_in_dlmm_for_initialized_positionAdd liquidity to an existing DLMM position through rebalance_liquidity.Ledger owner signs.
zap_outSwap a percentage of a detected token balance increase.Route must be whitelisted by program and discriminator; swap authority comes from the supplied route accounts.

Compatibility Matrix

AreaSupportedImportant constraint
Program IDzapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMizSame declared ID in the program.
DAMM v2 Zap InYesSwaps only through DAMM v2 swap2 inside the Zap In flow.
DLMM Zap InYesAdds through DLMM rebalance_liquidity; Zap does not withdraw or claim in this instruction.
DLMM strategiesSpot, Curve, BidAskmin_delta_id <= max_delta_id.
Zap Out routesDAMM v2 swap, DLMM swap2, Jupiter v6 route, Jupiter v6 shared-account routeRoute is checked by program ID plus 8-byte instruction discriminator.
Zap Out percentage1 to 100Values outside this range fail.
LedgerUser-owned PDASeeds are ["user_ledger", owner]; ledger instructions require owner signature.
Token transfer feesPartially supportedZap In math uses transfer-fee-excluded amounts where it calculates liquidity or strategy amounts.

Whitelisted Zap Out Routes

Zap Out only invokes a swap if the supplied amm_program and the first 8 bytes of payload_data match one of the whitelisted pairs:
RouteProgram-level check
DAMM v2 swapDAMM v2 program plus DAMM v2 swap discriminator.
DLMM swapDLMM program plus swap2 discriminator.
Jupiter v6 routeJupiter v6 program plus route discriminator.
Jupiter v6 shared-account routeJupiter v6 program plus shared-account route discriminator.
Unsupported Jupiter instruction variants, custom routers, or arbitrary AMM instructions are rejected with AmmIsNotSupported.

Access Controls and Accounts

ActionRequired authority
Initialize ledgerowner signer and payer signer.
Set ledger balanceLedger owner signer.
Update ledger balance after swapLedger owner signer.
Close ledgerLedger owner signer and rent_receiver signer.
DAMM v2 Zap InLedger owner signer, also used as DAMM v2 position owner.
DLMM Zap InLedger owner signer, plus rent_payer signer.
Zap OutNo owner signer is enforced by Zap itself; the invoked swap route must receive whatever signers/accounts it requires.
The ledger account has has_one = owner checks on mutable instructions. For uninitialized DLMM positions, the position account must be a signer, must be empty, and must not equal the owner or rent payer. Zap Out does not verify the token account owner; integrators should build the surrounding transaction so the route authority and token accounts are the intended user accounts.

Flow Constraints

FlowConstraint
DAMM v2 Zap InZap calls DAMM v2 add_liquidity with token_a_amount_threshold and token_b_amount_threshold set to u64::MAX; price protection comes from max_sqrt_price_change_bps around the optional balancing swap.
DAMM v2 Zap InIf the surplus-side swap calculation fails or returns zero input/output, Zap returns successfully after the first add-liquidity attempt and leaves remaining amounts in the ledger.
DLMM Zap InStrategy parameters are generated from the pair’s on-chain active bin at execution. The caller-supplied active_id is forwarded to DLMM with max_active_bin_slippage.
DLMM Zap InZap sets should_claim_fee = false, should_claim_reward = false, min_withdraw_x_amount = 0, min_withdraw_y_amount = 0, and removes = [].
Zap Outpayload_data must start with an 8-byte supported instruction discriminator, and offset_amount_in must point to the amount-in field to rewrite.

Token Compatibility

Zap In calculates transfer-fee-excluded amounts for token mints when it needs to reason about net deposit amounts. For Token 2022 mints without a transfer fee extension, the calculation is treated like a normal token amount.
Do not assume every Token 2022 extension is compatible with every underlying DAMM v2, DLMM, or Jupiter route. Zap can coordinate supported instructions, but the downstream program still defines whether a token behavior is valid.

Not a Fit

Use a direct integration instead of Zap when:
  • The target AMM is not DAMM v2 or DLMM.
  • The Zap Out route is not one of the four whitelisted instruction types.
  • The flow needs Zap In swaps through Jupiter or another external router inside the Zap instruction.
  • The DLMM flow needs Zap itself to withdraw liquidity, claim fees, or claim rewards.
  • The token behavior is unsupported by the underlying product or route.
  • The product copy needs to promise best execution, guaranteed output, or automatic route selection.