For the complete documentation index, see llms.txt. This page is also available as Markdown.

Launchpad Integration

This page describes how applications should integrate with Crystal Launchpad.

For a high-level explanation of how the launchpad works, see the Launchpad Overview.

Integration Model

Launchpad tokens have two states:

State
Trading source
Recommended functions

Ungraduated

Virtual bonding curve

quoteBuy, quoteSell, buy, sell

Graduated

Crystal orderbook + AMM

Standard Crystal swaps/orders, or buy / sell

A Crystal market is created when the token is created, but it is not routable through the normal pair router until graduation.

Before graduation:

getMarketByTokens(weth, token) = placeholder

After graduation:

getMarketByTokens(weth, token) = real market

Because the placeholder is nonzero, integrations should not use market != address(0) alone to determine whether the token has graduated.

Detecting Launchpad State

getVirtualReserves

function getVirtualReserves(address token)
    external
    view
    returns (
        uint256 virtualNativeReserve,
        uint256 virtualTokenReserve
    )

For an active launchpad token, both values are nonzero.

After graduation, the launchpad state is deleted and both values return zero.

This is the simplest way to distinguish the active bonding-curve state.

launchpadTokenToMarket

The public mapping exposes:

The market field is the future Crystal market address, even before that market becomes routable.

After graduation, the mapping entry is cleared.

wasLaunchpad

Returns true if a market originated from the launchpad.

allTokens

Enumerates launchpad-created tokens.

Creating a Token

The name and symbol must be nonempty.

Creation:

  • deploys a new CrystalToken;

  • creates its future type-4 Crystal market;

  • stores the token in allTokens;

  • initializes the bonding curve;

  • prepares the graduated AMM position; and

  • emits TokenCreated.

If msg.value > 0, Crystal immediately performs an exact-input buy using that native amount.

Buying

Before graduation, the trade executes against the virtual curve.

After graduation, the same function routes through the normal Crystal market.

Exact-input mode

Then:

msg.value must equal amountIn.

Exact-output mode

Then:

If amountIn == 0, the final maximum-input check is disabled.

The transaction must still provide enough native value for the trade.

Graduation during a buy

A single buy can reach graduation.

Crystal first executes the amount required to finish the bonding curve. It then activates the graduated market and can continue any remaining requested trade through the newly active market.

Applications should therefore treat graduation as something that can occur inside a trade, rather than as a separate state transition transaction.

Selling

Before graduation, the trade executes against the virtual curve.

After graduation, it routes through the normal Crystal market.

Exact-input mode

Exact-output mode

If amountIn == 0, the maximum-input check is disabled.

The user must approve Crystal to transfer the launchpad token.

Quoting

quoteBuy

Uses the same exact-input/exact-output semantics as buy.

The graduated return value is true when the quoted trade would graduate the token or when the quote uses the graduated market.

A quote that reaches graduation accounts for the launchpad portion and the immediate post-graduation market transition.

quoteSell

Uses the same semantics as sell.

Before graduation it quotes the bonding curve. After graduation it quotes the Crystal market.

Quote functions are read-like

quoteBuy and quoteSell do not persist reserve changes, but they are not declared Solidity view.

Integrations should call them with eth_call / simulation rather than sending a transaction.

Curve State

An active launchpad stores:

where:

The initial values are:

Crystal uses integer rounding when updating reserves, so integrations should prefer quoteBuy and quoteSell over independently reproducing execution math.

Supply Model

Launchpad tokens use 18 decimals.

Current constants are:

Crystal also adds virtual token reserves for pricing.

The active curve begins at approximately:

and graduates at approximately:

The difference is 800 million tokens.

The virtual amount is part of curve accounting and should not be interpreted as additional circulating supply.

Graduation Condition

Graduation occurs when:

Once this condition is reached Crystal:

  • clears launchpadTokenToMarket[token];

  • sets wasLaunchpad[market] = true;

  • replaces the placeholder pair mapping with the real market;

  • applies graduated market parameters; and

  • emits market initialization events.

Afterward, standard Crystal routing can use the pair.

Graduated Market Parameters

Launchpad markets are created as type 4, meaning the AMM fee is set at 1%, enabled by default, and the price ticks are base-10 with a fixed 5 digits of precision.

Their fixed core settings are:

Parameter
Value

Quote asset

WETH

Base asset

Launchpad token

marketType

4

scaleFactor

9

tickSize

1

maxPrice

1e15

AMM enabled

true

AMM curve factor

9900 / 10000

Graduated fee and order-size parameters come from launchpadParams:

Launchpad Fees

launchpadFee is a multiplier scaled by 100000.

For example:

means:

For buys:

For sells, the same factor is applied to native output.

Collected launchpad fees are split between:

according to:

The resulting balances accrue in claimableRewards.

Graduated AMM Liquidity

Crystal prepares the initial graduated AMM position when the token is created.

The base side is:

The quote side is derived from the curve's launch-to-graduation reserve relationship.

The LP tokens for this initial position are transferred to:

so the initial launchpad-created LP position cannot be withdrawn by an ordinary LP holder.

Events

Before graduation

A bonding-curve trade emits:

The reserve fields are the virtual reserves after the bonding-curve portion of the trade.

Token creation

Graduation

Graduation emits:

After graduation

Market execution uses normal Crystal events such as:

A single transaction that crosses graduation can contain both launchpad and normal market events.

For a token page:

For trades that may graduate:

Important Integration Notes

  • Do not treat a nonzero getMarketByTokens result as proof of graduation because the launchpad uses a nonzero placeholder before graduation.

  • Prefer quoteBuy and quoteSell over reproducing the bonding-curve math locally.

  • buy can cross graduation and continue into the graduated market in one transaction.

  • buy and sell continue working after graduation.

  • Before graduation, listen to LaunchpadTrade.

  • After graduation, use the normal Crystal market events.

  • A launchpad fee such as 99700 means a 0.3% fee, not a 99.7% fee.

  • Launchpad tokens use 18 decimals.

  • The 200 million-token graduated AMM position is separate from the 800 million-token launchpad distribution.

Last updated