date
Feb 19, 2025
slug
four-meme-api
status
Published
tags
Blockchain
summary
API của Four.meme
type
Post

TokenManagerHelper3 (V3)

This smart contract is a wrapper of the TokenManager. It is designed for getting token information and performing pre-calculations easily.
Address
  • BSC: 0xF251F83e40a78868FcfA3FA4599Dad6494E46034
  • Arbitrum One: 0x02287dc3CcA964a025DAaB1111135A46C10D3A57
  • Base: 0x1172FABbAc4Fe05f5a5Cebd8EBBC593A76c42399
ABI File
TokenManagerHelper3.abi

Methods

  • getTokenInfo(address token) returns (uint256 version, address tokenManager, address quote, uint256 lastPrice, uint256 tradingFeeRate, uint256 minTradingFee, uint256 launchTime, uint256 offers, uint256 maxOffers, uint256 funds, uint256 maxFunds, bool liquidityAdded)
    • Get information about the token.
    • token: The address of your token
    • Returns:
      • version: The TokenManager version. If version returns 1, you should call V1 TokenManager methods for trading. If version returns 2, call V2
      • tokenManager: The address of the token manager which manages your token. We recommend using this address to call the TokenManager-related interfaces and parameters, replacing the hardcoded TokenManager addresses
      • quote: The address of the quote token of your token. If quote returns address 0, it means the token is traded by BNB. otherwise traded by BEP20
      • lastPrice: The last price of your token
      • tradingFeeRate: The trading fee rate of your token. The actual usage of the fee rate should be the return value divided by 10,000
      • minTradingFee: The amount of minimum trading fee
      • launchTime: Launch time of the token
      • offers: Amount of tokens that are not sold
      • maxOffers: Maximum amount of tokens that could be sold before creating Pancake pair
      • funds: Amount of paid BNB or BEP20 received
      • maxFunds: Maximum amount of paid BNB or BEP20 that could be received
      • liquidityAdded: True if the Pancake pair has been created
  • tryBuy(address token, uint256 amount, uint256 funds) public view returns (address tokenManager, address quote, uint256 estimatedAmount, uint256 estimatedCost, uint256 estimatedFee, uint256 amountMsgValue, uint256 amountApproval, uint256 amountFunds)
    • Attempt to buy a token and get estimated results.
    • token: The address of the token to purchase
    • amount: The amount of the token the user wants to purchase
    • funds: The amount of money the user wants to spend (in the quote currency)
    • Returns:
    • tokenManager: The address of the TokenManager associated with the token
    • quote: The address of the quote currency for the token, where address(0) represents ETH or BNB
    • estimatedAmount: The estimated amount of tokens that can be bought
    • estimatedCost: The estimated cost in the quote currency
    • estimatedFee: The estimated fee for the transaction
    • amountMsgValue: The value to be set in msg.value when calling TokenManager.buyToken() or TokenManager.buyTokenAMAP()
    • amountApproval: The amount of tokens that need to be pre-approved for TokenManager.buyToken() or TokenManager.buyTokenAMAP()
    • amountFunds: The value used for the funds parameter when calling TokenManager.buyTokenAMAP()
    • Example:
    • If the user wants to buy 10,000 tokens:
      • Call: tryBuy(token, 10000*1e18, 0)
    • If the user wants to spend 10 BNB to purchase tokens:
      • Call: tryBuy(token, 0, 10*1e18)
  • (V2) tryBuy(address token, uint256 amount, uint256 funds) returns (address tokenManager, address quote, uint256 estimatedAmount, uint256 estimatedCost, uint256 estimatedFee, uint256 fundRequirement, uint256 fundAsParameter)
    • Just pre-calculate the result if the user buys a specified amount of tokens if needed.
    • token: The address of tokenamount: The amount of token that the user wants to buy.funds: The amount of fundsReturns:tokenManager: The address of the token manager which manages your tokenquote: The address of the quote token of your token.estimatedAmount: The amount of token users will receive.estimatedCost: The amount of quote token users will spend for buying a tokenestimatedFee: The amount of quote token users will pay for trading fee ~~- fundRequirement: The amount of quote token your client program should specify in transaction BNB value or BEP20 allowancefundAsParameter: The amount of quote token should be used as the funds parameter if your client program wants to call TokenManager.purchaseTokenAMAP or TokenManager2.buyTokenAMAP
  • trySell(address token, uint256 amount) returns (address tokenManager, address quote, uint256 funds, uint256 fee)
    • Just pre-calculate the result if the user sells a specified amount of tokens if needed.
    • token: The address of token
    • amount: The amount of token that the user wants to sell
    • Returns:
      • tokenManager: The address of the token manager which manages your token
      • quote: The address of the quote token of your token
      • funds: The amount of quote token users will receive for selling a token
      • fee: The amount of quote token users will pay for trading fee
  • calcInitialPrice(uint256 maxRaising, uint256 totalSupply, uint256 offers, uint256 reserves) returns (uint256 priceWei)
    • This function calculates the initial price of each token based on the specified parameters such as the amount raised, total supply, tokens available for sale, and reserved tokens.
    • maxRaising: The maximum amount of BNB to be raised. It represents the maximum BNB amount the project aims to raise through the token issuance.
    • totalSupply: The total token supply. It represents the maximum amount of tokens the issuer plans to release.
    • offers: The number of tokens available for sale in the initial offering. It represents the amount of tokens available for public sale in the initial stage.
    • reserves: The reserved token amount. It represents the number of tokens retained by the issuer, typically for the team or future use.
    • Returns:
      • priceWei: The initial token price in Wei.

“Success is not final, failure is not fatal: it is the courage to continue that counts.“

Winston Churchill


© Hiếu Trần 2020 - 2025

Tip: Use console.table() for better array logging!
Anime Character