Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update price unit select option in trading view. #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/components/GlobalChart/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useMemo, useEffect, useRef } from "react";
import { ResponsiveContainer } from "recharts";
import { timeframeOptions } from "../../constants";
import { timeframeOptions, WETH_ADDRESS } from "../../constants";
import { useGlobalChartData, useGlobalData } from "../../contexts/GlobalData";
import { useMedia } from "react-use";
import DropdownSelect from "../DropdownSelect";
Expand All @@ -9,6 +9,8 @@ import { RowFixed } from "../Row";
import { OptionButton } from "../ButtonStyled";
import { getTimeframe } from "../../utils";
import { TYPE } from "../../Theme";
import { useAllTokenData } from "../../contexts/TokenData";
import { useSelectedNetwork } from "../../contexts/Network";

const CHART_VIEW = {
VOLUME: "Volume",
Expand All @@ -19,7 +21,7 @@ const VOLUME_WINDOW = {
WEEKLY: "WEEKLY",
DAYS: "DAYS",
};
const GlobalChart = ({ display }) => {
const GlobalChart = ({ display, unit }) => {
// chart options
const [chartView, setChartView] = useState(
display === "volume" ? CHART_VIEW.VOLUME : CHART_VIEW.LIQUIDITY
Expand All @@ -40,6 +42,12 @@ const GlobalChart = ({ display }) => {
weeklyVolumeChange,
} = useGlobalData();

const allTokens = useAllTokenData();
const network = useSelectedNetwork();
const wethNativeCurrency = Number(
allTokens[WETH_ADDRESS[network].toLowerCase()].derivedNativeCurrency
);

// based on window, get starttim
let utcStartTime = getTimeframe(timeWindow);

Expand Down Expand Up @@ -96,6 +104,8 @@ const GlobalChart = ({ display }) => {
data={dailyData}
base={totalLiquidityUSD}
baseChange={liquidityChangeUSD}
unit={unit}
wethCurrency={wethNativeCurrency}
title="Liquidity"
field="totalLiquidityUSD"
width={width}
Expand All @@ -120,6 +130,8 @@ const GlobalChart = ({ display }) => {
title={
volumeWindow === VOLUME_WINDOW.WEEKLY ? "Volume (7d)" : "Volume"
}
unit={unit}
wethCurrency={wethNativeCurrency}
field={
volumeWindow === VOLUME_WINDOW.WEEKLY
? "weeklyVolumeUSD"
Expand Down
Loading