Expand description
AMM (pump-swap) quote helpers.
Structs§
- AmmContext
- Common AMM trade context.
pool_creatoris the pool’s anchorcreatorfield;coin_creatoris the per-coin creator that receives the coin-creator fee slice (set toPubkey::default()to skip the slice). - BuyBase
Input Result - BuyQuote
Input Result - Sell
Base Input Result
Functions§
- buy_
base_ input - AMM buy: caller specifies desired tokens out, gets total SOL cost.
- buy_
quote_ input - AMM buy: caller specifies SOL input, gets tokens out.
- buy_
token_ quote_ with_ sol - Pure constant-product buy quote on an AMM pool, no fees applied.
out = sol_amount * pool_base / (pool_quote + sol_amount). - sell_
base_ input - AMM sell: caller specifies tokens in, gets net SOL out.
- sell_
quote - Constant-product sell quote, fees not applied.
out = amount * pool_quote / (pool_base + amount). - sell_
token_ quote_ with_ sol - Inverse of
sell_quote: given a desired SOL output, how many tokens must be sold.out = sol_amount * pool_base / (pool_quote - sol_amount). - validate_
market_ cap - Validate that the AMM pool’s current market cap is within
target_market_cap ± slippage_bps. Uses the fixedTOKEN_SUPPLYfor market-cap derivation:mcap = TOKEN_SUPPLY * pool_quote / pool_base.