Rust SDK
Rust Integration
DAMM v2
The rust-sdk
provides a convenient way to interact with the DAMM v2 program and get swap quotes.
Before you begin, here are some important resources:
- Program ID (Mainnet & Devnet):
cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG
- Rust SDK: DAMM v2
Getting Started
To use the Rust SDK, you need to add it as a dependency in your Cargo.toml
file. Since it’s a local dependency in this workspace, you can add it by specifying its path:
API Reference
get_quote
Calculates the result of a swap for a given pool.
Parameters
pool: &Pool
: A reference to thePool
state account, deserialized from on-chain data.current_timestamp: u64
: The current blockchain timestamp.current_slot: u64
: The current blockchain slot.actual_amount_in: u64
: The amount of the input token to be swapped.a_to_b: bool
: The direction of the swap.true
for token A to token B,false
for token B to token A.has_referral: bool
: Indicates if a referral fee should be considered.
Returns
A Result<SwapResult>
which contains the details of the swap if successful, including amount_out
, fees, and new liquidity states.