> ## 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.

# DAMM v2 TS SDK Getting Started

> Learn how to install @meteora-ag/cp-amm-sdk, initialize CpAmm, fetch DAMM v2 state, quote swaps, and build transactions.

This guide shows how to install and initialize the official DAMM v2 TypeScript SDK, `@meteora-ag/cp-amm-sdk`.

Before you begin, here are the main resources:

<CardGroup cols={2}>
  <Card title="TypeScript SDK" icon="node-js" iconType="solid" href="https://github.com/MeteoraAg/damm-v2-sdk">
    Public SDK source, examples, tests, and generated `cp_amm` IDL.
  </Card>

  <Card title="NPM Package" icon="npm" iconType="solid" href="https://www.npmjs.com/package/@meteora-ag/cp-amm-sdk">
    Published `@meteora-ag/cp-amm-sdk` package.
  </Card>
</CardGroup>

## Installation

To use the SDK in your project, install it with your preferred package manager:

<Tabs>
  <Tab title="npm">
    ```bash theme={"system"}
    npm install @meteora-ag/cp-amm-sdk @solana/web3.js @coral-xyz/anchor bn.js
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={"system"}
    pnpm add @meteora-ag/cp-amm-sdk @solana/web3.js @coral-xyz/anchor bn.js
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={"system"}
    yarn add @meteora-ag/cp-amm-sdk @solana/web3.js @coral-xyz/anchor bn.js
    ```
  </Tab>
</Tabs>

## Initialization

```typescript theme={"system"}
import { Connection, PublicKey } from "@solana/web3.js";
import { CpAmm } from "@meteora-ag/cp-amm-sdk";

const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
const cpAmm = new CpAmm(connection);

const pool = new PublicKey("POOL_ADDRESS");
const poolState = await cpAmm.fetchPoolState(pool);
```

You can also find pool addresses with the Data API:

```bash theme={"system"}
curl "https://damm-v2.datapi.meteora.ag/pools?page=1&page_size=20"
```

## Program ID

The SDK uses the public DAMM v2 program ID by default:

```typescript theme={"system"}
cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG
```

## Reference

<CardGroup cols={2}>
  <Card title="SDK Examples" icon="bolt" iconType="solid" href="/developer-guides/damm-v2/typescript-sdk/example">
    Explore full transaction flows, including pool initialization, swaps, liquidity, and more.
  </Card>

  <Card title="SDK Reference" icon="code" iconType="solid" href="/developer-guides/damm-v2/typescript-sdk/reference">
    Access the full method map, PDA helpers, and fee helpers for DAMM v2.
  </Card>
</CardGroup>

## Testing the SDK

The SDK repository includes Vitest and Bankrun tests. They use the SDK source and a local program fixture, so they are best for SDK contributors and regression testing. App integrators should also test against devnet or their own local validator flow before shipping transaction code.

```bash theme={"system"}
git clone https://github.com/MeteoraAg/damm-v2-sdk.git
cd damm-v2-sdk
pnpm install
pnpm run build
pnpm run check-types
pnpm test
```

## Faucets

<CardGroup cols={1}>
  <Card title="Devnet Faucet" icon="faucet" href="https://faucet.solana.com/">
    <p>Use this when your devnet test wallet needs SOL for fees and rent.</p>
  </Card>
</CardGroup>
