Skip to content
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
9 changes: 9 additions & 0 deletions src/components/Warnings/BorrowableOnlyInEModeWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Trans } from '@lingui/macro';

export const BorrowableOnlyInEModeWarning = () => {
return (
<Trans>
This reserve can only be borrowed in E-Mode. See below for which categories allow borrowing.
</Trans>
);
};
17 changes: 17 additions & 0 deletions src/components/infoTooltips/BorrowableOnlyInEModeTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Trans } from '@lingui/macro';

import { TextWithTooltip } from '../TextWithTooltip';

export const BorrowableOnlyInEModeTooltip = () => {
return (
<TextWithTooltip
text={<Trans>E-Mode only</Trans>}
variant="description"
textColor="fg-3"
iconSize={12}
wrapperProps={{ sx: { mt: '2px' } }}
>
<Trans>Borrowing is only available in E-Mode</Trans>
</TextWithTooltip>
);
};
2 changes: 1 addition & 1 deletion src/locales/el/messages.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/locales/en/messages.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ msgstr "{0} {symbol}..."
msgid "Amount available to unstake"
msgstr "Amount available to unstake"

#: src/components/infoTooltips/BorrowableOnlyInEModeTooltip.tsx
msgid "E-Mode only"
msgstr "E-Mode only"

#: src/components/transactions/Bridge/BridgeDestinationInput.tsx
msgid "To"
msgstr "To"
Expand Down Expand Up @@ -2302,6 +2306,10 @@ msgstr "collateral"
msgid "No rewards to claim"
msgstr "No rewards to claim"

#: src/components/Warnings/BorrowableOnlyInEModeWarning.tsx
msgid "This reserve can only be borrowed in E-Mode. See below for which categories allow borrowing."
msgstr "This reserve can only be borrowed in E-Mode. See below for which categories allow borrowing."

#: src/modules/reserve-overview/ReserveFactorOverview.tsx
msgid "Reserve factor"
msgstr "Reserve factor"
Expand Down Expand Up @@ -3091,6 +3099,10 @@ msgstr "Zero address not valid"
msgid "Invalid bridge protocol fee"
msgstr "Invalid bridge protocol fee"

#: src/components/infoTooltips/BorrowableOnlyInEModeTooltip.tsx
msgid "Borrowing is only available in E-Mode"
msgstr "Borrowing is only available in E-Mode"

