The BondingCurve contract address can be obtained from
MemeFactory.bondingCurve(). See Contract Overview for details.Constant Product Formula
KasFun uses a constant-product bonding curve (similar to Uniswap V2), enhanced with virtual reserves:Getting Curve Parameters
Before calculating prices, fetch the token’s current state and curve parameters:Price Calculation Functions
The BondingCurve contract provides three pure calculation functions:Calculate Buy Return
How many tokens will I get for a given KAS amount?Calculate Sell Return
How much KAS will I get for selling a given amount of tokens?Calculate Buy Cost
How much KAS do I need to spend to get a specific amount of tokens?Current Price
Get the current token price (KAS per token):Price Impact
For large trades, the price impact can be significant. Calculate it by comparing the effective price with the current price:Graduation Threshold
Each token has agraduationThreshold in its curve parameters. When kasReserves >= graduationThreshold, the token graduates: