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.

The dynamic-bonding-curve repository includes a Rust crate at dynamic-bonding-curve-sdk. It depends on the on-chain dynamic-bonding-curve crate and reuses program state and math types.

Install

Use the crate from the local workspace or a pinned Git revision:
[dependencies]
dynamic-bonding-curve-sdk = { git = "https://github.com/MeteoraAg/dynamic-bonding-curve", package = "dynamic-bonding-curve-sdk" }
For local development inside the program repository:
cd dynamic-bonding-curve
cargo test -p dynamic-bonding-curve-sdk

What It Provides

ModuleFunctionUse
quote_exact_inquote_exact_inQuote a swap for a fixed input amount.
quote_exact_outquote_exact_outQuote the required input for a fixed output amount.
quote_partial_fillquote_partial_fillQuote a partial-fill swap near the end of a bonding curve.
The crate is useful for Rust services, quote engines, tests, and keepers that already decode VirtualPool and PoolConfig accounts.

Quote Inputs

All three quote helpers require current pool and config state:
ParameterMeaning
pool: &VirtualPoolCurrent virtual pool account data.
config: &PoolConfigPool config account referenced by pool.config.
swap_base_for_quote: booltrue sells base for quote; false buys base with quote.
current_timestamp: u64Current cluster timestamp. Used when config.activation_type is timestamp.
current_slot: u64Current cluster slot. Used when config.activation_type is slot.
has_referral: boolWhether a referral fee should be included. Used by exact-in and partial-fill quotes.
eligible_for_first_swap_with_min_fee: boolWhether the quote should use the first-swap minimum fee path. Set this only when the transaction satisfies the program validation path.

Exact-In Quote

pub fn quote_exact_in(
    pool: &VirtualPool,
    config: &PoolConfig,
    swap_base_for_quote: bool,
    current_timestamp: u64,
    current_slot: u64,
    in_amount: u64,
    has_referral: bool,
    eligible_for_first_swap_with_min_fee: bool,
) -> anyhow::Result<SwapResult2>
Use this for swap2 exact-in mode, then apply your slippage policy before building the transaction.

Exact-Out Quote

pub fn quote_exact_out(
    pool: &VirtualPool,
    config: &PoolConfig,
    swap_base_for_quote: bool,
    current_timestamp: u64,
    current_slot: u64,
    out_amount: u64,
    eligible_for_first_swap_with_min_fee: bool,
) -> anyhow::Result<SwapResult2>
Exact-out quotes return the input amount required to receive out_amount. Apply a maximum input bound before sending the transaction.

Partial-Fill Quote

pub fn quote_partial_fill(
    pool: &VirtualPool,
    config: &PoolConfig,
    swap_base_for_quote: bool,
    current_timestamp: u64,
    current_slot: u64,
    in_amount: u64,
    has_referral: bool,
    eligible_for_first_swap_with_min_fee: bool,
) -> anyhow::Result<SwapResult2>
Partial fill is useful when the pool is close to migration_quote_threshold and a full exact-in swap might cross the migration boundary.

Return Data

SwapResult2 contains the values needed by quote engines and transaction builders:
FieldUse
included_fee_input_amountInput amount before excluded-fee adjustment.
excluded_fee_input_amountAmount that moves the curve after fee handling.
amount_leftUnused amount in partial-fill flows.
output_amountOutput token amount.
next_sqrt_pricePost-swap Q64.64 sqrt price.
trading_fee, protocol_fee, referral_feeFee split for the swap.

Tests

The Rust crate includes tests for exact-out and partial-fill behavior, plus binary fixtures for configs and pools with quote-token and both-token fee modes.
PathUse
dynamic-bonding-curve-sdk/src/tests/test_quote_exact_out.rsExact-out quote tests.
dynamic-bonding-curve-sdk/src/tests/test_quote_partial_fill.rsPartial-fill quote tests.
dynamic-bonding-curve-sdk/fixtures/*.binSerialized pool and config fixtures.