#: src/modules/governance/RepresentativesInfoPanel.tsx
msgid "Representing smart contract wallet (ie. Safe) addresses on other chains."
msgstr "Representing smart contract wallet (ie. Safe) addresses on other chains."
Expand Down
2 changes: 1 addition & 1 deletion src/locales/es/messages.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/locales/fr/messages.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/modules/markets/MarketAssetsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ProtocolAction } from '@aave/contract-helpers';
import { Trans } from '@lingui/macro';
import { Box, Button, Typography } from '@mui/material';
import { useRouter } from 'next/router';
import { BorrowableOnlyInEModeTooltip } from 'src/components/infoTooltips/BorrowableOnlyInEModeTooltip';
import { KernelAirdropTooltip } from 'src/components/infoTooltips/KernelAirdropTooltip';
import { OffboardingTooltip } from 'src/components/infoTooltips/OffboardingToolTip';
import { RenFILToolTip } from 'src/components/infoTooltips/RenFILToolTip';
Expand All @@ -13,6 +14,7 @@ import { ReserveSubheader } from 'src/components/ReserveSubheader';
import { AssetsBeingOffboarded } from 'src/components/Warnings/OffboardingWarning';
import { useRootStore } from 'src/store/root';
import { fetchIconSymbolAndName } from 'src/ui-config/reservePatches';
import { getBorrowableOnlyInEModeLabels } from 'src/utils/borrowableOnlyInEMode';
import { MARKETS } from 'src/utils/events';
import { showExternalIncentivesTooltip } from 'src/utils/utils';
import { useShallow } from 'zustand/shallow';
Expand Down Expand Up @@ -55,6 +57,8 @@ export const MarketAssetsListItem = ({ ...reserve }: ReserveWithProtocolIncentiv
? iconSymbol
: reserve.underlyingToken.symbol;

const borrowableOnlyInEModeLabels = getBorrowableOnlyInEModeLabels(reserve);

return (
<ListItem
px={5}
Expand Down Expand Up @@ -155,6 +159,7 @@ export const MarketAssetsListItem = ({ ...reserve }: ReserveWithProtocolIncentiv
protocolAction={ProtocolAction.borrow}
/>
{showBorrowingDisabledNote(reserve) && <ReserveSubheader value={'Disabled'} />}
{borrowableOnlyInEModeLabels.length > 0 && <BorrowableOnlyInEModeTooltip />}
</ListColumn>

<ListColumn align="right" minWidth={95} maxWidth={95}>
Expand Down
5 changes: 5 additions & 0 deletions src/modules/markets/MarketAssetsListMobileItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ProtocolAction } from '@aave/contract-helpers';
import { Trans } from '@lingui/macro';
import { Box, Button, Divider } from '@mui/material';
import { BorrowableOnlyInEModeTooltip } from 'src/components/infoTooltips/BorrowableOnlyInEModeTooltip';
import { KernelAirdropTooltip } from 'src/components/infoTooltips/KernelAirdropTooltip';
import { SpkAirdropTooltip } from 'src/components/infoTooltips/SpkAirdropTooltip';
import { SuperFestTooltip } from 'src/components/infoTooltips/SuperFestTooltip';
Expand All @@ -9,6 +10,7 @@ import { NoData } from 'src/components/primitives/NoData';
import { ReserveSubheader } from 'src/components/ReserveSubheader';
import { useRootStore } from 'src/store/root';
import { fetchIconSymbolAndName } from 'src/ui-config/reservePatches';
import { getBorrowableOnlyInEModeLabels } from 'src/utils/borrowableOnlyInEMode';
import { MARKETS } from 'src/utils/events';
import { showExternalIncentivesTooltip } from 'src/utils/utils';
import { useShallow } from 'zustand/shallow';
Expand Down Expand Up @@ -47,6 +49,8 @@ export const MarketAssetsListMobileItem = ({ ...reserve }: ReserveWithProtocolIn
? iconSymbol
: reserve.underlyingToken.symbol;

const borrowableOnlyInEModeLabels = getBorrowableOnlyInEModeLabels(reserve);

return (
<ListMobileItemWrapper
symbol={reserve.underlyingToken.symbol}
Expand Down Expand Up @@ -145,6 +149,7 @@ export const MarketAssetsListMobileItem = ({ ...reserve }: ReserveWithProtocolIn
protocolAction={ProtocolAction.borrow}
/>
{showBorrowingDisabledNote(reserve) && <ReserveSubheader value={'Disabled'} />}
{borrowableOnlyInEModeLabels.length > 0 && <BorrowableOnlyInEModeTooltip />}
</Box>
</Row>
<Button
Expand Down
9 changes: 9 additions & 0 deletions src/modules/reserve-overview/ReserveConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PausedTooltipText } from 'src/components/infoTooltips/PausedTooltip';
import { FormattedNumber } from 'src/components/primitives/FormattedNumber';
import { Link } from 'src/components/primitives/Link';
import { AMPLWarning } from 'src/components/Warnings/AMPLWarning';
import { BorrowableOnlyInEModeWarning } from 'src/components/Warnings/BorrowableOnlyInEModeWarning';
import { BorrowDisabledWarning } from 'src/components/Warnings/BorrowDisabledWarning';
import {
AssetsBeingOffboarded,
Expand All @@ -15,6 +16,7 @@ import {
import { ReserveWithId } from 'src/hooks/app-data-provider/useAppDataProvider';
import { useAssetCapsSDK } from 'src/hooks/useAssetCapsSDK';
import { useRootStore } from 'src/store/root';
import { getBorrowableOnlyInEModeLabels } from 'src/utils/borrowableOnlyInEMode';
import { GENERAL } from 'src/utils/events';
import { useShallow } from 'zustand/shallow';

Expand Down Expand Up @@ -54,6 +56,8 @@ export const ReserveConfiguration: React.FC<ReserveConfigurationProps> = ({ rese
const showSupplyCapStatus: boolean = reserve.supplyInfo.supplyCap.amount.value !== '0';
const showBorrowCapStatus: boolean = reserve.borrowInfo?.borrowCap.amount.value !== '0';

const borrowableOnlyInEModeLabels = getBorrowableOnlyInEModeLabels(reserve);

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

Expand Down Expand Up @@ -140,6 +144,11 @@ export const ReserveConfiguration: React.FC<ReserveConfigurationProps> = ({ rese
/>
</Alert>
)}
{borrowableOnlyInEModeLabels.length > 0 && (
<Alert sx={{ width: '100%', mb: '40px' }} severity="info">
<BorrowableOnlyInEModeWarning />
</Alert>
)}
<BorrowInfo
reserve={reserve}
currentMarketData={currentMarketData}
Expand Down
25 changes: 25 additions & 0 deletions src/utils/borrowableOnlyInEMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ReserveWithId } from 'src/hooks/app-data-provider/useAppDataProvider';

import { replaceUnderscoresWithSpaces } from './utils';

type EModeOnlyBorrowReserve = Pick<
ReserveWithId,
'borrowInfo' | 'eModeInfo' | 'isFrozen' | 'isPaused'
>;

/**
* Labels of the E-Mode categories a reserve can be borrowed in when borrowing is globally disabled
* for it (v3.6+ pools let an E-Mode re-enable a disabled reserve). Empty when the reserve is
* borrowable outside E-Mode, not borrowable at all, or frozen/paused (those have their own
* treatment). Trusts the backend's `canBeBorrowed`, which already accounts for the pool revision.
* Labels have underscores replaced with spaces, matching ReserveEModePanel.
* Shared so the markets row, the mobile card and the reserve page can't drift.
*/
export const getBorrowableOnlyInEModeLabels = (reserve: EModeOnlyBorrowReserve): string[] => {
if (reserve.borrowInfo?.borrowingState !== 'DISABLED' || reserve.isFrozen || reserve.isPaused) {
return [];
}
return (reserve.eModeInfo ?? [])
.filter((eMode) => eMode.canBeBorrowed)
.map((eMode) => replaceUnderscoresWithSpaces(eMode.label) ?? eMode.label);
};
Loading