This guide shows how to install and initialize the official Zap TypeScript SDK,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.
@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
- pnpm
- yarn
Dependencies
| Package | Version |
|---|---|
@coral-xyz/anchor | ^0.31.0 |
@solana/web3.js | ^1.98.0 |
@solana/spl-token | ^0.3.10 or newer |
@meteora-ag/cp-amm-sdk | Compatible |
@meteora-ag/dlmm | Compatible |
bn.js | ^5.2.1 |
decimal.js | ^10.4.3 |
Create A Client
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
| Network | Program ID |
|---|---|
| Mainnet Beta | zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz |
| Devnet | zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz |
ZAP_PROGRAM_ID, DAMM_V2_PROGRAM_ID, DLMM_PROGRAM_ID, JUP_V6_PROGRAM_ID, and MEMO_PROGRAM_ID.
Transaction Model
Zap builders return unsignedTransaction objects. The caller is responsible for fee payer, blockhash, signing, simulation, and submission.
| Flow stage | Purpose |
|---|---|
| Setup transaction | Create token accounts and wrap native SOL when required. |
| Swap transaction or transactions | Move the input token into pool token A/B or X/Y before zap-in, or perform a standalone swap used in rebalancing. |
| Ledger transaction | Initialize or reset UserLedger, then record token amounts from direct balances or post-swap deltas. |
| Zap transaction | Call the Zap program to add liquidity, rebalance DLMM liquidity, or invoke a whitelisted zap-out swap payload. |
| Cleanup transaction | Close the ledger and unwrap native SOL when required. |
Supported SDK Workflows
| Workflow | Methods |
|---|---|
| DAMM v2 zap in, direct input token | getZapInDammV2DirectPoolParams, then buildZapInDammV2Transaction |
| DAMM v2 zap in, indirect input token | getZapInDammV2IndirectPoolParams, then buildZapInDammV2Transaction |
| DLMM zap in, direct input token | estimateDlmmDirectSwap, getZapInDlmmDirectParams, then buildZapInDlmmTransaction |
| DLMM zap in, indirect input token | estimateDlmmIndirectSwap, getZapInDlmmIndirectParams, then buildZapInDlmmTransaction |
| DLMM position rebalance | estimateDlmmRebalanceSwap, then rebalanceDlmmPosition |
| Zap out through DAMM v2 | zapOutThroughDammV2 |
| Zap out through DLMM | zapOutThroughDlmm |
| Zap out through Jupiter | getJupiterQuote, getJupiterSwapInstruction, then zapOutThroughJupiter |
| Low-level zap out | zapOut with your own whitelisted payload and account metas |

