本页目前只有英文版。

Token Version Specification

Overview

The TokenVersion field is an enum that indicates which token implementation is being used for a specific token. This field is crucial for determining the capabilities and features available for each token launched through the Portal contract.

TokenVersion Enum Values

    /// @dev Token version
    /// Which token implementation is used
    enum TokenVersion {
        TOKEN_LEGACY_MINT_NO_PERMIT,
        TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATE, // for historical reasons, both 0 and 1 are the same: TOKEN_LEGACY_MINT_NO_PERMIT
        TOKEN_V2_PERMIT, // 2
        TOKEN_GOPLUS, // 3
        TOKEN_TAXED, // 4: The original tax token (FlapTaxToken)
        TOKEN_TAXED_V2, // 5: The new advanced tax token (FlapTaxTokenV2)
        TOKEN_TAXED_V3, // 6: The next-generation tax token with asymmetric buy/sell rates (FlapTaxTokenV3)
        TOKEN_V3_PERMIT // 7: Non-tax token using TokenV3 implementation with permit support

    }

The TokenVersion has the following values:

ValueNameDescription
0TOKEN_LEGACY_MINT_NO_PERMITLegacy token implementation without permit functionality
1TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATEHistorical duplicate (identical to value 0)
2TOKEN_V2_PERMITV2 token implementation with EIP-2612 permit support
3TOKEN_GOPLUSToken implementation with GoPlus security integration
4TOKEN_TAXEDOriginal tax token implementation (FlapTaxToken)
5TOKEN_TAXED_V2Advanced tax token implementation (FlapTaxTokenV2)
6TOKEN_TAXED_V3Next-generation tax token with asymmetric buy/sell rates (FlapTaxTokenV3)
7TOKEN_V3_PERMITNon-tax TokenV3 implementation with permit support, designed for PancakeSwap Infinity CL or Uniswap v4 style integrations

Version Details

  • TOKEN_LEGACY_MINT_NO_PERMIT (0 & 1): The obsolete token implementation. Due to historical reasons, both values 0 and 1 represent the same implementation type.
  • TOKEN_V2_PERMIT (2): Enhanced token with permit functionality allowing gasless approvals via signed messages (EIP-2612 standard).
  • TOKEN_GOPLUS (3): Token integrated with GoPlus security features for enhanced safety and verification. (Not Used in current deployments)
  • TOKEN_TAXED (4): The first generation tax token (FlapTaxToken) that implements tax mechanisms on transfers.
  • TOKEN_TAXED_V2 (5): The second generation tax token (FlapTaxTokenV2) with advanced tax features and improvements over the original tax token.
  • TOKEN_TAXED_V3 (6): The third generation tax token (FlapTaxTokenV3) with asymmetric buy/sell tax rates, commission receiver support, and bidirectional dynamic liquidation threshold. Launched via newTokenV6. This is the recommended token type for all new integrations.
  • TOKEN_V3_PERMIT (7): A zero-tax token (taxRate = 0) using the TokenV3 implementation with permit support. This version is intended for launches that combine with PancakeSwap Infinity CL or Uniswap v4 style liquidity flows, and is created via newTokenV7.

How to Get Token Version

There are two primary methods to retrieve the token version for a specific token:

Method 1: Index from Events

The protocol emits a TokenVersionSet event whenever a token's version is set or updated. You can listen to this event or query historical events to determine a token's version.

Event Definition:

event TokenVersionSet(address token, TokenVersion version);

Example Usage:

  • Listen for TokenVersionSet events on the Portal contract
  • Filter events by the token address
  • The version parameter contains the TokenVersion enum value

Method 2: Using getTokenV* Methods

The Portal contract provides multiple view functions to query token state, each returning progressively more fields. All of these methods include the tokenVersion field in their return values.

Available Methods:

  1. getTokenV5 - Returns TokenStateV5 structure

    function getTokenV5(address token) external view returns (TokenStateV5 memory state);
  2. getTokenV6 - Returns TokenStateV6 structure

    function getTokenV6(address token) external view returns (TokenStateV6 memory state);
  3. getTokenV7 - Returns TokenStateV7 structure

    function getTokenV7(address token) external view returns (TokenStateV7 memory state);
  4. getTokenV8 - Returns TokenStateV8 structure with asymmetric buyTaxRate and sellTaxRate (BNB mainnet & testnet only)

    function getTokenV8(address token) external view returns (TokenStateV8 memory state);
  5. getTokenV8Safe - Returns TokenStateV8Safe with enum fields as uint8 for forward compatibility (BNB mainnet & testnet only)

    function getTokenV8Safe(address token) external view returns (TokenStateV8Safe memory state);

All TokenState structures include:

  • TokenVersion tokenVersion - The version of the token implementation

Example Usage:

// Using getTokenV8 on BNB mainnet/testnet (recommended — includes asymmetric tax rates)
TokenStateV8 memory state = portal.getTokenV8(tokenAddress);
TokenVersion version = state.tokenVersion;
uint256 buyTax = state.buyTaxRate;
uint256 sellTax = state.sellTaxRate;

// Using getTokenV7 on other networks
TokenStateV7 memory state = portal.getTokenV7(tokenAddress);
TokenVersion version = state.tokenVersion;