add data request straking dashboard

This commit is contained in:
João Geonizeli
2021-08-18 19:38:35 -03:00
parent 8440aea593
commit dec7aadf5f
10 changed files with 139 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import type { Variables, RequestParameters, CacheConfig } from "relay-runtime";
import { Environment, Network, RecordSource, Store } from "relay-runtime";
export const fetchRelay = async (
const fetchRelay = async (
params: RequestParameters,
variables: Variables,
_cacheConfig: CacheConfig

View File

@@ -2,7 +2,7 @@ import type { FC } from "react";
import React from "react";
import { Switch, Route } from "react-router-dom";
import { Home, Orders, Wallet } from "./pages";
import { Dashbaord, Home, Orders, Wallet } from "./pages";
export const Routes: FC = () => {
return (
@@ -10,6 +10,9 @@ export const Routes: FC = () => {
<Route exact path="/">
<Home />
</Route>
<Route exact path="/dashboard">
<Dashbaord />
</Route>
<Route exact path="/wallet">
<Wallet />
</Route>

View File

@@ -14,6 +14,10 @@ const MenuItems: MenuItem[] = [
label: "Início",
path: "/",
},
{
label: "Dashbaord",
path: "/dashboard",
},
{
label: "Carteira",
path: "/wallet",

View File

@@ -0,0 +1,28 @@
import type { FC } from "react";
import React from "react";
import useSWR from "swr";
import { useCurrentUser } from "../../contexts/UserProvider";
import type { YieldwatchResponse } from "../../types/yieldwatch";
export const Dashbaord: FC = () => {
const { user } = useCurrentUser();
const { data } = useSWR<YieldwatchResponse>(
`https://www.yieldwatch.net/api/all/${user?.walletAddress}?platforms=pancake`
);
if (data?.status === "0" || !data) return null;
return (
<div>
<ul>
<li>Ganho: {data.result.PancakeSwap.staking.totalUSDValues.yield}</li>
<li>
Depositado: {data.result.PancakeSwap.staking.totalUSDValues.deposit}
</li>
<li>Total: {data.result.PancakeSwap.staking.totalUSDValues.total}</li>
</ul>
</div>
);
};

View File

@@ -0,0 +1 @@
export * from "./Dashboard";

View File

@@ -1,3 +1,4 @@
export * from "./Dashboard";
export * from "./Home";
export * from "./Wallet";
export * from "./Orders";
export * from "./Wallet";

View File

@@ -0,0 +1,85 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
type WatchBalance = {
USDPrice: number;
totalBalance: number;
maxMonitorValue: number;
walletBalance: number;
watchFromLP: number;
};
type Currencies = {
EUR: number;
RMB: number;
JPY: number;
GBP: number;
BTCB: number;
WBNB: number;
BRL: number;
AUD: number;
HKD: number;
SGD: number;
RUB: number;
KRW: number;
CAD: number;
THB: number;
CHF: number;
IDR: number;
TRY: number;
TWD: number;
};
type TotalUSDValues = {
deposit: number;
yield: number;
total: number;
};
type Vaults = {
totalUSDValues: TotalUSDValues;
vaults: any[];
};
type TotalUSDValues2 = {
deposit: number;
yield: number;
total: number;
};
type LPStaking = {
totalUSDValues: TotalUSDValues2;
vaults: any[];
};
type TotalUSDValues3 = {
deposit: number;
yield: number;
total: number;
};
type Staking = {
totalUSDValues: TotalUSDValues3;
vaults: any[];
};
type PancakeSwap = {
vaults: Vaults;
LPStaking: LPStaking;
staking: Staking;
};
type WalletBalance = {
totalUSDValue: number;
balances: any[];
};
type Result = {
watchBalance: WatchBalance;
currencies: Currencies;
PancakeSwap: PancakeSwap;
};
export type YieldwatchResponse = {
status: "0" | "1";
message: string;
result: Result;
};