Open jshekhawat opened 2 weeks ago
Am I correct in my assumption that this snippet only calculates the historical price with the current price of BONE? So any changes will just update the chart.
export async function getTokenUSDPriceHistory(address: string): Promise<USDHistoricalPrice[]> { try { const [ethPrice, historicalPrices] = await Promise.all([ getCurrentPrice(), getHistoricalPriceData(address) ]); return historicalPrices.map((price: HistoricalPrice) => { const tokenPriceInWei = ethers.BigNumber.from(price.tokenPrice); const tokenPriceInETH = ethers.utils.formatEther(tokenPriceInWei); const tokenPriceUSD = parseFloat(tokenPriceInETH) * parseFloat(ethPrice); return { tokenPriceUSD: tokenPriceUSD.toFixed(9), // Adjust decimal places as needed timestamp: price.timestamp }; }); } catch (error) { console.error('Error calculating USD price history:', error); throw new Error('Failed to calculate USD price history'); } }
yes :)
Am I correct in my assumption that this snippet only calculates the historical price with the current price of BONE? So any changes will just update the chart.