Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor frozen warnings #1141

Merged
merged 7 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
51 changes: 51 additions & 0 deletions src/components/infoTooltips/FrozenTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { ExclamationIcon } from '@heroicons/react/outline';
import { Trans } from '@lingui/macro';
import { Box, SvgIcon } from '@mui/material';

import { ContentWithTooltip } from '../ContentWithTooltip';
import { Link } from '../primitives/Link';
import { frozenProposalMap } from '../../utils/marketsAndNetworksConfig';

interface FrozenTooltipProps {
symbol?: string;
currentMarket?: string;
}

export const getFrozenProposalLink = (
symbol: string | undefined,
currentMarket: string | undefined
): string => {
if (currentMarket && currentMarket === 'proto_harmony_v3') {
return 'https://snapshot.org/#/aave.eth/proposal/0x81a78109941e5e0ac6cb5ebf82597c839c20ad6821a8c3ff063dba39032533d4';
} else if (currentMarket && currentMarket === 'proto_fantom_v3') {
return 'https://snapshot.org/#/aave.eth/proposal/0xeefcd76e523391a14cfd0a79b531ea0a3faf0eb4a058e255fac13a2d224cc647';
Copy link
Contributor

Choose a reason for hiding this comment

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

Small optimization if you wanted to, you could assign the baseUrl to a var for DRY

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now I'll just keep it as is, but I opened aave/aave-utilities#419 to create an enum so we don't have to hardcode the market names, and we can move these links to a separate config (either in utilities or interface) as well when this is added.

} else if (symbol && frozenProposalMap[symbol]) {
return frozenProposalMap[symbol];
} else {
return 'https://app.aave.com/governance';
}
};

export const FrozenTooltip = ({ symbol, currentMarket }: FrozenTooltipProps) => {
return (
<ContentWithTooltip
tooltipContent={
<Box>
<Trans>
This asset is frozen due to an Aave Protocol Governance decision.{' '}
<Link
href={getFrozenProposalLink(symbol, currentMarket)}
sx={{ textDecoration: 'underline' }}
>
<Trans>More details</Trans>
</Link>
</Trans>
</Box>
}
>
<SvgIcon sx={{ fontSize: '20px', color: 'error.main', ml: 2 }}>
<ExclamationIcon />
</SvgIcon>
</ContentWithTooltip>
);
};
39 changes: 0 additions & 39 deletions src/components/infoTooltips/FrozenWarning.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/components/transactions/Supply/SupplyModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
} from '../FlowCommons/TxModalDetails';
import { AAVEWarning } from '../Warnings/AAVEWarning';
import { AMPLWarning } from '../Warnings/AMPLWarning';
import { HarmonyWarning } from '../Warnings/HarmonyWarning';
import { IsolationModeWarning } from '../Warnings/IsolationModeWarning';
import { SNXWarning } from '../Warnings/SNXWarning';
import { SupplyActions } from './SupplyActions';
Expand Down Expand Up @@ -217,7 +216,6 @@ export const SupplyModalContent = ({
poolReserve.symbol === 'AAVE' &&
isFeatureEnabled.staking(currentMarketData) && <AAVEWarning />}
{poolReserve.symbol === 'SNX' && !maxAmountToSupply.eq('0') && <SNXWarning />}
{currentNetworkConfig.name === 'Harmony' && <HarmonyWarning learnMore={true} />}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This warning is unnecessary since supply is disabled when market is frozen


<AssetInput
value={amount}
Expand Down
27 changes: 0 additions & 27 deletions src/components/transactions/Warnings/HarmonyWarning.tsx

This file was deleted.

31 changes: 31 additions & 0 deletions src/components/transactions/Warnings/MarketWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Trans } from '@lingui/macro';
import { Link, Typography, AlertColor } from '@mui/material';

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

interface MarketWarningProps {
learnMore?: boolean; // Modify wording on link text,
warningMessage: string;
linkHref?: string;
warningType: AlertColor;
}

export const MarketWarning = ({
learnMore,
warningMessage,
linkHref,
warningType,
}: MarketWarningProps) => {
return (
<Warning severity={warningType}>
<Typography variant="caption">
<Trans>
{warningMessage}{' '}
drewcook marked this conversation as resolved.
Show resolved Hide resolved
<Link href={linkHref} target="_blank">
{learnMore ? 'Learn More' : 'Join the community discussion'}
</Link>
</Trans>
</Typography>
</Warning>
);
};
725 changes: 724 additions & 1 deletion src/locales/en/messages.js

Large diffs are not rendered by default.

32 changes: 12 additions & 20 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,6 @@ msgstr "Discord"
msgid "Due to a precision bug in the stETH contract, this asset can not be used in flashloan transactions"
msgstr "Due to a precision bug in the stETH contract, this asset can not be used in flashloan transactions"

#: src/components/transactions/Warnings/HarmonyWarning.tsx
msgid "Due to the Horizon bridge exploit, certain assets on the Harmony network are not at parity with Ethereum, which affects the Aave V3 Harmony market. <0>{0}</0>"
msgstr "Due to the Horizon bridge exploit, certain assets on the Harmony network are not at parity with Ethereum, which affects the Aave V3 Harmony market. <0>{0}</0>"

