Skip to main content
The code examples on this page use a bondingCurve contract instance for price quotes. Get its address from MemeFactory.bondingCurve(). See Contract Overview for details.

Buy Tokens

Send KAS to MemeFactory.buy() to receive tokens.
ParameterDescription
tokenToken contract address
minTokensOutMinimum tokens to receive (slippage protection)
msg.valueAmount of KAS to spend (wei)

Buy Event

Sell Tokens

Sell tokens back for KAS via MemeFactory.sell().
ParameterDescription
tokenToken contract address
tokenAmountAmount of tokens to sell (wei)
minKasOutMinimum KAS to receive (slippage protection)
Before selling, you must approve the MemeFactory contract to spend your tokens.

Sell Event

Slippage Protection

Always set minTokensOut (buy) or minKasOut (sell) to protect against price changes between quoting and execution.
SlippageMultiplierUse Case
5%quote * 95 / 100Low volatility
20%quote * 80 / 100Normal (recommended)
50%quote * 50 / 100High volatility / large orders
KasFun website uses 20% default slippage. For programmatic trading, adjust based on the token’s volatility and your order size relative to pool reserves.

Complete Trading Flow

Bonding curve trading is only available when the token is not yet fulfilled (info.fulfilled === false). Once fulfilled, buy/sell will revert.