Skip to main content
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:
The virtual reserves set the initial price and curve shape without requiring seed liquidity.

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:
When kasIn is very small relative to kasReserves, the price impact approaches zero and the effective price approaches the spot price.

Graduation Threshold

Each token has a graduationThreshold in its curve parameters. When kasReserves >= graduationThreshold, the token graduates: