The dynamic-bonding-curve-sdk provides a convenient way to interact with the Dynamic Bonding Curve program. Before you begin, here are some important resources:

quote_exact_in

This function calculates the result of a swap for a given amount of an exact input token. Function
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,
) -> Result<SwapResult2>
Parameters
  • pool: A reference to the VirtualPool state.
  • config: A reference to the PoolConfig for the pool.
  • swap_base_for_quote: A boolean indicating the direction of the trade. true for swapping base token for quote token, false otherwise.
  • current_timestamp: The current Solana cluster timestamp.
  • current_slot: The current Solana cluster slot.
  • in_amount: The amount of input tokens for the swap, excluding any transfer fees.
  • has_referral: A boolean indicating if a referral fee should be considered.
Returns It returns a Result<SwapResult2>, where SwapResult2 contains detailed information about the outcome of the swap, such as the amount in, fees, and the next sqrt price of the token.

quote_exact_out

This function calculates the result of a swap for a given amount of an exact output token. Function
pub fn quote_exact_out(
    pool: &VirtualPool,
    config: &PoolConfig,
    swap_base_for_quote: bool,
    current_timestamp: u64,
    current_slot: u64,
    out_amount: u64,
) -> Result<SwapResult2>
Parameters
  • pool: A reference to the VirtualPool state.
  • config: A reference to the PoolConfig for the pool.
  • swap_base_for_quote: A boolean indicating the direction of the trade. true for swapping base token for quote token, false otherwise.
  • current_timestamp: The current Solana cluster timestamp.
  • current_slot: The current Solana cluster slot.
  • out_amount: The amount of output tokens for the swap, excluding any transfer fees.
Returns It returns a Result<SwapResult2>, where SwapResult2 contains detailed information about the outcome of the swap, such as the amount in, fees, and the next sqrt price of the token.

quote_partial_fill

This function calculates the result of a swap for a given amount of a partial input token. This is useful for trading terminals to not be hurt by the last swap overpaying. Function
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,
) -> Result<SwapResult2>
Parameters
  • pool: A reference to the VirtualPool state.
  • config: A reference to the PoolConfig for the pool.
  • swap_base_for_quote: A boolean indicating the direction of the trade. true for swapping base token for quote token, false otherwise.
  • current_timestamp: The current Solana cluster timestamp.
  • current_slot: The current Solana cluster slot.
  • in_amount: The amount of input tokens for the swap, excluding any transfer fees.
  • has_referral: A boolean indicating if a referral fee should be considered.
Returns It returns a Result<SwapResult2>, where SwapResult2 contains detailed information about the outcome of the swap, such as the amount in, fees, and the next sqrt price of the token.