Skip to main content

Module amm

Module amm 

Source
Expand description

AMM (pump-swap) quote helpers.

Structs§

AmmContext
Common AMM trade context. pool_creator is the pool’s anchor creator field; coin_creator is the per-coin creator that receives the coin-creator fee slice (set to Pubkey::default() to skip the slice).
BuyBaseInputResult
BuyQuoteInputResult
SellBaseInputResult

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 fixed TOKEN_SUPPLY for market-cap derivation: mcap = TOKEN_SUPPLY * pool_quote / pool_base.