Skip to content

Commit

Permalink
fix: off boarding warnings (#1806)
Browse files Browse the repository at this point in the history
* fix: offboarding warnings, tusd patch on markets list

* fix: prettier

* fix: show token contract links if there is any outstanding debt

* fix: ci test coverage

---------

Co-authored-by: Nikita Boakrev <right2maresko@gmail.com>
  • Loading branch information
grothem and MareskoY authored Oct 19, 2023
1 parent a02063b commit ddb54a8
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const testData = {
],
},
};

describe.skip('SWITCH BORROWED, POLYGON V3 MARKET, INTEGRATION SPEC', () => {
const skipTestState = skipState(false);
configEnvWithTenderlyPolygonFork({ market: 'fork_proto_polygon_v3', v3: true });
Expand Down
17 changes: 0 additions & 17 deletions src/components/Warnings/BUSDOffBoardingWarning.tsx

This file was deleted.

22 changes: 22 additions & 0 deletions src/components/Warnings/OffboardingWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Trans } from '@lingui/macro';
import { CustomMarket } from 'src/ui-config/marketsConfig';

import { Link } from '../primitives/Link';

export const AssetsBeingOffboarded: { [market: string]: { [symbol: string]: string } } = {
[CustomMarket.proto_mainnet]: {
BUSD: 'https://governance.aave.com/t/arfc-busd-offboarding-plan/12170',
TUSD: 'https://governance.aave.com/t/arfc-tusd-offboarding-plan/14008',
},
};

export const OffboardingWarning = ({ discussionLink }: { discussionLink: string }) => {
return (
<Trans>
This asset is planned to be offboarded due to an Aave Protocol Governance decision.{' '}
<Link href={discussionLink} sx={{ textDecoration: 'underline' }}>
<Trans>More details</Trans>
</Link>
</Trans>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { ExclamationIcon } from '@heroicons/react/outline';
import { Box, SvgIcon } from '@mui/material';

import { ContentWithTooltip } from '../ContentWithTooltip';
import { BUSDOffBoardingWarning } from '../Warnings/BUSDOffBoardingWarning';
import { OffboardingWarning } from '../Warnings/OffboardingWarning';

export const BUSDOffBoardingTooltip = () => {
export const OffboardingTooltip = ({ discussionLink }: { discussionLink: string }) => {
return (
<ContentWithTooltip
tooltipContent={
<Box>
<BUSDOffBoardingWarning />
<OffboardingWarning discussionLink={discussionLink} />
</Box>
}
>
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2475,7 +2475,7 @@ msgstr "This asset is frozen due to an Aave Protocol Governance decision. On the
msgid "This asset is frozen due to an Aave community decision. <0>More details</0>"
msgstr "This asset is frozen due to an Aave community decision. <0>More details</0>"

#: src/components/Warnings/BUSDOffBoardingWarning.tsx
#: src/components/Warnings/OffboardingWarning.tsx
msgid "This asset is planned to be offboarded due to an Aave Protocol Governance decision. <0>More details</0>"
msgstr "This asset is planned to be offboarded due to an Aave Protocol Governance decision. <0>More details</0>"

Expand Down
7 changes: 4 additions & 3 deletions src/modules/dashboard/lists/ListItemWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Tooltip, Typography } from '@mui/material';
import { ReactNode } from 'react';
import { BorrowDisabledToolTip } from 'src/components/infoTooltips/BorrowDisabledToolTip';
import { BUSDOffBoardingTooltip } from 'src/components/infoTooltips/BUSDOffboardingToolTip';
import { OffboardingTooltip } from 'src/components/infoTooltips/OffboardingToolTip';
import { StETHCollateralToolTip } from 'src/components/infoTooltips/StETHCollateralToolTip';
import { AssetsBeingOffboarded } from 'src/components/Warnings/OffboardingWarning';
import { useAssetCaps } from 'src/hooks/useAssetCaps';
import { useRootStore } from 'src/store/root';
import { CustomMarket } from 'src/ui-config/marketsConfig';
Expand Down Expand Up @@ -51,7 +52,7 @@ export const ListItemWrapper = ({
const showRenFilTooltip = frozen && symbol === 'renFIL';
const showAmplTooltip = !frozen && symbol === 'AMPL';
const showstETHTooltip = symbol == 'stETH';
const showBUSDOffBoardingTooltip = symbol == 'BUSD';
const offboardingDiscussion = AssetsBeingOffboarded[currentMarket]?.[symbol];
const showBorrowDisabledTooltip = !frozen && !borrowEnabled;
const trackEvent = useRootStore((store) => store.trackEvent);

Expand Down Expand Up @@ -82,7 +83,7 @@ export const ListItemWrapper = ({
{showRenFilTooltip && <RenFILToolTip />}
{showAmplTooltip && <AMPLToolTip />}
{showstETHTooltip && <StETHCollateralToolTip />}
{showBUSDOffBoardingTooltip && <BUSDOffBoardingTooltip />}
{offboardingDiscussion && <OffboardingTooltip discussionLink={offboardingDiscussion} />}
{showBorrowDisabledTooltip && (
<BorrowDisabledToolTip symbol={symbol} currentMarket={currentMarket} />
)}
Expand Down
8 changes: 5 additions & 3 deletions src/modules/dashboard/lists/ListMobileItemWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ReactNode } from 'react';
import { BorrowDisabledToolTip } from 'src/components/infoTooltips/BorrowDisabledToolTip';
import { BUSDOffBoardingTooltip } from 'src/components/infoTooltips/BUSDOffboardingToolTip';
import { OffboardingTooltip } from 'src/components/infoTooltips/OffboardingToolTip';
import { StETHCollateralToolTip } from 'src/components/infoTooltips/StETHCollateralToolTip';
import { AssetsBeingOffboarded } from 'src/components/Warnings/OffboardingWarning';
import { CustomMarket } from 'src/ui-config/marketsConfig';

import { AMPLToolTip } from '../../../components/infoTooltips/AMPLToolTip';
Expand Down Expand Up @@ -46,15 +47,16 @@ export const ListMobileItemWrapper = ({
const showRenFilTooltip = frozen && symbol === 'renFIL';
const showAmplTooltip = !frozen && symbol === 'AMPL';
const showstETHTooltip = symbol == 'stETH';
const showBUSDOffBoardingTooltip = symbol == 'BUSD';
const offboardingDiscussion =
currentMarket && symbol ? AssetsBeingOffboarded[currentMarket]?.[symbol] : '';
const showBorrowDisabledTooltip = !frozen && !borrowEnabled;
return (
<>
{showFrozenTooltip && <FrozenTooltip symbol={symbol} currentMarket={currentMarket} />}
{showRenFilTooltip && <RenFILToolTip />}
{showAmplTooltip && <AMPLToolTip />}
{showstETHTooltip && <StETHCollateralToolTip />}
{showBUSDOffBoardingTooltip && <BUSDOffBoardingTooltip />}
{offboardingDiscussion && <OffboardingTooltip discussionLink={offboardingDiscussion} />}
{showBorrowDisabledTooltip && symbol && currentMarket && (
<BorrowDisabledToolTip symbol={symbol} currentMarket={currentMarket} />
)}
Expand Down
14 changes: 6 additions & 8 deletions src/modules/markets/MarketAssetsListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Trans } from '@lingui/macro';
import { Box, Button, Typography } from '@mui/material';
import { useRouter } from 'next/router';
import { BUSDOffBoardingTooltip } from 'src/components/infoTooltips/BUSDOffboardingToolTip';
import { OffboardingTooltip } from 'src/components/infoTooltips/OffboardingToolTip';
import { RenFILToolTip } from 'src/components/infoTooltips/RenFILToolTip';
import { IsolatedEnabledBadge } from 'src/components/isolationMode/IsolatedBadge';
import { NoData } from 'src/components/primitives/NoData';
import { ReserveSubheader } from 'src/components/ReserveSubheader';
import { AssetsBeingOffboarded } from 'src/components/Warnings/OffboardingWarning';
import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext';
import { useRootStore } from 'src/store/root';
import { CustomMarket } from 'src/ui-config/marketsConfig';

import { IncentivesCard } from '../../components/incentives/IncentivesCard';
import { AMPLToolTip } from '../../components/infoTooltips/AMPLToolTip';
Expand All @@ -25,10 +25,8 @@ export const MarketAssetsListItem = ({ ...reserve }: ComputedReserveData) => {
const { currentMarket } = useProtocolDataContext();
const trackEvent = useRootStore((store) => store.trackEvent);

let showStableBorrowRate = Number(reserve.totalStableDebtUSD) > 0;
if (currentMarket === CustomMarket.proto_mainnet && reserve.symbol === 'TUSD') {
showStableBorrowRate = false;
}
const offboardingDiscussion = AssetsBeingOffboarded[currentMarket]?.[reserve.symbol];

return (
<ListItem
px={6}
Expand Down Expand Up @@ -70,7 +68,7 @@ export const MarketAssetsListItem = ({ ...reserve }: ComputedReserveData) => {
</Box>
{reserve.symbol === 'AMPL' && <AMPLToolTip />}
{reserve.symbol === 'renFIL' && <RenFILToolTip />}
{reserve.symbol === 'BUSD' && <BUSDOffBoardingTooltip />}
{offboardingDiscussion && <OffboardingTooltip discussionLink={offboardingDiscussion} />}
</ListColumn>

<ListColumn>
Expand Down Expand Up @@ -114,7 +112,7 @@ export const MarketAssetsListItem = ({ ...reserve }: ComputedReserveData) => {

<ListColumn>
<IncentivesCard
value={showStableBorrowRate ? reserve.stableBorrowAPY : '-1'}
value={Number(reserve.totalStableDebtUSD) > 0 ? reserve.stableBorrowAPY : '-1'}
incentives={reserve.sIncentivesData || []}
symbol={reserve.symbol}
variant="main16"
Expand Down
8 changes: 1 addition & 7 deletions src/modules/markets/MarketAssetsListMobileItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NoData } from 'src/components/primitives/NoData';
import { ReserveSubheader } from 'src/components/ReserveSubheader';
import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext';
import { useRootStore } from 'src/store/root';
import { CustomMarket } from 'src/ui-config/marketsConfig';
import { MARKETS } from 'src/utils/mixPanelEvents';

import { IncentivesCard } from '../../components/incentives/IncentivesCard';
Expand All @@ -20,11 +19,6 @@ export const MarketAssetsListMobileItem = ({ ...reserve }: ComputedReserveData)
const { currentMarket } = useProtocolDataContext();
const trackEvent = useRootStore((store) => store.trackEvent);

let showStableBorrowRate = Number(reserve.totalStableDebtUSD) > 0;
if (currentMarket === CustomMarket.proto_mainnet && reserve.symbol === 'TUSD') {
showStableBorrowRate = false;
}

return (
<ListMobileItemWrapper
symbol={reserve.symbol}
Expand Down Expand Up @@ -125,7 +119,7 @@ export const MarketAssetsListMobileItem = ({ ...reserve }: ComputedReserveData)
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
<IncentivesCard
align="flex-end"
value={showStableBorrowRate ? reserve.stableBorrowAPY : '-1'}
value={Number(reserve.totalStableDebtUSD) > 0 ? reserve.stableBorrowAPY : '-1'}
incentives={reserve.sIncentivesData || []}
symbol={reserve.symbol}
variant="secondary14"
Expand Down
13 changes: 9 additions & 4 deletions src/modules/reserve-overview/ReserveConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { Link } from 'src/components/primitives/Link';
import { Warning } from 'src/components/primitives/Warning';
import { AMPLWarning } from 'src/components/Warnings/AMPLWarning';
import { BorrowDisabledWarning } from 'src/components/Warnings/BorrowDisabledWarning';
import { BUSDOffBoardingWarning } from 'src/components/Warnings/BUSDOffBoardingWarning';
import {
AssetsBeingOffboarded,
OffboardingWarning,
} from 'src/components/Warnings/OffboardingWarning';
import { ComputedReserveData } from 'src/hooks/app-data-provider/useAppDataProvider';
import { useAssetCaps } from 'src/hooks/useAssetCaps';
import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext';
Expand Down Expand Up @@ -38,10 +41,12 @@ export const ReserveConfiguration: React.FC<ReserveConfigurationProps> = ({ rese
const showBorrowCapStatus: boolean = reserve.borrowCap !== '0';
const trackEvent = useRootStore((store) => store.trackEvent);

const offboardingDiscussion = AssetsBeingOffboarded[currentMarket]?.[reserve.symbol];

return (
<>
<Box>
{reserve.isFrozen && reserve.symbol != 'BUSD' ? (
{reserve.isFrozen && !offboardingDiscussion ? (
<Warning sx={{ mt: '16px', mb: '40px' }} severity="error">
<Trans>
This asset is frozen due to an Aave community decision.{' '}
Expand All @@ -53,9 +58,9 @@ export const ReserveConfiguration: React.FC<ReserveConfigurationProps> = ({ rese
</Link>
</Trans>
</Warning>
) : reserve.symbol === 'BUSD' ? (
) : offboardingDiscussion ? (
<Warning sx={{ mt: '16px', mb: '40px' }} severity="error">
<BUSDOffBoardingWarning />
<OffboardingWarning discussionLink={offboardingDiscussion} />
</Warning>
) : (
reserve.symbol == 'AMPL' && (
Expand Down
13 changes: 10 additions & 3 deletions src/modules/reserve-overview/TokenLinkDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ export const TokenLinkDropdown = ({
if (!poolReserve) {
return null;
}
const showDebtTokenHeader = poolReserve.borrowingEnabled || poolReserve.stableBorrowRateEnabled;

const showVariableDebtToken =
poolReserve.borrowingEnabled || Number(poolReserve.totalVariableDebt) > 0;

const showStableDebtToken =
poolReserve.stableBorrowRateEnabled || Number(poolReserve.totalStableDebt) > 0;

const showDebtTokenHeader = showVariableDebtToken || showStableDebtToken;

return (
<>
Expand Down Expand Up @@ -147,7 +154,7 @@ export const TokenLinkDropdown = ({
</Typography>
</Box>
)}
{poolReserve.borrowingEnabled && (
{showVariableDebtToken && (
<MenuItem
component="a"
href={currentNetworkConfig.explorerLinkBuilder({
Expand All @@ -171,7 +178,7 @@ export const TokenLinkDropdown = ({
</Typography>
</MenuItem>
)}
{poolReserve.stableBorrowRateEnabled && (
{showStableDebtToken && (
<MenuItem
component="a"
href={currentNetworkConfig.explorerLinkBuilder({
Expand Down

0 comments on commit ddb54a8

Please sign in to comment.