How to find the reserve/price/fdv from the circulating supply of a token?
Option1: Read from the Chain
You can directly read the information about a token through the getTokenV2 call to the on chain contract.
/// @notice Get token state/// @param token The address of the token/// @return state The state of the tokenfunctiongetTokenV2(address token) externalviewreturns (TokenStateV2memory state);/// @dev Token version/// Which token implementation is usedenumTokenVersion { 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, TOKEN_GOPLUS}/// @notice the status of a token/// The token has 4 statuses:// - Tradable: The token can be traded(buy/sell)// - InDuel: (obsolete) The token is in a battle, it can only be bought but not sold.// - Killed: (obsolete) 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 DEXenumTokenStatus { Invalid,// The token does not exist Tradable, InDuel,// obsolete Killed,// obsolete DEX}/// @notice the state of a token (with dex related fields)structTokenStateV2 { TokenStatus status; // the status of the tokenuint256 reserve; // the reserve of the tokenuint256 circulatingSupply; // the circulatingSupply of the tokenuint256 price; // the price of the token TokenVersion tokenVersion; // the version of the token implementation this token is usinguint256 r; // the r of the curve of the tokenuint256 dexSupplyThresh; // the cirtulating supply threshold for adding the token to the DEX}
Option 2: Calculate them from the current supply
Whenever a user buys or sells token on the bonding curve, the following event would be emitted:
/// @notice emitted when the circulating supply of a token changes/// @param token The address of the token/// @param newSupply The new circulating supplyeventFlapTokenCirculatingSupplyChanged(address token, uint256 newSupply);
You can simply index this event to get the latest circulating supply of any token. With the circulating supply of the token, you can get the reserve, price and FDV with the following typescript snippet: