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
pool
: A reference to theVirtualPool
state.config
: A reference to thePoolConfig
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.
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
pool
: A reference to theVirtualPool
state.config
: A reference to thePoolConfig
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.
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
pool
: A reference to theVirtualPool
state.config
: A reference to thePoolConfig
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.
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.