#: src/modules/dashboard/DashboardEModeButton.tsx
msgid "E-Mode"
msgstr "E-Mode"
Expand Down Expand Up @@ -1126,14 +1122,6 @@ msgstr "Participating in this {symbol} reserve gives annualized rewards."
msgid "Pending..."
msgstr "Pending..."

#: src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsList.tsx
msgid "Per the community, borrowing in this market is currently disabled. <0>Learn More</0>"
msgstr "Per the community, borrowing in this market is currently disabled. <0>Learn More</0>"

#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx
msgid "Per the community, supplying in this market is currently disabled. <0>Learn More</0>"
msgstr "Per the community, supplying in this market is currently disabled. <0>Learn More</0>"

#: src/modules/reserve-overview/ReserveActions.tsx
msgid "Please connect a wallet to view your personal information here."
msgstr "Please connect a wallet to view your personal information here."
Expand Down Expand Up @@ -1670,6 +1658,14 @@ msgstr "This asset has reached its borrow cap. Nothing is available to be borrow
msgid "This asset has reached its supply cap. Nothing is available to be supplied from this market."
msgstr "This asset has reached its supply cap. Nothing is available to be supplied from this market."

#: src/components/infoTooltips/FrozenTooltip.tsx
msgid "This asset is frozen due to an Aave Protocol Governance decision. <0>More details</0>"
msgstr "This asset is frozen due to an Aave Protocol Governance decision. <0>More details</0>"

#: src/modules/reserve-overview/ReserveConfiguration.tsx
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/infoTooltips/GasTooltip.tsx
msgid "This gas calculation is only an estimation. Your wallet will set the price of the transaction. You can modify the gas settings directly from your wallet provider."
msgstr "This gas calculation is only an estimation. Your wallet will set the price of the transaction. You can modify the gas settings directly from your wallet provider."
Expand Down Expand Up @@ -2179,10 +2175,6 @@ msgstr "{0} Balance"
msgid "{0} Faucet"
msgstr "{0} Faucet"

#: src/modules/reserve-overview/ReserveConfiguration.tsx
msgid "{0} is frozen due to an Aave community decision. <0>More details</0>"
msgstr "{0} is frozen due to an Aave community decision. <0>More details</0>"

#: src/modules/staking/StakingPanel.tsx
msgid "{d}d"
msgstr "{d}d"
Expand All @@ -2200,14 +2192,14 @@ msgstr "{m}m"
msgid "{networkName} Faucet"
msgstr "{networkName} Faucet"

#: src/components/infoTooltips/FrozenWarning.tsx
msgid "{symbol} is frozen due to an Aave Protocol Governance decision. <0>More details</0>"
msgstr "{symbol} is frozen due to an Aave Protocol Governance decision. <0>More details</0>"

#: src/modules/staking/StakingPanel.tsx
msgid "{s}s"
msgstr "{s}s"

#: src/components/CircleIcon.tsx
msgid "{tooltipText}"
msgstr "{tooltipText}"

#: src/components/transactions/Warnings/MarketWarning.tsx
msgid "{warningMessage} <0>{0}</0>"
msgstr "{warningMessage} <0>{0}</0>"
46 changes: 28 additions & 18 deletions src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { VariableAPYTooltip } from 'src/components/infoTooltips/VariableAPYToolt
import { StableAPYTooltip } from 'src/components/infoTooltips/StableAPYTooltip';
import { Warning } from 'src/components/primitives/Warning';
import { AssetCapsProvider } from 'src/hooks/useAssetCaps';
import { MarketWarning } from 'src/components/transactions/Warnings/MarketWarning';

