Docs · liquidity engine

How creator fees become
deeper liquidity.

A technical reference for how every coin launched here is created on Raydium LaunchLab under the StonkFun platform, how its creator fees are split into the coin and its quote token, and how both sides are deposited into the coin's Raydium pool with the LP burned.

On this page
  1. Overview
  2. Paired with anything
  3. Coin lifecycle
  4. The liquidity engine
  5. 1 · Collect
  6. 2 · Split
  7. 3 · Deposit
  8. 4 · Burn
  9. Rebalance math
  10. Engine wallets
  11. Transactions
  12. Why the graduated pool
  13. The keeper
  14. Trade indexing
  15. Failure handling
  16. Parameters
  17. Trust model
  18. FAQ

Overview#

Every coin launched here is a standard Raydium LaunchLab launch: a Token-2022 mint created with initialize_with_token2022, 1,000,000,000 supply, a constant-product bonding curve that migrates to a Raydium CPMM pool when it completes. It is attributed to the StonkFun platform, so it shows up on StonkFun with its token page, chart and fee forwarding. The only difference is who the pool's creator is.

Normally the creator's share of trading fees is income for whoever launched the coin. Here, the creator is a per-coin engine wallet, and a keeper process turns its income into liquidity: half the value is converted into the coin, the two sides are deposited into the coin's pool, and the LP tokens are burned.

Every trade on a milk.fund coin, on the curve or in the graduated pool, here, on StonkFun or anywhere else, makes its pool permanently deeper. Liquidity added by the engine can never be withdrawn by anyone.

Paired with anything#

A coin can pair against any quote token StonkFun lists as launchable: SOL, stablecoins, xStocks, PreStocks, Backpack and Tessera assets, and community coins. The quote is what the bonding curve raises and the other side of the pool after graduation, so a coin paired with NVDAX is priced in NVDAX and its liquidity is NVDAX.

  • The curve is sized per quote from StonkFun's /launchlab/pricing: totalFundRaisingB is the raw raise in the quote's own decimals, chosen so every pair opens and graduates at the same USD market cap.
  • Fees, inventory and deposits are all in the coin's quote token. Thresholds are set in USD so they mean the same on every pair.
  • A dev buy is paid in the quote token, so launching against anything but SOL needs that token in your wallet.

Coin lifecycle#

PhaseWhere fees goWhat the engine does
Launch—The coin is minted with its own engine wallet as the LaunchLab creator. The launcher signs as fee payer and can add a dev buy.
On the curveStonkFun forwards the creator share to the engine walletBuys the coin on the curve with half the value and holds the rest in the quote token: a 50/50 inventory.
Graduation—LaunchLab migrates the curve's liquidity into a Raydium CPMM pool. The engine's inventory is now deployable.
In the poolStonkFun keeps forwarding the creator shareRebalances to the pool price, deposits both sides, burns the LP.

The liquidity engine#

Each keeper cycle runs four steps per coin. Each step is its own transaction, simulated before it is sent.

1 · Collect#

StonkFun takes the pool's 1% platform fee and forwards the creator's share to the pool creator, the engine wallet, in the quote token. There is nothing to sign for it: the engine books whatever arrived since its last snapshot as fees. For SOL pairs, any WSOL is unwrapped first. If anything has accrued in the LaunchLab creator vault instead (older fee shapes do), it is claimed with claim_creator_fee once it is worth $1.

2 · Split#

The engine targets an inventory that is 50% coin and 50% quote by value. Before graduation it buys on the bonding curve with buy_exact_in; after graduation it buys in the CPMM pool with swap_base_input. The buy size comes from the rebalance math, so tokens left over from earlier rounds are used before buying more.

3 · Deposit#

Once the coin has graduated and the quote inventory is worth at least $2, the engine deposits into the pool. It asks for the LP that both sides of its inventory can back, less 2% headroom, and caps each side at what it holds, so a small price move still fits. Dust that does not pair stays in inventory for the next cycle.

4 · Burn#

The LP tokens minted by the deposit are burned with an SPL Burn in the same transaction. The pool keeps the reserves; nobody holds the claim on them. Each coin page shows the pool's burned share as lp_burned / lp_supply.

Rebalance math#

Let Q be spendable quote (for SOL pairs, the balance minus the 0.01 SOL rent reserve), T the engine's token balance and p the price in quote per token.

On the curve (p = (virtualB + realB) / (virtualA − realA)):
  value  = Q + T·p
  buy    = value · 0.5 − T·p          // bring the coin side to 50%
  if buy ≥ $0.25 and buy ≤ Q: buy_exact_in(buy)

In the CPMM pool (p = quoteReserve / coinReserve):
  buy    = (Q − T·p) / 2                // equal value on both sides at the pool price
  if buy ≥ $0.25: swap_base_input(buy)

Deposit:
  lp     = min(T · lpSupply / coinReserve,
               Q · lpSupply / quoteReserve) · (1 − 2%)
  deposit(lp, maxCoin = T, maxQuote = Q) + burn(lp)

Because the pool buy happens immediately before the deposit, the post-buy price is slightly above p. The headroom on lp absorbs that drift; the unpaired remainder is a few basis points and is deployed next cycle.

Engine wallets#

Each coin has its own engine wallet, derived from a master seed and the mint, and set as the pool's creator at launch, so its fees, inventory and deposits never mix with another coin's. No private key is stored; the keeper re-derives it each cycle. The engine wallet keeps a 0.01 SOL reserve for token-account rent that is never deployed, and the keeper wallet tops it up and pays every network fee.

