BSC
Bonding Curve On BSC Mainnet
Our Bonding curve on BSC is as follows:
How to find the reserve/price/fdv from the supply of a token?
Option1: Read from the Chain
You can directly read the information about a token from the getToken call to the on chain contract.
/// @notice Get Token State
/// @param token The address of the token
/// @return state The state of the token
function getToken(address token) external view returns (TokenState memory state);
/// @notice the status of a token
/// The token has 4 statuses:
// - Tradable: The token can be traded(buy/sell)
// - InDuel: The token is in a battle, it can only be bought but not sold.
// - Killed: The token is killed, it can not be traded anymore. Can only be redeemed for another token.
// - DEX: The token has been added to the DEX
enum TokenStatus {
Invalid, // The token does not exist
Tradable,
InDuel,
Killed,
DEX
}
/// @notice the state of a token
struct TokenState {
TokenStatus status; // the status of the token
uint256 reserve; // the reserve of the token
uint256 supply; // the supply of the token
uint256 price; // the price of the token
bool inGame; // is the token in the game
uint256 seqInGame; // the sequence of the token in the game (only valid when inGame is true)
}
Option 2: Calculate them from the current supply
Before the token listed on DEX, its supply is always changing when people sell or buy it against the bonding curve:
When the user buys tokens from the bonding curve, we mint tokens to user
When the user sells his tokens for BNB, we burn the selling tokens
You can simply index the ERC20 Transfer events to get the current supply of the token. When you get the current supply of the token, reserve, mc, price can all be calculated from the current supply.
Here we provide a typescript snippet:
Last updated