rust-sdk provides a convenient way to interact with the DAMM v2 program.
Before you begin, here are some important resources:
Getting Started
To use the Rust SDK, you need to add it as a dependency in yourCargo.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 thePoolstate 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.truefor token A to token B,falsefor token B to token A.has_referral: bool: Indicates if a referral fee should be considered.
Returns
AResult<SwapResult> which contains the details of the swap if successful, including amount_out, fees, and new liquidity states.
