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)
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 V2tokenManager
: 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 addressesquote
: 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 BEP20lastPrice
: The last price of your tokentradingFeeRate
: The trading fee rate of your token. The actual usage of the fee rate should be the return value divided by 10,000minTradingFee
: The amount of minimum trading feelaunchTime
: Launch time of the tokenoffers
: Amount of tokens that are not soldmaxOffers
: Maximum amount of tokens that could be sold before creating Pancake pairfunds
: Amount of paid BNB or BEP20 receivedmaxFunds
: Maximum amount of paid BNB or BEP20 that could be receivedliquidityAdded
: True if the Pancake pair has been created
Get information about the token.
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)
token
: The address of the token to purchaseamount
: The amount of the token the user wants to purchasefunds
: The amount of money the user wants to spend (in the quote currency)tokenManager
: The address of the TokenManager associated with the tokenquote
: The address of the quote currency for the token, whereaddress(0)
represents ETH or BNBestimatedAmount
: The estimated amount of tokens that can be boughtestimatedCost
: The estimated cost in the quote currencyestimatedFee
: The estimated fee for the transactionamountMsgValue
: The value to be set inmsg.value
when callingTokenManager.buyToken()
orTokenManager.buyTokenAMAP()
amountApproval
: The amount of tokens that need to be pre-approved forTokenManager.buyToken()
orTokenManager.buyTokenAMAP()
amountFunds
: The value used for thefunds
parameter when callingTokenManager.buyTokenAMAP()
- 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)
Attempt to buy a token and get estimated results.
Returns:
Example:
(V2) tryBuy(address token, uint256 amount, uint256 funds) returns (address tokenManager, address quote, uint256 estimatedAmount, uint256 estimatedCost, uint256 estimatedFee, uint256 fundRequirement, uint256 fundAsParameter)
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 shouldspecify in transaction BNB value or BEP20 allowancefundAsParameter
: The amount of quote token should be used as thefunds
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)
token
: The address of tokenamount
: The amount of token that the user wants to sell- Returns:
tokenManager
: The address of the token manager which manages your tokenquote
: The address of the quote token of your tokenfunds
: The amount of quote token users will receive for selling a tokenfee
: The amount of quote token users will pay for trading fee
Just pre-calculate the result if the user sells a specified amount of tokens if needed.
calcInitialPrice(uint256 maxRaising, uint256 totalSupply, uint256 offers, uint256 reserves) returns (uint256 priceWei)
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.
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.