import { useState } from 'react' import useMangoStats from '../../hooks/useMangoStats' import Chart from '../Chart' const icons = { BTC: '/assets/icons/btc.svg', ETH: '/assets/icons/eth.svg', SOL: '/assets/icons/sol.svg', SRM: '/assets/icons/srm.svg', USDT: '/assets/icons/usdt.svg', USDC: '/assets/icons/usdc.svg', WUSDT: '/assets/icons/usdt.svg', } const dailyStartTime = new Date(Date.now() - 1 * 24 * 60 * 60 * 1000).getTime() const weeklyStartTime = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).getTime() const getAverageStats = (stats, startFrom, type) => { const timeFilteredStats = stats.filter( (d) => new Date(d.time).getTime() > startFrom ) const sum = timeFilteredStats.map((s) => s[type]).reduce((a, b) => a + b, 0) const avg = sum / timeFilteredStats.length || 0 return (avg * 100).toFixed(4) } const AverageInterest = ({ periodLabel, statTypeLabel, interest }) => { return ( <>