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

Dex - localize time on chart #611

Merged
merged 2 commits into from
Aug 23, 2023
Merged
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
2 changes: 1 addition & 1 deletion projects/dex-ui/src/components/Swap/SwapRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const SwapRoot = () => {
// We need _some_ address in order to make quotes work when there's no account connected.
const [recipient, setRecipient] = useState<string>(NULL_ADDRESS);
const [inAmount, setInAmount] = useState<TokenValue>();
const [inToken, setInToken] = useState<Token>(fromToken ? (tokens[fromToken] ? tokens[fromToken] : tokens["WETH"]) : tokens["WETH"]);
const [inToken, setInToken] = useState<Token>(fromToken ? (tokens[fromToken] ? tokens[fromToken] : tokens["ETH"]) : tokens["ETH"]);
const [outToken, setOutToken] = useState<Token>(toToken ? (tokens[toToken] ? tokens[toToken] : tokens["BEAN"]) : tokens["BEAN"]);
const [outAmount, setOutAmount] = useState<TokenValue>();
const [slippage, setSlippage] = useState<number>(0.1);
Expand Down
9 changes: 7 additions & 2 deletions projects/dex-ui/src/components/Well/Chart/ChartSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { ChartContainer } from "./ChartStyles";
import { BottomDrawer } from "src/components/BottomDrawer";
import { size } from "src/breakpoints";

function timeToLocal(originalTime: number) {
const d = new Date(originalTime * 1000);
return Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()) / 1000;
}

export const ChartSection: FC<{ well: Well }> = ({ well }) => {
const [tab, setTab] = useState(0);
const [showDropdown, setShowDropdown] = useState(false);
Expand All @@ -31,11 +36,11 @@ export const ChartSection: FC<{ well: Well }> = ({ well }) => {
let _volumeData: any = [];
for (let i = 0; i < chartData.length; i++) {
_liquidityData.push({
time: Number(chartData[i].lastUpdateTimestamp),
time: timeToLocal(Number(chartData[i].lastUpdateTimestamp)),
value: Number(chartData[i].totalLiquidityUSD).toFixed(2)
});
_volumeData.push({
time: Number(chartData[i].lastUpdateTimestamp),
time: timeToLocal(Number(chartData[i].lastUpdateTimestamp)),
value: Number(chartData[i].deltaVolumeUSD).toFixed(2)
});
}
Expand Down
5 changes: 3 additions & 2 deletions projects/dex-ui/src/settings/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { DexSettings } from ".";
export const DevSettings: DexSettings = {
PRODUCTION: false,
AQUIFER_ADDRESS: import.meta.env.VITE_AQUIFER_ADDRESS,
SUBGRAPH_URL: "http://127.0.0.1:8000/subgraphs/name/beanstalk-wells",
WELLS_ORIGIN_BLOCK: parseInt(import.meta.env.VITE_WELLS_ORIGIN_BLOCK) || 16400000,
SUBGRAPH_URL: "https://graph.node.bean.money/subgraphs/name/basin",
// SUBGRAPH_URL: "http://127.0.0.1:8000/subgraphs/name/beanstalk-wells",
WELLS_ORIGIN_BLOCK: parseInt(import.meta.env.VITE_WELLS_ORIGIN_BLOCK) || 17977922,
LOAD_HISTORY_FROM_GRAPH: !!parseInt(import.meta.env.VITE_LOAD_HISTORY_FROM_GRAPH) || false
};

Expand Down
2 changes: 1 addition & 1 deletion projects/dex-ui/src/settings/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DexSettings } from ".";
export const ProdSettings: DexSettings = {
PRODUCTION: true,
AQUIFER_ADDRESS: import.meta.env.VITE_AQUIFER_ADDRESS,
SUBGRAPH_URL: "https://graph.node.bean.money/subgraphs/name/basin ",
SUBGRAPH_URL: "https://graph.node.bean.money/subgraphs/name/basin",
WELLS_ORIGIN_BLOCK: 17977922,
LOAD_HISTORY_FROM_GRAPH: true
};