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.

Use the rust-sdk crate when you need Rust tooling around DAMM v2 quotes and initial pool math.

Install

If your project is in the same workspace as damm-v2, depend on the local crate by path:
[dependencies]
rust-sdk = { path = "../damm-v2/rust-sdk" }
cp-amm = { path = "../damm-v2/programs/cp-amm", features = ["no-entrypoint", "no-custom-entrypoint"] }
If you vendor or pin it from Git, keep the rust-sdk and cp-amm revisions aligned so account structs, fee logic, and quote math match. The Rust library reads cp-amm account structs and math directly.

What It Provides

ModulePurpose
quote_exact_in::get_quoteQuote exact- input swaps from a Pool state
quote_exact_out::get_quoteQuote exact-output swaps
quote_partial_fill_in::get_quoteQuote partial-fill exact-input swaps
calculate_initial_sqrt_price::calculate_concentrated_initial_sqrt_priceCalculate concentrated pool initial square-root price
calculate_initial_sqrt_price::calculate_compounding_initial_sqrt_price_and_liquidityCalculate compounding pool initial square-root price and liquidity
utilsActivation and swap-enabled helpers

Program ID

The public DAMM v2 program ID is the same on mainnet and devnet:
pub const CP_AMM_PROGRAM_ID: &str =
    "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
The backing program crate is cp-amm 0.2.0.

Quote Inputs

Rust quote helpers expect a deserialized cp_amm::state::Pool and current chain context:
InputWhy it matters
PoolContains price, liquidity, reserves, fee state, activation settings, and collect fee mode
Current timestampUsed by timestamp-activated fees and dynamic fee updates
Current slotUsed by slot-activated fees
Swap amount and directionDetermines exact-in, partial-fill, or exact-out result
Referral flagChanges protocol/referral fee split
Use the on-chain account data for transaction-critical quotes. API data is useful for discovery and charts, but the pool account is the source of truth for execution. The quote modules return the same SwapResult2 shape used by the program and TypeScript SDK, including claiming_fee, compounding_fee, protocol_fee, referral_fee, included_fee_input_amount, excluded_fee_input_amount, output_amount, next_sqrt_price, and amount_left.

Initial Price Helpers

Use the initial-price helpers when preparing pool creation inputs in Rust:
FunctionUse
calculate_concentrated_initial_sqrt_price(token_a_amount, token_b_amount, min_sqrt_price, max_sqrt_price)Computes a concentrated pool initial square-root price from initial token amounts and price bounds.
calculate_compounding_initial_sqrt_price_and_liquidity(token_a_amount, token_b_amount)Computes compounding pool initial square-root price and liquidity from full-range reserves.
For transaction construction, use the TypeScript SDK unless your Rust stack owns signing, simulation, and account planning.

Tests

The public repository includes Rust tests and fixtures for quote paths and initial price calculations:
git clone https://github.com/MeteoraAg/damm-v2.git
cd damm-v2
cargo test -p rust-sdk
These tests are suitable for quote-engine regression coverage. CPI programs should also add Anchor/local-validator tests for account metas, signer constraints, remaining accounts, and Token 2022 behavior.

Rust SDK Or CPI

NeedUse
Off-chain Rust quote engineRust library
On-chain program composing swaps or liquidityRust CPI
Full transaction construction from an appTypeScript SDK