Skip to content
Merged

Franm #1438

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 components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Footer = () => {
padding: '16px 0px',
color: 'figma.grey.300',
fontWeight: '500',
mt: 8,
mt: 4,
}}
>
<Typography fontSize="0.85em">Exactly Protocol © {date.getFullYear()}</Typography>
Expand Down
21 changes: 18 additions & 3 deletions components/MobileTabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { ReactNode, useState } from 'react';
import React, { ReactNode, useState, useEffect, useRef } from 'react';
import { Box, Button } from '@mui/material';
import { track } from 'utils/mixpanel';
import { useRouter } from 'next/router';

export type MobileTab = {
title: string;
Expand All @@ -12,11 +13,25 @@ type Props = {
};

function MobileTabs({ tabs }: Props) {
const [selected, setSelected] = useState<number>(0);
const { query } = useRouter();
const contentRef = useRef<HTMLDivElement>(null);

const tabType = query.tab === 'b' ? 1 : 0;
const [selected, setSelected] = useState<number>(tabType);

useEffect(() => {
setSelected(tabType);
}, [tabType]);

useEffect(() => {
if (query.tab && tabType === 1 && contentRef.current) {
contentRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}, [query.tab, tabType]);

return (
<>
<Box display="flex" justifyContent="center" mb={1}>
<Box display="flex" justifyContent="center" mb={1} ref={contentRef}>
{tabs.map(({ title }, i) => (
<Button
key={`mobile-tab-${title}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ function FloatingPoolDashboard({ type }: Props) {
</Typography>
<AddExaTokensButton />
</Stack>
<FloatingPoolDashboardTable rows={floatingRows} type={type} />

{floatingRows.length === 0 ? (
<Typography color="grey.500" mt={1} fontSize="14px" mx={1.5}>
{t('No {{operations}} found', { operations: type === 'deposit' ? t('deposits') : t('borrows') })}
</Typography>
) : (
<FloatingPoolDashboardTable rows={floatingRows} type={type} />
)}
</Grid>
);
}
Expand Down
6 changes: 5 additions & 1 deletion components/dashboard/DashboardContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import DashboardMobile from './DashboardMobile';
import ConnectYourWallet from './ConnectYourWallet';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import useRouter from 'hooks/useRouter';

function DashboardContent() {
const { t } = useTranslation();
Expand All @@ -34,8 +35,11 @@ function DashboardContent() {

const { isConnected, impersonateActive } = useWeb3();
const theme = useTheme();
const { query } = useRouter();
const isMobileOrTablet = useMediaQuery(theme.breakpoints.down('md'));

const tabType = query.tab === 'b' ? 1 : 0;

const allTabs = useMemo(
() => [
{
Expand Down Expand Up @@ -85,7 +89,7 @@ function DashboardContent() {

return (
<Grid mt="24px">
<DashboardTabs initialTab={allTabs[0].value} allTabs={allTabs} />
<DashboardTabs initialTab={allTabs[tabType].value} allTabs={allTabs} />
</Grid>
);
}
Expand Down
7 changes: 6 additions & 1 deletion components/markets/MarketsTables/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ const MarketTables: FC = () => {
),
);

setRows(sortByDefault(defaultRows, tempRows));
setRows(
sortByDefault(
defaultRows,
tempRows.filter((row) => row.symbol !== 'USDC.e'),
),
);

setIsLoading(false);
}, [accountData, chain, defaultRows, rates, setIndexerError]);
Expand Down
5 changes: 4 additions & 1 deletion components/markets/MarketsTables/poolTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ const PoolTable: FC<PoolTableProps> = ({ isLoading, headers, rows }) => {
const { handleActionClick, isDisable } = useActionButton();
const assets = useAssets();
const { palette } = useTheme();
const defaultRows = useMemo<TableRow[]>(() => assets.map((s) => ({ symbol: s })), [assets]);
const defaultRows = useMemo<TableRow[]>(
() => assets.filter((s) => s !== 'USDC.e').map((s) => ({ symbol: s })),
[assets],
);
const { setOrderBy, sortData, direction: sortDirection, isActive: sortActive } = useSorting<TableRow>();
const tempRows = isLoading ? defaultRows : rows;

Expand Down
11 changes: 8 additions & 3 deletions hooks/useDashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ export default function useDashboard(type: 'deposit' | 'borrow') {
const getFloatingData = useCallback(async (): Promise<FloatingPoolItemData[] | undefined> => {
if (!accountData) return;

const allMarkets = Object.values(accountData).sort((a: MarketAccount, b: MarketAccount) => {
return orderAssets.indexOf(a.assetSymbol) - orderAssets.indexOf(b.assetSymbol);
});
const allMarkets = Object.values(accountData)
.filter((market: MarketAccount) => {
const amount = isDeposit ? market.floatingDepositAssets : market.floatingBorrowAssets;
return amount > 0n;
})
.sort((a: MarketAccount, b: MarketAccount) => {
return orderAssets.indexOf(a.assetSymbol) - orderAssets.indexOf(b.assetSymbol);
});

return await Promise.all(
allMarkets.map(
Expand Down
27 changes: 0 additions & 27 deletions hooks/useExtra.ts

This file was deleted.

7 changes: 3 additions & 4 deletions hooks/useNetAPR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export default () => {
}, [subgraphURL, walletAddress]);

return useMemo(() => {
if (!accountData || !accounts || isFetching || !floatingDeposit[0].apr || !floatingBorrow[0].apr) return {};

if (!accountData || !accounts || isFetching) return {};
const markets = Object.values(accountData);
const now = dayjs().unix();

Expand Down Expand Up @@ -56,15 +55,15 @@ export default () => {

const floatingDepositAPRs = floatingDeposit.reduce(
(acc, { symbol, apr }) => {
acc[symbol] = parseEther(String(apr));
acc[symbol] = parseEther(String(apr ?? 0));
return acc;
},
{} as Record<string, bigint>,
);

const floatingBorrowAPRs = floatingBorrow.reduce(
(acc, { symbol, apr }) => {
acc[symbol] = parseEther(String(apr));
acc[symbol] = parseEther(String(apr ?? 0));
return acc;
},
{} as Record<string, bigint>,
Expand Down
39 changes: 1 addition & 38 deletions pages/strategies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import useFloatingPoolAPR from 'hooks/useFloatingPoolAPR';
import useRewards from 'hooks/useRewards';
import { parseEther } from 'viem';
import { useVELOPoolAPR } from 'hooks/useVELO';
import { useExtraDepositAPR } from 'hooks/useExtra';
import { useWeb3 } from 'hooks/useWeb3';
import FeaturedStrategies from 'components/strategies/FeaturedStrategies';
import { useModal } from '../contexts/ModalContext';
Expand Down Expand Up @@ -71,7 +70,6 @@ const Strategies: NextPage = () => {
}, [getMarketAccount, rates, usdcDepositAPR]);

const veloRate = useVELOPoolAPR() ?? '0%';
const extraRate = useExtraDepositAPR();

const featured: (Strategy & { chainId?: number })[] = useMemo(
() =>
Expand Down Expand Up @@ -470,43 +468,8 @@ const Strategies: NextPage = () => {
),
imgPath: '/img/assets/VELO.svg',
},
{
chainId: optimism.id,
title: t('Deposit EXA on Extra Finance'),
description: t('Deposit EXA on Extra Finance and earn interest on it.'),
tags: [
...(extraRate && extraRate > 10n ** 16n
? [{ prefix: t('up to'), text: `${toPercentage(Number(extraRate ?? 0) / 1e18)} APR` }]
: []),
{ text: t('Basic'), size: 'small' as const },
],
button: (
<a
href="https://app.extrafi.io/lend/EXA"
target="_blank"
rel="noreferrer noopener"
style={{ width: '100%' }}
>
<Button
fullWidth
variant="contained"
onClick={() =>
track('Button Clicked', {
location: 'Strategies',
name: 'extra finance',
isNew: false,
href: 'https://app.extrafi.io/lend/EXA',
})
}
>
{t('Go to Extra Finance')}
</Button>
</a>
),
imgPath: '/img/assets/EXTRA.svg',
},
].filter((s) => s.chainId === chain.id || s.chainId === undefined),
[chain.id, extraRate, query, t, veloRate],
[chain.id, query, t, veloRate],
);

return (
Expand Down
Loading