Transactions#

StepInstructionsSigners
LaunchComputeBudget · initialize_with_token2022 (+ allow-config, curve-rule accounts) · optional wrap · buy_exact_in · unwraplauncher, mint
CollectComputeBudget · CloseAccount(WSOL) or claim_creator_feekeeper, engine
Curve buyComputeBudget · create ATAs (idempotent) · wrap · buy_exact_in · unwrapkeeper, engine
Pool buyComputeBudget · create ATAs (idempotent) · wrap · swap_base_input · unwrapkeeper, engine
Deposit + burnComputeBudget · create LP ATA · wrap · deposit · Burn(LP) · unwrapkeeper, engine

Wrap and unwrap only appear on SOL pairs. All engine transactions are v0 with a 600k compute-unit limit.

Why the graduated pool#

A LaunchLab coin graduates into one Raydium CPMM pool, and that is where its price and volume live. Depositing anywhere else would split liquidity across venues, leave the main pool thin, and hand the spread between them to arbitrageurs. Deepening the pool the coin graduated into is the only placement that lowers slippage for every trader. It also closes the loop: trades in that pool keep paying the creator share back into the engine.

The keeper#

An off-chain keeper runs the engine around the clock. Every 15 seconds it:

  1. Refreshes LaunchLab curve state for every live coin, which decides whether it trades on the curve or in its pool.
  2. Runs collect → split → deposit → burn for every coin, several coins in parallel.
  3. Indexes new trades and refreshes holders for the site.

Trade indexing#

Trades come from chain, so trades placed on StonkFun, Raydium or any aggregator appear too. The keeper pages getSignaturesForAddress on the LaunchLab pool and, after graduation, on the CPMM pool, then parses each transaction with jsonParsed:

  • Side and size come from the trader: the largest change in the coin balance outside the venue.
  • Quote amount is the venue vaults' quote delta. When the coin and the quote move the same way it is a deposit or withdrawal, not a trade, and it is skipped.

Failure handling#

FailureBehaviour
Simulation failsNothing is sent. An error row is written to the engine log (deduplicated for 10 minutes) and the step retries next cycle.
Sent but not confirmedResent with a fresh blockhash only once the old one has expired, so a step never runs twice. The next cycle reads real balances.
Keeper offlineForwarded fees wait on the engine wallet. Nothing is lost; the next run picks everything up.
No USD price for the quoteThe engine skips that coin until a price is available, so thresholds are never misjudged.
Coin never graduatesInventory stays on the engine wallet as coin + quote. Its buys still supported the price on the curve.

Parameters#

The live values the engine runs with.

KeyValueNote
fees.sourceCreator share, forwardedStonkFun takes the pool's 1% fee and forwards the creator's share to the coin's engine wallet, in the quote token.
claim.minUsd1 USDAnything left in the LaunchLab creator vault is claimed once it is worth this much.
split.tokenBps50%Target share of inventory value held as the coin.
split.rebalancePool ratioAfter graduation, buys only what is needed to pair the quote at the pool price.
swap.curve.slippage3%buy_exact_in on the bonding curve before graduation.
swap.amm.slippage3%swap_base_input on the graduated pool.
deposit.minUsd2 USDInventory below this keeps accumulating.
deposit.slippage2%Headroom between the LP asked for and the inventory that backs it.
lp.modeBurnBurned in the deposit transaction: added liquidity can never be withdrawn.
reserve.sol0.01 SOLNever deployed; pays token-account rent. Topped up by the keeper.
keeper.cycle15 sRefresh curves → claim, split, deposit, burn → index trades.
keeper.feePayerKeeper walletPays every network fee and tops up engine wallets' rent reserve.
launch.creatorEngine walletEach coin's own engine wallet is the pool creator, so StonkFun forwards its fees there. Fixed at mint.
launch.pairAny StonkFun pairSOL, stables, xStocks, PreStocks, memes: whatever StonkFun lists as launchable.
launch.supply1,000,000,000Token-2022, 6 decimals, standard launch: no transfer tax.

Trust model#

  • Trading, curve math, graduation and pool accounting are Raydium's LaunchLab and CPMM programs. The site only builds transactions.
  • Fee forwarding is StonkFun's: it pays the creator share to each coin's engine wallet.
  • Forwarded fees and inventory sit in each coin's engine wallet until the keeper deploys them.
  • LP that has been burned is out of anyone's reach, the operator included.
  • Every engine action is a public transaction linked from the Engine page.
  • The server only relays transactions against the prepared mint and fee payer, through the LaunchLab program.

FAQ#

Does the creator earn anything?+

No creator fee income. Creators get a coin whose liquidity grows with its volume, and can take the dev buy in the launch transaction.

What can a coin pair with?+

Anything StonkFun lists as launchable when you launch: SOL, USDC, xStocks like NVDAX or SPYX, and more. See Paired with anything.

What happens to fees before graduation?+

They are split: half buys the coin on the curve, half is held in the quote token. That inventory is deposited the moment the coin graduates.

Can the added liquidity be pulled?+

No. The LP tokens are burned in the same transaction as the deposit.

Does my coin show up on StonkFun?+

Yes. Launches carry StonkFun's platform id and match its launch shape, so StonkFun adopts them like its own.