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.

This guide shows how to install and initialize the official Zap TypeScript SDK, @meteora-ag/zap-sdk. Before you begin, here are the main resources:

TypeScript SDK

Zap TypeScript SDK repository.

Zap NPM Package

Published package for transaction builders, state reads, PDA helpers, and examples.

Install

To use the SDK in your project, install it with your preferred package manager:
npm install @meteora-ag/zap-sdk @solana/web3.js @solana/spl-token @coral-xyz/anchor bn.js

Dependencies

PackageVersion
@coral-xyz/anchor^0.31.0
@solana/web3.js^1.98.0
@solana/spl-token^0.3.10 or newer
@meteora-ag/cp-amm-sdkCompatible
@meteora-ag/dlmmCompatible
bn.js^5.2.1
decimal.js^10.4.3

Create A Client

import { Connection } from "@solana/web3.js";
import { Zap } from "@meteora-ag/zap-sdk";

const connection = new Connection(process.env.RPC_URL!, "confirmed");

const zap = new Zap(connection, {
  jupiterApiUrl: "https://api.jup.ag",
  jupiterApiKey: process.env.JUPITER_API_KEY,
});
jupiterApiUrl and jupiterApiKey are optional in the SDK constructor. Pass them whenever your Jupiter endpoint requires authenticated quote or swap-instruction requests. You can get the API key from Jupiter Developer Portal.

Program ID

NetworkProgram ID
Mainnet BetazapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz
DevnetzapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz
The SDK also exports ZAP_PROGRAM_ID, DAMM_V2_PROGRAM_ID, DLMM_PROGRAM_ID, JUP_V6_PROGRAM_ID, and MEMO_PROGRAM_ID.

Transaction Model

Zap builders return unsigned Transaction objects. The caller is responsible for fee payer, blockhash, signing, simulation, and submission.
Flow stagePurpose
Setup transactionCreate token accounts and wrap native SOL when required.
Swap transaction or transactionsMove the input token into pool token A/B or X/Y before zap-in, or perform a standalone swap used in rebalancing.
Ledger transactionInitialize or reset UserLedger, then record token amounts from direct balances or post-swap deltas.
Zap transactionCall the Zap program to add liquidity, rebalance DLMM liquidity, or invoke a whitelisted zap-out swap payload.
Cleanup transactionClose the ledger and unwrap native SOL when required.
For zap-in flows, preserve this order. The ledger stores intermediate token amounts that the following Zap instruction consumes.

Supported SDK Workflows

WorkflowMethods
DAMM v2 zap in, direct input tokengetZapInDammV2DirectPoolParams, then buildZapInDammV2Transaction
DAMM v2 zap in, indirect input tokengetZapInDammV2IndirectPoolParams, then buildZapInDammV2Transaction
DLMM zap in, direct input tokenestimateDlmmDirectSwap, getZapInDlmmDirectParams, then buildZapInDlmmTransaction
DLMM zap in, indirect input tokenestimateDlmmIndirectSwap, getZapInDlmmIndirectParams, then buildZapInDlmmTransaction
DLMM position rebalanceestimateDlmmRebalanceSwap, then rebalanceDlmmPosition
Zap out through DAMM v2zapOutThroughDammV2
Zap out through DLMMzapOutThroughDlmm
Zap out through JupitergetJupiterQuote, getJupiterSwapInstruction, then zapOutThroughJupiter
Low-level zap outzapOut with your own whitelisted payload and account metas

Testing the SDK

If you have cloned the SDK repository, start with package-level checks and tests:
pnpm install
pnpm run build
pnpm test