diff --git a/src/components/App.tsx b/src/components/App.tsx index 34eb2bdde..2920134f2 100755 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,11 +1,10 @@ -import React from "react"; import { Navigate, Outlet, Route, Routes } from "react-router-dom"; import { Heading } from "@chakra-ui/react"; import loadable from "@loadable/component"; import FullPageSpinner from "./shared/FullPageSpinner"; import { Pool } from "../utils/poolUtils"; import Layout from "./shared/Layout"; -import Home from "./pages/Home/Home"; +import React from "react"; const MultiPoolPortal = loadable( () => import(/* webpackPrefetch: true */ "./pages/MultiPoolPortal"), @@ -63,13 +62,6 @@ const FusePoolCreatePage = loadable( } ); -const RSSAssetsPage = loadable( - () => import(/* webpackPrefetch: true */ "./pages/RSSAssetsPage"), - { - fallback: , - } -); - const Pool2Page = loadable( () => import(/* webpackPrefetch: true */ "./pages/Pool2/Pool2Page"), { @@ -119,10 +111,6 @@ const App = React.memo(() => { } /> - }> - } /> - - } /> } /> @@ -136,7 +124,6 @@ const App = React.memo(() => { } /> } /> - } /> } /> diff --git a/src/components/pages/ErrorPage.tsx b/src/components/pages/ErrorPage.tsx index dd9a995d8..672d61b63 100644 --- a/src/components/pages/ErrorPage.tsx +++ b/src/components/pages/ErrorPage.tsx @@ -1,5 +1,4 @@ /* istanbul ignore file */ -import React from "react"; import { Code, Box, Heading, Text, Link } from "@chakra-ui/react"; diff --git a/src/components/pages/Fuse/FusePoolsPage.tsx b/src/components/pages/Fuse/FusePoolsPage.tsx index eca42efd1..84a08fbe0 100644 --- a/src/components/pages/Fuse/FusePoolsPage.tsx +++ b/src/components/pages/Fuse/FusePoolsPage.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { Avatar, AvatarGroup, Link, Spinner, Text } from "@chakra-ui/react"; import { Center, Column, Row, useIsMobile } from "buttered-chakra"; import { useTranslation } from "react-i18next"; @@ -21,6 +20,7 @@ import { letterScore, usePoolRSS } from "hooks/useRSS"; import { SimpleTooltip } from "components/shared/SimpleTooltip"; import { useFusePools } from "hooks/fuse/useFusePools"; import Footer from "components/shared/Footer"; +import React from "react"; const FusePoolsPage = React.memo(() => { const { isAuthed } = useRari(); diff --git a/src/components/pages/Fuse/FuseStatsBar.tsx b/src/components/pages/Fuse/FuseStatsBar.tsx index bd595ef68..afa4d1658 100644 --- a/src/components/pages/Fuse/FuseStatsBar.tsx +++ b/src/components/pages/Fuse/FuseStatsBar.tsx @@ -1,6 +1,6 @@ import { Heading } from "@chakra-ui/react"; import { RowOrColumn, Column, Center } from "buttered-chakra"; -import React, { ReactNode } from "react"; +import { ReactNode } from "react"; import { useTranslation } from "react-i18next"; import { useRari } from "context/RariContext"; import { useIsSmallScreen } from "hooks/useIsSmallScreen"; diff --git a/src/components/pages/Fuse/FuseTabBar.tsx b/src/components/pages/Fuse/FuseTabBar.tsx index 7937d1c59..a3dee7ec2 100644 --- a/src/components/pages/Fuse/FuseTabBar.tsx +++ b/src/components/pages/Fuse/FuseTabBar.tsx @@ -1,7 +1,6 @@ import { DeleteIcon, SmallAddIcon } from "@chakra-ui/icons"; import { ButtonGroup, Input, Link, Text } from "@chakra-ui/react"; import { RowOrColumn, Row, Center } from "buttered-chakra"; -import React from "react"; import { useTranslation } from "react-i18next"; import { useLocation, useNavigate, useParams } from "react-router-dom"; import { useIsSmallScreen } from "../../../hooks/useIsSmallScreen"; diff --git a/src/components/pages/Fuse/Modals/AddAssetModal.tsx b/src/components/pages/Fuse/Modals/AddAssetModal.tsx index 856099467..5b8fcabf0 100644 --- a/src/components/pages/Fuse/Modals/AddAssetModal.tsx +++ b/src/components/pages/Fuse/Modals/AddAssetModal.tsx @@ -13,7 +13,7 @@ import { useToast, } from "@chakra-ui/react"; import { Column, Center } from "buttered-chakra"; -import React, { useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import DashboardBox, { diff --git a/src/components/pages/Fuse/Modals/PoolModal/AmountSelect.tsx b/src/components/pages/Fuse/Modals/PoolModal/AmountSelect.tsx index b124d1d2f..7526a9034 100644 --- a/src/components/pages/Fuse/Modals/PoolModal/AmountSelect.tsx +++ b/src/components/pages/Fuse/Modals/PoolModal/AmountSelect.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import { useState } from "react"; import { Row, Column, Center, useIsMobile } from "buttered-chakra"; import LogRocket from "logrocket"; @@ -802,141 +802,140 @@ const StatsColumn = ({ const { rari, fuse } = useRari(); - const { - data: updatedAssets, - }: UseQueryResult = useQuery( - mode + " " + index + " " + JSON.stringify(assets) + " " + amount, - async () => { - const ethPrice: number = fuse.web3.utils.fromWei( - await rari.getEthUsdPriceBN() - ) as any; - - const assetToBeUpdated = assets[index]; + const { data: updatedAssets }: UseQueryResult = + useQuery( + mode + " " + index + " " + JSON.stringify(assets) + " " + amount, + async () => { + const ethPrice: number = fuse.web3.utils.fromWei( + await rari.getEthUsdPriceBN() + ) as any; - const interestRateModel = await fuse.getInterestRateModel( - assetToBeUpdated.cToken - ); + const assetToBeUpdated = assets[index]; - let updatedAsset: USDPricedFuseAsset; - if (mode === Mode.SUPPLY) { - const supplyBalance = - parseInt(assetToBeUpdated.supplyBalance as any) + amount; - - const totalSupply = - parseInt(assetToBeUpdated.totalSupply as any) + amount; - - updatedAsset = { - ...assetToBeUpdated, - - supplyBalance, - supplyBalanceUSD: - ((supplyBalance * assetToBeUpdated.underlyingPrice) / 1e36) * - ethPrice, - - totalSupply, - supplyRatePerBlock: interestRateModel.getSupplyRate( - fuse.web3.utils.toBN( - totalSupply > 0 - ? new BigNumber(assetToBeUpdated.totalBorrow) - .dividedBy(totalSupply.toString()) - .multipliedBy(1e18) - .toFixed(0) - : 0 - ) - ), - }; - } else if (mode === Mode.WITHDRAW) { - const supplyBalance = - parseInt(assetToBeUpdated.supplyBalance as any) - amount; - - const totalSupply = - parseInt(assetToBeUpdated.totalSupply as any) - amount; - - updatedAsset = { - ...assetToBeUpdated, - - supplyBalance, - supplyBalanceUSD: - ((supplyBalance * assetToBeUpdated.underlyingPrice) / 1e36) * - ethPrice, - - totalSupply, - supplyRatePerBlock: interestRateModel.getSupplyRate( - fuse.web3.utils.toBN( - totalSupply > 0 - ? new BigNumber(assetToBeUpdated.totalBorrow) - .dividedBy(totalSupply.toString()) - .multipliedBy(1e18) - .toFixed(0) - : 0 - ) - ), - }; - } else if (mode === Mode.BORROW) { - const borrowBalance = - parseInt(assetToBeUpdated.borrowBalance as any) + amount; - - const totalBorrow = - parseInt(assetToBeUpdated.totalBorrow as any) + amount; - - updatedAsset = { - ...assetToBeUpdated, - - borrowBalance, - borrowBalanceUSD: - ((borrowBalance * assetToBeUpdated.underlyingPrice) / 1e36) * - ethPrice, - - totalBorrow, - borrowRatePerBlock: interestRateModel.getBorrowRate( - fuse.web3.utils.toBN( - assetToBeUpdated.totalSupply > 0 - ? new BigNumber(totalBorrow.toString()) - .dividedBy(assetToBeUpdated.totalSupply) - .multipliedBy(1e18) - .toFixed(0) - : 0 - ) - ), - }; - } else if (mode === Mode.REPAY) { - const borrowBalance = - parseInt(assetToBeUpdated.borrowBalance as any) - amount; - - const totalBorrow = - parseInt(assetToBeUpdated.totalBorrow as any) - amount; - - updatedAsset = { - ...assetToBeUpdated, - - borrowBalance, - borrowBalanceUSD: - ((borrowBalance * assetToBeUpdated.underlyingPrice) / 1e36) * - ethPrice, - - totalBorrow, - borrowRatePerBlock: interestRateModel.getBorrowRate( - fuse.web3.utils.toBN( - assetToBeUpdated.totalSupply > 0 - ? new BigNumber(totalBorrow.toString()) - .dividedBy(assetToBeUpdated.totalSupply) - .multipliedBy(1e18) - .toFixed(0) - : 0 - ) - ), - }; - } + const interestRateModel = await fuse.getInterestRateModel( + assetToBeUpdated.cToken + ); - return assets.map((value, _index) => { - if (_index === index) { - return updatedAsset; - } else { - return value; + let updatedAsset: USDPricedFuseAsset; + if (mode === Mode.SUPPLY) { + const supplyBalance = + parseInt(assetToBeUpdated.supplyBalance as any) + amount; + + const totalSupply = + parseInt(assetToBeUpdated.totalSupply as any) + amount; + + updatedAsset = { + ...assetToBeUpdated, + + supplyBalance, + supplyBalanceUSD: + ((supplyBalance * assetToBeUpdated.underlyingPrice) / 1e36) * + ethPrice, + + totalSupply, + supplyRatePerBlock: interestRateModel.getSupplyRate( + fuse.web3.utils.toBN( + totalSupply > 0 + ? new BigNumber(assetToBeUpdated.totalBorrow) + .dividedBy(totalSupply.toString()) + .multipliedBy(1e18) + .toFixed(0) + : 0 + ) + ), + }; + } else if (mode === Mode.WITHDRAW) { + const supplyBalance = + parseInt(assetToBeUpdated.supplyBalance as any) - amount; + + const totalSupply = + parseInt(assetToBeUpdated.totalSupply as any) - amount; + + updatedAsset = { + ...assetToBeUpdated, + + supplyBalance, + supplyBalanceUSD: + ((supplyBalance * assetToBeUpdated.underlyingPrice) / 1e36) * + ethPrice, + + totalSupply, + supplyRatePerBlock: interestRateModel.getSupplyRate( + fuse.web3.utils.toBN( + totalSupply > 0 + ? new BigNumber(assetToBeUpdated.totalBorrow) + .dividedBy(totalSupply.toString()) + .multipliedBy(1e18) + .toFixed(0) + : 0 + ) + ), + }; + } else if (mode === Mode.BORROW) { + const borrowBalance = + parseInt(assetToBeUpdated.borrowBalance as any) + amount; + + const totalBorrow = + parseInt(assetToBeUpdated.totalBorrow as any) + amount; + + updatedAsset = { + ...assetToBeUpdated, + + borrowBalance, + borrowBalanceUSD: + ((borrowBalance * assetToBeUpdated.underlyingPrice) / 1e36) * + ethPrice, + + totalBorrow, + borrowRatePerBlock: interestRateModel.getBorrowRate( + fuse.web3.utils.toBN( + assetToBeUpdated.totalSupply > 0 + ? new BigNumber(totalBorrow.toString()) + .dividedBy(assetToBeUpdated.totalSupply) + .multipliedBy(1e18) + .toFixed(0) + : 0 + ) + ), + }; + } else if (mode === Mode.REPAY) { + const borrowBalance = + parseInt(assetToBeUpdated.borrowBalance as any) - amount; + + const totalBorrow = + parseInt(assetToBeUpdated.totalBorrow as any) - amount; + + updatedAsset = { + ...assetToBeUpdated, + + borrowBalance, + borrowBalanceUSD: + ((borrowBalance * assetToBeUpdated.underlyingPrice) / 1e36) * + ethPrice, + + totalBorrow, + borrowRatePerBlock: interestRateModel.getBorrowRate( + fuse.web3.utils.toBN( + assetToBeUpdated.totalSupply > 0 + ? new BigNumber(totalBorrow.toString()) + .dividedBy(assetToBeUpdated.totalSupply) + .multipliedBy(1e18) + .toFixed(0) + : 0 + ) + ), + }; } - }); - } - ); + + return assets.map((value, _index) => { + if (_index === index) { + return updatedAsset; + } else { + return value; + } + }); + } + ); const asset = assets[index]; const updatedAsset = updatedAssets ? updatedAssets[index] : null; diff --git a/src/components/pages/Fuse/Modals/PoolModal/index.tsx b/src/components/pages/Fuse/Modals/PoolModal/index.tsx index 350a60c0b..06b716f9a 100644 --- a/src/components/pages/Fuse/Modals/PoolModal/index.tsx +++ b/src/components/pages/Fuse/Modals/PoolModal/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import { Modal, ModalOverlay, ModalContent } from "@chakra-ui/react"; import AmountSelect from "./AmountSelect"; diff --git a/src/components/pages/Home/Home.tsx b/src/components/pages/Home/Home.tsx deleted file mode 100644 index 00f9d8eeb..000000000 --- a/src/components/pages/Home/Home.tsx +++ /dev/null @@ -1,266 +0,0 @@ -import React, { useMemo } from "react"; -import { Input, InputGroup, InputLeftElement } from "@chakra-ui/input"; -import { Heading, Text, Link, SimpleGrid, Box } from "@chakra-ui/react"; -import { Column, Row } from "buttered-chakra"; -import { useIsSmallScreen } from "hooks/useIsSmallScreen"; -import NewHeader from "components/shared/Header2/NewHeader"; -import Marquee from "react-fast-marquee"; -import HomeFuseCard from "./HomeFuseCard"; -import { Link as RouterLink } from "react-router-dom"; - -import { motion } from "framer-motion"; - -import { smallStringUsdFormatter } from "utils/bigUtils"; - -import { APYWithRefreshMovingStat } from "components/shared/MovingStat"; -import { useTVLFetchers } from "hooks/useTVL"; -import HomeVaultCard from "./HomeVaultCard"; -import Footer from "components/shared/Footer"; -import OpportunityCard from "./OpportunityCard"; -import HomeCarousel from "./HomeCarousel"; - -// constants -import { - HOMEPAGE_FUSE_POOLS, - HOMEPAGE_OPPORTUNIES, - HOMEPAGE_EARN_VAULTS, -} from "constants/homepage"; -import { useFusePoolsData } from "hooks/useFusePoolData"; -import { SaffronProvider } from "../Tranches/SaffronContext"; -import { SearchIcon } from "@chakra-ui/icons"; -import DashboardBox from "components/shared/DashboardBox"; - -const Home = React.memo(() => { - // const { isAuthed } = useRari(); - const isMobile = useIsSmallScreen(); - - const { getNumberTVL } = useTVLFetchers(); - - const pools = useFusePoolsData( - HOMEPAGE_FUSE_POOLS.map(({ id }: { id: number }) => id) - ); - - return ( - - - {/* Header */} - - - {/* Hero */} - - - - - Easily earn, lend
and borrow -
-
- - - } - /> - - - -
-
- - {/* Fuse Pools */} - - - {pools?.map((pool, i) => ( - - ))} - - - - {/* Opportunities */} - - - - Explore Opportunities - - - View All - - - - - - {HOMEPAGE_OPPORTUNIES.slice( - 0, - isMobile ? 4 : HOMEPAGE_OPPORTUNIES.length - ).map((opportunity, i) => ( - - ))} - - - - - {/* Factoid Carousel */} - - - - - - - Discover infinite possibilities across the Rari Capital - Ecosystem - - - - - - - - - - {/* Easily Earn (Vaults) */} - - - - Easily Earn - - - - View All - - - - - - {HOMEPAGE_EARN_VAULTS.map((opportunity) => ( - - ))} - - - - - {/* Explore Today */} - -