Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
transmissions11 committed May 23, 2021
1 parent 6cbd89f commit d1d618a
Show file tree
Hide file tree
Showing 61 changed files with 224 additions and 1,114 deletions.
15 changes: 1 addition & 14 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -63,13 +62,6 @@ const FusePoolCreatePage = loadable(
}
);

const RSSAssetsPage = loadable(
() => import(/* webpackPrefetch: true */ "./pages/RSSAssetsPage"),
{
fallback: <FullPageSpinner />,
}
);

const Pool2Page = loadable(
() => import(/* webpackPrefetch: true */ "./pages/Pool2/Pool2Page"),
{
Expand Down Expand Up @@ -119,10 +111,6 @@ const App = React.memo(() => {
<Route path="/" element={<Navigate to="/" replace={true} />} />
</Route>

<Route path="/rss" element={<Outlet />}>
<Route path="/assets" element={<RSSAssetsPage />} />
</Route>

<Route path="/tranches" element={<TranchesPage />} />

<Route path="/pool2" element={<Pool2Page />} />
Expand All @@ -136,7 +124,6 @@ const App = React.memo(() => {
<Route path="/fuse/pool/:poolId/edit" element={<FusePoolEditPage />} />

<Route path="/" element={<MultiPoolPortal />} />
<Route path="/home" element={<Home />} />

<Route path="*" element={<PageNotFound />} />
</Routes>
Expand Down
1 change: 0 additions & 1 deletion src/components/pages/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* istanbul ignore file */
import React from "react";

import { Code, Box, Heading, Text, Link } from "@chakra-ui/react";

Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/Fuse/FusePoolsPage.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/Fuse/FuseStatsBar.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
1 change: 0 additions & 1 deletion src/components/pages/Fuse/FuseTabBar.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/Fuse/Modals/AddAssetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
263 changes: 131 additions & 132 deletions src/components/pages/Fuse/Modals/PoolModal/AmountSelect.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -802,141 +802,140 @@ const StatsColumn = ({

const { rari, fuse } = useRari();

const {
data: updatedAssets,
}: UseQueryResult<USDPricedFuseAsset[]> = 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<USDPricedFuseAsset[]> =
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;
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/Fuse/Modals/PoolModal/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Loading

2 comments on commit d1d618a

@vercel
Copy link

@vercel vercel bot commented on d1d618a May 23, 2021

Choose a reason for hiding this comment

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

@github-actions
Copy link

Choose a reason for hiding this comment

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

Bundled size for the package is listed below:

build/static/media: 679.69 KB
build/static/js: 30.56 MB
build/static/css: 15.63 KB
build/static: 31.25 MB
build: 31.33 MB

Please sign in to comment.