diff --git a/src/pages/Earn/Pools/PoolDetail/Chart.tsx b/src/pages/Earn/Pools/PoolDetail/Chart.tsx
index 2e192d61..29e19126 100644
--- a/src/pages/Earn/Pools/PoolDetail/Chart.tsx
+++ b/src/pages/Earn/Pools/PoolDetail/Chart.tsx
@@ -9,7 +9,7 @@ import {
DashboardChartDuration,
DashboardChartType,
} from "types/dashboard-api";
-import { formatCurrency, formatDate, formatPercentage } from "utils";
+import { formatDate, formatDateRange, getSumOfDashboardChartData } from "utils";
import Select from "pages/Earn/Pools/Select";
import { MOBILE_SCREEN_CLASS } from "constants/layout";
import { Numeric } from "@xpla/xpla.js";
@@ -17,6 +17,8 @@ import IconButton from "components/IconButton";
import iconFullscreen from "assets/icons/icon-fullscreen.svg";
import useHashModal from "hooks/useHashModal";
import Modal from "components/Modal";
+import CurrencyFormatter from "components/utils/CurrencyFormatter";
+import PercentageFormatter from "components/utils/PercentageFormatter";
import useChartData from "./useChartData";
const chartTypeTabs: {
@@ -58,9 +60,11 @@ const chartValueFormatter = (
value: Numeric.Input,
chartType: DashboardChartType,
) => {
- return chartType === "apr"
- ? formatPercentage(Numeric.parse(value).mul(100))
- : formatCurrency(value);
+ return chartType === "apr" ? (
+
+ ) : (
+
+ );
};
function Chart({ tokenAddress: poolAddress }: { tokenAddress: string }) {
@@ -136,10 +140,16 @@ function Chart({ tokenAddress: poolAddress }: { tokenAddress: string }) {
>
- {chartValueFormatter(
- chartData?.[chartData.length - 1]?.v.toString() || "0",
- selectedChartType,
+ {selectedChartType === "volume" && (
+
)}
+ {selectedChartType !== "volume" &&
+ chartValueFormatter(
+ chartData?.[chartData.length - 1]?.v.toString() || "0",
+ selectedChartType,
+ )}
@@ -151,10 +161,13 @@ function Chart({ tokenAddress: poolAddress }: { tokenAddress: string }) {
margin-bottom: 7px;
`}
>
- {chartData?.[0]
- ? `${formatDate(chartData[0].t)} - ${formatDate(
- chartData[chartData.length - 1].t,
- )}`
+ {selectedChartType === "volume" &&
+ formatDateRange(
+ chartData?.[0]?.t,
+ chartData?.[chartData.length - 1]?.t,
+ )}
+ {selectedChartType !== "volume" && chartData?.[0]
+ ? formatDate(chartData[chartData.length - 1].t)
: ""}
@@ -166,6 +179,20 @@ function Chart({ tokenAddress: poolAddress }: { tokenAddress: string }) {
return {
data: chartData?.map((item) => item.v) || [],
renderTooltip({ value, index }) {
+ const [prevDate, currentDate] = [
+ chartData?.[index - 1]?.t,
+ chartData?.[index]?.t,
+ ];
+
+ if (!currentDate) {
+ return null;
+ }
+
+ const formattedDate =
+ duration !== "month" && selectedChartType === "volume"
+ ? formatDateRange(prevDate, currentDate)
+ : formatDate(currentDate);
+
return (
- {chartData?.[index] && formatDate(chartData?.[index].t)}
+ {formattedDate}
);
},
};
- }, [chartData, selectedChartType]);
+ }, [chartData, duration, selectedChartType]);
return (
diff --git a/src/pages/Earn/Pools/PoolDetail/PoolSummary.tsx b/src/pages/Earn/Pools/PoolDetail/PoolSummary.tsx
index 2f83fe4d..e2e4800f 100644
--- a/src/pages/Earn/Pools/PoolDetail/PoolSummary.tsx
+++ b/src/pages/Earn/Pools/PoolDetail/PoolSummary.tsx
@@ -2,23 +2,19 @@ import { css } from "@emotion/react";
import styled from "@emotion/styled";
import { Numeric } from "@xpla/xpla.js";
import AssetIcon from "components/AssetIcon";
-import ChangeRateFormatter from "components/ChangeRateFormatter";
+import ChangeRateFormatter from "components/utils/ChangeRateFormatter";
import Hr from "components/Hr";
import Panel from "components/Panel";
import Typography from "components/Typography";
import useAssets from "hooks/useAssets";
import { Row, Col } from "react-grid-system";
-import {
- amountToValue,
- formatDecimals,
- formatNumber,
- formatPercentage,
-} from "utils";
+import { amountToValue, formatDecimals, formatNumber } from "utils";
import usePool from "hooks/usePool";
import { getAddressFromAssetInfo } from "utils/dezswap";
import useDashboardPoolDetail from "hooks/dashboard/useDashboardPoolDetail";
import { Link } from "react-router-dom";
-import HoverUnderline from "components/HoverUnderline";
+import HoverUnderline from "components/utils/HoverUnderline";
+import PercentageFormatter from "components/utils/PercentageFormatter";
const Wrapper = styled.div`
width: 100%;
@@ -150,10 +146,11 @@ function PoolSummary({ poolAddress }: { poolAddress: string }) {
- {!Number.isNaN(Number(dashboardPoolData?.recent.apr)) &&
- formatPercentage(
- Numeric.parse(dashboardPoolData?.recent.apr || 0).mul(100),
- )}
+ {!Number.isNaN(Number(dashboardPoolData?.recent.apr)) && (
+
+ )}
diff --git a/src/pages/Earn/Pools/PoolItem.tsx b/src/pages/Earn/Pools/PoolItem.tsx
index 38dca36e..b5293ca5 100644
--- a/src/pages/Earn/Pools/PoolItem.tsx
+++ b/src/pages/Earn/Pools/PoolItem.tsx
@@ -8,14 +8,7 @@ import useBalance from "hooks/useBalance";
import useNetwork from "hooks/useNetwork";
import { useEffect, useMemo, useRef, useState } from "react";
import { Row, Col, useScreenClass, Hidden } from "react-grid-system";
-import {
- formatNumber,
- formatDecimals,
- amountToValue,
- getAddressLink,
- formatCurrency,
- formatPercentage,
-} from "utils";
+import { formatNumber, formatDecimals, getAddressLink } from "utils";
import iconDefaultToken from "assets/icons/icon-default-token.svg";
import iconBookmark from "assets/icons/icon-bookmark-default.svg";
import iconBookmarkSelected from "assets/icons/icon-bookmark-selected.svg";
@@ -33,9 +26,12 @@ import Tooltip from "components/Tooltip";
import usePairs from "hooks/usePairs";
import Outlink from "components/Outlink";
import SimplePieChart from "components/SimplePieChart";
-import HoverUnderline from "components/HoverUnderline";
+import HoverUnderline from "components/utils/HoverUnderline";
import usePool from "hooks/usePool";
import useDashboard from "hooks/dashboard/useDashboard";
+import CurrencyFormatter from "components/utils/CurrencyFormatter";
+import AssetValueFormatter from "components/utils/AssetValueFormatter";
+import PercentageFormatter from "components/utils/PercentageFormatter";
import Expand from "../Expand";
const TableRow = styled(Box)`
@@ -329,19 +325,24 @@ function PoolItem({ poolAddress, bookmarked, onBookmarkClick }: PoolItemProps) {