Skip to content

Commit

Permalink
ichi pool warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbacoa committed Apr 13, 2022
1 parent 493e8ca commit 18104e5
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
import { InfoIcon, InfoOutlineIcon } from '@chakra-ui/icons';
import { Heading, useDisclosure } from '@chakra-ui/react';
import { GlowingBox } from 'components/shared/GlowingButton';
import { CTokenAvatarGroup } from 'components/shared/Icons/CTokenIcon';
import { motion } from 'framer-motion';
import { Row } from 'lib/chakraUtils';
import React, { useState } from 'react'
import { TokensDataMap } from 'types/tokens';
import { PluginInfoModal } from '../../Modals/PluginModal/PluginInfoModal';
import { InfoIcon, InfoOutlineIcon } from "@chakra-ui/icons";
import { Heading, useDisclosure } from "@chakra-ui/react";
import { GlowingBox } from "components/shared/GlowingButton";
import { CTokenAvatarGroup } from "components/shared/Icons/CTokenIcon";
import { motion } from "framer-motion";
import { Row } from "lib/chakraUtils";
import React, { useState } from "react";
import { TokensDataMap } from "types/tokens";
import { PluginInfoModal } from "../../Modals/PluginModal/PluginInfoModal";

export const FuseRewardsBanner = ({
rewardTokensData,
hasPluginIncentives = false
hasPluginIncentives = false,
}: {
rewardTokensData: TokensDataMap;
hasPluginIncentives: boolean | undefined
hasPluginIncentives: boolean | undefined;
}) => {

const [hovered, setHovered] = useState(false);
const { isOpen, onClose, onOpen } = useDisclosure();
if (!Object.keys(rewardTokensData).length) return null

const icon = hasPluginIncentives ? "🔌" : "🎉 "
if (!Object.keys(rewardTokensData).length) return null;

const icon = hasPluginIncentives ? "🔌" : "🎉 ";

return (
<>
{hasPluginIncentives && <PluginInfoModal isOpen={isOpen} onClose={onClose} />}
{hasPluginIncentives && (
<PluginInfoModal isOpen={isOpen} onClose={onClose} />
)}
<motion.div
initial={{ opacity: 0, y: 40 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0 }}
style={{ width: "100%" }}
>
<GlowingBox w="100%" h="50px" mt={4}
<GlowingBox
w="100%"
h="50px"
mt={4}
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
transition="transform 0.2s ease 0s"
Expand All @@ -51,7 +54,8 @@ export const FuseRewardsBanner = ({
>
<Heading fontSize="md" ml={2}>
{" "}
{icon} This pool is offering {hasPluginIncentives && ' plugin '} rewards
{icon} This pool is offering {hasPluginIncentives && " plugin "}{" "}
rewards
</Heading>
<CTokenAvatarGroup
tokenAddresses={Object.keys(rewardTokensData)}
Expand All @@ -60,15 +64,27 @@ export const FuseRewardsBanner = ({
popOnHover={true}
/>
{!hasPluginIncentives ? null : !hovered ? (
<InfoOutlineIcon ml={"auto"} boxSize="20px" hover={{
border: "1px dotted white"
}} borderRadius={"lg"} />
) : <InfoIcon ml={"auto"} boxSize="20px" hover={{
border: "1px dotted white"
}} borderRadius={"lg"} />}
<InfoOutlineIcon
ml={"auto"}
boxSize="20px"
hover={{
border: "1px dotted white",
}}
borderRadius={"lg"}
/>
) : (
<InfoIcon
ml={"auto"}
boxSize="20px"
hover={{
border: "1px dotted white",
}}
borderRadius={"lg"}
/>
)}
</Row>
</GlowingBox>
</motion.div >
</motion.div>
</>
)
);
};
46 changes: 29 additions & 17 deletions src/components/pages/Fuse/FusePoolPage/FusePoolPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// Chakra and UI
import {
Box,
Spinner,
Text,
HStack,
} from "@chakra-ui/react";
import { Box, Spinner, Text, HStack, Alert } from "@chakra-ui/react";
import { Column, Center, RowOrColumn } from "lib/chakraUtils";
import DashboardBox from "components/shared/DashboardBox";

Expand Down Expand Up @@ -32,14 +27,14 @@ import { useIsComptrollerAdmin } from "hooks/fuse/useIsComptrollerAdmin";

import { AdminAlert, PendingAdminAlert } from "components/shared/AdminAlert";
import AppLink from "components/shared/AppLink";
import { EditIcon } from "@chakra-ui/icons";
import { EditIcon, WarningTwoIcon } from "@chakra-ui/icons";
import { FuseUniV3Alert } from "./Banners/FuseUniV3Alert";
import { FuseRewardsBanner } from "./Banners/FuseRewardsBanner";
import { CollateralRatioBar } from "./Banners/CollateralRatioBar";
import { SupplyList } from "./SupplyList";
import { BorrowList } from "./BorrowList";
import { useConvexPoolIncentives } from "hooks/convex/useConvexRewards";

import { isWarnedComptroller } from "constants/fuse";

const FusePoolPage = memo(() => {
const { isAuthed } = useRari();
Expand All @@ -54,12 +49,18 @@ const FusePoolPage = memo(() => {
const { rewardTokens: rdRewardTokens } = incentivesData;

const pluginIncentives = useConvexPoolIncentives(data?.comptroller);
const { rewardTokens: pluginRewardTokens = [], hasIncentives: hasPluginIncentives } = pluginIncentives ?? {}

const rewardTokens = useMemo(() => [...rdRewardTokens, ...pluginRewardTokens], [pluginRewardTokens, rdRewardTokens])
const rewardTokensData = useTokensDataAsMap(rewardTokens)
const {
rewardTokens: pluginRewardTokens = [],
hasIncentives: hasPluginIncentives,
} = pluginIncentives ?? {};

const rewardTokens = useMemo(
() => [...rdRewardTokens, ...pluginRewardTokens],
[pluginRewardTokens, rdRewardTokens]
);
const rewardTokensData = useTokensDataAsMap(rewardTokens);

const isAdmin = useIsComptrollerAdmin(data?.comptroller);
const isAdmin = useIsComptrollerAdmin(data?.comptroller);

return (
<>
Expand Down Expand Up @@ -103,14 +104,25 @@ const FusePoolPage = memo(() => {
/>
)}

{!!data && isWarnedComptroller(data.comptroller) && (
<Alert colorScheme={"red"} borderRadius={5} mt="5">
<HStack>
<WarningTwoIcon color="red" mr={2} />
<Text color="black">Funds deposited in this pool are at risk. Do not use this pool</Text>
</HStack>
</Alert>
)}

{!!data && isAuthed && (
<PendingAdminAlert comptroller={data?.comptroller} />
)}

<FuseRewardsBanner
rewardTokensData={rewardTokensData}
hasPluginIncentives={hasPluginIncentives}
/>
{!!data && !isWarnedComptroller(data.comptroller) && (
<FuseRewardsBanner
rewardTokensData={rewardTokensData}
hasPluginIncentives={hasPluginIncentives}
/>
)}

<FuseUniV3Alert assets={data?.assets ?? []} />

Expand Down
10 changes: 10 additions & 0 deletions src/constants/fuse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const WARNED_COMPTROLLERS = [
"0xa58056e9dcc7bf3006dbb695a4cd70a11553b9bf",
"0xf53c73332459b0dbd14d8e073319e585f7a46434",
"0xAbDFCdb1503d89D9a6fFE052a526d7A41f5b76D6",
"0xa58056E9DcC7Bf3006DBb695a4cD70A11553b9bF"
];

export const isWarnedComptroller = (addr: string) => {
return WARNED_COMPTROLLERS.includes(addr);
};
1 change: 1 addition & 0 deletions src/gql/getTopPerformingFuseAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const GET_TOP_PERFORMING_FUSE_ASSET = gql`
pool_not_in: [
"0xa58056e9dcc7bf3006dbb695a4cd70a11553b9bf"
"0xf53c73332459b0dbd14d8e073319e585f7a46434"
"0xAbDFCdb1503d89D9a6fFE052a526d7A41f5b76D6"
]
}
orderBy: $orderBy
Expand Down
1 change: 1 addition & 0 deletions src/gql/getTopPerformingFuseStable.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const GET_TOP_PERFORMING_FUSE_ASSET_OF_UNDERLYING = gql`
pool_not_in: [
"0xa58056e9dcc7bf3006dbb695a4cd70a11553b9bf"
"0xf53c73332459b0dbd14d8e073319e585f7a46434"
"0xAbDFCdb1503d89D9a6fFE052a526d7A41f5b76D6"
]
}
orderBy: $orderBy
Expand Down

1 comment on commit 18104e5

@vercel
Copy link

@vercel vercel bot commented on 18104e5 Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.