DAMM v2
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:
cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG
Cargo.toml
file. Since it’s a local dependency in this workspace, you can add it by specifying its path:
get_quote
pool: &Pool
: A reference to the Pool
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.Result<SwapResult>
which contains the details of the swap if successful, including amount_out
, fees, and new liquidity states.