export const BorrowAssetsList = () => {
const { currentNetworkConfig } = useProtocolDataContext();
Expand Down Expand Up @@ -116,28 +117,37 @@ export const BorrowAssetsList = () => {
noData={borrowDisabled}
subChildrenComponent={
<Box sx={{ px: 6, mb: 4 }}>
{borrowDisabled && currentNetworkConfig.name === 'Harmony' ? (
<Warning severity="warning">
{borrowDisabled && currentNetworkConfig.name === 'Harmony' && (
<MarketWarning
learnMore={true}
linkHref={`https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614`}
warningMessage={
'Due to the Horizon bridge exploit, certain assets on the Harmony network are not at parity with Ethereum, which affects the Aave V3 Harmony market.'
}
warningType={'error'}
/>
)}

{borrowDisabled && currentNetworkConfig.name === 'Fantom' && (
<MarketWarning
linkHref={`https://snapshot.org/#/aave.eth/proposal/0xeefcd76e523391a14cfd0a79b531ea0a3faf0eb4a058e255fac13a2d224cc647`}
learnMore={true}
warningMessage={'Per the community, the Fantom market has been frozen.'}
warningType={'error'}
/>
)}

{+collateralUsagePercent >= 0.98 && (
<Warning severity="error">
<Trans>
Per the community, borrowing in this market is currently disabled.{' '}
<Link
href="https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614"
target="_blank"
>
Learn More
</Link>
Be careful - You are very close to liquidation. Consider depositing more collateral
or paying down some of your borrowed positions
</Trans>
</Warning>
) : (
)}

{!borrowDisabled && (
<>
{+collateralUsagePercent >= 0.98 && (
<Warning severity="error">
<Trans>
Be careful - You are very close to liquidation. Consider depositing more
collateral or paying down some of your borrowed positions
</Trans>
</Warning>
)}
{user?.isInIsolationMode && (
<Warning severity="warning">
<Trans>Borrowing power and assets are limited due to Isolation mode. </Trans>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/dashboard/lists/ListItemWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Tooltip, Typography } from '@mui/material';
import { ReactNode } from 'react';
import { CustomMarket } from 'src/ui-config/marketsConfig';
import { AMPLWarning } from '../../../components/infoTooltips/AMPLWarning';
import { FrozenWarning } from '../../../components/infoTooltips/FrozenWarning';
import { FrozenTooltip } from '../../../components/infoTooltips/FrozenTooltip';
import { ListColumn } from '../../../components/lists/ListColumn';
import { ListItem } from '../../../components/lists/ListItem';
import { Link, ROUTES } from '../../../components/primitives/Link';
Expand Down Expand Up @@ -59,7 +59,7 @@ export const ListItemWrapper = ({
<ETHBorrowWarning />
) : (
<>
{frozen && <FrozenWarning symbol={symbol} />}
{frozen && <FrozenTooltip symbol={symbol} currentMarket={currentMarket} />}
{!frozen && symbol === 'AMPL' && <AMPLWarning />}
{showSupplyCapTooltips && supplyCap.displayMaxedTooltip({ supplyCap })}
{showBorrowCapTooltips && borrowCap.displayMaxedTooltip({ borrowCap })}
Expand Down
8 changes: 6 additions & 2 deletions src/modules/dashboard/lists/ListMobileItemWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactNode } from 'react';
import { CustomMarket } from 'src/ui-config/marketsConfig';
import { AMPLWarning } from '../../../components/infoTooltips/AMPLWarning';
import { FrozenWarning } from '../../../components/infoTooltips/FrozenWarning';
import { FrozenTooltip } from '../../../components/infoTooltips/FrozenTooltip';
import { ListMobileItem } from '../../../components/lists/ListMobileItem';

interface ListMobileItemWrapperProps {
Expand Down Expand Up @@ -40,7 +40,11 @@ export const ListMobileItemWrapper = ({
name={name}
underlyingAsset={underlyingAsset}
warningComponent={
frozen ? <FrozenWarning symbol={symbol} /> : symbol === 'AMPL' ? <AMPLWarning /> : undefined
frozen ? (
<FrozenTooltip symbol={symbol} currentMarket={currentMarket} />
) : symbol === 'AMPL' ? (
<AMPLWarning />
) : undefined
}
loading={loading}
currentMarket={currentMarket}
Expand Down
30 changes: 16 additions & 14 deletions src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { ListLoader } from '../ListLoader';
import { SupplyAssetsListItem } from './SupplyAssetsListItem';
import { SupplyAssetsListMobileItem } from './SupplyAssetsListMobileItem';
import { Warning } from 'src/components/primitives/Warning';
import { HarmonyWarning } from 'src/components/transactions/Warnings/HarmonyWarning';
import { AssetCapsProvider } from 'src/hooks/useAssetCaps';
import { MarketWarning } from 'src/components/transactions/Warnings/MarketWarning';

export const SupplyAssetsList = () => {
const { currentNetworkConfig } = useProtocolDataContext();
Expand Down Expand Up @@ -166,19 +166,21 @@ export const SupplyAssetsList = () => {
<>
<Box sx={{ px: 6 }}>
{supplyDisabled && currentNetworkConfig.name === 'Harmony' ? (
<Warning severity="warning">
<Trans>
Per the community, supplying in this market is currently disabled.{' '}
<Link
href="https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614"
target="_blank"
>
Learn More
</Link>
</Trans>
</Warning>
) : currentNetworkConfig.name === 'Harmony' ? (
<HarmonyWarning learnMore={true} />
<MarketWarning
learnMore={true}
linkHref={`https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614`}
warningMessage={
'Due to the Horizon bridge exploit, certain assets on the Harmony network are not at parity with Ethereum, which affects the Aave V3 Harmony market.'
}
warningType={'error'}
/>
) : supplyDisabled && currentNetworkConfig.name === 'Fantom' ? (
<MarketWarning
linkHref={`https://snapshot.org/#/aave.eth/proposal/0xeefcd76e523391a14cfd0a79b531ea0a3faf0eb4a058e255fac13a2d224cc647`}
learnMore={true}
warningMessage={'Per the community, the Fantom market has been frozen.'}
warningType={'error'}
/>
) : user?.isInIsolationMode ? (
<Warning severity="warning">
<Trans>
Expand Down
Loading