Launch A Token

Launch A Token

newTokenV2

To Launch a new token, you send a transaction to call the newTokenV2 method:

// solidity interface 

/// @notice Create a new token (V2) with flexible parameters
/// @param params The parameters for the new token
/// @return token The address of the created token
function newTokenV2(NewTokenV2Params calldata params) external payable returns (address token); 

/// @notice Create a new token (V4) with DEX ID and LP fee profile support
/// @param params The parameters for the new token including DEX ID and LP fee profile
/// @return token The address of the created token
/// @dev Similar to newTokenV3 but with DEX ID and LP fee profile support. Allows specifying preferred DEX and fee tier
function newTokenV4(NewTokenV4Params calldata params) external payable returns (address token);


/// @notice Parameters for creating a new token (V2)
struct NewTokenV2Params {
    /// The name of the token
    string name;
    /// The symbol of the token
    string symbol;
    /// The ipfs cid of the metadata 
    string meta;
    /// The DEX supply threshold type
    DexThreshType dexThresh;
    /// The salt for deterministic deployment
    bytes32 salt;
    /// The tax rate in basis points (if non-zero, this is a tax token)
    uint16 taxRate;
    /// The migrator type (see MigratorType enum)
    MigratorType migratorType;
    /// The quote token address (native gas token if zero address)
    address quoteToken;
    /// The initial quote token amount to spend for buying
    uint256 quoteAmt;
    /// The beneficiary address for the token
    /// For rev share tokens, this is the address that can claim the LP fees
    /// For tax tokens, this is the address that receives the tax fees
    address beneficiary;
    /// The optional permit data for the quote token
    bytes permitData;
}



/// @notice Parameters for creating a new token (V4) with DEX ID and LP fee profile support
struct NewTokenV4Params {
    /// The name of the token
    string name;
    /// The symbol of the token
    string symbol;
    /// The metadata URI of the token
    string meta;
    /// The DEX supply threshold type
    DexThreshType dexThresh;
    /// The salt for deterministic deployment
    bytes32 salt;
    /// The tax rate in basis points (if non-zero, this is a tax token)
    uint16 taxRate;
    /// The migrator type (see MigratorType enum)
    MigratorType migratorType;
    /// The quote token address (native gas token if zero address)
    address quoteToken;
    /// The initial quote token amount to spend for buying
    uint256 quoteAmt;
    /// The beneficiary address for the token
    /// For rev share tokens, this is the address that can claim the LP fees
    /// For tax tokens, this is the address that receives the tax fees
    address beneficiary;
    /// The optional permit data for the quote token
    bytes permitData;
    /// @notice The ID of the extension to be used for the new token if not zero
    bytes32 extensionID;
    /// @notice Additional extension specific data to be passed to the extension's `onTokenCreation` method, check the extension's documentation for details on the expected format and content.
    bytes extensionData;
    /// @notice The preferred DEX ID for the token
    DEXId dexId;
    /// @notice The preferred V3 LP fee profile for the token
    V3LPFeeProfile lpFeeProfile;
}

/// @notice the V3 LP fee profile
/// @dev determines the LP fee tier to use when migrating tokens to Uniswap V3 or Pancake V3
enum V3LPFeeProfile {
    LP_FEE_PROFILE_STANDARD, // Standard fee tier:  0.25% on PancakeSwap, 0.3% on Uniswap
    LP_FEE_PROFILE_LOW, // Low fee tier: typically, 0.01% on PancakeSwap, 0.05% on Uniswap
    LP_FEE_PROFILE_HIGH // High fee tier (1% for exotic pairs)

}

/// @notice the DEX ID
/// @dev determines the DEX we want to migrate to
/// On BSC:
///   - only DEX0 will be enabled, which is PancakeSwap
/// On xLayer:
///   - only DEX0 will be enabled, which is PotatoSwap
/// On Monad:
///   - DEX0 is Uniswap
///   - DEX1 is PancakeSwap
///   - DEX2 is Monday
/// Note that, currently, we only support at most 3 DEXes
/// We may add more DEXes in the future if needed
enum DEXId {
    DEX0,
    DEX1,
    DEX2
}

/// @notice the migrator type
/// @dev the migrator type determines how the liquidity is added to the DEX.
/// Note: To mitigate the risk of DOS, if a V3 migrator is used but the liquidity cannot
/// be added to v3 pools, the migrator will fallback to a V2 migrator.
enum MigratorType {
    V3_MIGRATOR, // Migrate the liquidity to a Uniswap V3 like pool
    V2_MIGRATOR // Migrate the liquidity to a Uniswap V2 like pool
}

/// @dev dex threshold types
enum DexThreshType {
    TWO_THIRDS, //  66.67% supply
    FOUR_FIFTHS, // 80% supply
    HALF, // 50% supply
    _95_PERCENT, // 95% supply
    _81_PERCENT, // 81% supply
    _1_PERCENT // 1% supply => mainly for testing

}

Before sending the transaction, we should prepare the metadata:

All the metadata are stored on IPFS. You can upload your image and the meta of your token to ipfs through our API.

Check the following example to learn how to upload the image along with the meta data json to IPFS:

After successfully uploading the image and metadata to IPFS, you will get an IPFS cid which is similar to bafkreicwlkpvrcqg4bbhyp2fnhdwbqos5ghka6gdjra3tdkgxxs74hqsze (e.g. this is the cid of the BROCCOLI token’s metadata

After that, you can get the meta json from any ipfs gateway, eg:

Note the meta json has the following format:

The image field itself is another ipfs cid for the image. Then you can get the image here: https://ipfs.io/ipfs/bafkreiccy2x5735r2q3zvcce3ub3hcgpslnn5n3dqa7fn3tgr7qgtlbjhi

Now we have the ipfs cid of the meta json, let's proceed to construct the transaction call.

The new newTokenV2 method takes a single struct (or tuple in solidity’s jargon) as its input. Let’s explain some fields of the NewTokenV2Params struct:

  • meta : this is the ipfs cid you get from last section , eg, bafkreicwlkpvrcqg4bbhyp2fnhdwbqos5ghka6gdjra3tdkgxxs74hqsze

  • dexThresh : This determines the threshold to migrate token to DEX. Our UI uses FOUR_FIFTHS by default, which means when 80% or more of the total supply has been sold from the bonding curve , the token will be migrated to DEX.

  • taxRate : since v3.3.0, we support creating a tax token. The tax is only applied for the first 30days after the token being migrated to DEX. The maximum tax rate is 10%

  • migratorType : The migrator for the token. Note, if a token has tax, it can only be migrated to a V2 pool, which means only a V2_MIGRATOR is allowed for a tax token. For other tokens, it is recommended to use a V3_MIGRATOR. With a V3_MIGRATOR we will optimize your liquidity and enable the revenue share feature for you token.

  • quoteToken : The quote token you want to use. When your quote token is the native gas token (i.e ETH or BNB), leave quoteToken as the zero address. Note: only enabled quoteToken can be used.

  • quoteAmt: The amount of quoteToken you want to spend to buy token on creation.

  • beneficiary : If the token has not TAX and using a V3_MIGRATOR , the rev share fees can be claimed with this address; If the token has TAX, this address will receive the tax fee.

  • permitData : If your quoteToken is not zero address (i.e, not native gas token ETH or BNB, but some ERC20 token). You can construct the permitData to avoid another approve TX. Check our example below to see how to construct the permitData.

  • salt : The salt is mandate. All tokens created from the newTokenV2 method have a vanity ending. If the token has no tax, it has an ending of 8888 or it has an ending of 7777.

Here is an example script for generating the salt:

  • The suffix is 8888 if your token has not tax, otherwise it is 7777

  • The token impl address is :

    • 0x8B4329947e34B6d56D71A3385caC122BaDe7d78D for non tax token

    • 0x5dd913731C12aD8DF3E574859FDe45412bF4aaD9 for tax token

  • Portal address on BSC is 0xe2cE6ab80874Fa9Fa2aAE65D277Dd6B8e65C9De0

In the above example script, we using a random private key as the seed. In reality, you can use any random number or string as your seed to find the salt.

newTokenV3, newTokenV4, and newTokenV5

In addition to newTokenV2, the portal also supports newTokenV3, newTokenV4, and newTokenV5 with additional features:

newTokenV3

Adds extension support to newTokenV2. Extensions allow custom logic to be executed during token creation and trading.

  • extensionID: The unique identifier for the extension to use (bytes32(0) for no extension)

  • extensionData: Additional data passed to the extension's onTokenCreation method

newTokenV4

Adds DEX preference configuration to newTokenV3:

  • dexId: The preferred DEX ID for the token (DEX0, DEX1, or DEX2)

  • lpFeeProfile: The preferred V3 LP fee profile (STANDARD, LOW, VERY_LOW, or SUPER_LOW)

newTokenV5

TODO

Important: newTokenV5 is not yet enabled and will be available once the audit is complete.

Events

For backward compatibility, each newly launched token will emit one or more events rather than a single event:

  • TokenCreated : Every token launch will emit a TokenCreated event.

  • TokenCurveSet : (optional), if a token launch does not emit this event, its curve is the first one in the CurveType enum , which is 16 ( i.e curveParameter = 16 ether )

  • TokenCurveSetV2: (optional), starting from v4.7.0, this event is always emitted even when the token is using the legacy bonding curve.

  • TokenDexSupplyThreshSet : (optional), if a token does not emit this event, its dex threshold is by default the first one in the DexThreshType enum, which is 6.67e8 ether.

  • TokenQuoteSet : (optional), if a token does not emit this event, its quote token is the native gas token (i.e, zero address). Otherwise the quote token 's address is the quoteToken arg in the event (Currently, we support USD1 and lisUSD on BSC)

  • TokenMigratorSet : (optional), if a token does not emit this event, its Migrator type is by default V3_MIGRATOR (i.e, the first one in the MigratorType enum).

  • FlapTokenTaxSet : (optional), if a token does not emit this event, the tax is 0 or it is not a tax token.

  • FlapTokenStaged : (optional), emitted when a token is staged but not yet created (for two-step token launch).

  • TokenExtensionEnabled : (optional), emitted when an extension is enabled for a token.

  • TokenDexPreferenceSet : (optional), emitted when a token's DEX preference is set (includes DEX ID and LP fee profile). For backward compatibility, if a token does not emit this event, its DEX preference is DEX0 and STANDARD fee profile.

  • TokenPoolInfoUpdated : (optional), emitted when a token's pool information is updated.

Last updated