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 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
3 changes: 0 additions & 3 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ jobs:
fail-fast: false
matrix:
market:
- fantom
- polygon
- avalanche
- optimism
Expand Down Expand Up @@ -181,7 +180,6 @@ jobs:
fail-fast: false
matrix:
market:
- fantom
- polygon
- avalanche
- optimism
Expand Down Expand Up @@ -232,7 +230,6 @@ jobs:
fail-fast: false
matrix:
market:
- fantom
- polygon
- avalanche
- optimism
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test-deploy-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ jobs:
fail-fast: false
matrix:
market:
- fantom
- polygon
- avalanche
- optimism
Expand Down Expand Up @@ -174,7 +173,6 @@ jobs:
fail-fast: false
matrix:
market:
- fantom
- polygon
- avalanche
- optimism
Expand Down Expand Up @@ -217,7 +215,6 @@ jobs:
fail-fast: false
matrix:
market:
- fantom
- polygon
- avalanche
- optimism
Expand Down
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.

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

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

const WarningMessage = ({ market }: { market: string }) => {
if (market === 'Harmony') {
return (
<Trans>
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.
</Trans>
);
} else if (market === 'Fantom') {
return <Trans>Per the community, the Fantom market has been frozen.</Trans>;
} else {
return <></>;
}
};

const getLink = (market: string, forum: boolean | undefined): string => {
if (market === 'Harmony') {
if (forum) {
return 'https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614';
} else {
return 'https://snapshot.org/#/aave.eth/proposal/0x81a78109941e5e0ac6cb5ebf82597c839c20ad6821a8c3ff063dba39032533d4';
}
} else if (market === 'Fantom') {
if (forum) {
return 'https://governance.aave.com/t/arc-aave-v3-fantom-freeze-reserves/9166';
} else {
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.

Similarly. I think we should create a src/constants/ directory for this. This is how I've typically seen it in large frontend apps, modularizing the constants. Was thinking about this as I was writing CHART_HEIGHTs this week for the graphs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also will be covered in other comment ^

Copy link
Collaborator

Choose a reason for hiding this comment

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

Once we get that file setup, we could setup a mapping of market name to proposal info. Then I think in the asset list components we wouldn't need to do any checking of market name, we just look up in the mapping by market name, if it's empty don't render. Could help clean up some of those if statements in the other pages.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this idea

}
} else {
return '';
}
};

interface MarketWarningProps {
marketName: string;
forum?: boolean;
}

export const MarketWarning = ({ marketName, forum }: MarketWarningProps) => {
return (
<Warning severity="error">
<Typography variant="caption">
<WarningMessage market={marketName} />{' '}
<Link href={getLink(marketName, forum)} target="_blank">
{forum ? <Trans>Join the community discussion</Trans> : <Trans>Learn more</Trans>}
</Link>
</Typography>
</Warning>
);
};
2 changes: 1 addition & 1 deletion src/locales/en/messages.js

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,9 @@ 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/components/transactions/Warnings/MarketWarning.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."
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."

#: src/modules/dashboard/DashboardEModeButton.tsx
msgid "E-Mode"
Expand Down Expand Up @@ -878,6 +878,10 @@ msgstr "Isolated Debt Ceiling"
msgid "Isolated assets have limited borrowing power and other assets cannot be used as collateral."
msgstr "Isolated assets have limited borrowing power and other assets cannot be used as collateral."

#: src/components/transactions/Warnings/MarketWarning.tsx
msgid "Join the community discussion"
msgstr "Join the community discussion"

#: src/layouts/components/LanguageSwitcher.tsx
msgid "Language"
msgstr "Language"
Expand All @@ -889,6 +893,7 @@ msgstr "Language"
#: src/components/transactions/StakeCooldown/StakeCooldownModalContent.tsx
#: src/components/transactions/Warnings/BorrowCapWarning.tsx
#: src/components/transactions/Warnings/DebtCeilingWarning.tsx
#: src/components/transactions/Warnings/MarketWarning.tsx
#: src/components/transactions/Warnings/SupplyCapWarning.tsx
#: src/modules/dashboard/LiquidationRiskParametresModal/LiquidationRiskParametresModal.tsx
#: src/modules/reserve-overview/ReserveConfiguration.tsx
Expand Down Expand Up @@ -1126,13 +1131,9 @@ 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/components/transactions/Warnings/MarketWarning.tsx
msgid "Per the community, the Fantom market has been frozen."
msgstr "Per the community, the Fantom market has been frozen."

#: src/modules/reserve-overview/ReserveActions.tsx
msgid "Please connect a wallet to view your personal information here."
Expand Down Expand Up @@ -1670,6 +1671,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 +2188,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,10 +2205,6 @@ 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"
Expand Down
34 changes: 16 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,25 @@ export const BorrowAssetsList = () => {
noData={borrowDisabled}
subChildrenComponent={
<Box sx={{ px: 6, mb: 4 }}>
{borrowDisabled && currentNetworkConfig.name === 'Harmony' ? (
<Warning severity="warning">
{borrowDisabled && currentNetworkConfig.name === 'Harmony' && (
<MarketWarning marketName="Harmony" />
)}

{borrowDisabled && currentNetworkConfig.name === 'Fantom' && (
<MarketWarning marketName="Fantom" />
)}

{+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
Loading