Skip to content

SNAKexchange - Information for Token Creators

This guide is for developers and teams who have created a token on the Xian Network and wish to have it listed for trading on SNAKexchange.

Listing a Token on SNAKexchange

SNAKexchange is a permissionless protocol. This means that you do not need to ask for permission from anyone to list your token. Any user can create a new trading pair for any two tokens by becoming the first liquidity provider for that pair.

To create a new market for your token (e.g., con_MY_TOKEN) against a base asset like XIAN (currency), a user simply needs to call the addLiquidity function on the con_dex_v2 router contract. If a pair for con_MY_TOKEN and currency doesn't already exist, the protocol will automatically create one.

Pair Balance Limit

The token balance of a pair must be below 1e14. If the pair’s balance exceeds this, transactions will revert. Token developers should account for this limit during token creation.

Token Contract Interface Requirements

For a token to be fully compatible with the SNAKexchange protocol, its smart contract must adhere to a specific interface. The SNAKexchange contracts will verify this interface before allowing a pair to be created.

Your token contract must correctly implement the following three functions:

1. transfer(amount, to)

This is the standard function for transferring tokens from the caller's account to a recipient (to) address.

  • amount: The quantity of tokens to transfer.

  • to: The address of the recipient.

2. transfer_from(amount, to, main_account)

This function is crucial for the operation of the DEX router. It allows a third party (in this case, the con_dex_v2 router contract) to transfer tokens from one user's account (main_account) to another (to), provided the main_account has previously approved the caller to spend that amount.

  • amount: The quantity of tokens to transfer.

  • to: The address of the recipient (e.g., the con_pairs contract).

  • main_account: The address of the user who owns the tokens and has granted an allowance.

Users will first call approve on your token contract, giving an allowance to the con_dex_v2 router. When they then call a function like addLiquidity or swapExactTokensForTokens, the router uses transfer_from to pull the specified amount of tokens from the user's wallet into the con_pairs contract.

3. balance_of(address)

This is a standard view function that returns the token balance of a given address. The protocol uses this to verify balances, particularly when handling fee-on-transfer tokens.

  • address: The address whose token balance is being queried.

Best Practices for Token Compatibility

To ensure smooth and predictable operation on SNAKexchange, please consider the following best practices when developing your token:

  • Fee-on-Transfer Tokens: Some tokens take a fee on every transfer. While standard swaps may not work correctly with these tokens, SNAKexchange provides special functions to support them: swapExactTokenForTokenSupportingFeeOnTransferTokens, swapExactTokensForTokensSupportingFeeOnTransferTokens. These functions work by measuring the actual token balance increase in the recipient's wallet rather than relying on calculated amounts, which accounts for any fees taken during the transfer. If your token implements a transfer fee, be sure to instruct your users to use these specific swap functions.

  • External Balance Changes: If a token automatically increases balances in the pair contract (e.g., via reflections), the DEX will treat the increase as a user deposit and assign it to the pair. Token developers should exclude pair contract from such mechanisms to control how these gains are allocated.

  • Multi-Hop Swaps – Token Transfer Considerations: During multi-hop swaps, the token’s transfer function is not called for transfers that occur between pair contracts. Token developers should account for this behavior when designing the token.

  • con_pairs implements a reentrancy lock to prevent malicious reentrant calls. If your token’s transfer or transfer_from functions attempt to call back into the DEX, the transaction will revert because the DEX is already in a locked state.

By ensuring your token contract meets these interface requirements and follows best practices, you can provide a seamless trading experience for your community on SNAKexchange.